blob: 3a8371990d751d4b2b8aeccf014d3fc3b33d6b3f [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,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100233 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200234 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200235 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200236 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200237 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200238 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200239 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100240 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100241 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430242 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100243 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100244 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800245 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200246 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200247 ALC889A_INTEL,
248 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200249 ALC888_ASUS_M90V,
250 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200251 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100252 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200253 ALC883_SONY_VAIO_TT,
Takashi Iwai49535502009-06-30 15:28:30 +0200254 ALC882_AUTO,
255 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200256};
257
Kailang Yangdf694da2005-12-05 19:42:22 +0100258/* for GPIO Poll */
259#define GPIO_MASK 0x03
260
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200261/* extra amp-initialization sequence types */
262enum {
263 ALC_INIT_NONE,
264 ALC_INIT_DEFAULT,
265 ALC_INIT_GPIO1,
266 ALC_INIT_GPIO2,
267 ALC_INIT_GPIO3,
268};
269
Takashi Iwai6c819492009-08-10 18:47:44 +0200270struct alc_mic_route {
271 hda_nid_t pin;
272 unsigned char mux_idx;
273 unsigned char amix_idx;
274};
275
276#define MUX_IDX_UNDEF ((unsigned char)-1)
277
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278struct alc_spec {
279 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100280 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100282 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100283 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200285 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200286 * don't forget NULL
287 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200288 */
289 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200291 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 struct hda_pcm_stream *stream_analog_playback;
293 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100294 struct hda_pcm_stream *stream_analog_alt_playback;
295 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200297 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 struct hda_pcm_stream *stream_digital_playback;
299 struct hda_pcm_stream *stream_digital_capture;
300
301 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200302 struct hda_multi_out multiout; /* playback set-up
303 * max_channels, dacs must be set
304 * dig_out_nid and hp_nid are optional
305 */
Takashi Iwai63300792008-01-24 15:31:36 +0100306 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100307 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100308 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310 /* capture */
311 unsigned int num_adc_nids;
312 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100313 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200314 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
316 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200317 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 const struct hda_input_mux *input_mux;
319 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200320 struct alc_mic_route ext_mic;
321 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100324 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200326 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200327 int const_channel_count;
328 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
330 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100331 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200332
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200333 /* dynamic controls, init_verbs and input_mux */
334 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200335 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200336 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200337 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai49535502009-06-30 15:28:30 +0200338 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
339 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100340
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100341 /* hooks */
342 void (*init_hook)(struct hda_codec *codec);
343 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100344#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500345 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100346#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100347
Takashi Iwai834be882006-03-01 14:16:17 +0100348 /* for pin sensing */
349 unsigned int sense_updated: 1;
350 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100351 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200352 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200353
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100354 /* other flags */
355 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200356 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100357
Takashi Iwai2134ea42008-01-10 16:53:55 +0100358 /* for virtual master */
359 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200360#ifdef CONFIG_SND_HDA_POWER_SAVE
361 struct hda_loopback_check loopback;
362#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200363
364 /* for PLL fix */
365 hda_nid_t pll_nid;
366 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100367};
368
369/*
370 * configuration template - to be copied to the spec instance
371 */
372struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200373 struct snd_kcontrol_new *mixers[5]; /* should be identical size
374 * with spec
375 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100376 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100377 const struct hda_verb *init_verbs[5];
378 unsigned int num_dacs;
379 hda_nid_t *dac_nids;
380 hda_nid_t dig_out_nid; /* optional */
381 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800382 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100383 unsigned int num_adc_nids;
384 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100385 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100386 hda_nid_t dig_in_nid;
387 unsigned int num_channel_mode;
388 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200389 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200390 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200391 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100392 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100393 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200394 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100395 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200396#ifdef CONFIG_SND_HDA_POWER_SAVE
397 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500398 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200399#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400};
401
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
403/*
404 * input MUX handling
405 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200406static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408{
409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
410 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200411 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
412 if (mux_idx >= spec->num_mux_defs)
413 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100414 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
415 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200416 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417}
418
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200419static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
420 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421{
422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
423 struct alc_spec *spec = codec->spec;
424 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
425
426 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
427 return 0;
428}
429
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200430static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
431 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432{
433 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
434 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100435 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100437 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100438 hda_nid_t nid = spec->capsrc_nids ?
439 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200440 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
Takashi Iwaicd896c32008-11-18 12:36:33 +0100442 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
443 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100444 if (!imux->num_items && mux_idx > 0)
445 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100446
Takashi Iwaia22d5432009-07-27 12:54:26 +0200447 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200448 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100449 /* Matrix-mixer style (e.g. ALC882) */
450 unsigned int *cur_val = &spec->cur_mux[adc_idx];
451 unsigned int i, idx;
452
453 idx = ucontrol->value.enumerated.item[0];
454 if (idx >= imux->num_items)
455 idx = imux->num_items - 1;
456 if (*cur_val == idx)
457 return 0;
458 for (i = 0; i < imux->num_items; i++) {
459 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
460 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
461 imux->items[i].index,
462 HDA_AMP_MUTE, v);
463 }
464 *cur_val = idx;
465 return 1;
466 } else {
467 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100468 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100469 &spec->cur_mux[adc_idx]);
470 }
471}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200472
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473/*
474 * channel mode setting
475 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200476static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
477 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478{
479 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
480 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100481 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
482 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483}
484
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200485static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
486 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487{
488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
489 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100490 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200491 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200492 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493}
494
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200495static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
496 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497{
498 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
499 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200500 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
501 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200502 &spec->ext_channel_count);
503 if (err >= 0 && !spec->const_channel_count) {
504 spec->multiout.max_channels = spec->ext_channel_count;
505 if (spec->need_dac_fix)
506 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
507 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200508 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509}
510
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200513 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100514 * being part of a format specifier. Maximum allowed length of a value is
515 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100516 *
517 * Note: some retasking pin complexes seem to ignore requests for input
518 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
519 * are requested. Therefore order this list so that this behaviour will not
520 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200521 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
522 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200523 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100524static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100525 "Mic 50pc bias", "Mic 80pc bias",
526 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100527};
528static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100529 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100530};
531/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200532 * in the pin being assumed to be exclusively an input or an output pin. In
533 * addition, "input" pins may or may not process the mic bias option
534 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
535 * accept requests for bias as of chip versions up to March 2006) and/or
536 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100537 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200538#define ALC_PIN_DIR_IN 0x00
539#define ALC_PIN_DIR_OUT 0x01
540#define ALC_PIN_DIR_INOUT 0x02
541#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
542#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100543
Kailang Yangea1fb292008-08-26 12:58:38 +0200544/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545 * For each direction the minimum and maximum values are given.
546 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200547static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100548 { 0, 2 }, /* ALC_PIN_DIR_IN */
549 { 3, 4 }, /* ALC_PIN_DIR_OUT */
550 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200551 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
552 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553};
554#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
555#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
556#define alc_pin_mode_n_items(_dir) \
557 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
558
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200559static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200561{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100562 unsigned int item_num = uinfo->value.enumerated.item;
563 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
564
565 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200566 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
568
569 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
570 item_num = alc_pin_mode_min(dir);
571 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200572 return 0;
573}
574
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200575static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
576 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200577{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100578 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200579 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
580 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200582 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
584 AC_VERB_GET_PIN_WIDGET_CONTROL,
585 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200586
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100587 /* Find enumerated value for current pinctl setting */
588 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2c2009-08-02 13:30:45 +0200589 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100590 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200591 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592 return 0;
593}
594
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200595static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100597{
598 signed int change;
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 hda_nid_t nid = kcontrol->private_value & 0xffff;
601 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
602 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200603 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
604 AC_VERB_GET_PIN_WIDGET_CONTROL,
605 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100606
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200607 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100608 val = alc_pin_mode_min(dir);
609
610 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100611 if (change) {
612 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200613 snd_hda_codec_write_cache(codec, nid, 0,
614 AC_VERB_SET_PIN_WIDGET_CONTROL,
615 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100616
Kailang Yangea1fb292008-08-26 12:58:38 +0200617 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100618 * for the requested pin mode. Enum values of 2 or less are
619 * input modes.
620 *
621 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200622 * reduces noise slightly (particularly on input) so we'll
623 * do it. However, having both input and output buffers
624 * enabled simultaneously doesn't seem to be problematic if
625 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100626 */
627 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200628 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
629 HDA_AMP_MUTE, HDA_AMP_MUTE);
630 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
631 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100632 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200633 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
634 HDA_AMP_MUTE, HDA_AMP_MUTE);
635 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
636 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100637 }
638 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200639 return change;
640}
641
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100642#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200643 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100644 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100645 .info = alc_pin_mode_info, \
646 .get = alc_pin_mode_get, \
647 .put = alc_pin_mode_put, \
648 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100649
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100650/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
651 * together using a mask with more than one bit set. This control is
652 * currently used only by the ALC260 test model. At this stage they are not
653 * needed for any "production" models.
654 */
655#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200656#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200657
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200658static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
659 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100660{
661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
662 hda_nid_t nid = kcontrol->private_value & 0xffff;
663 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
664 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200665 unsigned int val = snd_hda_codec_read(codec, nid, 0,
666 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100667
668 *valp = (val & mask) != 0;
669 return 0;
670}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200671static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
672 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100673{
674 signed int change;
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 val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
680 AC_VERB_GET_GPIO_DATA,
681 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100682
683 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200684 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
685 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100686 gpio_data &= ~mask;
687 else
688 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200689 snd_hda_codec_write_cache(codec, nid, 0,
690 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100691
692 return change;
693}
694#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
695 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100696 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100697 .info = alc_gpio_data_info, \
698 .get = alc_gpio_data_get, \
699 .put = alc_gpio_data_put, \
700 .private_value = nid | (mask<<16) }
701#endif /* CONFIG_SND_DEBUG */
702
Jonathan Woithe92621f12006-02-28 11:47:47 +0100703/* A switch control to allow the enabling of the digital IO pins on the
704 * ALC260. This is incredibly simplistic; the intention of this control is
705 * to provide something in the test model allowing digital outputs to be
706 * identified if present. If models are found which can utilise these
707 * outputs a more complete mixer control can be devised for those models if
708 * necessary.
709 */
710#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200711#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200712
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200713static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
714 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100715{
716 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
717 hda_nid_t nid = kcontrol->private_value & 0xffff;
718 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
719 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200720 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100721 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100722
723 *valp = (val & mask) != 0;
724 return 0;
725}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200726static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
727 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100728{
729 signed int change;
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 val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200734 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100735 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200736 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100737
738 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200739 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100740 if (val==0)
741 ctrl_data &= ~mask;
742 else
743 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200744 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
745 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100746
747 return change;
748}
749#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
750 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100751 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100752 .info = alc_spdif_ctrl_info, \
753 .get = alc_spdif_ctrl_get, \
754 .put = alc_spdif_ctrl_put, \
755 .private_value = nid | (mask<<16) }
756#endif /* CONFIG_SND_DEBUG */
757
Jonathan Woithef8225f62008-01-08 12:16:54 +0100758/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
759 * Again, this is only used in the ALC26x test models to help identify when
760 * the EAPD line must be asserted for features to work.
761 */
762#ifdef CONFIG_SND_DEBUG
763#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
764
765static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value *ucontrol)
767{
768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
769 hda_nid_t nid = kcontrol->private_value & 0xffff;
770 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
771 long *valp = ucontrol->value.integer.value;
772 unsigned int val = snd_hda_codec_read(codec, nid, 0,
773 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
774
775 *valp = (val & mask) != 0;
776 return 0;
777}
778
779static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
780 struct snd_ctl_elem_value *ucontrol)
781{
782 int change;
783 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
784 hda_nid_t nid = kcontrol->private_value & 0xffff;
785 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
786 long val = *ucontrol->value.integer.value;
787 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
788 AC_VERB_GET_EAPD_BTLENABLE,
789 0x00);
790
791 /* Set/unset the masked control bit(s) as needed */
792 change = (!val ? 0 : mask) != (ctrl_data & mask);
793 if (!val)
794 ctrl_data &= ~mask;
795 else
796 ctrl_data |= mask;
797 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
798 ctrl_data);
799
800 return change;
801}
802
803#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
804 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100805 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100806 .info = alc_eapd_ctrl_info, \
807 .get = alc_eapd_ctrl_get, \
808 .put = alc_eapd_ctrl_put, \
809 .private_value = nid | (mask<<16) }
810#endif /* CONFIG_SND_DEBUG */
811
Kailang Yangdf694da2005-12-05 19:42:22 +0100812/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100813 * set up the input pin config (depending on the given auto-pin type)
814 */
815static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
816 int auto_pin_type)
817{
818 unsigned int val = PIN_IN;
819
820 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
821 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100822 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100823 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
824 if (pincap & AC_PINCAP_VREF_80)
825 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200826 else if (pincap & AC_PINCAP_VREF_50)
827 val = PIN_VREF50;
828 else if (pincap & AC_PINCAP_VREF_100)
829 val = PIN_VREF100;
830 else if (pincap & AC_PINCAP_VREF_GRD)
831 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100832 }
833 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
834}
835
836/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100837 */
838static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
839{
840 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
841 return;
842 spec->mixers[spec->num_mixers++] = mix;
843}
844
845static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
846{
847 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
848 return;
849 spec->init_verbs[spec->num_init_verbs++] = verb;
850}
851
852/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100853 * set up from the preset table
854 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200855static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200856 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100857{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200858 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100859 int i;
860
861 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100862 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100863 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200864 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
865 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100866 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200867
Kailang Yangdf694da2005-12-05 19:42:22 +0100868 spec->channel_mode = preset->channel_mode;
869 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200870 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200871 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100872
Hector Martin3b315d72009-06-02 10:54:19 +0200873 if (preset->const_channel_count)
874 spec->multiout.max_channels = preset->const_channel_count;
875 else
876 spec->multiout.max_channels = spec->channel_mode[0].channels;
877 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100878
879 spec->multiout.num_dacs = preset->num_dacs;
880 spec->multiout.dac_nids = preset->dac_nids;
881 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800882 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100883 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200884
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200885 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200886 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200887 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100888 spec->input_mux = preset->input_mux;
889
890 spec->num_adc_nids = preset->num_adc_nids;
891 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100892 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100893 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100894
895 spec->unsol_event = preset->unsol_event;
896 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200897#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100898 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200899 spec->loopback.amplist = preset->loopbacks;
900#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200901
902 if (preset->setup)
903 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100904}
905
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200906/* Enable GPIO mask and set output */
907static struct hda_verb alc_gpio1_init_verbs[] = {
908 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
909 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
910 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
911 { }
912};
913
914static struct hda_verb alc_gpio2_init_verbs[] = {
915 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
916 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
917 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
918 { }
919};
920
Kailang Yangbdd148a2007-05-08 15:19:08 +0200921static struct hda_verb alc_gpio3_init_verbs[] = {
922 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
923 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
924 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
925 { }
926};
927
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200928/*
929 * Fix hardware PLL issue
930 * On some codecs, the analog PLL gating control must be off while
931 * the default value is 1.
932 */
933static void alc_fix_pll(struct hda_codec *codec)
934{
935 struct alc_spec *spec = codec->spec;
936 unsigned int val;
937
938 if (!spec->pll_nid)
939 return;
940 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
941 spec->pll_coef_idx);
942 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
943 AC_VERB_GET_PROC_COEF, 0);
944 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
945 spec->pll_coef_idx);
946 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
947 val & ~(1 << spec->pll_coef_bit));
948}
949
950static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
951 unsigned int coef_idx, unsigned int coef_bit)
952{
953 struct alc_spec *spec = codec->spec;
954 spec->pll_nid = nid;
955 spec->pll_coef_idx = coef_idx;
956 spec->pll_coef_bit = coef_bit;
957 alc_fix_pll(codec);
958}
959
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200960static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200961{
962 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200963 unsigned int nid = spec->autocfg.hp_pins[0];
964 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200965
Takashi Iwaiad87c642009-11-02 14:23:15 +0100966 if (!nid)
967 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800968 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200969 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
970 nid = spec->autocfg.speaker_pins[i];
971 if (!nid)
972 break;
973 snd_hda_codec_write(codec, nid, 0,
974 AC_VERB_SET_PIN_WIDGET_CONTROL,
975 spec->jack_present ? 0 : PIN_OUT);
976 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200977}
978
Takashi Iwai6c819492009-08-10 18:47:44 +0200979static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
980 hda_nid_t nid)
981{
982 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
983 int i, nums;
984
985 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
986 for (i = 0; i < nums; i++)
987 if (conn[i] == nid)
988 return i;
989 return -1;
990}
991
Kailang Yang7fb0d782008-10-15 11:12:35 +0200992static void alc_mic_automute(struct hda_codec *codec)
993{
994 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200995 struct alc_mic_route *dead, *alive;
996 unsigned int present, type;
997 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200998
Takashi Iwaib59bdf32009-08-11 09:47:30 +0200999 if (!spec->auto_mic)
1000 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001001 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1002 return;
1003 if (snd_BUG_ON(!spec->adc_nids))
1004 return;
1005
1006 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1007
Wu Fengguang864f92b2009-11-18 12:38:02 +08001008 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001009 if (present) {
1010 alive = &spec->ext_mic;
1011 dead = &spec->int_mic;
1012 } else {
1013 alive = &spec->int_mic;
1014 dead = &spec->ext_mic;
1015 }
1016
Takashi Iwai6c819492009-08-10 18:47:44 +02001017 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1018 if (type == AC_WID_AUD_MIX) {
1019 /* Matrix-mixer style (e.g. ALC882) */
1020 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1021 alive->mux_idx,
1022 HDA_AMP_MUTE, 0);
1023 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1024 dead->mux_idx,
1025 HDA_AMP_MUTE, HDA_AMP_MUTE);
1026 } else {
1027 /* MUX style (e.g. ALC880) */
1028 snd_hda_codec_write_cache(codec, cap_nid, 0,
1029 AC_VERB_SET_CONNECT_SEL,
1030 alive->mux_idx);
1031 }
1032
1033 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001034}
1035
Kailang Yangc9b58002007-10-16 14:30:01 +02001036/* unsolicited event for HP jack sensing */
1037static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1038{
1039 if (codec->vendor_id == 0x10ec0880)
1040 res >>= 28;
1041 else
1042 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001043 switch (res) {
1044 case ALC880_HP_EVENT:
1045 alc_automute_pin(codec);
1046 break;
1047 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001048 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001049 break;
1050 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001051}
1052
1053static void alc_inithook(struct hda_codec *codec)
1054{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001055 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001056 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001057}
1058
Kailang Yangf9423e72008-05-27 12:32:25 +02001059/* additional initialization for ALC888 variants */
1060static void alc888_coef_init(struct hda_codec *codec)
1061{
1062 unsigned int tmp;
1063
1064 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1065 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1066 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001067 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001068 /* alc888S-VC */
1069 snd_hda_codec_read(codec, 0x20, 0,
1070 AC_VERB_SET_PROC_COEF, 0x830);
1071 else
1072 /* alc888-VB */
1073 snd_hda_codec_read(codec, 0x20, 0,
1074 AC_VERB_SET_PROC_COEF, 0x3030);
1075}
1076
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001077static void alc889_coef_init(struct hda_codec *codec)
1078{
1079 unsigned int tmp;
1080
1081 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1082 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1083 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1084 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1085}
1086
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001087/* turn on/off EAPD control (only if available) */
1088static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1089{
1090 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1091 return;
1092 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1093 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1094 on ? 2 : 0);
1095}
1096
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001097static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001098{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001099 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001100
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001101 switch (type) {
1102 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001103 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1104 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001105 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001106 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1107 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001108 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001109 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1110 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001111 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001112 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001113 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001114 set_eapd(codec, 0x0f, 1);
1115 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001116 break;
1117 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001118 case 0x10ec0267:
1119 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001120 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001121 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001122 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001123 case 0x10ec0660:
1124 case 0x10ec0662:
1125 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001127 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001128 set_eapd(codec, 0x14, 1);
1129 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001130 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001131 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 switch (codec->vendor_id) {
1133 case 0x10ec0260:
1134 snd_hda_codec_write(codec, 0x1a, 0,
1135 AC_VERB_SET_COEF_INDEX, 7);
1136 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1137 AC_VERB_GET_PROC_COEF, 0);
1138 snd_hda_codec_write(codec, 0x1a, 0,
1139 AC_VERB_SET_COEF_INDEX, 7);
1140 snd_hda_codec_write(codec, 0x1a, 0,
1141 AC_VERB_SET_PROC_COEF,
1142 tmp | 0x2010);
1143 break;
1144 case 0x10ec0262:
1145 case 0x10ec0880:
1146 case 0x10ec0882:
1147 case 0x10ec0883:
1148 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001149 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001150 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001151 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001152 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001153 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001154 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001155 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001156#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001157 case 0x10ec0267:
1158 case 0x10ec0268:
1159 snd_hda_codec_write(codec, 0x20, 0,
1160 AC_VERB_SET_COEF_INDEX, 7);
1161 tmp = snd_hda_codec_read(codec, 0x20, 0,
1162 AC_VERB_GET_PROC_COEF, 0);
1163 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001164 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001165 snd_hda_codec_write(codec, 0x20, 0,
1166 AC_VERB_SET_PROC_COEF,
1167 tmp | 0x3000);
1168 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001169#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001170 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001171 break;
1172 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001173}
Kailang Yangea1fb292008-08-26 12:58:38 +02001174
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001175static void alc_init_auto_hp(struct hda_codec *codec)
1176{
1177 struct alc_spec *spec = codec->spec;
1178
1179 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001180 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001181
Kailang Yangc9b58002007-10-16 14:30:01 +02001182 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001183 if (spec->autocfg.line_out_pins[0] &&
1184 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001185 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001186 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001187 else
1188 return;
1189 }
1190
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001191 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1192 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001193 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1194 AC_VERB_SET_UNSOLICITED_ENABLE,
1195 AC_USRSP_EN | ALC880_HP_EVENT);
1196 spec->unsol_event = alc_sku_unsol_event;
1197}
1198
Takashi Iwai6c819492009-08-10 18:47:44 +02001199static void alc_init_auto_mic(struct hda_codec *codec)
1200{
1201 struct alc_spec *spec = codec->spec;
1202 struct auto_pin_cfg *cfg = &spec->autocfg;
1203 hda_nid_t fixed, ext;
1204 int i;
1205
1206 /* there must be only two mic inputs exclusively */
1207 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1208 if (cfg->input_pins[i])
1209 return;
1210
1211 fixed = ext = 0;
1212 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1213 hda_nid_t nid = cfg->input_pins[i];
1214 unsigned int defcfg;
1215 if (!nid)
1216 return;
1217 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1218 switch (get_defcfg_connect(defcfg)) {
1219 case AC_JACK_PORT_FIXED:
1220 if (fixed)
1221 return; /* already occupied */
1222 fixed = nid;
1223 break;
1224 case AC_JACK_PORT_COMPLEX:
1225 if (ext)
1226 return; /* already occupied */
1227 ext = nid;
1228 break;
1229 default:
1230 return; /* invalid entry */
1231 }
1232 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001233 if (!ext || !fixed)
1234 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001235 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1236 return; /* no unsol support */
1237 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1238 ext, fixed);
1239 spec->ext_mic.pin = ext;
1240 spec->int_mic.pin = fixed;
1241 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1242 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1243 spec->auto_mic = 1;
1244 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1245 AC_VERB_SET_UNSOLICITED_ENABLE,
1246 AC_USRSP_EN | ALC880_MIC_EVENT);
1247 spec->unsol_event = alc_sku_unsol_event;
1248}
1249
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001250/* check subsystem ID and set up device-specific initialization;
1251 * return 1 if initialized, 0 if invalid SSID
1252 */
1253/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1254 * 31 ~ 16 : Manufacture ID
1255 * 15 ~ 8 : SKU ID
1256 * 7 ~ 0 : Assembly ID
1257 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1258 */
1259static int alc_subsystem_id(struct hda_codec *codec,
1260 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001261 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001262{
1263 unsigned int ass, tmp, i;
1264 unsigned nid;
1265 struct alc_spec *spec = codec->spec;
1266
1267 ass = codec->subsystem_id & 0xffff;
1268 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1269 goto do_sku;
1270
1271 /* invalid SSID, check the special NID pin defcfg instead */
1272 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001273 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001274 * 29~21 : reserve
1275 * 20 : PCBEEP input
1276 * 19~16 : Check sum (15:1)
1277 * 15~1 : Custom
1278 * 0 : override
1279 */
1280 nid = 0x1d;
1281 if (codec->vendor_id == 0x10ec0260)
1282 nid = 0x17;
1283 ass = snd_hda_codec_get_pincfg(codec, nid);
1284 snd_printd("realtek: No valid SSID, "
1285 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001286 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001287 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001288 return 0;
1289 if ((ass >> 30) != 1) /* no physical connection */
1290 return 0;
1291
1292 /* check sum */
1293 tmp = 0;
1294 for (i = 1; i < 16; i++) {
1295 if ((ass >> i) & 1)
1296 tmp++;
1297 }
1298 if (((ass >> 16) & 0xf) != tmp)
1299 return 0;
1300do_sku:
1301 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1302 ass & 0xffff, codec->vendor_id);
1303 /*
1304 * 0 : override
1305 * 1 : Swap Jack
1306 * 2 : 0 --> Desktop, 1 --> Laptop
1307 * 3~5 : External Amplifier control
1308 * 7~6 : Reserved
1309 */
1310 tmp = (ass & 0x38) >> 3; /* external Amp control */
1311 switch (tmp) {
1312 case 1:
1313 spec->init_amp = ALC_INIT_GPIO1;
1314 break;
1315 case 3:
1316 spec->init_amp = ALC_INIT_GPIO2;
1317 break;
1318 case 7:
1319 spec->init_amp = ALC_INIT_GPIO3;
1320 break;
1321 case 5:
1322 spec->init_amp = ALC_INIT_DEFAULT;
1323 break;
1324 }
1325
1326 /* is laptop or Desktop and enable the function "Mute internal speaker
1327 * when the external headphone out jack is plugged"
1328 */
1329 if (!(ass & 0x8000))
1330 return 1;
1331 /*
1332 * 10~8 : Jack location
1333 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1334 * 14~13: Resvered
1335 * 15 : 1 --> enable the function "Mute internal speaker
1336 * when the external headphone out jack is plugged"
1337 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001339 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001340 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1341 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001342 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001343 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001344 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001345 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001346 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001347 else if (tmp == 3)
1348 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001349 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001350 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001351 for (i = 0; i < spec->autocfg.line_outs; i++)
1352 if (spec->autocfg.line_out_pins[i] == nid)
1353 return 1;
1354 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001355 }
1356
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001357 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001358 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001359 return 1;
1360}
Kailang Yangea1fb292008-08-26 12:58:38 +02001361
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001362static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001363 hda_nid_t porta, hda_nid_t porte,
1364 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001365{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001366 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001367 struct alc_spec *spec = codec->spec;
1368 snd_printd("realtek: "
1369 "Enable default setup for auto mode as fallback\n");
1370 spec->init_amp = ALC_INIT_DEFAULT;
1371 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001372 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001373 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001374}
1375
Takashi Iwai41e41f12005-06-08 14:48:49 +02001376/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001377 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001378 */
1379
1380struct alc_pincfg {
1381 hda_nid_t nid;
1382 u32 val;
1383};
1384
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001385struct alc_fixup {
1386 const struct alc_pincfg *pins;
1387 const struct hda_verb *verbs;
1388};
1389
1390static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001391 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001392 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001393{
1394 const struct alc_pincfg *cfg;
1395
1396 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1397 if (!quirk)
1398 return;
1399
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001400 fix += quirk->value;
1401 cfg = fix->pins;
1402 if (cfg) {
1403 for (; cfg->nid; cfg++)
1404 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1405 }
1406 if (fix->verbs)
1407 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001408}
1409
Kailang Yang274693f2009-12-03 10:07:50 +01001410static int alc_read_coef_idx(struct hda_codec *codec,
1411 unsigned int coef_idx)
1412{
1413 unsigned int val;
1414 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1415 coef_idx);
1416 val = snd_hda_codec_read(codec, 0x20, 0,
1417 AC_VERB_GET_PROC_COEF, 0);
1418 return val;
1419}
1420
Takashi Iwaif95474e2007-07-10 00:47:43 +02001421/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001422 * ALC888
1423 */
1424
1425/*
1426 * 2ch mode
1427 */
1428static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1429/* Mic-in jack as mic in */
1430 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1431 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1432/* Line-in jack as Line in */
1433 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1434 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1435/* Line-Out as Front */
1436 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1437 { } /* end */
1438};
1439
1440/*
1441 * 4ch mode
1442 */
1443static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1444/* Mic-in jack as mic in */
1445 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1446 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1447/* Line-in jack as Surround */
1448 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1449 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1450/* Line-Out as Front */
1451 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1452 { } /* end */
1453};
1454
1455/*
1456 * 6ch mode
1457 */
1458static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1459/* Mic-in jack as CLFE */
1460 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1461 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1462/* Line-in jack as Surround */
1463 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1464 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1465/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1466 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1467 { } /* end */
1468};
1469
1470/*
1471 * 8ch mode
1472 */
1473static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1474/* Mic-in jack as CLFE */
1475 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1476 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1477/* Line-in jack as Surround */
1478 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1479 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1480/* Line-Out as Side */
1481 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1482 { } /* end */
1483};
1484
1485static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1486 { 2, alc888_4ST_ch2_intel_init },
1487 { 4, alc888_4ST_ch4_intel_init },
1488 { 6, alc888_4ST_ch6_intel_init },
1489 { 8, alc888_4ST_ch8_intel_init },
1490};
1491
1492/*
1493 * ALC888 Fujitsu Siemens Amillo xa3530
1494 */
1495
1496static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1497/* Front Mic: set to PIN_IN (empty by default) */
1498 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1499/* Connect Internal HP to Front */
1500 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1503/* Connect Bass HP to Front */
1504 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1505 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1506 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1507/* Connect Line-Out side jack (SPDIF) to Side */
1508 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1509 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1510 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1511/* Connect Mic jack to CLFE */
1512 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1514 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1515/* Connect Line-in jack to Surround */
1516 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1518 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1519/* Connect HP out jack to Front */
1520 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1521 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1522 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1523/* Enable unsolicited event for HP jack and Line-out jack */
1524 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1525 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1526 {}
1527};
1528
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001529static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001530{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001531 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001532 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001533 hda_nid_t nid;
1534 int i;
1535
1536 spec->jack_present = 0;
1537 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1538 nid = spec->autocfg.hp_pins[i];
1539 if (!nid)
1540 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001541 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001542 spec->jack_present = 1;
1543 break;
1544 }
1545 }
1546
1547 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001548 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001549 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1550 nid = spec->autocfg.speaker_pins[i];
1551 if (!nid)
1552 break;
1553 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1554 HDA_AMP_MUTE, mute);
1555 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001556}
1557
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001558static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1559 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001560{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001561 if (codec->vendor_id == 0x10ec0880)
1562 res >>= 28;
1563 else
1564 res >>= 26;
1565 if (res == ALC880_HP_EVENT)
1566 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001567}
1568
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001569static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001570{
1571 struct alc_spec *spec = codec->spec;
1572
1573 spec->autocfg.hp_pins[0] = 0x15;
1574 spec->autocfg.speaker_pins[0] = 0x14;
1575 spec->autocfg.speaker_pins[1] = 0x16;
1576 spec->autocfg.speaker_pins[2] = 0x17;
1577 spec->autocfg.speaker_pins[3] = 0x19;
1578 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001579}
1580
1581static void alc889_intel_init_hook(struct hda_codec *codec)
1582{
1583 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001584 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001585}
1586
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001587static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001588{
1589 struct alc_spec *spec = codec->spec;
1590
1591 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1592 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1593 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1594 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001595}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001596
1597/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001598 * ALC888 Acer Aspire 4930G model
1599 */
1600
1601static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1602/* Front Mic: set to PIN_IN (empty by default) */
1603 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1604/* Unselect Front Mic by default in input mixer 3 */
1605 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001606/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001607 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1608/* Connect Internal HP to front */
1609 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1610 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1611 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1612/* Connect HP out to front */
1613 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1614 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1615 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1616 { }
1617};
1618
Hector Martin3b315d72009-06-02 10:54:19 +02001619/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001620 * ALC888 Acer Aspire 6530G model
1621 */
1622
1623static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1624/* Bias voltage on for external mic port */
1625 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001626/* Front Mic: set to PIN_IN (empty by default) */
1627 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1628/* Unselect Front Mic by default in input mixer 3 */
1629 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001630/* Enable unsolicited event for HP jack */
1631 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1632/* Enable speaker output */
1633 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1634 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1635/* Enable headphone output */
1636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1638 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1639 { }
1640};
1641
1642/*
Hector Martin018df412009-06-04 00:13:40 +02001643 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001644 */
1645
Hector Martin018df412009-06-04 00:13:40 +02001646static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001647/* Front Mic: set to PIN_IN (empty by default) */
1648 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1649/* Unselect Front Mic by default in input mixer 3 */
1650 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1651/* Enable unsolicited event for HP jack */
1652 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1653/* Connect Internal Front to Front */
1654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1656 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1657/* Connect Internal Rear to Rear */
1658 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1659 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1661/* Connect Internal CLFE to CLFE */
1662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1664 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1665/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001666 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001667 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1668 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1669/* Enable all DACs */
1670/* DAC DISABLE/MUTE 1? */
1671/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1672 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1673 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1674/* DAC DISABLE/MUTE 2? */
1675/* some bit here disables the other DACs. Init=0x4900 */
1676 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1677 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001678/* DMIC fix
1679 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1680 * which makes the stereo useless. However, either the mic or the ALC889
1681 * makes the signal become a difference/sum signal instead of standard
1682 * stereo, which is annoying. So instead we flip this bit which makes the
1683 * codec replicate the sum signal to both channels, turning it into a
1684 * normal mono mic.
1685 */
1686/* DMIC_CONTROL? Init value = 0x0001 */
1687 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1688 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001689 { }
1690};
1691
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001692static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001693 /* Front mic only available on one ADC */
1694 {
1695 .num_items = 4,
1696 .items = {
1697 { "Mic", 0x0 },
1698 { "Line", 0x2 },
1699 { "CD", 0x4 },
1700 { "Front Mic", 0xb },
1701 },
1702 },
1703 {
1704 .num_items = 3,
1705 .items = {
1706 { "Mic", 0x0 },
1707 { "Line", 0x2 },
1708 { "CD", 0x4 },
1709 },
1710 }
1711};
1712
Tony Vroond2fd4b02009-06-21 00:40:10 +01001713static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1714 /* Interal mic only available on one ADC */
1715 {
Tony Vroon684a8842009-06-26 09:27:50 +01001716 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001717 .items = {
1718 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001719 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001720 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001721 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001722 { "Int Mic", 0xb },
1723 },
1724 },
1725 {
Tony Vroon684a8842009-06-26 09:27:50 +01001726 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001727 .items = {
1728 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001729 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001730 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001731 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001732 },
1733 }
1734};
1735
Hector Martin018df412009-06-04 00:13:40 +02001736static struct hda_input_mux alc889_capture_sources[3] = {
1737 /* Digital mic only available on first "ADC" */
1738 {
1739 .num_items = 5,
1740 .items = {
1741 { "Mic", 0x0 },
1742 { "Line", 0x2 },
1743 { "CD", 0x4 },
1744 { "Front Mic", 0xb },
1745 { "Input Mix", 0xa },
1746 },
1747 },
1748 {
1749 .num_items = 4,
1750 .items = {
1751 { "Mic", 0x0 },
1752 { "Line", 0x2 },
1753 { "CD", 0x4 },
1754 { "Input Mix", 0xa },
1755 },
1756 },
1757 {
1758 .num_items = 4,
1759 .items = {
1760 { "Mic", 0x0 },
1761 { "Line", 0x2 },
1762 { "CD", 0x4 },
1763 { "Input Mix", 0xa },
1764 },
1765 }
1766};
1767
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001768static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001769 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1770 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1771 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1772 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1773 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1774 HDA_OUTPUT),
1775 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1776 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1777 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1778 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1779 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1780 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1781 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1782 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1783 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1785 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001787 { } /* end */
1788};
1789
Hector Martin556eea92009-12-20 22:51:23 +01001790static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1792 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1794 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1795 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1796 HDA_OUTPUT),
1797 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1798 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1799 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1800 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1801 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1803 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1805 { } /* end */
1806};
1807
1808
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001809static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001810{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001811 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001812
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001813 spec->autocfg.hp_pins[0] = 0x15;
1814 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001815 spec->autocfg.speaker_pins[1] = 0x16;
1816 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001817}
1818
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001819static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001820{
1821 struct alc_spec *spec = codec->spec;
1822
1823 spec->autocfg.hp_pins[0] = 0x15;
1824 spec->autocfg.speaker_pins[0] = 0x14;
1825 spec->autocfg.speaker_pins[1] = 0x16;
1826 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001827}
1828
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001829static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001830{
1831 struct alc_spec *spec = codec->spec;
1832
1833 spec->autocfg.hp_pins[0] = 0x15;
1834 spec->autocfg.speaker_pins[0] = 0x14;
1835 spec->autocfg.speaker_pins[1] = 0x16;
1836 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001837}
1838
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001839/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001840 * ALC880 3-stack model
1841 *
1842 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001843 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1844 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001845 */
1846
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001847static hda_nid_t alc880_dac_nids[4] = {
1848 /* front, rear, clfe, rear_surr */
1849 0x02, 0x05, 0x04, 0x03
1850};
1851
1852static hda_nid_t alc880_adc_nids[3] = {
1853 /* ADC0-2 */
1854 0x07, 0x08, 0x09,
1855};
1856
1857/* The datasheet says the node 0x07 is connected from inputs,
1858 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001859 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001861static hda_nid_t alc880_adc_nids_alt[2] = {
1862 /* ADC1-2 */
1863 0x08, 0x09,
1864};
1865
1866#define ALC880_DIGOUT_NID 0x06
1867#define ALC880_DIGIN_NID 0x0a
1868
1869static struct hda_input_mux alc880_capture_source = {
1870 .num_items = 4,
1871 .items = {
1872 { "Mic", 0x0 },
1873 { "Front Mic", 0x3 },
1874 { "Line", 0x2 },
1875 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001877};
1878
1879/* channel source setting (2/6 channel selection for 3-stack) */
1880/* 2ch mode */
1881static struct hda_verb alc880_threestack_ch2_init[] = {
1882 /* set line-in to input, mute it */
1883 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1884 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1885 /* set mic-in to input vref 80%, mute it */
1886 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1887 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 { } /* end */
1889};
1890
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001891/* 6ch mode */
1892static struct hda_verb alc880_threestack_ch6_init[] = {
1893 /* set line-in to output, unmute it */
1894 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1895 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1896 /* set mic-in to output, unmute it */
1897 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1898 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1899 { } /* end */
1900};
1901
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001902static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001903 { 2, alc880_threestack_ch2_init },
1904 { 6, alc880_threestack_ch6_init },
1905};
1906
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001907static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001908 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001909 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001910 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001911 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001912 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1913 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001914 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1915 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001916 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1917 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1918 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1919 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1922 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1923 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001924 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001925 {
1926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1927 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001928 .info = alc_ch_mode_info,
1929 .get = alc_ch_mode_get,
1930 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001931 },
1932 { } /* end */
1933};
1934
1935/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001936static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1937 struct snd_ctl_elem_info *uinfo)
1938{
1939 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1940 struct alc_spec *spec = codec->spec;
1941 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001942
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001943 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001944 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1945 HDA_INPUT);
1946 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001947 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001948 return err;
1949}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001951static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1952 unsigned int size, unsigned int __user *tlv)
1953{
1954 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1955 struct alc_spec *spec = codec->spec;
1956 int err;
1957
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001958 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001959 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1960 HDA_INPUT);
1961 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001962 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001963 return err;
1964}
1965
1966typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1967 struct snd_ctl_elem_value *ucontrol);
1968
1969static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1970 struct snd_ctl_elem_value *ucontrol,
1971 getput_call_t func)
1972{
1973 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1974 struct alc_spec *spec = codec->spec;
1975 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1976 int err;
1977
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001978 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001979 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1980 3, 0, HDA_INPUT);
1981 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001982 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001983 return err;
1984}
1985
1986static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1987 struct snd_ctl_elem_value *ucontrol)
1988{
1989 return alc_cap_getput_caller(kcontrol, ucontrol,
1990 snd_hda_mixer_amp_volume_get);
1991}
1992
1993static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1994 struct snd_ctl_elem_value *ucontrol)
1995{
1996 return alc_cap_getput_caller(kcontrol, ucontrol,
1997 snd_hda_mixer_amp_volume_put);
1998}
1999
2000/* capture mixer elements */
2001#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2002
2003static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2004 struct snd_ctl_elem_value *ucontrol)
2005{
2006 return alc_cap_getput_caller(kcontrol, ucontrol,
2007 snd_hda_mixer_amp_switch_get);
2008}
2009
2010static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2011 struct snd_ctl_elem_value *ucontrol)
2012{
2013 return alc_cap_getput_caller(kcontrol, ucontrol,
2014 snd_hda_mixer_amp_switch_put);
2015}
2016
Takashi Iwaia23b6882009-03-23 15:21:36 +01002017#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002018 { \
2019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2020 .name = "Capture Switch", \
2021 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2022 .count = num, \
2023 .info = alc_cap_sw_info, \
2024 .get = alc_cap_sw_get, \
2025 .put = alc_cap_sw_put, \
2026 }, \
2027 { \
2028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2029 .name = "Capture Volume", \
2030 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2031 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2032 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2033 .count = num, \
2034 .info = alc_cap_vol_info, \
2035 .get = alc_cap_vol_get, \
2036 .put = alc_cap_vol_put, \
2037 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002038 }
2039
2040#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002041 { \
2042 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2043 /* .name = "Capture Source", */ \
2044 .name = "Input Source", \
2045 .count = num, \
2046 .info = alc_mux_enum_info, \
2047 .get = alc_mux_enum_get, \
2048 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002049 }
2050
2051#define DEFINE_CAPMIX(num) \
2052static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2053 _DEFINE_CAPMIX(num), \
2054 _DEFINE_CAPSRC(num), \
2055 { } /* end */ \
2056}
2057
2058#define DEFINE_CAPMIX_NOSRC(num) \
2059static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2060 _DEFINE_CAPMIX(num), \
2061 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002062}
2063
2064/* up to three ADCs */
2065DEFINE_CAPMIX(1);
2066DEFINE_CAPMIX(2);
2067DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002068DEFINE_CAPMIX_NOSRC(1);
2069DEFINE_CAPMIX_NOSRC(2);
2070DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002071
2072/*
2073 * ALC880 5-stack model
2074 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002075 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2076 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2078 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2079 */
2080
2081/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002082static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002083 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002084 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 { } /* end */
2086};
2087
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002088/* channel source setting (6/8 channel selection for 5-stack) */
2089/* 6ch mode */
2090static struct hda_verb alc880_fivestack_ch6_init[] = {
2091 /* set line-in to input, mute it */
2092 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2093 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002094 { } /* end */
2095};
2096
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002097/* 8ch mode */
2098static struct hda_verb alc880_fivestack_ch8_init[] = {
2099 /* set line-in to output, unmute it */
2100 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2101 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2102 { } /* end */
2103};
2104
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002105static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002106 { 6, alc880_fivestack_ch6_init },
2107 { 8, alc880_fivestack_ch8_init },
2108};
2109
2110
2111/*
2112 * ALC880 6-stack model
2113 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002114 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2115 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002116 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2117 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2118 */
2119
2120static hda_nid_t alc880_6st_dac_nids[4] = {
2121 /* front, rear, clfe, rear_surr */
2122 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002123};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002124
2125static struct hda_input_mux alc880_6stack_capture_source = {
2126 .num_items = 4,
2127 .items = {
2128 { "Mic", 0x0 },
2129 { "Front Mic", 0x1 },
2130 { "Line", 0x2 },
2131 { "CD", 0x4 },
2132 },
2133};
2134
2135/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002136static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002137 { 8, NULL },
2138};
2139
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002140static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002141 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002142 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002143 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002144 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002145 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2146 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002147 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2148 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002149 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002150 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002151 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2152 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2153 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2154 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2157 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002159 {
2160 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2161 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002162 .info = alc_ch_mode_info,
2163 .get = alc_ch_mode_get,
2164 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002165 },
2166 { } /* end */
2167};
2168
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002169
2170/*
2171 * ALC880 W810 model
2172 *
2173 * W810 has rear IO for:
2174 * Front (DAC 02)
2175 * Surround (DAC 03)
2176 * Center/LFE (DAC 04)
2177 * Digital out (06)
2178 *
2179 * The system also has a pair of internal speakers, and a headphone jack.
2180 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002181 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002182 * There is a variable resistor to control the speaker or headphone
2183 * volume. This is a hardware-only device without a software API.
2184 *
2185 * Plugging headphones in will disable the internal speakers. This is
2186 * implemented in hardware, not via the driver using jack sense. In
2187 * a similar fashion, plugging into the rear socket marked "front" will
2188 * disable both the speakers and headphones.
2189 *
2190 * For input, there's a microphone jack, and an "audio in" jack.
2191 * These may not do anything useful with this driver yet, because I
2192 * haven't setup any initialization verbs for these yet...
2193 */
2194
2195static hda_nid_t alc880_w810_dac_nids[3] = {
2196 /* front, rear/surround, clfe */
2197 0x02, 0x03, 0x04
2198};
2199
2200/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002201static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002202 { 6, NULL }
2203};
2204
2205/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002206static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002208 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002209 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002210 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002211 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2212 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002213 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2214 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002215 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2216 { } /* end */
2217};
2218
2219
2220/*
2221 * Z710V model
2222 *
2223 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002224 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2225 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002226 */
2227
2228static hda_nid_t alc880_z71v_dac_nids[1] = {
2229 0x02
2230};
2231#define ALC880_Z71V_HP_DAC 0x03
2232
2233/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002234static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002235 { 2, NULL }
2236};
2237
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002238static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002239 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002240 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002241 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002242 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002243 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2244 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2245 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2246 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2247 { } /* end */
2248};
2249
2250
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002251/*
2252 * ALC880 F1734 model
2253 *
2254 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2255 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2256 */
2257
2258static hda_nid_t alc880_f1734_dac_nids[1] = {
2259 0x03
2260};
2261#define ALC880_F1734_HP_DAC 0x02
2262
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002263static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002264 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002265 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002266 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2267 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002268 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2269 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2271 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 { } /* end */
2273};
2274
Takashi Iwai937b4162008-02-11 14:52:36 +01002275static struct hda_input_mux alc880_f1734_capture_source = {
2276 .num_items = 2,
2277 .items = {
2278 { "Mic", 0x1 },
2279 { "CD", 0x4 },
2280 },
2281};
2282
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002283
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002284/*
2285 * ALC880 ASUS model
2286 *
2287 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2288 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2289 * Mic = 0x18, Line = 0x1a
2290 */
2291
2292#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2293#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2294
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002295static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002296 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002297 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002298 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002299 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002300 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2301 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002302 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2303 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002304 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2305 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2306 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2307 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2308 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2309 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002310 {
2311 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2312 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002313 .info = alc_ch_mode_info,
2314 .get = alc_ch_mode_get,
2315 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002316 },
2317 { } /* end */
2318};
2319
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002320/*
2321 * ALC880 ASUS W1V model
2322 *
2323 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2324 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2325 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2326 */
2327
2328/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002329static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002330 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2331 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002332 { } /* end */
2333};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002334
Kailang Yangdf694da2005-12-05 19:42:22 +01002335/* TCL S700 */
2336static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2337 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2338 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2339 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2340 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2341 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2342 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2343 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2344 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2345 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002346 { } /* end */
2347};
2348
Kailang Yangccc656c2006-10-17 12:32:26 +02002349/* Uniwill */
2350static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002351 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2352 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2353 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2354 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002355 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2356 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2357 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2358 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2359 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2360 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2361 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2362 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2363 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2364 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2365 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2366 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002367 {
2368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2369 .name = "Channel Mode",
2370 .info = alc_ch_mode_info,
2371 .get = alc_ch_mode_get,
2372 .put = alc_ch_mode_put,
2373 },
2374 { } /* end */
2375};
2376
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002377static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2378 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2379 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2380 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2381 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2382 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2383 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2384 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2385 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2386 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2387 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2388 { } /* end */
2389};
2390
Kailang Yangccc656c2006-10-17 12:32:26 +02002391static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002392 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2393 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2394 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2395 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2397 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2398 { } /* end */
2399};
2400
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002402 * virtual master controls
2403 */
2404
2405/*
2406 * slave controls for virtual master
2407 */
2408static const char *alc_slave_vols[] = {
2409 "Front Playback Volume",
2410 "Surround Playback Volume",
2411 "Center Playback Volume",
2412 "LFE Playback Volume",
2413 "Side Playback Volume",
2414 "Headphone Playback Volume",
2415 "Speaker Playback Volume",
2416 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002417 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002418 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002419 NULL,
2420};
2421
2422static const char *alc_slave_sws[] = {
2423 "Front Playback Switch",
2424 "Surround Playback Switch",
2425 "Center Playback Switch",
2426 "LFE Playback Switch",
2427 "Side Playback Switch",
2428 "Headphone Playback Switch",
2429 "Speaker Playback Switch",
2430 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002431 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002432 "Line-Out Playback Switch",
2433 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002434 NULL,
2435};
2436
2437/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002438 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002440
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002441#define NID_MAPPING (-1)
2442
2443#define SUBDEV_SPEAKER_ (0 << 6)
2444#define SUBDEV_HP_ (1 << 6)
2445#define SUBDEV_LINE_ (2 << 6)
2446#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2447#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2448#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2449
Takashi Iwai603c4012008-07-30 15:01:44 +02002450static void alc_free_kctls(struct hda_codec *codec);
2451
Takashi Iwai67d634c2009-11-16 15:35:59 +01002452#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002453/* additional beep mixers; the actual parameters are overwritten at build */
2454static struct snd_kcontrol_new alc_beep_mixer[] = {
2455 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002456 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002457 { } /* end */
2458};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002459#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002460
Linus Torvalds1da177e2005-04-16 15:20:36 -07002461static int alc_build_controls(struct hda_codec *codec)
2462{
2463 struct alc_spec *spec = codec->spec;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002464 struct snd_kcontrol *kctl;
2465 struct snd_kcontrol_new *knew;
2466 int i, j, err;
2467 unsigned int u;
2468 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002469
2470 for (i = 0; i < spec->num_mixers; i++) {
2471 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2472 if (err < 0)
2473 return err;
2474 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002475 if (spec->cap_mixer) {
2476 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2477 if (err < 0)
2478 return err;
2479 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002480 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002481 err = snd_hda_create_spdif_out_ctls(codec,
2482 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483 if (err < 0)
2484 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002485 if (!spec->no_analog) {
2486 err = snd_hda_create_spdif_share_sw(codec,
2487 &spec->multiout);
2488 if (err < 0)
2489 return err;
2490 spec->multiout.share_spdif = 1;
2491 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492 }
2493 if (spec->dig_in_nid) {
2494 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2495 if (err < 0)
2496 return err;
2497 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002498
Takashi Iwai67d634c2009-11-16 15:35:59 +01002499#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002500 /* create beep controls if needed */
2501 if (spec->beep_amp) {
2502 struct snd_kcontrol_new *knew;
2503 for (knew = alc_beep_mixer; knew->name; knew++) {
2504 struct snd_kcontrol *kctl;
2505 kctl = snd_ctl_new1(knew, codec);
2506 if (!kctl)
2507 return -ENOMEM;
2508 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002509 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002510 if (err < 0)
2511 return err;
2512 }
2513 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002514#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002515
Takashi Iwai2134ea42008-01-10 16:53:55 +01002516 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002517 if (!spec->no_analog &&
2518 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002519 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002520 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002521 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002522 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002523 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002524 if (err < 0)
2525 return err;
2526 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002527 if (!spec->no_analog &&
2528 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002529 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2530 NULL, alc_slave_sws);
2531 if (err < 0)
2532 return err;
2533 }
2534
Takashi Iwai603c4012008-07-30 15:01:44 +02002535 alc_free_kctls(codec); /* no longer needed */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002536
2537 /* assign Capture Source enums to NID */
2538 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2539 if (!kctl)
2540 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2541 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwaid1409ae2009-12-17 15:01:31 +01002542 hda_nid_t *nids = spec->capsrc_nids;
2543 if (!nids)
2544 nids = spec->adc_nids;
Takashi Iwai21949f02009-12-23 08:31:59 +01002545 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002546 if (err < 0)
2547 return err;
2548 }
2549 if (spec->cap_mixer) {
2550 const char *kname = kctl ? kctl->id.name : NULL;
2551 for (knew = spec->cap_mixer; knew->name; knew++) {
2552 if (kname && strcmp(knew->name, kname) == 0)
2553 continue;
2554 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2555 for (i = 0; kctl && i < kctl->count; i++) {
2556 err = snd_hda_add_nid(codec, kctl, i,
2557 spec->adc_nids[i]);
2558 if (err < 0)
2559 return err;
2560 }
2561 }
2562 }
2563
2564 /* other nid->control mapping */
2565 for (i = 0; i < spec->num_mixers; i++) {
2566 for (knew = spec->mixers[i]; knew->name; knew++) {
2567 if (knew->iface != NID_MAPPING)
2568 continue;
2569 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2570 if (kctl == NULL)
2571 continue;
2572 u = knew->subdevice;
2573 for (j = 0; j < 4; j++, u >>= 8) {
2574 nid = u & 0x3f;
2575 if (nid == 0)
2576 continue;
2577 switch (u & 0xc0) {
2578 case SUBDEV_SPEAKER_:
2579 nid = spec->autocfg.speaker_pins[nid];
2580 break;
2581 case SUBDEV_LINE_:
2582 nid = spec->autocfg.line_out_pins[nid];
2583 break;
2584 case SUBDEV_HP_:
2585 nid = spec->autocfg.hp_pins[nid];
2586 break;
2587 default:
2588 continue;
2589 }
2590 err = snd_hda_add_nid(codec, kctl, 0, nid);
2591 if (err < 0)
2592 return err;
2593 }
2594 u = knew->private_value;
2595 for (j = 0; j < 4; j++, u >>= 8) {
2596 nid = u & 0xff;
2597 if (nid == 0)
2598 continue;
2599 err = snd_hda_add_nid(codec, kctl, 0, nid);
2600 if (err < 0)
2601 return err;
2602 }
2603 }
2604 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002605 return 0;
2606}
2607
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002608
Linus Torvalds1da177e2005-04-16 15:20:36 -07002609/*
2610 * initialize the codec volumes, etc
2611 */
2612
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002613/*
2614 * generic initialization of ADC, input mixers and output mixers
2615 */
2616static struct hda_verb alc880_volume_init_verbs[] = {
2617 /*
2618 * Unmute ADC0-2 and set the default input to mic-in
2619 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002620 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002622 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002623 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002624 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002625 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002626
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002627 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2628 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002629 * Note: PASD motherboards uses the Line In 2 as the input for front
2630 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002632 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002633 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2634 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2635 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2636 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2637 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002641 /*
2642 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002643 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002644 /* set vol=0 to output mixers */
2645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2646 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2647 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2648 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2649 /* set up input amps for analog loopback */
2650 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002651 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002653 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2654 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002657 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002659
2660 { }
2661};
2662
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663/*
2664 * 3-stack pin configuration:
2665 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2666 */
2667static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2668 /*
2669 * preset connection lists of input pins
2670 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2671 */
2672 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2673 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2674 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2675
2676 /*
2677 * Set pin mode and muting
2678 */
2679 /* set front pin widgets 0x14 for output */
2680 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2681 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2682 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2683 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2684 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2685 /* Mic2 (as headphone out) for HP output */
2686 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2687 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2688 /* Line In pin widget for input */
2689 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2690 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2691 /* Line2 (as front mic) pin widget for input and vref at 80% */
2692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2693 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2694 /* CD pin widget for input */
2695 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2696
2697 { }
2698};
2699
2700/*
2701 * 5-stack pin configuration:
2702 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2703 * line-in/side = 0x1a, f-mic = 0x1b
2704 */
2705static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2706 /*
2707 * preset connection lists of input pins
2708 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2709 */
2710 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2711 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2712
2713 /*
2714 * Set pin mode and muting
2715 */
2716 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2718 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2719 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2720 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002721 /* unmute pins for output (no gain on this amp) */
2722 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2723 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2724 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2725 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2726
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002728 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002729 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2730 /* Mic2 (as headphone out) for HP output */
2731 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002732 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002733 /* Line In pin widget for input */
2734 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2735 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2736 /* Line2 (as front mic) pin widget for input and vref at 80% */
2737 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2738 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2739 /* CD pin widget for input */
2740 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002741
2742 { }
2743};
2744
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002745/*
2746 * W810 pin configuration:
2747 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2748 */
2749static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002750 /* hphone/speaker input selector: front DAC */
2751 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2752
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002753 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2754 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2755 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2756 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2757 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2758 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2759
2760 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002761 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002762
Linus Torvalds1da177e2005-04-16 15:20:36 -07002763 { }
2764};
2765
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002766/*
2767 * Z71V pin configuration:
2768 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2769 */
2770static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002771 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002775
Takashi Iwai16ded522005-06-10 19:58:24 +02002776 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002777 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002778 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002779 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002780
2781 { }
2782};
2783
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002784/*
2785 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002786 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2787 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002788 */
2789static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2790 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2791
Takashi Iwai16ded522005-06-10 19:58:24 +02002792 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002793 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002794 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002796 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002797 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002798 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002799 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2800
Takashi Iwai16ded522005-06-10 19:58:24 +02002801 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002802 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002803 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002804 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002805 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002806 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002807 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002808 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002809 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002810
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002811 { }
2812};
Takashi Iwai16ded522005-06-10 19:58:24 +02002813
Kailang Yangccc656c2006-10-17 12:32:26 +02002814/*
2815 * Uniwill pin configuration:
2816 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2817 * line = 0x1a
2818 */
2819static struct hda_verb alc880_uniwill_init_verbs[] = {
2820 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2821
2822 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2823 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2824 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2825 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2826 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2827 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2828 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2829 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2830 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2832 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2833 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2834 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2836
2837 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2838 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2839 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2840 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2841 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2842 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2843 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2844 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2845 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2846
2847 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2848 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2849
2850 { }
2851};
2852
2853/*
2854* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002855* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002856 */
2857static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2858 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2859
2860 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2864 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2866 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2867 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2868 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2869 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2870 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2871 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2872
2873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2875 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2876 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2877 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2878 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2879
2880 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2881 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2882
2883 { }
2884};
2885
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002886static struct hda_verb alc880_beep_init_verbs[] = {
2887 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2888 { }
2889};
2890
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002891/* auto-toggle front mic */
2892static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2893{
2894 unsigned int present;
2895 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002896
Wu Fengguang864f92b2009-11-18 12:38:02 +08002897 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002898 bits = present ? HDA_AMP_MUTE : 0;
2899 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002900}
2901
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002902static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002903{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002904 struct alc_spec *spec = codec->spec;
2905
2906 spec->autocfg.hp_pins[0] = 0x14;
2907 spec->autocfg.speaker_pins[0] = 0x15;
2908 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002909}
2910
2911static void alc880_uniwill_init_hook(struct hda_codec *codec)
2912{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002913 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002914 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002915}
2916
2917static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2918 unsigned int res)
2919{
2920 /* Looks like the unsol event is incompatible with the standard
2921 * definition. 4bit tag is placed at 28 bit!
2922 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002923 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002924 case ALC880_MIC_EVENT:
2925 alc880_uniwill_mic_automute(codec);
2926 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002927 default:
2928 alc_automute_amp_unsol_event(codec, res);
2929 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002930 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002931}
2932
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002933static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002934{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002935 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002936
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002937 spec->autocfg.hp_pins[0] = 0x14;
2938 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002939}
2940
2941static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2942{
2943 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002944
Kailang Yangccc656c2006-10-17 12:32:26 +02002945 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002946 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2947 present &= HDA_AMP_VOLMASK;
2948 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2949 HDA_AMP_VOLMASK, present);
2950 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2951 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002952}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002953
Kailang Yangccc656c2006-10-17 12:32:26 +02002954static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2955 unsigned int res)
2956{
2957 /* Looks like the unsol event is incompatible with the standard
2958 * definition. 4bit tag is placed at 28 bit!
2959 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002960 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002961 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002962 else
2963 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002964}
2965
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002966/*
2967 * F1734 pin configuration:
2968 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2969 */
2970static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002971 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002972 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2973 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2974 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2975 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2976
2977 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2978 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2980 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2981
2982 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2983 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002984 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002985 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2986 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2987 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2988 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2989 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2990 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002991
Takashi Iwai937b4162008-02-11 14:52:36 +01002992 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2993 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2994
Takashi Iwai16ded522005-06-10 19:58:24 +02002995 { }
2996};
2997
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002998/*
2999 * ASUS pin configuration:
3000 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3001 */
3002static struct hda_verb alc880_pin_asus_init_verbs[] = {
3003 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3004 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3005 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3006 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3007
3008 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3009 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3010 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3012 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3014 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3016
3017 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3018 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3019 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3020 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3021 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3022 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3023 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3025 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003026
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003027 { }
3028};
3029
3030/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003031#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3032#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003033#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003034
Kailang Yangdf694da2005-12-05 19:42:22 +01003035/* Clevo m520g init */
3036static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3037 /* headphone output */
3038 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3039 /* line-out */
3040 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3041 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3042 /* Line-in */
3043 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3044 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3045 /* CD */
3046 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3047 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3048 /* Mic1 (rear panel) */
3049 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3050 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3051 /* Mic2 (front panel) */
3052 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3053 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3054 /* headphone */
3055 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3056 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3057 /* change to EAPD mode */
3058 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3059 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3060
3061 { }
3062};
3063
3064static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003065 /* change to EAPD mode */
3066 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3067 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3068
Kailang Yangdf694da2005-12-05 19:42:22 +01003069 /* Headphone output */
3070 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3071 /* Front output*/
3072 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3073 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3074
3075 /* Line In pin widget for input */
3076 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3077 /* CD pin widget for input */
3078 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3079 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3080 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3081
3082 /* change to EAPD mode */
3083 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3084 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3085
3086 { }
3087};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088
3089/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003090 * LG m1 express dual
3091 *
3092 * Pin assignment:
3093 * Rear Line-In/Out (blue): 0x14
3094 * Build-in Mic-In: 0x15
3095 * Speaker-out: 0x17
3096 * HP-Out (green): 0x1b
3097 * Mic-In/Out (red): 0x19
3098 * SPDIF-Out: 0x1e
3099 */
3100
3101/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3102static hda_nid_t alc880_lg_dac_nids[3] = {
3103 0x05, 0x02, 0x03
3104};
3105
3106/* seems analog CD is not working */
3107static struct hda_input_mux alc880_lg_capture_source = {
3108 .num_items = 3,
3109 .items = {
3110 { "Mic", 0x1 },
3111 { "Line", 0x5 },
3112 { "Internal Mic", 0x6 },
3113 },
3114};
3115
3116/* 2,4,6 channel modes */
3117static struct hda_verb alc880_lg_ch2_init[] = {
3118 /* set line-in and mic-in to input */
3119 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3120 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3121 { }
3122};
3123
3124static struct hda_verb alc880_lg_ch4_init[] = {
3125 /* set line-in to out and mic-in to input */
3126 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3127 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3128 { }
3129};
3130
3131static struct hda_verb alc880_lg_ch6_init[] = {
3132 /* set line-in and mic-in to output */
3133 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3134 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3135 { }
3136};
3137
3138static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3139 { 2, alc880_lg_ch2_init },
3140 { 4, alc880_lg_ch4_init },
3141 { 6, alc880_lg_ch6_init },
3142};
3143
3144static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003145 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3146 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003147 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3148 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3149 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3150 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3151 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3152 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3155 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3156 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3157 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3158 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3159 {
3160 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3161 .name = "Channel Mode",
3162 .info = alc_ch_mode_info,
3163 .get = alc_ch_mode_get,
3164 .put = alc_ch_mode_put,
3165 },
3166 { } /* end */
3167};
3168
3169static struct hda_verb alc880_lg_init_verbs[] = {
3170 /* set capture source to mic-in */
3171 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3172 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3173 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3174 /* mute all amp mixer inputs */
3175 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003176 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3177 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003178 /* line-in to input */
3179 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3180 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3181 /* built-in mic */
3182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3183 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3184 /* speaker-out */
3185 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3186 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 /* mic-in to input */
3188 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3189 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3190 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3191 /* HP-out */
3192 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3195 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003196 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003197 { }
3198};
3199
3200/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003201static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003202{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003203 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003204
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003205 spec->autocfg.hp_pins[0] = 0x1b;
3206 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003207}
3208
3209/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003210 * LG LW20
3211 *
3212 * Pin assignment:
3213 * Speaker-out: 0x14
3214 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003215 * Built-in Mic-In: 0x19
3216 * Line-In: 0x1b
3217 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003218 * SPDIF-Out: 0x1e
3219 */
3220
Takashi Iwaid6815182006-03-23 16:06:23 +01003221static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003222 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003223 .items = {
3224 { "Mic", 0x0 },
3225 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003226 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003227 },
3228};
3229
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003230#define alc880_lg_lw_modes alc880_threestack_modes
3231
Takashi Iwaid6815182006-03-23 16:06:23 +01003232static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003233 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3234 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3235 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3236 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3237 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3238 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3239 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3240 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3241 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3242 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3245 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3246 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003247 {
3248 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3249 .name = "Channel Mode",
3250 .info = alc_ch_mode_info,
3251 .get = alc_ch_mode_get,
3252 .put = alc_ch_mode_put,
3253 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003254 { } /* end */
3255};
3256
3257static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003258 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3259 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3260 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3261
Takashi Iwaid6815182006-03-23 16:06:23 +01003262 /* set capture source to mic-in */
3263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3264 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3265 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003267 /* speaker-out */
3268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3270 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3273 /* mic-in to input */
3274 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3275 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3276 /* built-in mic */
3277 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3278 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3279 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003280 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003281 { }
3282};
3283
3284/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003285static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003286{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003287 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003288
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003289 spec->autocfg.hp_pins[0] = 0x1b;
3290 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003291}
3292
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003293static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3294 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3295 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3298 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3299 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3300 { } /* end */
3301};
3302
3303static struct hda_input_mux alc880_medion_rim_capture_source = {
3304 .num_items = 2,
3305 .items = {
3306 { "Mic", 0x0 },
3307 { "Internal Mic", 0x1 },
3308 },
3309};
3310
3311static struct hda_verb alc880_medion_rim_init_verbs[] = {
3312 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3313
3314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3315 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3316
3317 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3318 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3319 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3320 /* Mic2 (as headphone out) for HP output */
3321 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3322 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3323 /* Internal Speaker */
3324 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3325 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3326
3327 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3328 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3329
3330 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3331 { }
3332};
3333
3334/* toggle speaker-output according to the hp-jack state */
3335static void alc880_medion_rim_automute(struct hda_codec *codec)
3336{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003337 struct alc_spec *spec = codec->spec;
3338 alc_automute_amp(codec);
3339 /* toggle EAPD */
3340 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003341 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3342 else
3343 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3344}
3345
3346static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3347 unsigned int res)
3348{
3349 /* Looks like the unsol event is incompatible with the standard
3350 * definition. 4bit tag is placed at 28 bit!
3351 */
3352 if ((res >> 28) == ALC880_HP_EVENT)
3353 alc880_medion_rim_automute(codec);
3354}
3355
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003356static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003357{
3358 struct alc_spec *spec = codec->spec;
3359
3360 spec->autocfg.hp_pins[0] = 0x14;
3361 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003362}
3363
Takashi Iwaicb53c622007-08-10 17:21:45 +02003364#ifdef CONFIG_SND_HDA_POWER_SAVE
3365static struct hda_amp_list alc880_loopbacks[] = {
3366 { 0x0b, HDA_INPUT, 0 },
3367 { 0x0b, HDA_INPUT, 1 },
3368 { 0x0b, HDA_INPUT, 2 },
3369 { 0x0b, HDA_INPUT, 3 },
3370 { 0x0b, HDA_INPUT, 4 },
3371 { } /* end */
3372};
3373
3374static struct hda_amp_list alc880_lg_loopbacks[] = {
3375 { 0x0b, HDA_INPUT, 1 },
3376 { 0x0b, HDA_INPUT, 6 },
3377 { 0x0b, HDA_INPUT, 7 },
3378 { } /* end */
3379};
3380#endif
3381
Takashi Iwaid6815182006-03-23 16:06:23 +01003382/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003383 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003384 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003385
Linus Torvalds1da177e2005-04-16 15:20:36 -07003386static int alc_init(struct hda_codec *codec)
3387{
3388 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003389 unsigned int i;
3390
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003391 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003392 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003393
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003394 for (i = 0; i < spec->num_init_verbs; i++)
3395 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003396
3397 if (spec->init_hook)
3398 spec->init_hook(codec);
3399
Linus Torvalds1da177e2005-04-16 15:20:36 -07003400 return 0;
3401}
3402
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003403static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3404{
3405 struct alc_spec *spec = codec->spec;
3406
3407 if (spec->unsol_event)
3408 spec->unsol_event(codec, res);
3409}
3410
Takashi Iwaicb53c622007-08-10 17:21:45 +02003411#ifdef CONFIG_SND_HDA_POWER_SAVE
3412static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3413{
3414 struct alc_spec *spec = codec->spec;
3415 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3416}
3417#endif
3418
Linus Torvalds1da177e2005-04-16 15:20:36 -07003419/*
3420 * Analog playback callbacks
3421 */
3422static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3423 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003424 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003425{
3426 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003427 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3428 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003429}
3430
3431static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3432 struct hda_codec *codec,
3433 unsigned int stream_tag,
3434 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003435 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003436{
3437 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003438 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3439 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003440}
3441
3442static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3443 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003444 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003445{
3446 struct alc_spec *spec = codec->spec;
3447 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3448}
3449
3450/*
3451 * Digital out
3452 */
3453static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3454 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003455 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003456{
3457 struct alc_spec *spec = codec->spec;
3458 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3459}
3460
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003461static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3462 struct hda_codec *codec,
3463 unsigned int stream_tag,
3464 unsigned int format,
3465 struct snd_pcm_substream *substream)
3466{
3467 struct alc_spec *spec = codec->spec;
3468 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3469 stream_tag, format, substream);
3470}
3471
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003472static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3473 struct hda_codec *codec,
3474 struct snd_pcm_substream *substream)
3475{
3476 struct alc_spec *spec = codec->spec;
3477 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3478}
3479
Linus Torvalds1da177e2005-04-16 15:20:36 -07003480static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3481 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003482 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003483{
3484 struct alc_spec *spec = codec->spec;
3485 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3486}
3487
3488/*
3489 * Analog capture
3490 */
Takashi Iwai63300792008-01-24 15:31:36 +01003491static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003492 struct hda_codec *codec,
3493 unsigned int stream_tag,
3494 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003495 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003496{
3497 struct alc_spec *spec = codec->spec;
3498
Takashi Iwai63300792008-01-24 15:31:36 +01003499 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003500 stream_tag, 0, format);
3501 return 0;
3502}
3503
Takashi Iwai63300792008-01-24 15:31:36 +01003504static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003505 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003506 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003507{
3508 struct alc_spec *spec = codec->spec;
3509
Takashi Iwai888afa12008-03-18 09:57:50 +01003510 snd_hda_codec_cleanup_stream(codec,
3511 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003512 return 0;
3513}
3514
3515
3516/*
3517 */
3518static struct hda_pcm_stream alc880_pcm_analog_playback = {
3519 .substreams = 1,
3520 .channels_min = 2,
3521 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003522 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003523 .ops = {
3524 .open = alc880_playback_pcm_open,
3525 .prepare = alc880_playback_pcm_prepare,
3526 .cleanup = alc880_playback_pcm_cleanup
3527 },
3528};
3529
3530static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003531 .substreams = 1,
3532 .channels_min = 2,
3533 .channels_max = 2,
3534 /* NID is set in alc_build_pcms */
3535};
3536
3537static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3538 .substreams = 1,
3539 .channels_min = 2,
3540 .channels_max = 2,
3541 /* NID is set in alc_build_pcms */
3542};
3543
3544static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3545 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003546 .channels_min = 2,
3547 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003548 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003549 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003550 .prepare = alc880_alt_capture_pcm_prepare,
3551 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003552 },
3553};
3554
3555static struct hda_pcm_stream alc880_pcm_digital_playback = {
3556 .substreams = 1,
3557 .channels_min = 2,
3558 .channels_max = 2,
3559 /* NID is set in alc_build_pcms */
3560 .ops = {
3561 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003562 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003563 .prepare = alc880_dig_playback_pcm_prepare,
3564 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003565 },
3566};
3567
3568static struct hda_pcm_stream alc880_pcm_digital_capture = {
3569 .substreams = 1,
3570 .channels_min = 2,
3571 .channels_max = 2,
3572 /* NID is set in alc_build_pcms */
3573};
3574
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003575/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003576static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003577 .substreams = 0,
3578 .channels_min = 0,
3579 .channels_max = 0,
3580};
3581
Linus Torvalds1da177e2005-04-16 15:20:36 -07003582static int alc_build_pcms(struct hda_codec *codec)
3583{
3584 struct alc_spec *spec = codec->spec;
3585 struct hda_pcm *info = spec->pcm_rec;
3586 int i;
3587
3588 codec->num_pcms = 1;
3589 codec->pcm_info = info;
3590
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003591 if (spec->no_analog)
3592 goto skip_analog;
3593
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003594 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3595 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003596 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003597
Takashi Iwai4a471b72005-12-07 13:56:29 +01003598 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003599 if (snd_BUG_ON(!spec->multiout.dac_nids))
3600 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003601 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3602 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3603 }
3604 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003605 if (snd_BUG_ON(!spec->adc_nids))
3606 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003607 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3608 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3609 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003610
Takashi Iwai4a471b72005-12-07 13:56:29 +01003611 if (spec->channel_mode) {
3612 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3613 for (i = 0; i < spec->num_channel_mode; i++) {
3614 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3615 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3616 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003617 }
3618 }
3619
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003620 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003621 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003622 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003623 snprintf(spec->stream_name_digital,
3624 sizeof(spec->stream_name_digital),
3625 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003626 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003627 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003628 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003629 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003630 if (spec->dig_out_type)
3631 info->pcm_type = spec->dig_out_type;
3632 else
3633 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003634 if (spec->multiout.dig_out_nid &&
3635 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003636 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3637 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3638 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003639 if (spec->dig_in_nid &&
3640 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003641 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3642 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3643 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003644 /* FIXME: do we need this for all Realtek codec models? */
3645 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003646 }
3647
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003648 if (spec->no_analog)
3649 return 0;
3650
Takashi Iwaie08a0072006-09-07 17:52:14 +02003651 /* If the use of more than one ADC is requested for the current
3652 * model, configure a second analog capture-only PCM.
3653 */
3654 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003655 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3656 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003657 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003658 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003659 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003660 if (spec->alt_dac_nid) {
3661 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3662 *spec->stream_analog_alt_playback;
3663 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3664 spec->alt_dac_nid;
3665 } else {
3666 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3667 alc_pcm_null_stream;
3668 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3669 }
3670 if (spec->num_adc_nids > 1) {
3671 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3672 *spec->stream_analog_alt_capture;
3673 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3674 spec->adc_nids[1];
3675 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3676 spec->num_adc_nids - 1;
3677 } else {
3678 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3679 alc_pcm_null_stream;
3680 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003681 }
3682 }
3683
Linus Torvalds1da177e2005-04-16 15:20:36 -07003684 return 0;
3685}
3686
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003687static inline void alc_shutup(struct hda_codec *codec)
3688{
3689 snd_hda_shutup_pins(codec);
3690}
3691
Takashi Iwai603c4012008-07-30 15:01:44 +02003692static void alc_free_kctls(struct hda_codec *codec)
3693{
3694 struct alc_spec *spec = codec->spec;
3695
3696 if (spec->kctls.list) {
3697 struct snd_kcontrol_new *kctl = spec->kctls.list;
3698 int i;
3699 for (i = 0; i < spec->kctls.used; i++)
3700 kfree(kctl[i].name);
3701 }
3702 snd_array_free(&spec->kctls);
3703}
3704
Linus Torvalds1da177e2005-04-16 15:20:36 -07003705static void alc_free(struct hda_codec *codec)
3706{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003707 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003708
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003709 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003710 return;
3711
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003712 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003713 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003714 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003715 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003716}
3717
Hector Martinf5de24b2009-12-20 22:51:31 +01003718#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003719static void alc_power_eapd(struct hda_codec *codec)
3720{
3721 /* We currently only handle front, HP */
3722 switch (codec->vendor_id) {
3723 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003724 set_eapd(codec, 0x0f, 0);
3725 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003726 break;
3727 case 0x10ec0262:
3728 case 0x10ec0267:
3729 case 0x10ec0268:
3730 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003731 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003732 case 0x10ec0272:
3733 case 0x10ec0660:
3734 case 0x10ec0662:
3735 case 0x10ec0663:
3736 case 0x10ec0862:
3737 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003738 set_eapd(codec, 0x14, 0);
3739 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003740 break;
3741 }
3742}
3743
Hector Martinf5de24b2009-12-20 22:51:31 +01003744static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3745{
3746 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003747 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003748 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003749 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003750 return 0;
3751}
3752#endif
3753
Takashi Iwaie044c392008-10-27 16:56:24 +01003754#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003755static int alc_resume(struct hda_codec *codec)
3756{
Takashi Iwaie044c392008-10-27 16:56:24 +01003757 codec->patch_ops.init(codec);
3758 snd_hda_codec_resume_amp(codec);
3759 snd_hda_codec_resume_cache(codec);
3760 return 0;
3761}
Takashi Iwaie044c392008-10-27 16:56:24 +01003762#endif
3763
Linus Torvalds1da177e2005-04-16 15:20:36 -07003764/*
3765 */
3766static struct hda_codec_ops alc_patch_ops = {
3767 .build_controls = alc_build_controls,
3768 .build_pcms = alc_build_pcms,
3769 .init = alc_init,
3770 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003771 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003772#ifdef SND_HDA_NEEDS_RESUME
3773 .resume = alc_resume,
3774#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003775#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003776 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003777 .check_power_status = alc_check_power_status,
3778#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003779 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003780};
3781
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003782
3783/*
3784 * Test configuration for debugging
3785 *
3786 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3787 * enum controls.
3788 */
3789#ifdef CONFIG_SND_DEBUG
3790static hda_nid_t alc880_test_dac_nids[4] = {
3791 0x02, 0x03, 0x04, 0x05
3792};
3793
3794static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003795 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003796 .items = {
3797 { "In-1", 0x0 },
3798 { "In-2", 0x1 },
3799 { "In-3", 0x2 },
3800 { "In-4", 0x3 },
3801 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003802 { "Front", 0x5 },
3803 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003804 },
3805};
3806
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003807static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003808 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003809 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003810 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003811 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003812};
3813
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003814static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3815 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003816{
3817 static char *texts[] = {
3818 "N/A", "Line Out", "HP Out",
3819 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3820 };
3821 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3822 uinfo->count = 1;
3823 uinfo->value.enumerated.items = 8;
3824 if (uinfo->value.enumerated.item >= 8)
3825 uinfo->value.enumerated.item = 7;
3826 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3827 return 0;
3828}
3829
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003830static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3831 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003832{
3833 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3834 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3835 unsigned int pin_ctl, item = 0;
3836
3837 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3838 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3839 if (pin_ctl & AC_PINCTL_OUT_EN) {
3840 if (pin_ctl & AC_PINCTL_HP_EN)
3841 item = 2;
3842 else
3843 item = 1;
3844 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3845 switch (pin_ctl & AC_PINCTL_VREFEN) {
3846 case AC_PINCTL_VREF_HIZ: item = 3; break;
3847 case AC_PINCTL_VREF_50: item = 4; break;
3848 case AC_PINCTL_VREF_GRD: item = 5; break;
3849 case AC_PINCTL_VREF_80: item = 6; break;
3850 case AC_PINCTL_VREF_100: item = 7; break;
3851 }
3852 }
3853 ucontrol->value.enumerated.item[0] = item;
3854 return 0;
3855}
3856
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003857static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3858 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003859{
3860 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3861 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3862 static unsigned int ctls[] = {
3863 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3864 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3865 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3866 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3867 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3868 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3869 };
3870 unsigned int old_ctl, new_ctl;
3871
3872 old_ctl = snd_hda_codec_read(codec, nid, 0,
3873 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3874 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3875 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003876 int val;
3877 snd_hda_codec_write_cache(codec, nid, 0,
3878 AC_VERB_SET_PIN_WIDGET_CONTROL,
3879 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003880 val = ucontrol->value.enumerated.item[0] >= 3 ?
3881 HDA_AMP_MUTE : 0;
3882 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3883 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003884 return 1;
3885 }
3886 return 0;
3887}
3888
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003889static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3890 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003891{
3892 static char *texts[] = {
3893 "Front", "Surround", "CLFE", "Side"
3894 };
3895 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3896 uinfo->count = 1;
3897 uinfo->value.enumerated.items = 4;
3898 if (uinfo->value.enumerated.item >= 4)
3899 uinfo->value.enumerated.item = 3;
3900 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3901 return 0;
3902}
3903
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003904static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3905 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003906{
3907 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3908 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3909 unsigned int sel;
3910
3911 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3912 ucontrol->value.enumerated.item[0] = sel & 3;
3913 return 0;
3914}
3915
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003916static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3917 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003918{
3919 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3920 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3921 unsigned int sel;
3922
3923 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3924 if (ucontrol->value.enumerated.item[0] != sel) {
3925 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003926 snd_hda_codec_write_cache(codec, nid, 0,
3927 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003928 return 1;
3929 }
3930 return 0;
3931}
3932
3933#define PIN_CTL_TEST(xname,nid) { \
3934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3935 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003936 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003937 .info = alc_test_pin_ctl_info, \
3938 .get = alc_test_pin_ctl_get, \
3939 .put = alc_test_pin_ctl_put, \
3940 .private_value = nid \
3941 }
3942
3943#define PIN_SRC_TEST(xname,nid) { \
3944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3945 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003946 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003947 .info = alc_test_pin_src_info, \
3948 .get = alc_test_pin_src_get, \
3949 .put = alc_test_pin_src_put, \
3950 .private_value = nid \
3951 }
3952
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003953static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003954 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3955 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3956 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3957 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003958 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3959 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3960 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3961 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003962 PIN_CTL_TEST("Front Pin Mode", 0x14),
3963 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3964 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3965 PIN_CTL_TEST("Side Pin Mode", 0x17),
3966 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3967 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3968 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3969 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3970 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3971 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3972 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3973 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3974 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3975 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3976 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3977 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3978 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3979 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3980 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3981 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003984 {
3985 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3986 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003987 .info = alc_ch_mode_info,
3988 .get = alc_ch_mode_get,
3989 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003990 },
3991 { } /* end */
3992};
3993
3994static struct hda_verb alc880_test_init_verbs[] = {
3995 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4001 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4002 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4003 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004004 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004005 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4006 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4007 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4008 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004009 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4012 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4013 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004014 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4017 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4018 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004019 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004020 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4021 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004022 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4023 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4024 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004025 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004026 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4027 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4028 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4029 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004030 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004032 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004033 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004034 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004035 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004036 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004037 /* Analog input/passthru */
4038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004043 { }
4044};
4045#endif
4046
Linus Torvalds1da177e2005-04-16 15:20:36 -07004047/*
4048 */
4049
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004050static const char *alc880_models[ALC880_MODEL_LAST] = {
4051 [ALC880_3ST] = "3stack",
4052 [ALC880_TCL_S700] = "tcl",
4053 [ALC880_3ST_DIG] = "3stack-digout",
4054 [ALC880_CLEVO] = "clevo",
4055 [ALC880_5ST] = "5stack",
4056 [ALC880_5ST_DIG] = "5stack-digout",
4057 [ALC880_W810] = "w810",
4058 [ALC880_Z71V] = "z71v",
4059 [ALC880_6ST] = "6stack",
4060 [ALC880_6ST_DIG] = "6stack-digout",
4061 [ALC880_ASUS] = "asus",
4062 [ALC880_ASUS_W1V] = "asus-w1v",
4063 [ALC880_ASUS_DIG] = "asus-dig",
4064 [ALC880_ASUS_DIG2] = "asus-dig2",
4065 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004066 [ALC880_UNIWILL_P53] = "uniwill-p53",
4067 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004068 [ALC880_F1734] = "F1734",
4069 [ALC880_LG] = "lg",
4070 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004071 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004072#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004073 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004074#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004075 [ALC880_AUTO] = "auto",
4076};
4077
4078static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004079 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004080 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4081 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4082 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4083 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4084 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4085 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4086 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4087 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004088 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4089 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004090 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4091 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4092 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4093 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4094 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4095 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4096 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4097 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4098 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4099 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004100 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004101 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4102 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4103 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004104 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004105 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004106 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4107 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004108 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4109 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004110 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4111 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4112 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4113 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004114 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4115 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004116 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004117 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004118 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004119 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004120 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4121 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004122 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004123 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004124 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004125 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004126 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004127 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004128 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004129 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004130 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004131 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4132 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004133 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004134 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4135 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4136 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4137 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004138 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4139 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004140 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004141 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004142 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4143 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004144 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4145 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4146 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004147 /* default Intel */
4148 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004149 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4150 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004151 {}
4152};
4153
Takashi Iwai16ded522005-06-10 19:58:24 +02004154/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004155 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004156 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004157static struct alc_config_preset alc880_presets[] = {
4158 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004159 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004160 .init_verbs = { alc880_volume_init_verbs,
4161 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004162 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004163 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004164 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4165 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004166 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004167 .input_mux = &alc880_capture_source,
4168 },
4169 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004170 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004171 .init_verbs = { alc880_volume_init_verbs,
4172 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004173 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004174 .dac_nids = alc880_dac_nids,
4175 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004176 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4177 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004178 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004179 .input_mux = &alc880_capture_source,
4180 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004181 [ALC880_TCL_S700] = {
4182 .mixers = { alc880_tcl_s700_mixer },
4183 .init_verbs = { alc880_volume_init_verbs,
4184 alc880_pin_tcl_S700_init_verbs,
4185 alc880_gpio2_init_verbs },
4186 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4187 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004188 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4189 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004190 .hp_nid = 0x03,
4191 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4192 .channel_mode = alc880_2_jack_modes,
4193 .input_mux = &alc880_capture_source,
4194 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004195 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004196 .mixers = { alc880_three_stack_mixer,
4197 alc880_five_stack_mixer},
4198 .init_verbs = { alc880_volume_init_verbs,
4199 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004200 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4201 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004202 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4203 .channel_mode = alc880_fivestack_modes,
4204 .input_mux = &alc880_capture_source,
4205 },
4206 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004207 .mixers = { alc880_three_stack_mixer,
4208 alc880_five_stack_mixer },
4209 .init_verbs = { alc880_volume_init_verbs,
4210 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004211 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4212 .dac_nids = alc880_dac_nids,
4213 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004214 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4215 .channel_mode = alc880_fivestack_modes,
4216 .input_mux = &alc880_capture_source,
4217 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004218 [ALC880_6ST] = {
4219 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004220 .init_verbs = { alc880_volume_init_verbs,
4221 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004222 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4223 .dac_nids = alc880_6st_dac_nids,
4224 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4225 .channel_mode = alc880_sixstack_modes,
4226 .input_mux = &alc880_6stack_capture_source,
4227 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004228 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004229 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004230 .init_verbs = { alc880_volume_init_verbs,
4231 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004232 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4233 .dac_nids = alc880_6st_dac_nids,
4234 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004235 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4236 .channel_mode = alc880_sixstack_modes,
4237 .input_mux = &alc880_6stack_capture_source,
4238 },
4239 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004240 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004241 .init_verbs = { alc880_volume_init_verbs,
4242 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004243 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004244 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4245 .dac_nids = alc880_w810_dac_nids,
4246 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004247 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4248 .channel_mode = alc880_w810_modes,
4249 .input_mux = &alc880_capture_source,
4250 },
4251 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004252 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004253 .init_verbs = { alc880_volume_init_verbs,
4254 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004255 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4256 .dac_nids = alc880_z71v_dac_nids,
4257 .dig_out_nid = ALC880_DIGOUT_NID,
4258 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004259 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4260 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004261 .input_mux = &alc880_capture_source,
4262 },
4263 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004264 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004265 .init_verbs = { alc880_volume_init_verbs,
4266 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004267 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4268 .dac_nids = alc880_f1734_dac_nids,
4269 .hp_nid = 0x02,
4270 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4271 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004272 .input_mux = &alc880_f1734_capture_source,
4273 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004274 .setup = alc880_uniwill_p53_setup,
4275 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004276 },
4277 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004278 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004279 .init_verbs = { alc880_volume_init_verbs,
4280 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004281 alc880_gpio1_init_verbs },
4282 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4283 .dac_nids = alc880_asus_dac_nids,
4284 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4285 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004286 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004287 .input_mux = &alc880_capture_source,
4288 },
4289 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004290 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004291 .init_verbs = { alc880_volume_init_verbs,
4292 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004293 alc880_gpio1_init_verbs },
4294 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4295 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004296 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004297 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4298 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004299 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004300 .input_mux = &alc880_capture_source,
4301 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004302 [ALC880_ASUS_DIG2] = {
4303 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004304 .init_verbs = { alc880_volume_init_verbs,
4305 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004306 alc880_gpio2_init_verbs }, /* use GPIO2 */
4307 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4308 .dac_nids = alc880_asus_dac_nids,
4309 .dig_out_nid = ALC880_DIGOUT_NID,
4310 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4311 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004312 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004313 .input_mux = &alc880_capture_source,
4314 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004315 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004316 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004317 .init_verbs = { alc880_volume_init_verbs,
4318 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004319 alc880_gpio1_init_verbs },
4320 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4321 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004322 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004323 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4324 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004325 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004326 .input_mux = &alc880_capture_source,
4327 },
4328 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004329 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004330 .init_verbs = { alc880_volume_init_verbs,
4331 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004332 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4333 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004334 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004335 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4336 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004337 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004338 .input_mux = &alc880_capture_source,
4339 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004340 [ALC880_UNIWILL] = {
4341 .mixers = { alc880_uniwill_mixer },
4342 .init_verbs = { alc880_volume_init_verbs,
4343 alc880_uniwill_init_verbs },
4344 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4345 .dac_nids = alc880_asus_dac_nids,
4346 .dig_out_nid = ALC880_DIGOUT_NID,
4347 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4348 .channel_mode = alc880_threestack_modes,
4349 .need_dac_fix = 1,
4350 .input_mux = &alc880_capture_source,
4351 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004352 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004353 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004354 },
4355 [ALC880_UNIWILL_P53] = {
4356 .mixers = { alc880_uniwill_p53_mixer },
4357 .init_verbs = { alc880_volume_init_verbs,
4358 alc880_uniwill_p53_init_verbs },
4359 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4360 .dac_nids = alc880_asus_dac_nids,
4361 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004362 .channel_mode = alc880_threestack_modes,
4363 .input_mux = &alc880_capture_source,
4364 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004365 .setup = alc880_uniwill_p53_setup,
4366 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004367 },
4368 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004369 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004370 .init_verbs = { alc880_volume_init_verbs,
4371 alc880_uniwill_p53_init_verbs,
4372 alc880_beep_init_verbs },
4373 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4374 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004375 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004376 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4377 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004378 .input_mux = &alc880_capture_source,
4379 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004380 .setup = alc880_uniwill_p53_setup,
4381 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004382 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004383 [ALC880_CLEVO] = {
4384 .mixers = { alc880_three_stack_mixer },
4385 .init_verbs = { alc880_volume_init_verbs,
4386 alc880_pin_clevo_init_verbs },
4387 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4388 .dac_nids = alc880_dac_nids,
4389 .hp_nid = 0x03,
4390 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4391 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004392 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004393 .input_mux = &alc880_capture_source,
4394 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004395 [ALC880_LG] = {
4396 .mixers = { alc880_lg_mixer },
4397 .init_verbs = { alc880_volume_init_verbs,
4398 alc880_lg_init_verbs },
4399 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4400 .dac_nids = alc880_lg_dac_nids,
4401 .dig_out_nid = ALC880_DIGOUT_NID,
4402 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4403 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004404 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004405 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004406 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004407 .setup = alc880_lg_setup,
4408 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004409#ifdef CONFIG_SND_HDA_POWER_SAVE
4410 .loopbacks = alc880_lg_loopbacks,
4411#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004412 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004413 [ALC880_LG_LW] = {
4414 .mixers = { alc880_lg_lw_mixer },
4415 .init_verbs = { alc880_volume_init_verbs,
4416 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004417 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004418 .dac_nids = alc880_dac_nids,
4419 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004420 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4421 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004422 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004423 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004424 .setup = alc880_lg_lw_setup,
4425 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004426 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004427 [ALC880_MEDION_RIM] = {
4428 .mixers = { alc880_medion_rim_mixer },
4429 .init_verbs = { alc880_volume_init_verbs,
4430 alc880_medion_rim_init_verbs,
4431 alc_gpio2_init_verbs },
4432 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4433 .dac_nids = alc880_dac_nids,
4434 .dig_out_nid = ALC880_DIGOUT_NID,
4435 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4436 .channel_mode = alc880_2_jack_modes,
4437 .input_mux = &alc880_medion_rim_capture_source,
4438 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004439 .setup = alc880_medion_rim_setup,
4440 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004441 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004442#ifdef CONFIG_SND_DEBUG
4443 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004444 .mixers = { alc880_test_mixer },
4445 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004446 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4447 .dac_nids = alc880_test_dac_nids,
4448 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004449 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4450 .channel_mode = alc880_test_modes,
4451 .input_mux = &alc880_test_capture_source,
4452 },
4453#endif
4454};
4455
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004456/*
4457 * Automatic parse of I/O pins from the BIOS configuration
4458 */
4459
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004460enum {
4461 ALC_CTL_WIDGET_VOL,
4462 ALC_CTL_WIDGET_MUTE,
4463 ALC_CTL_BIND_MUTE,
4464};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004465static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004466 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4467 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004468 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004469};
4470
4471/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004472static int add_control(struct alc_spec *spec, int type, const char *name,
4473 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004475 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004476
Takashi Iwai603c4012008-07-30 15:01:44 +02004477 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4478 knew = snd_array_new(&spec->kctls);
4479 if (!knew)
4480 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004481 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004482 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004483 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004484 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004485 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004486 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004487 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004488 return 0;
4489}
4490
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004491static int add_control_with_pfx(struct alc_spec *spec, int type,
4492 const char *pfx, const char *dir,
4493 const char *sfx, unsigned long val)
4494{
4495 char name[32];
4496 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4497 return add_control(spec, type, name, val);
4498}
4499
4500#define add_pb_vol_ctrl(spec, type, pfx, val) \
4501 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4502#define add_pb_sw_ctrl(spec, type, pfx, val) \
4503 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4504
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004505#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4506#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4507#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4508#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004509#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4510#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4511#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4512#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4513#define ALC880_PIN_CD_NID 0x1c
4514
4515/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004516static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4517 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004518{
4519 hda_nid_t nid;
4520 int assigned[4];
4521 int i, j;
4522
4523 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004524 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004525
4526 /* check the pins hardwired to audio widget */
4527 for (i = 0; i < cfg->line_outs; i++) {
4528 nid = cfg->line_out_pins[i];
4529 if (alc880_is_fixed_pin(nid)) {
4530 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004531 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004532 assigned[idx] = 1;
4533 }
4534 }
4535 /* left pins can be connect to any audio widget */
4536 for (i = 0; i < cfg->line_outs; i++) {
4537 nid = cfg->line_out_pins[i];
4538 if (alc880_is_fixed_pin(nid))
4539 continue;
4540 /* search for an empty channel */
4541 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004542 if (!assigned[j]) {
4543 spec->multiout.dac_nids[i] =
4544 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004545 assigned[j] = 1;
4546 break;
4547 }
4548 }
4549 }
4550 spec->multiout.num_dacs = cfg->line_outs;
4551 return 0;
4552}
4553
4554/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004555static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4556 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004557{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004558 static const char *chname[4] = {
4559 "Front", "Surround", NULL /*CLFE*/, "Side"
4560 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004561 hda_nid_t nid;
4562 int i, err;
4563
4564 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004565 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004566 continue;
4567 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4568 if (i == 2) {
4569 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004570 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4571 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004572 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4573 HDA_OUTPUT));
4574 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004575 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004576 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4577 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004578 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4579 HDA_OUTPUT));
4580 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004581 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004582 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4583 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004584 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4585 HDA_INPUT));
4586 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004587 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004588 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4589 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004590 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4591 HDA_INPUT));
4592 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004593 return err;
4594 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004595 const char *pfx;
4596 if (cfg->line_outs == 1 &&
4597 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4598 pfx = "Speaker";
4599 else
4600 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004601 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004602 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4603 HDA_OUTPUT));
4604 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004605 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004606 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004607 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4608 HDA_INPUT));
4609 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004610 return err;
4611 }
4612 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004613 return 0;
4614}
4615
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004616/* add playback controls for speaker and HP outputs */
4617static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4618 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004619{
4620 hda_nid_t nid;
4621 int err;
4622
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004623 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004624 return 0;
4625
4626 if (alc880_is_fixed_pin(pin)) {
4627 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004628 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004629 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004630 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004631 else
4632 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633 /* control HP volume/switch on the output mixer amp */
4634 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004635 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004636 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4637 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004638 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004639 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004640 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4641 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004642 return err;
4643 } else if (alc880_is_multi_pin(pin)) {
4644 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004645 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004646 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004647 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4648 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004649 return err;
4650 }
4651 return 0;
4652}
4653
4654/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004655static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4656 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004657 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004658{
Kailang Yangdf694da2005-12-05 19:42:22 +01004659 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004660
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004661 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004662 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4663 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004664 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004665 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004666 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4667 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004668 return err;
4669 return 0;
4670}
4671
Takashi Iwai05f5f472009-08-25 13:10:18 +02004672static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004673{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004674 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4675 return (pincap & AC_PINCAP_IN) != 0;
4676}
4677
4678/* create playback/capture controls for input pins */
4679static int alc_auto_create_input_ctls(struct hda_codec *codec,
4680 const struct auto_pin_cfg *cfg,
4681 hda_nid_t mixer,
4682 hda_nid_t cap1, hda_nid_t cap2)
4683{
4684 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004685 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004686 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004687
4688 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004689 hda_nid_t pin;
4690
4691 pin = cfg->input_pins[i];
4692 if (!alc_is_input_pin(codec, pin))
4693 continue;
4694
4695 if (mixer) {
4696 idx = get_connection_index(codec, mixer, pin);
4697 if (idx >= 0) {
4698 err = new_analog_input(spec, pin,
4699 auto_pin_cfg_labels[i],
4700 idx, mixer);
4701 if (err < 0)
4702 return err;
4703 }
4704 }
4705
4706 if (!cap1)
4707 continue;
4708 idx = get_connection_index(codec, cap1, pin);
4709 if (idx < 0 && cap2)
4710 idx = get_connection_index(codec, cap2, pin);
4711 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004712 imux->items[imux->num_items].label =
4713 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004714 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004715 imux->num_items++;
4716 }
4717 }
4718 return 0;
4719}
4720
Takashi Iwai05f5f472009-08-25 13:10:18 +02004721static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4722 const struct auto_pin_cfg *cfg)
4723{
4724 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4725}
4726
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004727static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4728 unsigned int pin_type)
4729{
4730 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4731 pin_type);
4732 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004733 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4734 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004735}
4736
Kailang Yangdf694da2005-12-05 19:42:22 +01004737static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4738 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004739 int dac_idx)
4740{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004741 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004742 /* need the manual connection? */
4743 if (alc880_is_multi_pin(nid)) {
4744 struct alc_spec *spec = codec->spec;
4745 int idx = alc880_multi_pin_idx(nid);
4746 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4747 AC_VERB_SET_CONNECT_SEL,
4748 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4749 }
4750}
4751
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004752static int get_pin_type(int line_out_type)
4753{
4754 if (line_out_type == AUTO_PIN_HP_OUT)
4755 return PIN_HP;
4756 else
4757 return PIN_OUT;
4758}
4759
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004760static void alc880_auto_init_multi_out(struct hda_codec *codec)
4761{
4762 struct alc_spec *spec = codec->spec;
4763 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004764
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004765 for (i = 0; i < spec->autocfg.line_outs; i++) {
4766 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004767 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4768 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004769 }
4770}
4771
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004772static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004773{
4774 struct alc_spec *spec = codec->spec;
4775 hda_nid_t pin;
4776
Takashi Iwai82bc9552006-03-21 11:24:42 +01004777 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004778 if (pin) /* connect to front */
4779 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004780 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004781 if (pin) /* connect to front */
4782 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4783}
4784
4785static void alc880_auto_init_analog_input(struct hda_codec *codec)
4786{
4787 struct alc_spec *spec = codec->spec;
4788 int i;
4789
4790 for (i = 0; i < AUTO_PIN_LAST; i++) {
4791 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004792 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004793 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004794 if (nid != ALC880_PIN_CD_NID &&
4795 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004796 snd_hda_codec_write(codec, nid, 0,
4797 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004798 AMP_OUT_MUTE);
4799 }
4800 }
4801}
4802
4803/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004804/* return 1 if successful, 0 if the proper config is not found,
4805 * or a negative error code
4806 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004807static int alc880_parse_auto_config(struct hda_codec *codec)
4808{
4809 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004810 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004811 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004812
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004813 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4814 alc880_ignore);
4815 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004816 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004817 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004818 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004819
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004820 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4821 if (err < 0)
4822 return err;
4823 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4824 if (err < 0)
4825 return err;
4826 err = alc880_auto_create_extra_out(spec,
4827 spec->autocfg.speaker_pins[0],
4828 "Speaker");
4829 if (err < 0)
4830 return err;
4831 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4832 "Headphone");
4833 if (err < 0)
4834 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004835 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004836 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004837 return err;
4838
4839 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4840
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004841 /* check multiple SPDIF-out (for recent codecs) */
4842 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4843 hda_nid_t dig_nid;
4844 err = snd_hda_get_connections(codec,
4845 spec->autocfg.dig_out_pins[i],
4846 &dig_nid, 1);
4847 if (err < 0)
4848 continue;
4849 if (!i)
4850 spec->multiout.dig_out_nid = dig_nid;
4851 else {
4852 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004853 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004854 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004855 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004856 }
4857 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004858 if (spec->autocfg.dig_in_pin)
4859 spec->dig_in_nid = ALC880_DIGIN_NID;
4860
Takashi Iwai603c4012008-07-30 15:01:44 +02004861 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004862 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004863
Takashi Iwaid88897e2008-10-31 15:01:37 +01004864 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004865
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004866 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004867 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004868
Kailang Yang6227cdc2010-02-25 08:36:52 +01004869 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004870
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004871 return 1;
4872}
4873
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004874/* additional initialization for auto-configuration model */
4875static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004876{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004877 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004878 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004879 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004880 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004881 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004882 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004883}
4884
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004885/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4886 * one of two digital mic pins, e.g. on ALC272
4887 */
4888static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004889{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004890 struct alc_spec *spec = codec->spec;
4891 int i;
4892
4893 for (i = 0; i < spec->num_adc_nids; i++) {
4894 hda_nid_t cap = spec->capsrc_nids ?
4895 spec->capsrc_nids[i] : spec->adc_nids[i];
4896 int iidx, eidx;
4897
4898 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4899 if (iidx < 0)
4900 continue;
4901 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4902 if (eidx < 0)
4903 continue;
4904 spec->int_mic.mux_idx = iidx;
4905 spec->ext_mic.mux_idx = eidx;
4906 if (spec->capsrc_nids)
4907 spec->capsrc_nids += i;
4908 spec->adc_nids += i;
4909 spec->num_adc_nids = 1;
4910 return;
4911 }
4912 snd_printd(KERN_INFO "hda_codec: %s: "
4913 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4914 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4915 spec->auto_mic = 0; /* disable auto-mic to be sure */
4916}
4917
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004918/* choose the ADC/MUX containing the input pin and initialize the setup */
4919static void fixup_single_adc(struct hda_codec *codec)
4920{
4921 struct alc_spec *spec = codec->spec;
Frederik Deweerdtd2db09b2010-03-05 16:34:31 +01004922 hda_nid_t pin = 0;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004923 int i;
4924
4925 /* search for the input pin; there must be only one */
4926 for (i = 0; i < AUTO_PIN_LAST; i++) {
4927 if (spec->autocfg.input_pins[i]) {
4928 pin = spec->autocfg.input_pins[i];
4929 break;
4930 }
4931 }
4932 if (!pin)
4933 return;
4934
4935 /* set the default connection to that pin */
4936 for (i = 0; i < spec->num_adc_nids; i++) {
4937 hda_nid_t cap = spec->capsrc_nids ?
4938 spec->capsrc_nids[i] : spec->adc_nids[i];
4939 int idx;
4940
4941 idx = get_connection_index(codec, cap, pin);
4942 if (idx < 0)
4943 continue;
4944 /* use only this ADC */
4945 if (spec->capsrc_nids)
4946 spec->capsrc_nids += i;
4947 spec->adc_nids += i;
4948 spec->num_adc_nids = 1;
4949 /* select or unmute this route */
4950 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4951 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4952 HDA_AMP_MUTE, 0);
4953 } else {
4954 snd_hda_codec_write_cache(codec, cap, 0,
4955 AC_VERB_SET_CONNECT_SEL, idx);
4956 }
4957 return;
4958 }
4959}
4960
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004961static void set_capture_mixer(struct hda_codec *codec)
4962{
4963 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004964 static struct snd_kcontrol_new *caps[2][3] = {
4965 { alc_capture_mixer_nosrc1,
4966 alc_capture_mixer_nosrc2,
4967 alc_capture_mixer_nosrc3 },
4968 { alc_capture_mixer1,
4969 alc_capture_mixer2,
4970 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004971 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004972 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004973 int mux = 0;
4974 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004975 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004976 else if (spec->input_mux) {
4977 if (spec->input_mux->num_items > 1)
4978 mux = 1;
4979 else if (spec->input_mux->num_items == 1)
4980 fixup_single_adc(codec);
4981 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01004982 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4983 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004984}
4985
Takashi Iwai67d634c2009-11-16 15:35:59 +01004986#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004987#define set_beep_amp(spec, nid, idx, dir) \
4988 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004989#else
4990#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4991#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004992
4993/*
4994 * OK, here we have finally the patch for ALC880
4995 */
4996
Linus Torvalds1da177e2005-04-16 15:20:36 -07004997static int patch_alc880(struct hda_codec *codec)
4998{
4999 struct alc_spec *spec;
5000 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005001 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005002
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005003 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005004 if (spec == NULL)
5005 return -ENOMEM;
5006
5007 codec->spec = spec;
5008
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005009 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5010 alc880_models,
5011 alc880_cfg_tbl);
5012 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005013 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5014 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005015 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005016 }
5017
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005018 if (board_config == ALC880_AUTO) {
5019 /* automatic parse from the BIOS config */
5020 err = alc880_parse_auto_config(codec);
5021 if (err < 0) {
5022 alc_free(codec);
5023 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005024 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005025 printk(KERN_INFO
5026 "hda_codec: Cannot set up configuration "
5027 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005028 board_config = ALC880_3ST;
5029 }
5030 }
5031
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005032 err = snd_hda_attach_beep_device(codec, 0x1);
5033 if (err < 0) {
5034 alc_free(codec);
5035 return err;
5036 }
5037
Kailang Yangdf694da2005-12-05 19:42:22 +01005038 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005039 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005040
Linus Torvalds1da177e2005-04-16 15:20:36 -07005041 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5042 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005043 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005044
Linus Torvalds1da177e2005-04-16 15:20:36 -07005045 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5046 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5047
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005048 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005049 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005050 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005051 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005052 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005053 if (wcap != AC_WID_AUD_IN) {
5054 spec->adc_nids = alc880_adc_nids_alt;
5055 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005056 } else {
5057 spec->adc_nids = alc880_adc_nids;
5058 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005059 }
5060 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005061 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005062 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005063
Takashi Iwai2134ea42008-01-10 16:53:55 +01005064 spec->vmaster_nid = 0x0c;
5065
Linus Torvalds1da177e2005-04-16 15:20:36 -07005066 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005067 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005068 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005069#ifdef CONFIG_SND_HDA_POWER_SAVE
5070 if (!spec->loopback.amplist)
5071 spec->loopback.amplist = alc880_loopbacks;
5072#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005073
5074 return 0;
5075}
5076
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005077
Linus Torvalds1da177e2005-04-16 15:20:36 -07005078/*
5079 * ALC260 support
5080 */
5081
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005082static hda_nid_t alc260_dac_nids[1] = {
5083 /* front */
5084 0x02,
5085};
5086
5087static hda_nid_t alc260_adc_nids[1] = {
5088 /* ADC0 */
5089 0x04,
5090};
5091
Kailang Yangdf694da2005-12-05 19:42:22 +01005092static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005093 /* ADC1 */
5094 0x05,
5095};
5096
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005097/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5098 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5099 */
5100static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005101 /* ADC0, ADC1 */
5102 0x04, 0x05
5103};
5104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005105#define ALC260_DIGOUT_NID 0x03
5106#define ALC260_DIGIN_NID 0x06
5107
5108static struct hda_input_mux alc260_capture_source = {
5109 .num_items = 4,
5110 .items = {
5111 { "Mic", 0x0 },
5112 { "Front Mic", 0x1 },
5113 { "Line", 0x2 },
5114 { "CD", 0x4 },
5115 },
5116};
5117
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005118/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005119 * headphone jack and the internal CD lines since these are the only pins at
5120 * which audio can appear. For flexibility, also allow the option of
5121 * recording the mixer output on the second ADC (ADC0 doesn't have a
5122 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005123 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005124static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5125 {
5126 .num_items = 3,
5127 .items = {
5128 { "Mic/Line", 0x0 },
5129 { "CD", 0x4 },
5130 { "Headphone", 0x2 },
5131 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005132 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005133 {
5134 .num_items = 4,
5135 .items = {
5136 { "Mic/Line", 0x0 },
5137 { "CD", 0x4 },
5138 { "Headphone", 0x2 },
5139 { "Mixer", 0x5 },
5140 },
5141 },
5142
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005143};
5144
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005145/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5146 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005147 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005148static struct hda_input_mux alc260_acer_capture_sources[2] = {
5149 {
5150 .num_items = 4,
5151 .items = {
5152 { "Mic", 0x0 },
5153 { "Line", 0x2 },
5154 { "CD", 0x4 },
5155 { "Headphone", 0x5 },
5156 },
5157 },
5158 {
5159 .num_items = 5,
5160 .items = {
5161 { "Mic", 0x0 },
5162 { "Line", 0x2 },
5163 { "CD", 0x4 },
5164 { "Headphone", 0x6 },
5165 { "Mixer", 0x5 },
5166 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005167 },
5168};
Michael Schwingencc959482009-02-22 18:58:45 +01005169
5170/* Maxdata Favorit 100XS */
5171static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5172 {
5173 .num_items = 2,
5174 .items = {
5175 { "Line/Mic", 0x0 },
5176 { "CD", 0x4 },
5177 },
5178 },
5179 {
5180 .num_items = 3,
5181 .items = {
5182 { "Line/Mic", 0x0 },
5183 { "CD", 0x4 },
5184 { "Mixer", 0x5 },
5185 },
5186 },
5187};
5188
Linus Torvalds1da177e2005-04-16 15:20:36 -07005189/*
5190 * This is just place-holder, so there's something for alc_build_pcms to look
5191 * at when it calculates the maximum number of channels. ALC260 has no mixer
5192 * element which allows changing the channel mode, so the verb list is
5193 * never used.
5194 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005195static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005196 { 2, NULL },
5197};
5198
Kailang Yangdf694da2005-12-05 19:42:22 +01005199
5200/* Mixer combinations
5201 *
5202 * basic: base_output + input + pc_beep + capture
5203 * HP: base_output + input + capture_alt
5204 * HP_3013: hp_3013 + input + capture
5205 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005206 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005207 */
5208
5209static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005210 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005211 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005212 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5213 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5214 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5215 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5216 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005217};
Kailang Yangdf694da2005-12-05 19:42:22 +01005218
5219static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005220 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5221 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5222 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5223 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5225 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5226 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005228 { } /* end */
5229};
5230
Takashi Iwaibec15c32008-01-28 18:16:30 +01005231/* update HP, line and mono out pins according to the master switch */
5232static void alc260_hp_master_update(struct hda_codec *codec,
5233 hda_nid_t hp, hda_nid_t line,
5234 hda_nid_t mono)
5235{
5236 struct alc_spec *spec = codec->spec;
5237 unsigned int val = spec->master_sw ? PIN_HP : 0;
5238 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005239 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005240 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005241 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005242 val);
5243 /* mono (speaker) depending on the HP jack sense */
5244 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005245 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005246 val);
5247}
5248
5249static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5250 struct snd_ctl_elem_value *ucontrol)
5251{
5252 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5253 struct alc_spec *spec = codec->spec;
5254 *ucontrol->value.integer.value = spec->master_sw;
5255 return 0;
5256}
5257
5258static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5259 struct snd_ctl_elem_value *ucontrol)
5260{
5261 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5262 struct alc_spec *spec = codec->spec;
5263 int val = !!*ucontrol->value.integer.value;
5264 hda_nid_t hp, line, mono;
5265
5266 if (val == spec->master_sw)
5267 return 0;
5268 spec->master_sw = val;
5269 hp = (kcontrol->private_value >> 16) & 0xff;
5270 line = (kcontrol->private_value >> 8) & 0xff;
5271 mono = kcontrol->private_value & 0xff;
5272 alc260_hp_master_update(codec, hp, line, mono);
5273 return 1;
5274}
5275
5276static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5277 {
5278 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5279 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005280 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005281 .info = snd_ctl_boolean_mono_info,
5282 .get = alc260_hp_master_sw_get,
5283 .put = alc260_hp_master_sw_put,
5284 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5285 },
5286 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5287 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5288 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5289 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5290 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5291 HDA_OUTPUT),
5292 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5293 { } /* end */
5294};
5295
5296static struct hda_verb alc260_hp_unsol_verbs[] = {
5297 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5298 {},
5299};
5300
5301static void alc260_hp_automute(struct hda_codec *codec)
5302{
5303 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005304
Wu Fengguang864f92b2009-11-18 12:38:02 +08005305 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005306 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5307}
5308
5309static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5310{
5311 if ((res >> 26) == ALC880_HP_EVENT)
5312 alc260_hp_automute(codec);
5313}
5314
Kailang Yangdf694da2005-12-05 19:42:22 +01005315static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005316 {
5317 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5318 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005319 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005320 .info = snd_ctl_boolean_mono_info,
5321 .get = alc260_hp_master_sw_get,
5322 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005323 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005324 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005325 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5326 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5327 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5328 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5329 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5330 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005331 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5332 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005333 { } /* end */
5334};
5335
Kailang Yang3f878302008-08-26 13:02:23 +02005336static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5337 .ops = &snd_hda_bind_vol,
5338 .values = {
5339 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5340 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5341 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5342 0
5343 },
5344};
5345
5346static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5347 .ops = &snd_hda_bind_sw,
5348 .values = {
5349 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5350 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5351 0
5352 },
5353};
5354
5355static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5356 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5357 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5358 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5359 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5360 { } /* end */
5361};
5362
Takashi Iwaibec15c32008-01-28 18:16:30 +01005363static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5364 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5365 {},
5366};
5367
5368static void alc260_hp_3013_automute(struct hda_codec *codec)
5369{
5370 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005371
Wu Fengguang864f92b2009-11-18 12:38:02 +08005372 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005373 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005374}
5375
5376static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5377 unsigned int res)
5378{
5379 if ((res >> 26) == ALC880_HP_EVENT)
5380 alc260_hp_3013_automute(codec);
5381}
5382
Kailang Yang3f878302008-08-26 13:02:23 +02005383static void alc260_hp_3012_automute(struct hda_codec *codec)
5384{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005385 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005386
Kailang Yang3f878302008-08-26 13:02:23 +02005387 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5388 bits);
5389 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5390 bits);
5391 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5392 bits);
5393}
5394
5395static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5396 unsigned int res)
5397{
5398 if ((res >> 26) == ALC880_HP_EVENT)
5399 alc260_hp_3012_automute(codec);
5400}
5401
5402/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005403 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5404 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01005405static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005406 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005407 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005408 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005409 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5410 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5411 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5412 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005413 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005414 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5415 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005416 { } /* end */
5417};
5418
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005419/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5420 * versions of the ALC260 don't act on requests to enable mic bias from NID
5421 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5422 * datasheet doesn't mention this restriction. At this stage it's not clear
5423 * whether this behaviour is intentional or is a hardware bug in chip
5424 * revisions available in early 2006. Therefore for now allow the
5425 * "Headphone Jack Mode" control to span all choices, but if it turns out
5426 * that the lack of mic bias for this NID is intentional we could change the
5427 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5428 *
5429 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5430 * don't appear to make the mic bias available from the "line" jack, even
5431 * though the NID used for this jack (0x14) can supply it. The theory is
5432 * that perhaps Acer have included blocking capacitors between the ALC260
5433 * and the output jack. If this turns out to be the case for all such
5434 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5435 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005436 *
5437 * The C20x Tablet series have a mono internal speaker which is controlled
5438 * via the chip's Mono sum widget and pin complex, so include the necessary
5439 * controls for such models. On models without a "mono speaker" the control
5440 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005441 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005442static struct snd_kcontrol_new alc260_acer_mixer[] = {
5443 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5444 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005445 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005446 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005447 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005448 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005449 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005450 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5451 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5453 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5454 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5455 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5456 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5457 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005458 { } /* end */
5459};
5460
Michael Schwingencc959482009-02-22 18:58:45 +01005461/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5462 */
5463static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5464 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5465 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5466 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5467 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5468 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5469 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5470 { } /* end */
5471};
5472
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005473/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5474 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5475 */
5476static struct snd_kcontrol_new alc260_will_mixer[] = {
5477 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5478 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5479 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5480 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5481 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5482 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5483 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5484 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5485 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5486 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005487 { } /* end */
5488};
5489
5490/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5491 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5492 */
5493static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5494 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5495 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5496 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5497 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5498 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5499 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5500 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5501 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5502 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5503 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5504 { } /* end */
5505};
5506
Kailang Yangdf694da2005-12-05 19:42:22 +01005507/*
5508 * initialization verbs
5509 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005510static struct hda_verb alc260_init_verbs[] = {
5511 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005512 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005513 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005514 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005515 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005516 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005517 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005518 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005519 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005520 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005521 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005522 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005523 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005524 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005525 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005526 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005527 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005528 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5529 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005530 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005531 /* set connection select to line in (default select for this ADC) */
5532 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005533 /* mute capture amp left and right */
5534 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5535 /* set connection select to line in (default select for this ADC) */
5536 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005537 /* set vol=0 Line-Out mixer amp left and right */
5538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5539 /* unmute pin widget amp left and right (no gain on this amp) */
5540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5541 /* set vol=0 HP mixer amp left and right */
5542 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5543 /* unmute pin widget amp left and right (no gain on this amp) */
5544 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5545 /* set vol=0 Mono mixer amp left and right */
5546 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5547 /* unmute pin widget amp left and right (no gain on this amp) */
5548 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5549 /* unmute LINE-2 out pin */
5550 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005551 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5552 * Line In 2 = 0x03
5553 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005554 /* mute analog inputs */
5555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5559 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005560 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005561 /* mute Front out path */
5562 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5563 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5564 /* mute Headphone out path */
5565 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5566 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5567 /* mute Mono out path */
5568 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5569 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005570 { }
5571};
5572
Takashi Iwai474167d2006-05-17 17:17:43 +02005573#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005574static struct hda_verb alc260_hp_init_verbs[] = {
5575 /* Headphone and output */
5576 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5577 /* mono output */
5578 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5579 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5580 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5581 /* Mic2 (front panel) pin widget for input and vref at 80% */
5582 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5583 /* Line In pin widget for input */
5584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5585 /* Line-2 pin widget for output */
5586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5587 /* CD pin widget for input */
5588 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5589 /* unmute amp left and right */
5590 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5591 /* set connection select to line in (default select for this ADC) */
5592 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5593 /* unmute Line-Out mixer amp left and right (volume = 0) */
5594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5595 /* mute pin widget amp left and right (no gain on this amp) */
5596 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5597 /* unmute HP mixer amp left and right (volume = 0) */
5598 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5599 /* mute pin widget amp left and right (no gain on this amp) */
5600 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005601 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5602 * Line In 2 = 0x03
5603 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005604 /* mute analog inputs */
5605 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5606 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5607 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5608 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5609 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005610 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5611 /* Unmute Front out path */
5612 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5613 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5614 /* Unmute Headphone out path */
5615 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5616 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5617 /* Unmute Mono out path */
5618 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5619 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5620 { }
5621};
Takashi Iwai474167d2006-05-17 17:17:43 +02005622#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005623
5624static struct hda_verb alc260_hp_3013_init_verbs[] = {
5625 /* Line out and output */
5626 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5627 /* mono output */
5628 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5629 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5630 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5631 /* Mic2 (front panel) pin widget for input and vref at 80% */
5632 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5633 /* Line In pin widget for input */
5634 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5635 /* Headphone pin widget for output */
5636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5637 /* CD pin widget for input */
5638 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5639 /* unmute amp left and right */
5640 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5641 /* set connection select to line in (default select for this ADC) */
5642 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5643 /* unmute Line-Out mixer amp left and right (volume = 0) */
5644 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5645 /* mute pin widget amp left and right (no gain on this amp) */
5646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5647 /* unmute HP mixer amp left and right (volume = 0) */
5648 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5649 /* mute pin widget amp left and right (no gain on this amp) */
5650 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005651 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5652 * Line In 2 = 0x03
5653 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005654 /* mute analog inputs */
5655 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5658 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5659 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005660 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5661 /* Unmute Front out path */
5662 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5663 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5664 /* Unmute Headphone out path */
5665 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5666 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5667 /* Unmute Mono out path */
5668 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5669 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5670 { }
5671};
5672
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005673/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005674 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5675 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005676 */
5677static struct hda_verb alc260_fujitsu_init_verbs[] = {
5678 /* Disable all GPIOs */
5679 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5680 /* Internal speaker is connected to headphone pin */
5681 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5682 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5683 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005684 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5685 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5686 /* Ensure all other unused pins are disabled and muted. */
5687 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5688 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005689 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005690 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005691 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005692 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5693 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5694 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005695
Jonathan Woithef7ace402006-02-28 11:46:14 +01005696 /* Disable digital (SPDIF) pins */
5697 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5698 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005699
Kailang Yangea1fb292008-08-26 12:58:38 +02005700 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005701 * when acting as an output.
5702 */
5703 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5704
5705 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005706 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5707 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5708 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5709 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5710 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5711 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5712 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5713 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5714 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005715
Jonathan Woithef7ace402006-02-28 11:46:14 +01005716 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5717 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5718 /* Unmute Line1 pin widget output buffer since it starts as an output.
5719 * If the pin mode is changed by the user the pin mode control will
5720 * take care of enabling the pin's input/output buffers as needed.
5721 * Therefore there's no need to enable the input buffer at this
5722 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005723 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005724 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005725 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005726 * mixer ctrl)
5727 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005728 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005729
Jonathan Woithef7ace402006-02-28 11:46:14 +01005730 /* Mute capture amp left and right */
5731 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005732 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005733 * in (on mic1 pin)
5734 */
5735 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005736
Jonathan Woithef7ace402006-02-28 11:46:14 +01005737 /* Do the same for the second ADC: mute capture input amp and
5738 * set ADC connection to line in (on mic1 pin)
5739 */
5740 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5741 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005742
Jonathan Woithef7ace402006-02-28 11:46:14 +01005743 /* Mute all inputs to mixer widget (even unconnected ones) */
5744 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5745 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005752
5753 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005754};
5755
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005756/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5757 * similar laptops (adapted from Fujitsu init verbs).
5758 */
5759static struct hda_verb alc260_acer_init_verbs[] = {
5760 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5761 * the headphone jack. Turn this on and rely on the standard mute
5762 * methods whenever the user wants to turn these outputs off.
5763 */
5764 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5765 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5766 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5767 /* Internal speaker/Headphone jack is connected to Line-out pin */
5768 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5769 /* Internal microphone/Mic jack is connected to Mic1 pin */
5770 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5771 /* Line In jack is connected to Line1 pin */
5772 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005773 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5774 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005775 /* Ensure all other unused pins are disabled and muted. */
5776 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5777 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005778 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5779 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5780 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5781 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5782 /* Disable digital (SPDIF) pins */
5783 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5784 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5785
Kailang Yangea1fb292008-08-26 12:58:38 +02005786 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005787 * bus when acting as outputs.
5788 */
5789 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5790 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5791
5792 /* Start with output sum widgets muted and their output gains at min */
5793 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5794 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5795 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5796 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5797 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5798 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5799 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5800 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5801 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5802
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005803 /* Unmute Line-out pin widget amp left and right
5804 * (no equiv mixer ctrl)
5805 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005806 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005807 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5808 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005809 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5810 * inputs. If the pin mode is changed by the user the pin mode control
5811 * will take care of enabling the pin's input/output buffers as needed.
5812 * Therefore there's no need to enable the input buffer at this
5813 * stage.
5814 */
5815 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5816 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5817
5818 /* Mute capture amp left and right */
5819 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5820 /* Set ADC connection select to match default mixer setting - mic
5821 * (on mic1 pin)
5822 */
5823 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5824
5825 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005826 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005827 */
5828 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005829 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005830
5831 /* Mute all inputs to mixer widget (even unconnected ones) */
5832 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5833 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5834 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5835 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5836 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5837 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5838 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5839 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5840
5841 { }
5842};
5843
Michael Schwingencc959482009-02-22 18:58:45 +01005844/* Initialisation sequence for Maxdata Favorit 100XS
5845 * (adapted from Acer init verbs).
5846 */
5847static struct hda_verb alc260_favorit100_init_verbs[] = {
5848 /* GPIO 0 enables the output jack.
5849 * Turn this on and rely on the standard mute
5850 * methods whenever the user wants to turn these outputs off.
5851 */
5852 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5853 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5854 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5855 /* Line/Mic input jack is connected to Mic1 pin */
5856 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5857 /* Ensure all other unused pins are disabled and muted. */
5858 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5859 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5860 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5861 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5862 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5863 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5864 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5865 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5867 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5868 /* Disable digital (SPDIF) pins */
5869 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5870 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5871
5872 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5873 * bus when acting as outputs.
5874 */
5875 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5876 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5877
5878 /* Start with output sum widgets muted and their output gains at min */
5879 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5880 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5881 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5882 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5883 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5884 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5885 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5886 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5887 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5888
5889 /* Unmute Line-out pin widget amp left and right
5890 * (no equiv mixer ctrl)
5891 */
5892 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5893 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5894 * inputs. If the pin mode is changed by the user the pin mode control
5895 * will take care of enabling the pin's input/output buffers as needed.
5896 * Therefore there's no need to enable the input buffer at this
5897 * stage.
5898 */
5899 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5900
5901 /* Mute capture amp left and right */
5902 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5903 /* Set ADC connection select to match default mixer setting - mic
5904 * (on mic1 pin)
5905 */
5906 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5907
5908 /* Do similar with the second ADC: mute capture input amp and
5909 * set ADC connection to mic to match ALSA's default state.
5910 */
5911 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5912 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5913
5914 /* Mute all inputs to mixer widget (even unconnected ones) */
5915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5917 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5918 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5919 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5921 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5922 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5923
5924 { }
5925};
5926
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005927static struct hda_verb alc260_will_verbs[] = {
5928 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5929 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5930 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5931 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5932 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5933 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5934 {}
5935};
5936
5937static struct hda_verb alc260_replacer_672v_verbs[] = {
5938 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5939 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5940 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5941
5942 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5943 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5944 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5945
5946 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5947 {}
5948};
5949
5950/* toggle speaker-output according to the hp-jack state */
5951static void alc260_replacer_672v_automute(struct hda_codec *codec)
5952{
5953 unsigned int present;
5954
5955 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005956 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005957 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005958 snd_hda_codec_write_cache(codec, 0x01, 0,
5959 AC_VERB_SET_GPIO_DATA, 1);
5960 snd_hda_codec_write_cache(codec, 0x0f, 0,
5961 AC_VERB_SET_PIN_WIDGET_CONTROL,
5962 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005963 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005964 snd_hda_codec_write_cache(codec, 0x01, 0,
5965 AC_VERB_SET_GPIO_DATA, 0);
5966 snd_hda_codec_write_cache(codec, 0x0f, 0,
5967 AC_VERB_SET_PIN_WIDGET_CONTROL,
5968 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005969 }
5970}
5971
5972static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5973 unsigned int res)
5974{
5975 if ((res >> 26) == ALC880_HP_EVENT)
5976 alc260_replacer_672v_automute(codec);
5977}
5978
Kailang Yang3f878302008-08-26 13:02:23 +02005979static struct hda_verb alc260_hp_dc7600_verbs[] = {
5980 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5982 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5983 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5984 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5985 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5986 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5987 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5988 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5989 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5990 {}
5991};
5992
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005993/* Test configuration for debugging, modelled after the ALC880 test
5994 * configuration.
5995 */
5996#ifdef CONFIG_SND_DEBUG
5997static hda_nid_t alc260_test_dac_nids[1] = {
5998 0x02,
5999};
6000static hda_nid_t alc260_test_adc_nids[2] = {
6001 0x04, 0x05,
6002};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006003/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006004 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006005 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006006 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006007static struct hda_input_mux alc260_test_capture_sources[2] = {
6008 {
6009 .num_items = 7,
6010 .items = {
6011 { "MIC1 pin", 0x0 },
6012 { "MIC2 pin", 0x1 },
6013 { "LINE1 pin", 0x2 },
6014 { "LINE2 pin", 0x3 },
6015 { "CD pin", 0x4 },
6016 { "LINE-OUT pin", 0x5 },
6017 { "HP-OUT pin", 0x6 },
6018 },
6019 },
6020 {
6021 .num_items = 8,
6022 .items = {
6023 { "MIC1 pin", 0x0 },
6024 { "MIC2 pin", 0x1 },
6025 { "LINE1 pin", 0x2 },
6026 { "LINE2 pin", 0x3 },
6027 { "CD pin", 0x4 },
6028 { "Mixer", 0x5 },
6029 { "LINE-OUT pin", 0x6 },
6030 { "HP-OUT pin", 0x7 },
6031 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006032 },
6033};
6034static struct snd_kcontrol_new alc260_test_mixer[] = {
6035 /* Output driver widgets */
6036 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6037 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6038 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6039 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6040 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6041 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6042
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006043 /* Modes for retasking pin widgets
6044 * Note: the ALC260 doesn't seem to act on requests to enable mic
6045 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6046 * mention this restriction. At this stage it's not clear whether
6047 * this behaviour is intentional or is a hardware bug in chip
6048 * revisions available at least up until early 2006. Therefore for
6049 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6050 * choices, but if it turns out that the lack of mic bias for these
6051 * NIDs is intentional we could change their modes from
6052 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6053 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006054 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6055 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6056 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6057 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6058 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6059 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6060
6061 /* Loopback mixer controls */
6062 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6063 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6064 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6065 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6066 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6067 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6068 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6069 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6070 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6071 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006072 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6073 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6074 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6075 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006076
6077 /* Controls for GPIO pins, assuming they are configured as outputs */
6078 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6079 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6080 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6081 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6082
Jonathan Woithe92621f12006-02-28 11:47:47 +01006083 /* Switches to allow the digital IO pins to be enabled. The datasheet
6084 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006085 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006086 */
6087 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6088 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6089
Jonathan Woithef8225f62008-01-08 12:16:54 +01006090 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6091 * this output to turn on an external amplifier.
6092 */
6093 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6094 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6095
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006096 { } /* end */
6097};
6098static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006099 /* Enable all GPIOs as outputs with an initial value of 0 */
6100 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6101 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6102 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6103
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006104 /* Enable retasking pins as output, initially without power amp */
6105 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6106 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6107 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6108 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6109 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6110 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6111
Jonathan Woithe92621f12006-02-28 11:47:47 +01006112 /* Disable digital (SPDIF) pins initially, but users can enable
6113 * them via a mixer switch. In the case of SPDIF-out, this initverb
6114 * payload also sets the generation to 0, output to be in "consumer"
6115 * PCM format, copyright asserted, no pre-emphasis and no validity
6116 * control.
6117 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006118 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6119 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6120
Kailang Yangea1fb292008-08-26 12:58:38 +02006121 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006122 * OUT1 sum bus when acting as an output.
6123 */
6124 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6125 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6126 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6127 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6128
6129 /* Start with output sum widgets muted and their output gains at min */
6130 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6131 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6132 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6133 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6134 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6135 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6136 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6137 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6138 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6139
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006140 /* Unmute retasking pin widget output buffers since the default
6141 * state appears to be output. As the pin mode is changed by the
6142 * user the pin mode control will take care of enabling the pin's
6143 * input/output buffers as needed.
6144 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006145 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6146 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6147 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6148 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6149 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6150 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6151 /* Also unmute the mono-out pin widget */
6152 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6153
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006154 /* Mute capture amp left and right */
6155 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006156 /* Set ADC connection select to match default mixer setting (mic1
6157 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006158 */
6159 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6160
6161 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006162 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006163 */
6164 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6165 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6166
6167 /* Mute all inputs to mixer widget (even unconnected ones) */
6168 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6169 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6170 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6171 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6172 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6173 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6174 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6175 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6176
6177 { }
6178};
6179#endif
6180
Takashi Iwai63300792008-01-24 15:31:36 +01006181#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6182#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006183
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006184#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6185#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6186
Kailang Yangdf694da2005-12-05 19:42:22 +01006187/*
6188 * for BIOS auto-configuration
6189 */
6190
6191static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006192 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006193{
6194 hda_nid_t nid_vol;
6195 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006196 int err;
6197
6198 if (nid >= 0x0f && nid < 0x11) {
6199 nid_vol = nid - 0x7;
6200 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6201 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6202 } else if (nid == 0x11) {
6203 nid_vol = nid - 0x7;
6204 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6205 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6206 } else if (nid >= 0x12 && nid <= 0x15) {
6207 nid_vol = 0x08;
6208 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6209 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6210 } else
6211 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006212
Takashi Iwai863b4512008-10-21 17:01:47 +02006213 if (!(*vol_bits & (1 << nid_vol))) {
6214 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006215 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006216 if (err < 0)
6217 return err;
6218 *vol_bits |= (1 << nid_vol);
6219 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006220 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006221 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006222 return err;
6223 return 1;
6224}
6225
6226/* add playback controls from the parsed DAC table */
6227static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6228 const struct auto_pin_cfg *cfg)
6229{
6230 hda_nid_t nid;
6231 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006232 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006233
6234 spec->multiout.num_dacs = 1;
6235 spec->multiout.dac_nids = spec->private_dac_nids;
6236 spec->multiout.dac_nids[0] = 0x02;
6237
6238 nid = cfg->line_out_pins[0];
6239 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006240 const char *pfx;
6241 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6242 pfx = "Master";
6243 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6244 pfx = "Speaker";
6245 else
6246 pfx = "Front";
6247 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006248 if (err < 0)
6249 return err;
6250 }
6251
Takashi Iwai82bc9552006-03-21 11:24:42 +01006252 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006253 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006254 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006255 if (err < 0)
6256 return err;
6257 }
6258
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006259 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006260 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006261 err = alc260_add_playback_controls(spec, nid, "Headphone",
6262 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006263 if (err < 0)
6264 return err;
6265 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006266 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006267}
6268
6269/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006270static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006271 const struct auto_pin_cfg *cfg)
6272{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006273 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006274}
6275
6276static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6277 hda_nid_t nid, int pin_type,
6278 int sel_idx)
6279{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006280 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006281 /* need the manual connection? */
6282 if (nid >= 0x12) {
6283 int idx = nid - 0x12;
6284 snd_hda_codec_write(codec, idx + 0x0b, 0,
6285 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006286 }
6287}
6288
6289static void alc260_auto_init_multi_out(struct hda_codec *codec)
6290{
6291 struct alc_spec *spec = codec->spec;
6292 hda_nid_t nid;
6293
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006294 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006295 if (nid) {
6296 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6297 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6298 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006299
Takashi Iwai82bc9552006-03-21 11:24:42 +01006300 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006301 if (nid)
6302 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6303
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006304 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006305 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006306 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006307}
Kailang Yangdf694da2005-12-05 19:42:22 +01006308
6309#define ALC260_PIN_CD_NID 0x16
6310static void alc260_auto_init_analog_input(struct hda_codec *codec)
6311{
6312 struct alc_spec *spec = codec->spec;
6313 int i;
6314
6315 for (i = 0; i < AUTO_PIN_LAST; i++) {
6316 hda_nid_t nid = spec->autocfg.input_pins[i];
6317 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006318 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006319 if (nid != ALC260_PIN_CD_NID &&
6320 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006321 snd_hda_codec_write(codec, nid, 0,
6322 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006323 AMP_OUT_MUTE);
6324 }
6325 }
6326}
6327
6328/*
6329 * generic initialization of ADC, input mixers and output mixers
6330 */
6331static struct hda_verb alc260_volume_init_verbs[] = {
6332 /*
6333 * Unmute ADC0-1 and set the default input to mic-in
6334 */
6335 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6336 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6337 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6338 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006339
Kailang Yangdf694da2005-12-05 19:42:22 +01006340 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6341 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006342 * Note: PASD motherboards uses the Line In 2 as the input for
6343 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006344 */
6345 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006346 /* mute analog inputs */
6347 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6348 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6349 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6350 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006352
6353 /*
6354 * Set up output mixers (0x08 - 0x0a)
6355 */
6356 /* set vol=0 to output mixers */
6357 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6358 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6359 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6360 /* set up input amps for analog loopback */
6361 /* Amp Indices: DAC = 0, mixer = 1 */
6362 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6363 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6364 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6365 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6366 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6367 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006368
Kailang Yangdf694da2005-12-05 19:42:22 +01006369 { }
6370};
6371
6372static int alc260_parse_auto_config(struct hda_codec *codec)
6373{
6374 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006375 int err;
6376 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6377
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006378 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6379 alc260_ignore);
6380 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006381 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006382 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6383 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006384 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006385 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006386 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006387 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006388 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006389 return err;
6390
6391 spec->multiout.max_channels = 2;
6392
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006393 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006394 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006395 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006396 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006397
Takashi Iwaid88897e2008-10-31 15:01:37 +01006398 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006399
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006400 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006401 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006402
Kailang Yang6227cdc2010-02-25 08:36:52 +01006403 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006404
Kailang Yangdf694da2005-12-05 19:42:22 +01006405 return 1;
6406}
6407
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006408/* additional initialization for auto-configuration model */
6409static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006410{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006411 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006412 alc260_auto_init_multi_out(codec);
6413 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006414 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006415 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006416}
6417
Takashi Iwaicb53c622007-08-10 17:21:45 +02006418#ifdef CONFIG_SND_HDA_POWER_SAVE
6419static struct hda_amp_list alc260_loopbacks[] = {
6420 { 0x07, HDA_INPUT, 0 },
6421 { 0x07, HDA_INPUT, 1 },
6422 { 0x07, HDA_INPUT, 2 },
6423 { 0x07, HDA_INPUT, 3 },
6424 { 0x07, HDA_INPUT, 4 },
6425 { } /* end */
6426};
6427#endif
6428
Kailang Yangdf694da2005-12-05 19:42:22 +01006429/*
6430 * ALC260 configurations
6431 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006432static const char *alc260_models[ALC260_MODEL_LAST] = {
6433 [ALC260_BASIC] = "basic",
6434 [ALC260_HP] = "hp",
6435 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006436 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006437 [ALC260_FUJITSU_S702X] = "fujitsu",
6438 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006439 [ALC260_WILL] = "will",
6440 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006441 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006442#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006443 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006444#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006445 [ALC260_AUTO] = "auto",
6446};
6447
6448static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006449 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006450 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006451 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006452 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006453 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006454 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006455 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006456 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006457 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006458 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6459 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6460 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6461 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6462 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6463 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6464 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6465 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6466 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006467 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006468 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006469 {}
6470};
6471
Kailang Yangdf694da2005-12-05 19:42:22 +01006472static struct alc_config_preset alc260_presets[] = {
6473 [ALC260_BASIC] = {
6474 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006475 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006476 .init_verbs = { alc260_init_verbs },
6477 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6478 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006479 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006480 .adc_nids = alc260_adc_nids,
6481 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6482 .channel_mode = alc260_modes,
6483 .input_mux = &alc260_capture_source,
6484 },
6485 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006486 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006487 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006488 .init_verbs = { alc260_init_verbs,
6489 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006490 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6491 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006492 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6493 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006494 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6495 .channel_mode = alc260_modes,
6496 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006497 .unsol_event = alc260_hp_unsol_event,
6498 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006499 },
Kailang Yang3f878302008-08-26 13:02:23 +02006500 [ALC260_HP_DC7600] = {
6501 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006502 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006503 .init_verbs = { alc260_init_verbs,
6504 alc260_hp_dc7600_verbs },
6505 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6506 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006507 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6508 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006509 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6510 .channel_mode = alc260_modes,
6511 .input_mux = &alc260_capture_source,
6512 .unsol_event = alc260_hp_3012_unsol_event,
6513 .init_hook = alc260_hp_3012_automute,
6514 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006515 [ALC260_HP_3013] = {
6516 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006517 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006518 .init_verbs = { alc260_hp_3013_init_verbs,
6519 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006520 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6521 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006522 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6523 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006524 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6525 .channel_mode = alc260_modes,
6526 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006527 .unsol_event = alc260_hp_3013_unsol_event,
6528 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006529 },
6530 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006531 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006532 .init_verbs = { alc260_fujitsu_init_verbs },
6533 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6534 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006535 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6536 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006537 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6538 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006539 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6540 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006541 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006542 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006543 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006544 .init_verbs = { alc260_acer_init_verbs },
6545 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6546 .dac_nids = alc260_dac_nids,
6547 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6548 .adc_nids = alc260_dual_adc_nids,
6549 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6550 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006551 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6552 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006553 },
Michael Schwingencc959482009-02-22 18:58:45 +01006554 [ALC260_FAVORIT100] = {
6555 .mixers = { alc260_favorit100_mixer },
6556 .init_verbs = { alc260_favorit100_init_verbs },
6557 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6558 .dac_nids = alc260_dac_nids,
6559 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6560 .adc_nids = alc260_dual_adc_nids,
6561 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6562 .channel_mode = alc260_modes,
6563 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6564 .input_mux = alc260_favorit100_capture_sources,
6565 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006566 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006567 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006568 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6569 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6570 .dac_nids = alc260_dac_nids,
6571 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6572 .adc_nids = alc260_adc_nids,
6573 .dig_out_nid = ALC260_DIGOUT_NID,
6574 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6575 .channel_mode = alc260_modes,
6576 .input_mux = &alc260_capture_source,
6577 },
6578 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006579 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006580 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6581 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6582 .dac_nids = alc260_dac_nids,
6583 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6584 .adc_nids = alc260_adc_nids,
6585 .dig_out_nid = ALC260_DIGOUT_NID,
6586 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6587 .channel_mode = alc260_modes,
6588 .input_mux = &alc260_capture_source,
6589 .unsol_event = alc260_replacer_672v_unsol_event,
6590 .init_hook = alc260_replacer_672v_automute,
6591 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006592#ifdef CONFIG_SND_DEBUG
6593 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006594 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006595 .init_verbs = { alc260_test_init_verbs },
6596 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6597 .dac_nids = alc260_test_dac_nids,
6598 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6599 .adc_nids = alc260_test_adc_nids,
6600 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6601 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006602 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6603 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006604 },
6605#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006606};
6607
Linus Torvalds1da177e2005-04-16 15:20:36 -07006608static int patch_alc260(struct hda_codec *codec)
6609{
6610 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006611 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006612
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006613 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006614 if (spec == NULL)
6615 return -ENOMEM;
6616
6617 codec->spec = spec;
6618
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006619 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6620 alc260_models,
6621 alc260_cfg_tbl);
6622 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006623 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006624 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006625 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006626 }
6627
Kailang Yangdf694da2005-12-05 19:42:22 +01006628 if (board_config == ALC260_AUTO) {
6629 /* automatic parse from the BIOS config */
6630 err = alc260_parse_auto_config(codec);
6631 if (err < 0) {
6632 alc_free(codec);
6633 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006634 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006635 printk(KERN_INFO
6636 "hda_codec: Cannot set up configuration "
6637 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006638 board_config = ALC260_BASIC;
6639 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006640 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006641
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006642 err = snd_hda_attach_beep_device(codec, 0x1);
6643 if (err < 0) {
6644 alc_free(codec);
6645 return err;
6646 }
6647
Kailang Yangdf694da2005-12-05 19:42:22 +01006648 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006649 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006650
Linus Torvalds1da177e2005-04-16 15:20:36 -07006651 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6652 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6653
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006654 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6655 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6656
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006657 if (!spec->adc_nids && spec->input_mux) {
6658 /* check whether NID 0x04 is valid */
6659 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006660 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006661 /* get type */
6662 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6663 spec->adc_nids = alc260_adc_nids_alt;
6664 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6665 } else {
6666 spec->adc_nids = alc260_adc_nids;
6667 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6668 }
6669 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006670 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006671 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006672
Takashi Iwai2134ea42008-01-10 16:53:55 +01006673 spec->vmaster_nid = 0x08;
6674
Linus Torvalds1da177e2005-04-16 15:20:36 -07006675 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006676 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006677 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006678#ifdef CONFIG_SND_HDA_POWER_SAVE
6679 if (!spec->loopback.amplist)
6680 spec->loopback.amplist = alc260_loopbacks;
6681#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006682
6683 return 0;
6684}
6685
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006686
Linus Torvalds1da177e2005-04-16 15:20:36 -07006687/*
Takashi Iwai49535502009-06-30 15:28:30 +02006688 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006689 *
6690 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6691 * configuration. Each pin widget can choose any input DACs and a mixer.
6692 * Each ADC is connected from a mixer of all inputs. This makes possible
6693 * 6-channel independent captures.
6694 *
6695 * In addition, an independent DAC for the multi-playback (not used in this
6696 * driver yet).
6697 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006698#define ALC882_DIGOUT_NID 0x06
6699#define ALC882_DIGIN_NID 0x0a
Takashi Iwai49535502009-06-30 15:28:30 +02006700#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6701#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6702#define ALC1200_DIGOUT_NID 0x10
6703
Linus Torvalds1da177e2005-04-16 15:20:36 -07006704
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006705static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006706 { 8, NULL }
6707};
6708
Takashi Iwai49535502009-06-30 15:28:30 +02006709/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006710static hda_nid_t alc882_dac_nids[4] = {
6711 /* front, rear, clfe, rear_surr */
6712 0x02, 0x03, 0x04, 0x05
6713};
Takashi Iwai49535502009-06-30 15:28:30 +02006714#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006715
Takashi Iwai49535502009-06-30 15:28:30 +02006716/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006717#define alc882_adc_nids alc880_adc_nids
6718#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai49535502009-06-30 15:28:30 +02006719#define alc883_adc_nids alc882_adc_nids_alt
6720static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6721static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6722#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006723
Takashi Iwaie1406342008-02-11 18:32:32 +01006724static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6725static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai49535502009-06-30 15:28:30 +02006726#define alc883_capsrc_nids alc882_capsrc_nids_alt
6727static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6728#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006729
Linus Torvalds1da177e2005-04-16 15:20:36 -07006730/* input MUX */
6731/* FIXME: should be a matrix-type input source selection */
6732
6733static struct hda_input_mux alc882_capture_source = {
6734 .num_items = 4,
6735 .items = {
6736 { "Mic", 0x0 },
6737 { "Front Mic", 0x1 },
6738 { "Line", 0x2 },
6739 { "CD", 0x4 },
6740 },
6741};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006742
Takashi Iwai49535502009-06-30 15:28:30 +02006743#define alc883_capture_source alc882_capture_source
6744
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006745static struct hda_input_mux alc889_capture_source = {
6746 .num_items = 3,
6747 .items = {
6748 { "Front Mic", 0x0 },
6749 { "Mic", 0x3 },
6750 { "Line", 0x2 },
6751 },
6752};
6753
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006754static struct hda_input_mux mb5_capture_source = {
6755 .num_items = 3,
6756 .items = {
6757 { "Mic", 0x1 },
6758 { "Line", 0x2 },
6759 { "CD", 0x4 },
6760 },
6761};
6762
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006763static struct hda_input_mux macmini3_capture_source = {
6764 .num_items = 2,
6765 .items = {
6766 { "Line", 0x2 },
6767 { "CD", 0x4 },
6768 },
6769};
6770
Takashi Iwai49535502009-06-30 15:28:30 +02006771static struct hda_input_mux alc883_3stack_6ch_intel = {
6772 .num_items = 4,
6773 .items = {
6774 { "Mic", 0x1 },
6775 { "Front Mic", 0x0 },
6776 { "Line", 0x2 },
6777 { "CD", 0x4 },
6778 },
6779};
6780
6781static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6782 .num_items = 2,
6783 .items = {
6784 { "Mic", 0x1 },
6785 { "Line", 0x2 },
6786 },
6787};
6788
6789static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6790 .num_items = 4,
6791 .items = {
6792 { "Mic", 0x0 },
6793 { "iMic", 0x1 },
6794 { "Line", 0x2 },
6795 { "CD", 0x4 },
6796 },
6797};
6798
6799static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6800 .num_items = 2,
6801 .items = {
6802 { "Mic", 0x0 },
6803 { "Int Mic", 0x1 },
6804 },
6805};
6806
6807static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6808 .num_items = 3,
6809 .items = {
6810 { "Mic", 0x0 },
6811 { "Front Mic", 0x1 },
6812 { "Line", 0x4 },
6813 },
6814};
6815
6816static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6817 .num_items = 2,
6818 .items = {
6819 { "Mic", 0x0 },
6820 { "Line", 0x2 },
6821 },
6822};
6823
6824static struct hda_input_mux alc889A_mb31_capture_source = {
6825 .num_items = 2,
6826 .items = {
6827 { "Mic", 0x0 },
6828 /* Front Mic (0x01) unused */
6829 { "Line", 0x2 },
6830 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006831 /* CD (0x04) unused? */
Takashi Iwai49535502009-06-30 15:28:30 +02006832 },
6833};
6834
6835/*
6836 * 2ch mode
6837 */
6838static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6839 { 2, NULL }
6840};
6841
Kailang Yangdf694da2005-12-05 19:42:22 +01006842/*
Kailang Yang272a5272007-05-14 11:00:38 +02006843 * 2ch mode
6844 */
6845static struct hda_verb alc882_3ST_ch2_init[] = {
6846 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6847 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6850 { } /* end */
6851};
6852
6853/*
Takashi Iwai49535502009-06-30 15:28:30 +02006854 * 4ch mode
6855 */
6856static struct hda_verb alc882_3ST_ch4_init[] = {
6857 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6858 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6859 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6860 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6861 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6862 { } /* end */
6863};
6864
6865/*
Kailang Yang272a5272007-05-14 11:00:38 +02006866 * 6ch mode
6867 */
6868static struct hda_verb alc882_3ST_ch6_init[] = {
6869 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6870 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6871 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6872 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6873 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6874 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6875 { } /* end */
6876};
6877
Takashi Iwai49535502009-06-30 15:28:30 +02006878static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006879 { 2, alc882_3ST_ch2_init },
Takashi Iwai49535502009-06-30 15:28:30 +02006880 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006881 { 6, alc882_3ST_ch6_init },
6882};
6883
Takashi Iwai49535502009-06-30 15:28:30 +02006884#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6885
Kailang Yang272a5272007-05-14 11:00:38 +02006886/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306887 * 2ch mode
6888 */
6889static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6890 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6891 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6892 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6893 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6894 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6895 { } /* end */
6896};
6897
6898/*
6899 * 4ch mode
6900 */
6901static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6902 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6903 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6904 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6905 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6906 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6907 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6908 { } /* end */
6909};
6910
6911/*
6912 * 6ch mode
6913 */
6914static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6915 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6916 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6917 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6918 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6919 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6920 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6921 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6922 { } /* end */
6923};
6924
6925static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6926 { 2, alc883_3ST_ch2_clevo_init },
6927 { 4, alc883_3ST_ch4_clevo_init },
6928 { 6, alc883_3ST_ch6_clevo_init },
6929};
6930
6931
6932/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006933 * 6ch mode
6934 */
6935static struct hda_verb alc882_sixstack_ch6_init[] = {
6936 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6937 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6938 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6939 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6940 { } /* end */
6941};
6942
6943/*
6944 * 8ch mode
6945 */
6946static struct hda_verb alc882_sixstack_ch8_init[] = {
6947 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6948 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6949 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6950 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6951 { } /* end */
6952};
6953
6954static struct hda_channel_mode alc882_sixstack_modes[2] = {
6955 { 6, alc882_sixstack_ch6_init },
6956 { 8, alc882_sixstack_ch8_init },
6957};
6958
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08006959
6960/* Macbook Air 2,1 */
6961
6962static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
6963 { 2, NULL },
6964};
6965
Takashi Iwai87350ad2007-08-16 18:19:38 +02006966/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006967 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006968 */
6969
6970/*
6971 * 2ch mode
6972 */
6973static struct hda_verb alc885_mbp_ch2_init[] = {
6974 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6975 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6976 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6977 { } /* end */
6978};
6979
6980/*
Takashi Iwaia3f730a2009-08-31 08:15:26 +02006981 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006982 */
Takashi Iwaia3f730a2009-08-31 08:15:26 +02006983static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006984 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6985 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6986 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6987 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6988 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6989 { } /* end */
6990};
6991
Takashi Iwaia3f730a2009-08-31 08:15:26 +02006992static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006993 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730a2009-08-31 08:15:26 +02006994 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006995};
6996
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006997/*
6998 * 2ch
6999 * Speakers/Woofer/HP = Front
7000 * LineIn = Input
7001 */
7002static struct hda_verb alc885_mb5_ch2_init[] = {
7003 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7004 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7005 { } /* end */
7006};
7007
7008/*
7009 * 6ch mode
7010 * Speakers/HP = Front
7011 * Woofer = LFE
7012 * LineIn = Surround
7013 */
7014static struct hda_verb alc885_mb5_ch6_init[] = {
7015 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7017 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7018 { } /* end */
7019};
7020
7021static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7022 { 2, alc885_mb5_ch2_init },
7023 { 6, alc885_mb5_ch6_init },
7024};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007025
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007026#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai49535502009-06-30 15:28:30 +02007027
7028/*
7029 * 2ch mode
7030 */
7031static struct hda_verb alc883_4ST_ch2_init[] = {
7032 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7033 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7034 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7035 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7036 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7037 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7038 { } /* end */
7039};
7040
7041/*
7042 * 4ch mode
7043 */
7044static struct hda_verb alc883_4ST_ch4_init[] = {
7045 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7046 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7047 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7048 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7049 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7050 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7051 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7052 { } /* end */
7053};
7054
7055/*
7056 * 6ch mode
7057 */
7058static struct hda_verb alc883_4ST_ch6_init[] = {
7059 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7060 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7061 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7062 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7063 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7064 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7065 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7066 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7067 { } /* end */
7068};
7069
7070/*
7071 * 8ch mode
7072 */
7073static struct hda_verb alc883_4ST_ch8_init[] = {
7074 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7075 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7076 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7077 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7078 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7079 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
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
7086static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7087 { 2, alc883_4ST_ch2_init },
7088 { 4, alc883_4ST_ch4_init },
7089 { 6, alc883_4ST_ch6_init },
7090 { 8, alc883_4ST_ch8_init },
7091};
7092
7093
7094/*
7095 * 2ch mode
7096 */
7097static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7098 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7099 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7100 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7101 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7102 { } /* end */
7103};
7104
7105/*
7106 * 4ch mode
7107 */
7108static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7109 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7110 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7111 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7112 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7113 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7114 { } /* end */
7115};
7116
7117/*
7118 * 6ch mode
7119 */
7120static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7121 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7122 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7123 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7124 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7125 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7126 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7127 { } /* end */
7128};
7129
7130static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7131 { 2, alc883_3ST_ch2_intel_init },
7132 { 4, alc883_3ST_ch4_intel_init },
7133 { 6, alc883_3ST_ch6_intel_init },
7134};
7135
7136/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007137 * 2ch mode
7138 */
7139static struct hda_verb alc889_ch2_intel_init[] = {
7140 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7141 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7142 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7143 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7144 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7145 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7146 { } /* end */
7147};
7148
7149/*
Takashi Iwai49535502009-06-30 15:28:30 +02007150 * 6ch mode
7151 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007152static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007153 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7154 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7155 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7156 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7157 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007158 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7159 { } /* end */
7160};
7161
7162/*
7163 * 8ch mode
7164 */
7165static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007166 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7167 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7168 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7169 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7170 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007171 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7172 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007173 { } /* end */
7174};
7175
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007176static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7177 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007178 { 6, alc889_ch6_intel_init },
7179 { 8, alc889_ch8_intel_init },
7180};
7181
7182/*
7183 * 6ch mode
7184 */
Takashi Iwai49535502009-06-30 15:28:30 +02007185static struct hda_verb alc883_sixstack_ch6_init[] = {
7186 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7187 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7188 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7189 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7190 { } /* end */
7191};
7192
7193/*
7194 * 8ch mode
7195 */
7196static struct hda_verb alc883_sixstack_ch8_init[] = {
7197 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7198 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7199 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7200 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7201 { } /* end */
7202};
7203
7204static struct hda_channel_mode alc883_sixstack_modes[2] = {
7205 { 6, alc883_sixstack_ch6_init },
7206 { 8, alc883_sixstack_ch8_init },
7207};
7208
7209
Linus Torvalds1da177e2005-04-16 15:20:36 -07007210/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7211 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7212 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01007213static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007214 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007215 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007216 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007217 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007218 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7219 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007220 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7221 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007222 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007223 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007224 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7225 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7226 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7227 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7228 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7229 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007230 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7232 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007233 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007234 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007235 { } /* end */
7236};
7237
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007238/* Macbook Air 2,1 same control for HP and internal Speaker */
7239
7240static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7241 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7242 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7243 { }
7244};
7245
7246
Takashi Iwai87350ad2007-08-16 18:19:38 +02007247static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007248 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7249 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7250 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7251 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7252 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007253 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7254 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7256 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007257 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007258 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7259 { } /* end */
7260};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007261
7262static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007263 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7264 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7265 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7266 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7267 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7268 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307269 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7270 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007271 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7272 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7273 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7274 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7275 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7276 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7277 { } /* end */
7278};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007279
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007280static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7281 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7282 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7283 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7284 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7285 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7286 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7287 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7288 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7289 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7290 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7291 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7292 { } /* end */
7293};
7294
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007295static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7296 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7297 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7298 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7299 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7300 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7301 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7303 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7304 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7305 { } /* end */
7306};
7307
7308
Kailang Yangbdd148a2007-05-08 15:19:08 +02007309static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7310 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7311 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7313 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7314 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7315 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7317 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007319 { } /* end */
7320};
7321
Kailang Yang272a5272007-05-14 11:00:38 +02007322static struct snd_kcontrol_new alc882_targa_mixer[] = {
7323 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7324 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7325 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7326 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7327 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7328 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7329 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7331 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02007332 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007333 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7334 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02007335 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007336 { } /* end */
7337};
7338
7339/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7340 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7341 */
7342static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7343 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7344 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7345 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7346 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7347 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7348 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7349 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7350 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7351 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7352 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7354 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02007355 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007356 { } /* end */
7357};
7358
Takashi Iwai914759b2007-09-06 14:52:04 +02007359static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7360 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7361 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7362 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7363 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7364 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7365 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7366 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7368 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007370 { } /* end */
7371};
7372
Kailang Yangdf694da2005-12-05 19:42:22 +01007373static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7374 {
7375 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7376 .name = "Channel Mode",
7377 .info = alc_ch_mode_info,
7378 .get = alc_ch_mode_get,
7379 .put = alc_ch_mode_put,
7380 },
7381 { } /* end */
7382};
7383
Takashi Iwai49535502009-06-30 15:28:30 +02007384static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007385 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007386 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7387 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007388 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007389 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7390 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007391 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007392 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7393 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007394 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007395 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7396 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007397
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007398 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007399 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007400 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007401 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007402 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007403 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007404 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007405 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007406 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007407 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007408 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007409 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007410 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007411 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007412 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007413 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007414 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007415 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007416 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7417 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007418 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007419 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7420 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007421 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007422 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7423 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7424 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7425 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7426 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007427 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007428 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007429
7430 /* FIXME: use matrix-type input source selection */
7431 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007432 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007433 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007434 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007435 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007436 /* ADC2: mute amp left and right */
7437 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007438 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007439 /* ADC3: mute amp left and right */
7440 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007441 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007442
7443 { }
7444};
7445
Takashi Iwai49535502009-06-30 15:28:30 +02007446static struct hda_verb alc882_adc1_init_verbs[] = {
7447 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7452 /* ADC1: mute amp left and right */
7453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7454 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7455 { }
7456};
7457
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007458static struct hda_verb alc882_eapd_verbs[] = {
7459 /* change to EAPD mode */
7460 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007461 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007462 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007463};
7464
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007465static struct hda_verb alc889_eapd_verbs[] = {
7466 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7467 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7468 { }
7469};
7470
Wu Fengguang6732bd02009-07-30 09:19:14 +02007471static struct hda_verb alc_hp15_unsol_verbs[] = {
7472 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7473 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7474 {}
7475};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007476
7477static struct hda_verb alc885_init_verbs[] = {
7478 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007479 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7480 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007481 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007482 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7483 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007484 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007485 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007487 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007488 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7489 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007490
7491 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007492 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007493 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7494 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7495 /* Front Pin: output 0 (0x0c) */
7496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7498 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7499 /* Rear Pin: output 1 (0x0d) */
7500 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7501 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7502 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7503 /* CLFE Pin: output 2 (0x0e) */
7504 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7505 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7506 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7507 /* Side Pin: output 3 (0x0f) */
7508 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7509 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7510 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7511 /* Mic (rear) pin: input vref at 80% */
7512 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7513 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7514 /* Front Mic pin: input vref at 80% */
7515 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7516 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7517 /* Line In pin: input */
7518 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7519 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7520
7521 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7522 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007523 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007524 /* Input mixer2 */
7525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007526 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007528 /* ADC2: mute amp left and right */
7529 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7530 /* ADC3: mute amp left and right */
7531 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7532
7533 { }
7534};
7535
7536static struct hda_verb alc885_init_input_verbs[] = {
7537 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7538 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7539 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7540 { }
7541};
7542
7543
7544/* Unmute Selector 24h and set the default input to front mic */
7545static struct hda_verb alc889_init_input_verbs[] = {
7546 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7547 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7548 { }
7549};
7550
7551
Takashi Iwai49535502009-06-30 15:28:30 +02007552#define alc883_init_verbs alc882_base_init_verbs
7553
Tobin Davis9102cd12006-12-15 10:02:12 +01007554/* Mac Pro test */
7555static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7556 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7557 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7558 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7559 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7560 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007561 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007562 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7563 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007564 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007565 { } /* end */
7566};
7567
7568static struct hda_verb alc882_macpro_init_verbs[] = {
7569 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7570 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7571 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7572 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7573 /* Front Pin: output 0 (0x0c) */
7574 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7575 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7576 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7577 /* Front Mic pin: input vref at 80% */
7578 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7579 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7580 /* Speaker: output */
7581 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7582 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7583 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7584 /* Headphone output (output 0 - 0x0c) */
7585 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7586 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7587 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7588
7589 /* FIXME: use matrix-type input source selection */
7590 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7591 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7594 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7595 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7596 /* Input mixer2 */
7597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7599 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7600 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7601 /* Input mixer3 */
7602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7603 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7604 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7605 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7606 /* ADC1: mute amp left and right */
7607 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7608 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7609 /* ADC2: mute amp left and right */
7610 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7611 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7612 /* ADC3: mute amp left and right */
7613 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7614 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7615
7616 { }
7617};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007618
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007619/* Macbook 5,1 */
7620static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007621 /* DACs */
7622 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7623 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7624 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7625 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007626 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7629 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007630 /* Surround mixer */
7631 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7632 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7633 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7634 /* LFE mixer */
7635 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7636 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7637 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7638 /* HP mixer */
7639 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7640 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7641 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7642 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007643 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7644 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007645 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7646 /* LFE Pin (0x0e) */
7647 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7649 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7650 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007651 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7652 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007653 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307654 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007655 /* Front Mic pin: input vref at 80% */
7656 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7657 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7658 /* Line In pin */
7659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7661
7662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
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 { }
7667};
7668
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007669/* Macmini 3,1 */
7670static struct hda_verb alc885_macmini3_init_verbs[] = {
7671 /* DACs */
7672 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7673 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7674 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7675 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7676 /* Front mixer */
7677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7680 /* Surround mixer */
7681 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7682 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7683 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7684 /* LFE mixer */
7685 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7686 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7687 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7688 /* HP mixer */
7689 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7690 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7691 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7692 /* Front Pin (0x0c) */
7693 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7694 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7695 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7696 /* LFE Pin (0x0e) */
7697 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7698 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7699 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7700 /* HP Pin (0x0f) */
7701 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7703 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7704 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7705 /* Line In pin */
7706 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7708
7709 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7710 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7711 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7712 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7713 { }
7714};
7715
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007716
7717static struct hda_verb alc885_mba21_init_verbs[] = {
7718 /*Internal and HP Speaker Mixer*/
7719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7722 /*Internal Speaker Pin (0x0c)*/
7723 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
7724 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7725 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7726 /* HP Pin: output 0 (0x0e) */
7727 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7729 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7730 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
7731 /* Line in (is hp when jack connected)*/
7732 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
7733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7734
7735 { }
7736 };
7737
7738
Takashi Iwai87350ad2007-08-16 18:19:38 +02007739/* Macbook Pro rev3 */
7740static struct hda_verb alc885_mbp3_init_verbs[] = {
7741 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7742 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7745 /* Rear mixer */
7746 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7748 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007749 /* HP mixer */
7750 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7751 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7752 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007753 /* Front Pin: output 0 (0x0c) */
7754 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7755 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7756 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007757 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007758 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007759 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7760 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007761 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7762 /* Mic (rear) pin: input vref at 80% */
7763 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7764 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7765 /* Front Mic pin: input vref at 80% */
7766 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7767 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7768 /* Line In pin: use output 1 when in LineOut mode */
7769 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7770 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7771 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7772
7773 /* FIXME: use matrix-type input source selection */
7774 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7775 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7776 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7777 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7778 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7779 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7780 /* Input mixer2 */
7781 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7782 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7783 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7784 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7785 /* Input mixer3 */
7786 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7787 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7788 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7789 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7790 /* ADC1: mute amp left and right */
7791 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7792 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7793 /* ADC2: mute amp left and right */
7794 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7795 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7796 /* ADC3: mute amp left and right */
7797 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7798 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7799
7800 { }
7801};
7802
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007803/* iMac 9,1 */
7804static struct hda_verb alc885_imac91_init_verbs[] = {
7805 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7809 /* Rear mixer */
7810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7811 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7812 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7813 /* HP Pin: output 0 (0x0c) */
7814 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7815 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7816 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7817 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7818 /* Internal Speakers: output 0 (0x0d) */
7819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7820 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7821 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7822 /* Mic (rear) pin: input vref at 80% */
7823 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7824 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7825 /* Front Mic pin: input vref at 80% */
7826 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7827 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7828 /* Line In pin: use output 1 when in LineOut mode */
7829 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7830 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7831 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7832
7833 /* FIXME: use matrix-type input source selection */
7834 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7835 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7836 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7837 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7838 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7839 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7840 /* Input mixer2 */
7841 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7842 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7843 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7844 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7845 /* Input mixer3 */
7846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7848 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7849 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7850 /* ADC1: mute amp left and right */
7851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7852 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7853 /* ADC2: mute amp left and right */
7854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7855 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7856 /* ADC3: mute amp left and right */
7857 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7858 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7859
7860 { }
7861};
7862
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007863/* iMac 24 mixer. */
7864static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7865 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7866 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7867 { } /* end */
7868};
7869
7870/* iMac 24 init verbs. */
7871static struct hda_verb alc885_imac24_init_verbs[] = {
7872 /* Internal speakers: output 0 (0x0c) */
7873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7875 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7876 /* Internal speakers: output 0 (0x0c) */
7877 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7878 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7879 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7880 /* Headphone: output 0 (0x0c) */
7881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7883 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7884 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7885 /* Front Mic: input vref at 80% */
7886 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7887 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7888 { }
7889};
7890
7891/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007892static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007893{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007894 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007895
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007896 spec->autocfg.hp_pins[0] = 0x14;
7897 spec->autocfg.speaker_pins[0] = 0x18;
7898 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007899}
7900
Takashi Iwai9d54f082010-02-22 08:34:40 +01007901#define alc885_mb5_setup alc885_imac24_setup
7902#define alc885_macmini3_setup alc885_imac24_setup
7903
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007904/* Macbook Air 2,1 */
7905static void alc885_mba21_setup(struct hda_codec *codec)
7906{
7907 struct alc_spec *spec = codec->spec;
7908
7909 spec->autocfg.hp_pins[0] = 0x14;
7910 spec->autocfg.speaker_pins[0] = 0x18;
7911}
7912
7913
7914
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007915static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007916{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007917 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007918
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007919 spec->autocfg.hp_pins[0] = 0x15;
7920 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007921}
7922
Takashi Iwai9d54f082010-02-22 08:34:40 +01007923static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10307924{
Takashi Iwai9d54f082010-02-22 08:34:40 +01007925 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10307926
Takashi Iwai9d54f082010-02-22 08:34:40 +01007927 spec->autocfg.hp_pins[0] = 0x14;
7928 spec->autocfg.speaker_pins[0] = 0x15;
7929 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007930}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007931
Kailang Yang272a5272007-05-14 11:00:38 +02007932static struct hda_verb alc882_targa_verbs[] = {
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
7936 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007938
Kailang Yang272a5272007-05-14 11:00:38 +02007939 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7940 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7941 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7942
7943 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007944 { } /* end */
7945};
7946
7947/* toggle speaker-output according to the hp-jack state */
7948static void alc882_targa_automute(struct hda_codec *codec)
7949{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007950 struct alc_spec *spec = codec->spec;
7951 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007952 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007953 spec->jack_present ? 1 : 3);
7954}
7955
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007956static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007957{
7958 struct alc_spec *spec = codec->spec;
7959
7960 spec->autocfg.hp_pins[0] = 0x14;
7961 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007962}
7963
7964static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7965{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007966 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007967 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007968}
7969
7970static struct hda_verb alc882_asus_a7j_verbs[] = {
7971 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7972 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7973
7974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7976 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007977
Kailang Yang272a5272007-05-14 11:00:38 +02007978 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7979 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7980 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7981
7982 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7983 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7984 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7985 { } /* end */
7986};
7987
Takashi Iwai914759b2007-09-06 14:52:04 +02007988static struct hda_verb alc882_asus_a7m_verbs[] = {
7989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7991
7992 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7993 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7994 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007995
Takashi Iwai914759b2007-09-06 14:52:04 +02007996 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7997 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7998 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7999
8000 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8001 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8002 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8003 { } /* end */
8004};
8005
Tobin Davis9102cd12006-12-15 10:02:12 +01008006static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8007{
8008 unsigned int gpiostate, gpiomask, gpiodir;
8009
8010 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8011 AC_VERB_GET_GPIO_DATA, 0);
8012
8013 if (!muted)
8014 gpiostate |= (1 << pin);
8015 else
8016 gpiostate &= ~(1 << pin);
8017
8018 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8019 AC_VERB_GET_GPIO_MASK, 0);
8020 gpiomask |= (1 << pin);
8021
8022 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8023 AC_VERB_GET_GPIO_DIRECTION, 0);
8024 gpiodir |= (1 << pin);
8025
8026
8027 snd_hda_codec_write(codec, codec->afg, 0,
8028 AC_VERB_SET_GPIO_MASK, gpiomask);
8029 snd_hda_codec_write(codec, codec->afg, 0,
8030 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8031
8032 msleep(1);
8033
8034 snd_hda_codec_write(codec, codec->afg, 0,
8035 AC_VERB_SET_GPIO_DATA, gpiostate);
8036}
8037
Takashi Iwai7debbe52007-08-16 15:01:03 +02008038/* set up GPIO at initialization */
8039static void alc885_macpro_init_hook(struct hda_codec *codec)
8040{
8041 alc882_gpio_mute(codec, 0, 0);
8042 alc882_gpio_mute(codec, 1, 0);
8043}
8044
8045/* set up GPIO and update auto-muting at initialization */
8046static void alc885_imac24_init_hook(struct hda_codec *codec)
8047{
8048 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008049 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008050}
8051
Kailang Yangdf694da2005-12-05 19:42:22 +01008052/*
8053 * generic initialization of ADC, input mixers and output mixers
8054 */
Takashi Iwai49535502009-06-30 15:28:30 +02008055static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008056 /*
8057 * Unmute ADC0-2 and set the default input to mic-in
8058 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008059 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8060 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8061 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8063
Kailang Yangdf694da2005-12-05 19:42:22 +01008064 /*
8065 * Set up output mixers (0x0c - 0x0f)
8066 */
8067 /* set vol=0 to output mixers */
8068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8069 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8070 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8071 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8072 /* set up input amps for analog loopback */
8073 /* Amp Indices: DAC = 0, mixer = 1 */
8074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8076 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8077 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8078 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8079 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8080 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8082 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8083 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8084
8085 /* FIXME: use matrix-type input source selection */
8086 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008087 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008088 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008089 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008091 { }
8092};
8093
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008094/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8095static struct hda_verb alc889A_mb31_ch2_init[] = {
8096 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8097 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8098 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8099 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8100 { } /* end */
8101};
8102
8103/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8104static struct hda_verb alc889A_mb31_ch4_init[] = {
8105 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8106 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8107 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8108 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8109 { } /* end */
8110};
8111
8112/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8113static struct hda_verb alc889A_mb31_ch5_init[] = {
8114 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8115 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8116 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8117 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8118 { } /* end */
8119};
8120
8121/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8122static struct hda_verb alc889A_mb31_ch6_init[] = {
8123 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8124 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8125 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8126 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8127 { } /* end */
8128};
8129
8130static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8131 { 2, alc889A_mb31_ch2_init },
8132 { 4, alc889A_mb31_ch4_init },
8133 { 5, alc889A_mb31_ch5_init },
8134 { 6, alc889A_mb31_ch6_init },
8135};
8136
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008137static struct hda_verb alc883_medion_eapd_verbs[] = {
8138 /* eanable EAPD on medion laptop */
8139 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8140 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8141 { }
8142};
8143
Takashi Iwai49535502009-06-30 15:28:30 +02008144#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008145
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008146static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8147 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8148 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8149 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8150 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8151 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8152 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8153 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8155 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8157 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8158 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8159 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008160 { } /* end */
8161};
8162
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008163static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008164 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8165 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8166 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8167 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8168 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8169 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8170 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8171 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8172 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8173 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008174 { } /* end */
8175};
8176
Jiang zhefb97dc62008-03-06 11:07:11 +01008177static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8178 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8179 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8180 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8181 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8183 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8184 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8185 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8186 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8187 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008188 { } /* end */
8189};
8190
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008191static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8192 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8193 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8194 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8195 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8196 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8197 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8198 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008200 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8202 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008203 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008204 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008205 { } /* end */
8206};
8207
8208static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8209 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8210 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8211 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8212 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8213 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8214 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8215 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8216 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8218 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8219 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8220 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8221 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008223 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8225 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008226 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008228 { } /* end */
8229};
8230
Jiang zhe17bba1b2008-06-04 12:11:07 +02008231static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8232 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8233 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8234 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8235 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8236 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8237 HDA_OUTPUT),
8238 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8239 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8240 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8241 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8242 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8243 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8244 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8245 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8247 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8249 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8250 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8251 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008252 { } /* end */
8253};
8254
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008255static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8256 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8257 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8258 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8259 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8260 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8261 HDA_OUTPUT),
8262 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8263 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8264 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8265 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8266 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8268 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8269 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8271 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8272 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8273 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8274 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8275 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8276 { } /* end */
8277};
8278
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008279static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008280 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008281 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008282 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008283 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008284 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8285 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008286 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8287 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008288 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8289 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8290 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8291 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8292 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8293 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008294 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8296 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008297 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008298 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008299 { } /* end */
8300};
8301
Sasha Alexandrc2592492009-06-16 14:52:54 -04008302static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008303 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008304 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008305 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008306 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008307 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8308 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8309 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8310 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8311 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8312 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008318 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008320 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008321};
Kailang Yangccc656c2006-10-17 12:32:26 +02008322
Sasha Alexandrc2592492009-06-16 14:52:54 -04008323static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008324 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008325 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008326 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008327 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008328 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8329 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008331 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008332 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008333 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8334 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8335 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008336 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008337};
Kailang Yangccc656c2006-10-17 12:32:26 +02008338
Takashi Iwaib99dba32009-09-17 18:23:00 +02008339static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8340 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8341 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8342 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8343 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8344 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8345 { } /* end */
8346};
8347
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008348static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8349 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8350 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008351 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8352 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8355 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008357 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008358};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008359
Kailang Yang272a5272007-05-14 11:00:38 +02008360static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8361 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8362 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8363 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8364 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8365 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8368 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8369 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008370 { } /* end */
8371};
8372
8373static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8374 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8375 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8376 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8377 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8378 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8379 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8380 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8381 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8382 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008383 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008384};
Kailang Yang272a5272007-05-14 11:00:38 +02008385
Tobin Davis2880a862007-08-07 11:50:26 +02008386static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008387 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8388 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008389 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008390 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8391 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8393 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008395 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008396};
Tobin Davis2880a862007-08-07 11:50:26 +02008397
Tony Vroond2fd4b02009-06-21 00:40:10 +01008398static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8399 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8400 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8401 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8402 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008403 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8404 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008405 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8406 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8407 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8408 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8409 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8410 { } /* end */
8411};
8412
Kailang Yange2757d52008-08-26 13:17:46 +02008413static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8414 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8415 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8416 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8417 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8418 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8419 0x0d, 1, 0x0, HDA_OUTPUT),
8420 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8421 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8422 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8423 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8424 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008425 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8426 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8427 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8428 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8429 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8430 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8432 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8433 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8434 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008435 { } /* end */
8436};
8437
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008438static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8439 /* Output mixers */
8440 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8441 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8442 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8443 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8444 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8445 HDA_OUTPUT),
8446 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8447 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8448 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8449 /* Output switches */
8450 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8451 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8452 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8453 /* Boost mixers */
8454 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8455 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8456 /* Input mixers */
8457 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8458 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8459 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8460 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8461 { } /* end */
8462};
8463
Guido Günther3e1647c2009-06-05 00:47:26 +02008464static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8465 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8466 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8467 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8468 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8469 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8470 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8471 { } /* end */
8472};
8473
Kailang Yange2757d52008-08-26 13:17:46 +02008474static struct hda_bind_ctls alc883_bind_cap_vol = {
8475 .ops = &snd_hda_bind_vol,
8476 .values = {
8477 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8478 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8479 0
8480 },
8481};
8482
8483static struct hda_bind_ctls alc883_bind_cap_switch = {
8484 .ops = &snd_hda_bind_sw,
8485 .values = {
8486 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8487 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8488 0
8489 },
8490};
8491
8492static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8493 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8494 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8495 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8496 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8497 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8499 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8500 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008501 { } /* end */
8502};
8503
8504static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008505 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8506 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8507 {
8508 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8509 /* .name = "Capture Source", */
8510 .name = "Input Source",
8511 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008512 .info = alc_mux_enum_info,
8513 .get = alc_mux_enum_get,
8514 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008515 },
8516 { } /* end */
8517};
8518
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008519static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8520 {
8521 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8522 .name = "Channel Mode",
8523 .info = alc_ch_mode_info,
8524 .get = alc_ch_mode_get,
8525 .put = alc_ch_mode_put,
8526 },
8527 { } /* end */
8528};
8529
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008530/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008531static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008532{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008533 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008534
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008535 spec->autocfg.hp_pins[0] = 0x15;
8536 spec->autocfg.speaker_pins[0] = 0x14;
8537 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008538}
8539
8540/* auto-toggle front mic */
8541/*
8542static void alc883_mitac_mic_automute(struct hda_codec *codec)
8543{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008544 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008545
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008546 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8547}
8548*/
8549
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008550static struct hda_verb alc883_mitac_verbs[] = {
8551 /* HP */
8552 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8553 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8554 /* Subwoofer */
8555 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8556 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8557
8558 /* enable unsolicited event */
8559 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8560 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8561
8562 { } /* end */
8563};
8564
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308565static struct hda_verb alc883_clevo_m540r_verbs[] = {
8566 /* HP */
8567 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8569 /* Int speaker */
8570 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8571
8572 /* enable unsolicited event */
8573 /*
8574 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8575 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8576 */
8577
8578 { } /* end */
8579};
8580
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008581static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008582 /* HP */
8583 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8585 /* Int speaker */
8586 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8587 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8588
8589 /* enable unsolicited event */
8590 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008591 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008592
8593 { } /* end */
8594};
8595
Jiang zhefb97dc62008-03-06 11:07:11 +01008596static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8597 /* HP */
8598 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8600 /* Subwoofer */
8601 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8602 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8603
8604 /* enable unsolicited event */
8605 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8606
8607 { } /* end */
8608};
8609
Sasha Alexandrc2592492009-06-16 14:52:54 -04008610static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008611 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8612 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8613
8614 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8615 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008616
David Heidelberger64a8be72009-06-08 16:15:18 +02008617/* Connect Line-Out side jack (SPDIF) to Side */
8618 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8619 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8620 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8621/* Connect Mic jack to CLFE */
8622 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8623 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8624 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8625/* Connect Line-in jack to Surround */
8626 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8627 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8628 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8629/* Connect HP out jack to Front */
8630 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8631 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8632 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008633
8634 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008635
8636 { } /* end */
8637};
8638
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008639static struct hda_verb alc883_lenovo_101e_verbs[] = {
8640 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8641 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8642 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8643 { } /* end */
8644};
8645
Kailang Yang272a5272007-05-14 11:00:38 +02008646static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8647 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8649 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8650 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8651 { } /* end */
8652};
8653
8654static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8657 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8658 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8659 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8660 { } /* end */
8661};
8662
Kailang Yang189609a2007-08-20 11:31:23 +02008663static struct hda_verb alc883_haier_w66_verbs[] = {
8664 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8665 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8666
8667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8668
8669 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8670 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8671 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8672 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8673 { } /* end */
8674};
8675
Kailang Yange2757d52008-08-26 13:17:46 +02008676static struct hda_verb alc888_lenovo_sky_verbs[] = {
8677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8679 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8680 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8681 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8682 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8683 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8684 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8685 { } /* end */
8686};
8687
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008688static struct hda_verb alc888_6st_dell_verbs[] = {
8689 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8690 { }
8691};
8692
Guido Günther3e1647c2009-06-05 00:47:26 +02008693static struct hda_verb alc883_vaiott_verbs[] = {
8694 /* HP */
8695 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8696 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8697
8698 /* enable unsolicited event */
8699 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8700
8701 { } /* end */
8702};
8703
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008704static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008705{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008706 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008707
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008708 spec->autocfg.hp_pins[0] = 0x1b;
8709 spec->autocfg.speaker_pins[0] = 0x14;
8710 spec->autocfg.speaker_pins[1] = 0x16;
8711 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008712}
8713
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008714static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008715 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008716 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8717 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008718 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008719 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008720};
8721
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008722/*
8723 * 2ch mode
8724 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008725static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008726 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8727 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8728 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8729 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008730 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008731};
8732
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008733/*
8734 * 4ch mode
8735 */
8736static struct hda_verb alc888_3st_hp_4ch_init[] = {
8737 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8738 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8739 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8740 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8741 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8742 { } /* end */
8743};
8744
8745/*
8746 * 6ch mode
8747 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008748static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008749 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8750 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008751 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008752 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8753 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008754 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8755 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008756};
8757
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008758static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008759 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008760 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008761 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008762};
8763
Kailang Yang272a5272007-05-14 11:00:38 +02008764/* toggle front-jack and RCA according to the hp-jack state */
8765static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8766{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008767 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008768
Takashi Iwai47fd8302007-08-10 17:11:07 +02008769 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8770 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8771 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8772 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008773}
8774
8775/* toggle RCA according to the front-jack state */
8776static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8777{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008778 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008779
Takashi Iwai47fd8302007-08-10 17:11:07 +02008780 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8781 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008782}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008783
Kailang Yang272a5272007-05-14 11:00:38 +02008784static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8785 unsigned int res)
8786{
8787 if ((res >> 26) == ALC880_HP_EVENT)
8788 alc888_lenovo_ms7195_front_automute(codec);
8789 if ((res >> 26) == ALC880_FRONT_EVENT)
8790 alc888_lenovo_ms7195_rca_automute(codec);
8791}
8792
8793static struct hda_verb alc883_medion_md2_verbs[] = {
8794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8795 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8796
8797 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8798
8799 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8800 { } /* end */
8801};
8802
8803/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008804static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008805{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008806 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008807
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008808 spec->autocfg.hp_pins[0] = 0x14;
8809 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008810}
8811
Kailang Yangccc656c2006-10-17 12:32:26 +02008812/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008813#define alc883_targa_init_hook alc882_targa_init_hook
8814#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008815
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008816static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8817{
8818 unsigned int present;
8819
Takashi Iwaid56757a2009-11-18 08:00:14 +01008820 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008821 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8822 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8823}
8824
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008825static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008826{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008827 struct alc_spec *spec = codec->spec;
8828
8829 spec->autocfg.hp_pins[0] = 0x15;
8830 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008831}
8832
8833static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8834{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008835 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008836 alc883_clevo_m720_mic_automute(codec);
8837}
8838
8839static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008840 unsigned int res)
8841{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008842 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008843 case ALC880_MIC_EVENT:
8844 alc883_clevo_m720_mic_automute(codec);
8845 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008846 default:
8847 alc_automute_amp_unsol_event(codec, res);
8848 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008849 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008850}
8851
Jiang zhefb97dc62008-03-06 11:07:11 +01008852/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008853static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008854{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008855 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008856
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008857 spec->autocfg.hp_pins[0] = 0x14;
8858 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008859}
8860
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008861static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008862{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008863 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008864
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008865 spec->autocfg.hp_pins[0] = 0x1b;
8866 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008867}
8868
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008869static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8870{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008871 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008872
Takashi Iwai47fd8302007-08-10 17:11:07 +02008873 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8874 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008875}
8876
8877static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8878{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008879 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008880
Takashi Iwai47fd8302007-08-10 17:11:07 +02008881 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8882 HDA_AMP_MUTE, bits);
8883 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8884 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008885}
8886
8887static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8888 unsigned int res)
8889{
8890 if ((res >> 26) == ALC880_HP_EVENT)
8891 alc883_lenovo_101e_all_automute(codec);
8892 if ((res >> 26) == ALC880_FRONT_EVENT)
8893 alc883_lenovo_101e_ispeaker_automute(codec);
8894}
8895
Takashi Iwai676a9b52007-08-16 15:23:35 +02008896/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008897static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008898{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008899 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008900
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008901 spec->autocfg.hp_pins[0] = 0x14;
8902 spec->autocfg.speaker_pins[0] = 0x15;
8903 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008904}
8905
Kailang Yangd1a991a2007-08-15 16:21:59 +02008906static struct hda_verb alc883_acer_eapd_verbs[] = {
8907 /* HP Pin: output 0 (0x0c) */
8908 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8910 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8911 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008912 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8913 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008914 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008915 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8916 /* eanable EAPD on medion laptop */
8917 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8918 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008919 /* enable unsolicited event */
8920 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008921 { }
8922};
8923
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008924static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8925 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8926 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8927 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8928 { } /* end */
8929};
8930
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008931static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008932{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008933 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008934
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008935 spec->autocfg.hp_pins[0] = 0x1b;
8936 spec->autocfg.speaker_pins[0] = 0x14;
8937 spec->autocfg.speaker_pins[1] = 0x15;
8938 spec->autocfg.speaker_pins[2] = 0x16;
8939 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008940}
8941
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008942static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008943{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008944 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008945
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008946 spec->autocfg.hp_pins[0] = 0x1b;
8947 spec->autocfg.speaker_pins[0] = 0x14;
8948 spec->autocfg.speaker_pins[1] = 0x15;
8949 spec->autocfg.speaker_pins[2] = 0x16;
8950 spec->autocfg.speaker_pins[3] = 0x17;
8951 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008952}
8953
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008954static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008955{
8956 struct alc_spec *spec = codec->spec;
8957
8958 spec->autocfg.hp_pins[0] = 0x15;
8959 spec->autocfg.speaker_pins[0] = 0x14;
8960 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008961}
8962
Kailang Yange2757d52008-08-26 13:17:46 +02008963static struct hda_verb alc888_asus_m90v_verbs[] = {
8964 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8965 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8966 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8967 /* enable unsolicited event */
8968 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8969 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8970 { } /* end */
8971};
8972
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008973static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008974{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008975 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008976
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008977 spec->autocfg.hp_pins[0] = 0x1b;
8978 spec->autocfg.speaker_pins[0] = 0x14;
8979 spec->autocfg.speaker_pins[1] = 0x15;
8980 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008981 spec->ext_mic.pin = 0x18;
8982 spec->int_mic.pin = 0x19;
8983 spec->ext_mic.mux_idx = 0;
8984 spec->int_mic.mux_idx = 1;
8985 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008986}
8987
8988static struct hda_verb alc888_asus_eee1601_verbs[] = {
8989 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8990 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8991 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8994 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8995 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8996 /* enable unsolicited event */
8997 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8998 { } /* end */
8999};
9000
Kailang Yange2757d52008-08-26 13:17:46 +02009001static void alc883_eee1601_inithook(struct hda_codec *codec)
9002{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009003 struct alc_spec *spec = codec->spec;
9004
9005 spec->autocfg.hp_pins[0] = 0x14;
9006 spec->autocfg.speaker_pins[0] = 0x1b;
9007 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009008}
9009
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009010static struct hda_verb alc889A_mb31_verbs[] = {
9011 /* Init rear pin (used as headphone output) */
9012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9014 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9015 /* Init line pin (used as output in 4ch and 6ch mode) */
9016 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9017 /* Init line 2 pin (used as headphone out by default) */
9018 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9019 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9020 { } /* end */
9021};
9022
9023/* Mute speakers according to the headphone jack state */
9024static void alc889A_mb31_automute(struct hda_codec *codec)
9025{
9026 unsigned int present;
9027
9028 /* Mute only in 2ch or 4ch mode */
9029 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9030 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009031 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009032 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9033 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9034 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9035 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9036 }
9037}
9038
9039static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9040{
9041 if ((res >> 26) == ALC880_HP_EVENT)
9042 alc889A_mb31_automute(codec);
9043}
9044
Takashi Iwai49535502009-06-30 15:28:30 +02009045
Takashi Iwaicb53c622007-08-10 17:21:45 +02009046#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai49535502009-06-30 15:28:30 +02009047#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009048#endif
9049
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009050/* pcm configuration: identical with ALC880 */
Takashi Iwai49535502009-06-30 15:28:30 +02009051#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9052#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9053#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9054#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9055
9056static hda_nid_t alc883_slave_dig_outs[] = {
9057 ALC1200_DIGOUT_NID, 0,
9058};
9059
9060static hda_nid_t alc1200_slave_dig_outs[] = {
9061 ALC883_DIGOUT_NID, 0,
9062};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009063
9064/*
9065 * configuration and preset
9066 */
Takashi Iwai49535502009-06-30 15:28:30 +02009067static const char *alc882_models[ALC882_MODEL_LAST] = {
9068 [ALC882_3ST_DIG] = "3stack-dig",
9069 [ALC882_6ST_DIG] = "6stack-dig",
9070 [ALC882_ARIMA] = "arima",
9071 [ALC882_W2JC] = "w2jc",
9072 [ALC882_TARGA] = "targa",
9073 [ALC882_ASUS_A7J] = "asus-a7j",
9074 [ALC882_ASUS_A7M] = "asus-a7m",
9075 [ALC885_MACPRO] = "macpro",
9076 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009077 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009078 [ALC885_MBA21] = "mba21",
Takashi Iwai49535502009-06-30 15:28:30 +02009079 [ALC885_MBP3] = "mbp3",
9080 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009081 [ALC885_IMAC91] = "imac91",
Takashi Iwai49535502009-06-30 15:28:30 +02009082 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009083 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9084 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai49535502009-06-30 15:28:30 +02009085 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009086 [ALC883_TARGA_DIG] = "targa-dig",
9087 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009088 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009089 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009090 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009091 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009092 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009093 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009094 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009095 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009096 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009097 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009098 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009099 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9100 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009101 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009102 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009103 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009104 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009105 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309106 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009107 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009108 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009109 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009110 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009111 [ALC889A_INTEL] = "intel-alc889a",
9112 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009113 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009114 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009115 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai49535502009-06-30 15:28:30 +02009116 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009117};
9118
Takashi Iwai49535502009-06-30 15:28:30 +02009119static struct snd_pci_quirk alc882_cfg_tbl[] = {
9120 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9121
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009122 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009123 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009124 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009125 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9126 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009127 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009128 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9129 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009130 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009131 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009132 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9133 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009134 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9135 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai49535502009-06-30 15:28:30 +02009136 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9137 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009138 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009139 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009140 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009141 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009142 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9143 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009144 /* default Acer -- disabled as it causes more problems.
9145 * model=auto should work fine now
9146 */
9147 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai49535502009-06-30 15:28:30 +02009148
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009149 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai49535502009-06-30 15:28:30 +02009150
Tobin Davisfebe3372007-06-12 11:27:46 +02009151 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009152 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9153 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009154 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009155 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009156 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai49535502009-06-30 15:28:30 +02009157
9158 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9159 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9160 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009161 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai49535502009-06-30 15:28:30 +02009162 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9163 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9164 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009165 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009166 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009167 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009168 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai49535502009-06-30 15:28:30 +02009169
9170 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009171 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02009172 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009173 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009174 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9175 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009176 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009177 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai49535502009-06-30 15:28:30 +02009178 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9179
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009180 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9181 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9182 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02009183 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009184 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai49535502009-06-30 15:28:30 +02009185 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009186 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009187 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009188 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9189 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9190 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9191 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9192 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9193 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009194 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009195 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9196 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9197 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009198 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009199 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9200 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009201 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009202 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009203 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009204 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009205 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009206 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009207 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009208 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02009209
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009210 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009211 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9212 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309213 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009214 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009215 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai49535502009-06-30 15:28:30 +02009216 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009217 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009218 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009219 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009220 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009221 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009222 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009223 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009224 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9225 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009226 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009227 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009228 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009229 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009230 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai49535502009-06-30 15:28:30 +02009231
Jiang zhe17bba1b2008-06-04 12:11:07 +02009232 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9233 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009234 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009235 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9236 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9237 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009238 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai49535502009-06-30 15:28:30 +02009239
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009240 {}
9241};
9242
Takashi Iwai49535502009-06-30 15:28:30 +02009243/* codec SSID table for Intel Mac */
9244static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9245 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9246 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9247 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9248 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9249 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9250 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9251 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9252 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9253 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9254 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009255 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai49535502009-06-30 15:28:30 +02009256 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009257 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9258 * so apparently no perfect solution yet
Takashi Iwai49535502009-06-30 15:28:30 +02009259 */
9260 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009261 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009262 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai49535502009-06-30 15:28:30 +02009263 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009264};
9265
Takashi Iwai49535502009-06-30 15:28:30 +02009266static struct alc_config_preset alc882_presets[] = {
9267 [ALC882_3ST_DIG] = {
9268 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009269 .init_verbs = { alc882_base_init_verbs,
9270 alc882_adc1_init_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02009271 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9272 .dac_nids = alc882_dac_nids,
9273 .dig_out_nid = ALC882_DIGOUT_NID,
9274 .dig_in_nid = ALC882_DIGIN_NID,
9275 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9276 .channel_mode = alc882_ch_modes,
9277 .need_dac_fix = 1,
9278 .input_mux = &alc882_capture_source,
9279 },
9280 [ALC882_6ST_DIG] = {
9281 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009282 .init_verbs = { alc882_base_init_verbs,
9283 alc882_adc1_init_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02009284 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9285 .dac_nids = alc882_dac_nids,
9286 .dig_out_nid = ALC882_DIGOUT_NID,
9287 .dig_in_nid = ALC882_DIGIN_NID,
9288 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9289 .channel_mode = alc882_sixstack_modes,
9290 .input_mux = &alc882_capture_source,
9291 },
9292 [ALC882_ARIMA] = {
9293 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009294 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9295 alc882_eapd_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02009296 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9297 .dac_nids = alc882_dac_nids,
9298 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9299 .channel_mode = alc882_sixstack_modes,
9300 .input_mux = &alc882_capture_source,
9301 },
9302 [ALC882_W2JC] = {
9303 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009304 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9305 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02009306 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9307 .dac_nids = alc882_dac_nids,
9308 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9309 .channel_mode = alc880_threestack_modes,
9310 .need_dac_fix = 1,
9311 .input_mux = &alc882_capture_source,
9312 .dig_out_nid = ALC882_DIGOUT_NID,
9313 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009314 [ALC885_MBA21] = {
9315 .mixers = { alc885_mba21_mixer },
9316 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9317 .num_dacs = 2,
9318 .dac_nids = alc882_dac_nids,
9319 .channel_mode = alc885_mba21_ch_modes,
9320 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9321 .input_mux = &alc882_capture_source,
9322 .unsol_event = alc_automute_amp_unsol_event,
9323 .setup = alc885_mba21_setup,
9324 .init_hook = alc_automute_amp,
9325 },
Takashi Iwai49535502009-06-30 15:28:30 +02009326 [ALC885_MBP3] = {
9327 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9328 .init_verbs = { alc885_mbp3_init_verbs,
9329 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009330 .num_dacs = 2,
Takashi Iwai49535502009-06-30 15:28:30 +02009331 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009332 .hp_nid = 0x04,
9333 .channel_mode = alc885_mbp_4ch_modes,
9334 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai49535502009-06-30 15:28:30 +02009335 .input_mux = &alc882_capture_source,
9336 .dig_out_nid = ALC882_DIGOUT_NID,
9337 .dig_in_nid = ALC882_DIGIN_NID,
9338 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009339 .setup = alc885_mbp3_setup,
9340 .init_hook = alc_automute_amp,
Takashi Iwai49535502009-06-30 15:28:30 +02009341 },
9342 [ALC885_MB5] = {
9343 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9344 .init_verbs = { alc885_mb5_init_verbs,
9345 alc880_gpio1_init_verbs },
9346 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9347 .dac_nids = alc882_dac_nids,
9348 .channel_mode = alc885_mb5_6ch_modes,
9349 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9350 .input_mux = &mb5_capture_source,
9351 .dig_out_nid = ALC882_DIGOUT_NID,
9352 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009353 .unsol_event = alc_automute_amp_unsol_event,
9354 .setup = alc885_mb5_setup,
9355 .init_hook = alc_automute_amp,
Takashi Iwai49535502009-06-30 15:28:30 +02009356 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009357 [ALC885_MACMINI3] = {
9358 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9359 .init_verbs = { alc885_macmini3_init_verbs,
9360 alc880_gpio1_init_verbs },
9361 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9362 .dac_nids = alc882_dac_nids,
9363 .channel_mode = alc885_macmini3_6ch_modes,
9364 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9365 .input_mux = &macmini3_capture_source,
9366 .dig_out_nid = ALC882_DIGOUT_NID,
9367 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009368 .unsol_event = alc_automute_amp_unsol_event,
9369 .setup = alc885_macmini3_setup,
9370 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009371 },
Takashi Iwai49535502009-06-30 15:28:30 +02009372 [ALC885_MACPRO] = {
9373 .mixers = { alc882_macpro_mixer },
9374 .init_verbs = { alc882_macpro_init_verbs },
9375 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9376 .dac_nids = alc882_dac_nids,
9377 .dig_out_nid = ALC882_DIGOUT_NID,
9378 .dig_in_nid = ALC882_DIGIN_NID,
9379 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9380 .channel_mode = alc882_ch_modes,
9381 .input_mux = &alc882_capture_source,
9382 .init_hook = alc885_macpro_init_hook,
9383 },
9384 [ALC885_IMAC24] = {
9385 .mixers = { alc885_imac24_mixer },
9386 .init_verbs = { alc885_imac24_init_verbs },
9387 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9388 .dac_nids = alc882_dac_nids,
9389 .dig_out_nid = ALC882_DIGOUT_NID,
9390 .dig_in_nid = ALC882_DIGIN_NID,
9391 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9392 .channel_mode = alc882_ch_modes,
9393 .input_mux = &alc882_capture_source,
9394 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009395 .setup = alc885_imac24_setup,
Takashi Iwai49535502009-06-30 15:28:30 +02009396 .init_hook = alc885_imac24_init_hook,
9397 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009398 [ALC885_IMAC91] = {
9399 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9400 .init_verbs = { alc885_imac91_init_verbs,
9401 alc880_gpio1_init_verbs },
9402 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9403 .dac_nids = alc882_dac_nids,
9404 .channel_mode = alc885_mbp_4ch_modes,
9405 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9406 .input_mux = &alc882_capture_source,
9407 .dig_out_nid = ALC882_DIGOUT_NID,
9408 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009409 .unsol_event = alc_automute_amp_unsol_event,
9410 .setup = alc885_imac91_setup,
9411 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009412 },
Takashi Iwai49535502009-06-30 15:28:30 +02009413 [ALC882_TARGA] = {
9414 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009415 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009416 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai49535502009-06-30 15:28:30 +02009417 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9418 .dac_nids = alc882_dac_nids,
9419 .dig_out_nid = ALC882_DIGOUT_NID,
9420 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9421 .adc_nids = alc882_adc_nids,
9422 .capsrc_nids = alc882_capsrc_nids,
9423 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9424 .channel_mode = alc882_3ST_6ch_modes,
9425 .need_dac_fix = 1,
9426 .input_mux = &alc882_capture_source,
9427 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009428 .setup = alc882_targa_setup,
9429 .init_hook = alc882_targa_automute,
Takashi Iwai49535502009-06-30 15:28:30 +02009430 },
9431 [ALC882_ASUS_A7J] = {
9432 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009433 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9434 alc882_asus_a7j_verbs},
Takashi Iwai49535502009-06-30 15:28:30 +02009435 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9436 .dac_nids = alc882_dac_nids,
9437 .dig_out_nid = ALC882_DIGOUT_NID,
9438 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9439 .adc_nids = alc882_adc_nids,
9440 .capsrc_nids = alc882_capsrc_nids,
9441 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9442 .channel_mode = alc882_3ST_6ch_modes,
9443 .need_dac_fix = 1,
9444 .input_mux = &alc882_capture_source,
9445 },
9446 [ALC882_ASUS_A7M] = {
9447 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009448 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9449 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai49535502009-06-30 15:28:30 +02009450 alc882_asus_a7m_verbs },
9451 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9452 .dac_nids = alc882_dac_nids,
9453 .dig_out_nid = ALC882_DIGOUT_NID,
9454 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9455 .channel_mode = alc880_threestack_modes,
9456 .need_dac_fix = 1,
9457 .input_mux = &alc882_capture_source,
9458 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009459 [ALC883_3ST_2ch_DIG] = {
9460 .mixers = { alc883_3ST_2ch_mixer },
9461 .init_verbs = { alc883_init_verbs },
9462 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9463 .dac_nids = alc883_dac_nids,
9464 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009465 .dig_in_nid = ALC883_DIGIN_NID,
9466 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9467 .channel_mode = alc883_3ST_2ch_modes,
9468 .input_mux = &alc883_capture_source,
9469 },
9470 [ALC883_3ST_6ch_DIG] = {
9471 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9472 .init_verbs = { alc883_init_verbs },
9473 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9474 .dac_nids = alc883_dac_nids,
9475 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009476 .dig_in_nid = ALC883_DIGIN_NID,
9477 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9478 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009479 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009480 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009481 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009482 [ALC883_3ST_6ch] = {
9483 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9484 .init_verbs = { alc883_init_verbs },
9485 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9486 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009487 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9488 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009489 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009490 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009491 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009492 [ALC883_3ST_6ch_INTEL] = {
9493 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9494 .init_verbs = { alc883_init_verbs },
9495 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9496 .dac_nids = alc883_dac_nids,
9497 .dig_out_nid = ALC883_DIGOUT_NID,
9498 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009499 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009500 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9501 .channel_mode = alc883_3ST_6ch_intel_modes,
9502 .need_dac_fix = 1,
9503 .input_mux = &alc883_3stack_6ch_intel,
9504 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009505 [ALC889A_INTEL] = {
9506 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009507 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9508 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009509 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9510 .dac_nids = alc883_dac_nids,
9511 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9512 .adc_nids = alc889_adc_nids,
9513 .dig_out_nid = ALC883_DIGOUT_NID,
9514 .dig_in_nid = ALC883_DIGIN_NID,
9515 .slave_dig_outs = alc883_slave_dig_outs,
9516 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9517 .channel_mode = alc889_8ch_intel_modes,
9518 .capsrc_nids = alc889_capsrc_nids,
9519 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009520 .setup = alc889_automute_setup,
9521 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009522 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009523 .need_dac_fix = 1,
9524 },
9525 [ALC889_INTEL] = {
9526 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9527 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009528 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009529 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9530 .dac_nids = alc883_dac_nids,
9531 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9532 .adc_nids = alc889_adc_nids,
9533 .dig_out_nid = ALC883_DIGOUT_NID,
9534 .dig_in_nid = ALC883_DIGIN_NID,
9535 .slave_dig_outs = alc883_slave_dig_outs,
9536 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9537 .channel_mode = alc889_8ch_intel_modes,
9538 .capsrc_nids = alc889_capsrc_nids,
9539 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009540 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009541 .init_hook = alc889_intel_init_hook,
9542 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009543 .need_dac_fix = 1,
9544 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009545 [ALC883_6ST_DIG] = {
9546 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9547 .init_verbs = { alc883_init_verbs },
9548 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9549 .dac_nids = alc883_dac_nids,
9550 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009551 .dig_in_nid = ALC883_DIGIN_NID,
9552 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9553 .channel_mode = alc883_sixstack_modes,
9554 .input_mux = &alc883_capture_source,
9555 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009556 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009557 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009558 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9559 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009560 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9561 .dac_nids = alc883_dac_nids,
9562 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009563 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9564 .channel_mode = alc883_3ST_6ch_modes,
9565 .need_dac_fix = 1,
9566 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009567 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009568 .setup = alc882_targa_setup,
9569 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009570 },
9571 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009572 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009573 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9574 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009575 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9576 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009577 .adc_nids = alc883_adc_nids_alt,
9578 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009579 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009580 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009581 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9582 .channel_mode = alc883_3ST_2ch_modes,
9583 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009584 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009585 .setup = alc882_targa_setup,
9586 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009587 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009588 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009589 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9590 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009591 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009592 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009593 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9594 .dac_nids = alc883_dac_nids,
9595 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9596 .adc_nids = alc883_adc_nids_rev,
9597 .capsrc_nids = alc883_capsrc_nids_rev,
9598 .dig_out_nid = ALC883_DIGOUT_NID,
9599 .dig_in_nid = ALC883_DIGIN_NID,
9600 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9601 .channel_mode = alc883_4ST_8ch_modes,
9602 .need_dac_fix = 1,
9603 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009604 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009605 .setup = alc882_targa_setup,
9606 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009607 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009608 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009609 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009610 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9611 * and the headphone jack. Turn this on and rely on the
9612 * standard mute methods whenever the user wants to turn
9613 * these outputs off.
9614 */
9615 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9616 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9617 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009618 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9619 .channel_mode = alc883_3ST_2ch_modes,
9620 .input_mux = &alc883_capture_source,
9621 },
Tobin Davis2880a862007-08-07 11:50:26 +02009622 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009623 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009624 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009625 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9626 .dac_nids = alc883_dac_nids,
9627 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009628 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9629 .channel_mode = alc883_3ST_2ch_modes,
9630 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009631 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009632 .setup = alc883_acer_aspire_setup,
9633 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009634 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009635 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009636 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009637 alc883_chmode_mixer },
9638 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9639 alc888_acer_aspire_4930g_verbs },
9640 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9641 .dac_nids = alc883_dac_nids,
9642 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9643 .adc_nids = alc883_adc_nids_rev,
9644 .capsrc_nids = alc883_capsrc_nids_rev,
9645 .dig_out_nid = ALC883_DIGOUT_NID,
9646 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9647 .channel_mode = alc883_3ST_6ch_modes,
9648 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009649 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009650 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009651 ARRAY_SIZE(alc888_2_capture_sources),
9652 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009653 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009654 .setup = alc888_acer_aspire_4930g_setup,
9655 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009656 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009657 [ALC888_ACER_ASPIRE_6530G] = {
9658 .mixers = { alc888_acer_aspire_6530_mixer },
9659 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9660 alc888_acer_aspire_6530g_verbs },
9661 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9662 .dac_nids = alc883_dac_nids,
9663 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9664 .adc_nids = alc883_adc_nids_rev,
9665 .capsrc_nids = alc883_capsrc_nids_rev,
9666 .dig_out_nid = ALC883_DIGOUT_NID,
9667 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9668 .channel_mode = alc883_3ST_2ch_modes,
9669 .num_mux_defs =
9670 ARRAY_SIZE(alc888_2_capture_sources),
9671 .input_mux = alc888_acer_aspire_6530_sources,
9672 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009673 .setup = alc888_acer_aspire_6530g_setup,
9674 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009675 },
Hector Martin3b315d72009-06-02 10:54:19 +02009676 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009677 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009678 alc883_chmode_mixer },
9679 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009680 alc889_acer_aspire_8930g_verbs,
9681 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009682 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9683 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009684 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9685 .adc_nids = alc889_adc_nids,
9686 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009687 .dig_out_nid = ALC883_DIGOUT_NID,
9688 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9689 .channel_mode = alc883_3ST_6ch_modes,
9690 .need_dac_fix = 1,
9691 .const_channel_count = 6,
9692 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009693 ARRAY_SIZE(alc889_capture_sources),
9694 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009695 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009696 .setup = alc889_acer_aspire_8930g_setup,
9697 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009698#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009699 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009700#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009701 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009702 [ALC888_ACER_ASPIRE_7730G] = {
9703 .mixers = { alc883_3ST_6ch_mixer,
9704 alc883_chmode_mixer },
9705 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9706 alc888_acer_aspire_7730G_verbs },
9707 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9708 .dac_nids = alc883_dac_nids,
9709 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9710 .adc_nids = alc883_adc_nids_rev,
9711 .capsrc_nids = alc883_capsrc_nids_rev,
9712 .dig_out_nid = ALC883_DIGOUT_NID,
9713 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9714 .channel_mode = alc883_3ST_6ch_modes,
9715 .need_dac_fix = 1,
9716 .const_channel_count = 6,
9717 .input_mux = &alc883_capture_source,
9718 .unsol_event = alc_automute_amp_unsol_event,
9719 .setup = alc888_acer_aspire_6530g_setup,
9720 .init_hook = alc_automute_amp,
9721 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009722 [ALC883_MEDION] = {
9723 .mixers = { alc883_fivestack_mixer,
9724 alc883_chmode_mixer },
9725 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009726 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009727 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9728 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009729 .adc_nids = alc883_adc_nids_alt,
9730 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009731 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009732 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9733 .channel_mode = alc883_sixstack_modes,
9734 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009735 },
Kailang Yang272a5272007-05-14 11:00:38 +02009736 [ALC883_MEDION_MD2] = {
9737 .mixers = { alc883_medion_md2_mixer},
9738 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9739 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9740 .dac_nids = alc883_dac_nids,
9741 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009742 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9743 .channel_mode = alc883_3ST_2ch_modes,
9744 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009745 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009746 .setup = alc883_medion_md2_setup,
9747 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009748 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009749 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009750 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009751 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9752 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9753 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009754 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9755 .channel_mode = alc883_3ST_2ch_modes,
9756 .input_mux = &alc883_capture_source,
9757 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309758 [ALC883_CLEVO_M540R] = {
9759 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9760 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9761 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9762 .dac_nids = alc883_dac_nids,
9763 .dig_out_nid = ALC883_DIGOUT_NID,
9764 .dig_in_nid = ALC883_DIGIN_NID,
9765 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9766 .channel_mode = alc883_3ST_6ch_clevo_modes,
9767 .need_dac_fix = 1,
9768 .input_mux = &alc883_capture_source,
9769 /* This machine has the hardware HP auto-muting, thus
9770 * we need no software mute via unsol event
9771 */
9772 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009773 [ALC883_CLEVO_M720] = {
9774 .mixers = { alc883_clevo_m720_mixer },
9775 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009776 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9777 .dac_nids = alc883_dac_nids,
9778 .dig_out_nid = ALC883_DIGOUT_NID,
9779 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9780 .channel_mode = alc883_3ST_2ch_modes,
9781 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009782 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009783 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009784 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009785 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009786 [ALC883_LENOVO_101E_2ch] = {
9787 .mixers = { alc883_lenovo_101e_2ch_mixer},
9788 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9789 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9790 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009791 .adc_nids = alc883_adc_nids_alt,
9792 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009793 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009794 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9795 .channel_mode = alc883_3ST_2ch_modes,
9796 .input_mux = &alc883_lenovo_101e_capture_source,
9797 .unsol_event = alc883_lenovo_101e_unsol_event,
9798 .init_hook = alc883_lenovo_101e_all_automute,
9799 },
Kailang Yang272a5272007-05-14 11:00:38 +02009800 [ALC883_LENOVO_NB0763] = {
9801 .mixers = { alc883_lenovo_nb0763_mixer },
9802 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9803 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9804 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009805 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9806 .channel_mode = alc883_3ST_2ch_modes,
9807 .need_dac_fix = 1,
9808 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009809 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009810 .setup = alc883_medion_md2_setup,
9811 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009812 },
9813 [ALC888_LENOVO_MS7195_DIG] = {
9814 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9815 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9816 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9817 .dac_nids = alc883_dac_nids,
9818 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009819 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9820 .channel_mode = alc883_3ST_6ch_modes,
9821 .need_dac_fix = 1,
9822 .input_mux = &alc883_capture_source,
9823 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9824 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009825 },
9826 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009827 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009828 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9829 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9830 .dac_nids = alc883_dac_nids,
9831 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009832 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9833 .channel_mode = alc883_3ST_2ch_modes,
9834 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009835 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009836 .setup = alc883_haier_w66_setup,
9837 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009838 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009839 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009840 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009841 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009842 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9843 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009844 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9845 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009846 .need_dac_fix = 1,
9847 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009848 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009849 .setup = alc888_3st_hp_setup,
9850 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009851 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009852 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009853 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009854 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9855 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9856 .dac_nids = alc883_dac_nids,
9857 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009858 .dig_in_nid = ALC883_DIGIN_NID,
9859 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9860 .channel_mode = alc883_sixstack_modes,
9861 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009862 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009863 .setup = alc888_6st_dell_setup,
9864 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009865 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009866 [ALC883_MITAC] = {
9867 .mixers = { alc883_mitac_mixer },
9868 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9869 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9870 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009871 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9872 .channel_mode = alc883_3ST_2ch_modes,
9873 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009874 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009875 .setup = alc883_mitac_setup,
9876 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009877 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009878 [ALC883_FUJITSU_PI2515] = {
9879 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9880 .init_verbs = { alc883_init_verbs,
9881 alc883_2ch_fujitsu_pi2515_verbs},
9882 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9883 .dac_nids = alc883_dac_nids,
9884 .dig_out_nid = ALC883_DIGOUT_NID,
9885 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9886 .channel_mode = alc883_3ST_2ch_modes,
9887 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009888 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009889 .setup = alc883_2ch_fujitsu_pi2515_setup,
9890 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009891 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009892 [ALC888_FUJITSU_XA3530] = {
9893 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9894 .init_verbs = { alc883_init_verbs,
9895 alc888_fujitsu_xa3530_verbs },
9896 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9897 .dac_nids = alc883_dac_nids,
9898 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9899 .adc_nids = alc883_adc_nids_rev,
9900 .capsrc_nids = alc883_capsrc_nids_rev,
9901 .dig_out_nid = ALC883_DIGOUT_NID,
9902 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9903 .channel_mode = alc888_4ST_8ch_intel_modes,
9904 .num_mux_defs =
9905 ARRAY_SIZE(alc888_2_capture_sources),
9906 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009907 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009908 .setup = alc888_fujitsu_xa3530_setup,
9909 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009910 },
Kailang Yange2757d52008-08-26 13:17:46 +02009911 [ALC888_LENOVO_SKY] = {
9912 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9913 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9914 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9915 .dac_nids = alc883_dac_nids,
9916 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009917 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9918 .channel_mode = alc883_sixstack_modes,
9919 .need_dac_fix = 1,
9920 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009921 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009922 .setup = alc888_lenovo_sky_setup,
9923 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009924 },
9925 [ALC888_ASUS_M90V] = {
9926 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9927 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9928 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9929 .dac_nids = alc883_dac_nids,
9930 .dig_out_nid = ALC883_DIGOUT_NID,
9931 .dig_in_nid = ALC883_DIGIN_NID,
9932 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9933 .channel_mode = alc883_3ST_6ch_modes,
9934 .need_dac_fix = 1,
9935 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009936 .unsol_event = alc_sku_unsol_event,
9937 .setup = alc883_mode2_setup,
9938 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009939 },
9940 [ALC888_ASUS_EEE1601] = {
9941 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009942 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009943 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9944 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9945 .dac_nids = alc883_dac_nids,
9946 .dig_out_nid = ALC883_DIGOUT_NID,
9947 .dig_in_nid = ALC883_DIGIN_NID,
9948 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9949 .channel_mode = alc883_3ST_2ch_modes,
9950 .need_dac_fix = 1,
9951 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009952 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009953 .init_hook = alc883_eee1601_inithook,
9954 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009955 [ALC1200_ASUS_P5Q] = {
9956 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9957 .init_verbs = { alc883_init_verbs },
9958 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9959 .dac_nids = alc883_dac_nids,
9960 .dig_out_nid = ALC1200_DIGOUT_NID,
9961 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009962 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009963 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9964 .channel_mode = alc883_sixstack_modes,
9965 .input_mux = &alc883_capture_source,
9966 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009967 [ALC889A_MB31] = {
9968 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9969 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9970 alc880_gpio1_init_verbs },
9971 .adc_nids = alc883_adc_nids,
9972 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009973 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009974 .dac_nids = alc883_dac_nids,
9975 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9976 .channel_mode = alc889A_mb31_6ch_modes,
9977 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9978 .input_mux = &alc889A_mb31_capture_source,
9979 .dig_out_nid = ALC883_DIGOUT_NID,
9980 .unsol_event = alc889A_mb31_unsol_event,
9981 .init_hook = alc889A_mb31_automute,
9982 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009983 [ALC883_SONY_VAIO_TT] = {
9984 .mixers = { alc883_vaiott_mixer },
9985 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9986 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9987 .dac_nids = alc883_dac_nids,
9988 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9989 .channel_mode = alc883_3ST_2ch_modes,
9990 .input_mux = &alc883_capture_source,
9991 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009992 .setup = alc883_vaiott_setup,
9993 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009994 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009995};
9996
9997
9998/*
Takashi Iwai49535502009-06-30 15:28:30 +02009999 * Pin config fixes
10000 */
10001enum {
10002 PINFIX_ABIT_AW9D_MAX
10003};
10004
10005static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10006 { 0x15, 0x01080104 }, /* side */
10007 { 0x16, 0x01011012 }, /* rear */
10008 { 0x17, 0x01016011 }, /* clfe */
10009 { }
10010};
10011
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010012static const struct alc_fixup alc882_fixups[] = {
10013 [PINFIX_ABIT_AW9D_MAX] = {
10014 .pins = alc882_abit_aw9d_pinfix
10015 },
Takashi Iwai49535502009-06-30 15:28:30 +020010016};
10017
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010018static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai49535502009-06-30 15:28:30 +020010019 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10020 {}
10021};
10022
10023/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010024 * BIOS auto configuration
10025 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010026static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10027 const struct auto_pin_cfg *cfg)
10028{
10029 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10030}
10031
Takashi Iwai49535502009-06-30 15:28:30 +020010032static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010033 hda_nid_t nid, int pin_type,
10034 int dac_idx)
10035{
10036 /* set as output */
10037 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010038 int idx;
10039
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010040 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010041 if (spec->multiout.dac_nids[dac_idx] == 0x25)
10042 idx = 4;
10043 else
10044 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010045 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
10046
10047}
10048
Takashi Iwai49535502009-06-30 15:28:30 +020010049static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010050{
10051 struct alc_spec *spec = codec->spec;
10052 int i;
10053
10054 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010055 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010056 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010057 if (nid)
Takashi Iwai49535502009-06-30 15:28:30 +020010058 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010059 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010060 }
10061}
10062
Takashi Iwai49535502009-06-30 15:28:30 +020010063static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010064{
10065 struct alc_spec *spec = codec->spec;
10066 hda_nid_t pin;
10067
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010068 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010069 if (pin) /* connect to front */
10070 /* use dac 0 */
Takashi Iwai49535502009-06-30 15:28:30 +020010071 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010072 pin = spec->autocfg.speaker_pins[0];
10073 if (pin)
Takashi Iwai49535502009-06-30 15:28:30 +020010074 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010075}
10076
Takashi Iwai49535502009-06-30 15:28:30 +020010077static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010078{
10079 struct alc_spec *spec = codec->spec;
10080 int i;
10081
10082 for (i = 0; i < AUTO_PIN_LAST; i++) {
10083 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai49535502009-06-30 15:28:30 +020010084 if (!nid)
10085 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010086 alc_set_input_pin(codec, nid, i);
Takashi Iwai49535502009-06-30 15:28:30 +020010087 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10088 snd_hda_codec_write(codec, nid, 0,
10089 AC_VERB_SET_AMP_GAIN_MUTE,
10090 AMP_OUT_MUTE);
10091 }
10092}
10093
10094static void alc882_auto_init_input_src(struct hda_codec *codec)
10095{
10096 struct alc_spec *spec = codec->spec;
10097 int c;
10098
10099 for (c = 0; c < spec->num_adc_nids; c++) {
10100 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10101 hda_nid_t nid = spec->capsrc_nids[c];
10102 unsigned int mux_idx;
10103 const struct hda_input_mux *imux;
10104 int conns, mute, idx, item;
10105
10106 conns = snd_hda_get_connections(codec, nid, conn_list,
10107 ARRAY_SIZE(conn_list));
10108 if (conns < 0)
10109 continue;
10110 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10111 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010112 if (!imux->num_items && mux_idx > 0)
10113 imux = &spec->input_mux[0];
Takashi Iwai49535502009-06-30 15:28:30 +020010114 for (idx = 0; idx < conns; idx++) {
10115 /* if the current connection is the selected one,
10116 * unmute it as default - otherwise mute it
10117 */
10118 mute = AMP_IN_MUTE(idx);
10119 for (item = 0; item < imux->num_items; item++) {
10120 if (imux->items[item].index == idx) {
10121 if (spec->cur_mux[c] == item)
10122 mute = AMP_IN_UNMUTE(idx);
10123 break;
10124 }
10125 }
10126 /* check if we have a selector or mixer
10127 * we could check for the widget type instead, but
10128 * just check for Amp-In presence (in case of mixer
10129 * without amp-in there is something wrong, this
10130 * function shouldn't be used or capsrc nid is wrong)
10131 */
10132 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010133 snd_hda_codec_write(codec, nid, 0,
10134 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai49535502009-06-30 15:28:30 +020010135 mute);
10136 else if (mute != AMP_IN_MUTE(idx))
10137 snd_hda_codec_write(codec, nid, 0,
10138 AC_VERB_SET_CONNECT_SEL,
10139 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010140 }
10141 }
10142}
10143
Takashi Iwai49535502009-06-30 15:28:30 +020010144/* add mic boosts if needed */
10145static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010146{
10147 struct alc_spec *spec = codec->spec;
Takashi Iwai49535502009-06-30 15:28:30 +020010148 int err;
10149 hda_nid_t nid;
10150
10151 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10152 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10153 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10154 "Mic Boost",
10155 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10156 if (err < 0)
10157 return err;
10158 }
10159 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10160 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10161 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10162 "Front Mic Boost",
10163 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10164 if (err < 0)
10165 return err;
10166 }
10167 return 0;
10168}
10169
10170/* almost identical with ALC880 parser... */
10171static int alc882_parse_auto_config(struct hda_codec *codec)
10172{
10173 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010174 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10175 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010176
Takashi Iwai05f5f472009-08-25 13:10:18 +020010177 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10178 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010179 if (err < 0)
10180 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010181 if (!spec->autocfg.line_outs)
10182 return 0; /* can't find valid BIOS pin config */
10183
10184 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10185 if (err < 0)
10186 return err;
10187 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10188 if (err < 0)
10189 return err;
10190 err = alc880_auto_create_extra_out(spec,
10191 spec->autocfg.speaker_pins[0],
10192 "Speaker");
10193 if (err < 0)
10194 return err;
10195 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10196 "Headphone");
10197 if (err < 0)
10198 return err;
10199 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10200 if (err < 0)
10201 return err;
10202
10203 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10204
10205 /* check multiple SPDIF-out (for recent codecs) */
10206 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10207 hda_nid_t dig_nid;
10208 err = snd_hda_get_connections(codec,
10209 spec->autocfg.dig_out_pins[i],
10210 &dig_nid, 1);
10211 if (err < 0)
10212 continue;
10213 if (!i)
10214 spec->multiout.dig_out_nid = dig_nid;
10215 else {
10216 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010217 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010218 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010219 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010220 }
10221 }
10222 if (spec->autocfg.dig_in_pin)
10223 spec->dig_in_nid = ALC880_DIGIN_NID;
10224
10225 if (spec->kctls.list)
10226 add_mixer(spec, spec->kctls.list);
10227
10228 add_verb(spec, alc883_auto_init_verbs);
10229 /* if ADC 0x07 is available, initialize it, too */
10230 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10231 add_verb(spec, alc882_adc1_init_verbs);
10232
10233 spec->num_mux_defs = 1;
10234 spec->input_mux = &spec->private_imux[0];
10235
Kailang Yang6227cdc2010-02-25 08:36:52 +010010236 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010237
10238 err = alc_auto_add_mic_boost(codec);
10239 if (err < 0)
10240 return err;
10241
Takashi Iwai776e1842007-08-29 15:07:11 +020010242 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010243}
10244
10245/* additional initialization for auto-configuration model */
Takashi Iwai49535502009-06-30 15:28:30 +020010246static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010247{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010248 struct alc_spec *spec = codec->spec;
Takashi Iwai49535502009-06-30 15:28:30 +020010249 alc882_auto_init_multi_out(codec);
10250 alc882_auto_init_hp_out(codec);
10251 alc882_auto_init_analog_input(codec);
10252 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010253 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010254 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010255}
10256
Takashi Iwai49535502009-06-30 15:28:30 +020010257static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010258{
10259 struct alc_spec *spec;
10260 int err, board_config;
10261
10262 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10263 if (spec == NULL)
10264 return -ENOMEM;
10265
10266 codec->spec = spec;
10267
Takashi Iwai49535502009-06-30 15:28:30 +020010268 switch (codec->vendor_id) {
10269 case 0x10ec0882:
10270 case 0x10ec0885:
10271 break;
10272 default:
10273 /* ALC883 and variants */
10274 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10275 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010276 }
10277
Takashi Iwai49535502009-06-30 15:28:30 +020010278 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10279 alc882_models,
10280 alc882_cfg_tbl);
10281
10282 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10283 board_config = snd_hda_check_board_codec_sid_config(codec,
10284 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10285
10286 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010287 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai49535502009-06-30 15:28:30 +020010288 codec->chip_name);
10289 board_config = ALC882_AUTO;
10290 }
10291
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010292 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai49535502009-06-30 15:28:30 +020010293
10294 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010295 /* automatic parse from the BIOS config */
Takashi Iwai49535502009-06-30 15:28:30 +020010296 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010297 if (err < 0) {
10298 alc_free(codec);
10299 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010300 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010301 printk(KERN_INFO
10302 "hda_codec: Cannot set up configuration "
10303 "from BIOS. Using base mode...\n");
Takashi Iwai49535502009-06-30 15:28:30 +020010304 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010305 }
10306 }
10307
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010308 err = snd_hda_attach_beep_device(codec, 0x1);
10309 if (err < 0) {
10310 alc_free(codec);
10311 return err;
10312 }
10313
Takashi Iwai49535502009-06-30 15:28:30 +020010314 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010315 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010316
Takashi Iwai49535502009-06-30 15:28:30 +020010317 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10318 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10319 /* FIXME: setup DAC5 */
10320 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10321 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10322
10323 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10324 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10325
10326 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010327 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai49535502009-06-30 15:28:30 +020010328
10329 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010330 int i, j;
Takashi Iwai49535502009-06-30 15:28:30 +020010331 spec->num_adc_nids = 0;
10332 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010333 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai49535502009-06-30 15:28:30 +020010334 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010335 hda_nid_t items[16];
Takashi Iwai49535502009-06-30 15:28:30 +020010336 hda_nid_t nid = alc882_adc_nids[i];
10337 unsigned int wcap = get_wcaps(codec, nid);
10338 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010339 wcap = get_wcaps_type(wcap);
Takashi Iwai49535502009-06-30 15:28:30 +020010340 if (wcap != AC_WID_AUD_IN)
10341 continue;
10342 spec->private_adc_nids[spec->num_adc_nids] = nid;
10343 err = snd_hda_get_connections(codec, nid, &cap, 1);
10344 if (err < 0)
10345 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010346 err = snd_hda_get_connections(codec, cap, items,
10347 ARRAY_SIZE(items));
10348 if (err < 0)
10349 continue;
10350 for (j = 0; j < imux->num_items; j++)
10351 if (imux->items[j].index >= err)
10352 break;
10353 if (j < imux->num_items)
10354 continue;
Takashi Iwai49535502009-06-30 15:28:30 +020010355 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10356 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010357 }
Takashi Iwai49535502009-06-30 15:28:30 +020010358 spec->adc_nids = spec->private_adc_nids;
10359 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010360 }
10361
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010362 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010363 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010364
Takashi Iwai2134ea42008-01-10 16:53:55 +010010365 spec->vmaster_nid = 0x0c;
10366
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010367 codec->patch_ops = alc_patch_ops;
Takashi Iwai49535502009-06-30 15:28:30 +020010368 if (board_config == ALC882_AUTO)
10369 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010370#ifdef CONFIG_SND_HDA_POWER_SAVE
10371 if (!spec->loopback.amplist)
Takashi Iwai49535502009-06-30 15:28:30 +020010372 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010373#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010374
10375 return 0;
10376}
10377
Takashi Iwai49535502009-06-30 15:28:30 +020010378
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010379/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010380 * ALC262 support
10381 */
10382
10383#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10384#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10385
10386#define alc262_dac_nids alc260_dac_nids
10387#define alc262_adc_nids alc882_adc_nids
10388#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010389#define alc262_capsrc_nids alc882_capsrc_nids
10390#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010391
10392#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010393#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010394
Kailang Yang4e555fe2008-08-26 13:05:55 +020010395static hda_nid_t alc262_dmic_adc_nids[1] = {
10396 /* ADC0 */
10397 0x09
10398};
10399
10400static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10401
Kailang Yangdf694da2005-12-05 19:42:22 +010010402static struct snd_kcontrol_new alc262_base_mixer[] = {
10403 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10404 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10405 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10406 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10407 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10408 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10409 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10410 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010411 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010412 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10413 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010414 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010415 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10416 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10417 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10418 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010419 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010420};
10421
Takashi Iwaice875f02008-01-28 18:17:43 +010010422/* update HP, line and mono-out pins according to the master switch */
10423static void alc262_hp_master_update(struct hda_codec *codec)
10424{
10425 struct alc_spec *spec = codec->spec;
10426 int val = spec->master_sw;
10427
10428 /* HP & line-out */
10429 snd_hda_codec_write_cache(codec, 0x1b, 0,
10430 AC_VERB_SET_PIN_WIDGET_CONTROL,
10431 val ? PIN_HP : 0);
10432 snd_hda_codec_write_cache(codec, 0x15, 0,
10433 AC_VERB_SET_PIN_WIDGET_CONTROL,
10434 val ? PIN_HP : 0);
10435 /* mono (speaker) depending on the HP jack sense */
10436 val = val && !spec->jack_present;
10437 snd_hda_codec_write_cache(codec, 0x16, 0,
10438 AC_VERB_SET_PIN_WIDGET_CONTROL,
10439 val ? PIN_OUT : 0);
10440}
10441
10442static void alc262_hp_bpc_automute(struct hda_codec *codec)
10443{
10444 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010445
10446 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010447 alc262_hp_master_update(codec);
10448}
10449
10450static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10451{
10452 if ((res >> 26) != ALC880_HP_EVENT)
10453 return;
10454 alc262_hp_bpc_automute(codec);
10455}
10456
10457static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10458{
10459 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010460
10461 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010462 alc262_hp_master_update(codec);
10463}
10464
10465static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10466 unsigned int res)
10467{
10468 if ((res >> 26) != ALC880_HP_EVENT)
10469 return;
10470 alc262_hp_wildwest_automute(codec);
10471}
10472
Takashi Iwaib72519b2009-05-08 14:31:55 +020010473#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010474
10475static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10476 struct snd_ctl_elem_value *ucontrol)
10477{
10478 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10479 struct alc_spec *spec = codec->spec;
10480 int val = !!*ucontrol->value.integer.value;
10481
10482 if (val == spec->master_sw)
10483 return 0;
10484 spec->master_sw = val;
10485 alc262_hp_master_update(codec);
10486 return 1;
10487}
10488
Takashi Iwaib72519b2009-05-08 14:31:55 +020010489#define ALC262_HP_MASTER_SWITCH \
10490 { \
10491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10492 .name = "Master Playback Switch", \
10493 .info = snd_ctl_boolean_mono_info, \
10494 .get = alc262_hp_master_sw_get, \
10495 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010496 }, \
10497 { \
10498 .iface = NID_MAPPING, \
10499 .name = "Master Playback Switch", \
10500 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010501 }
10502
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010503
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010504static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010505 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010506 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10507 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10508 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010509 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10510 HDA_OUTPUT),
10511 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10512 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010513 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10514 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010515 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010516 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10517 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010518 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010519 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10520 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10521 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10522 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010523 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10524 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10525 { } /* end */
10526};
10527
Kailang Yangcd7509a2007-01-26 18:33:17 +010010528static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010529 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010530 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10531 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10532 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10533 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010534 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10535 HDA_OUTPUT),
10536 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10537 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010538 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10539 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010540 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010541 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10542 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10543 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10544 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010545 { } /* end */
10546};
10547
10548static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10549 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10550 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010551 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010552 { } /* end */
10553};
10554
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010555/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010556static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010557{
10558 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010559
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010560 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010561 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010562}
10563
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010564static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010565 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10566 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010567 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10568 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10570 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10571 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10572 { } /* end */
10573};
10574
10575static struct hda_verb alc262_hp_t5735_verbs[] = {
10576 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10577 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10578
10579 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10580 { }
10581};
10582
Kailang Yang8c427222008-01-10 13:03:59 +010010583static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010584 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10585 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010586 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10587 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010588 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10589 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10590 { } /* end */
10591};
10592
10593static struct hda_verb alc262_hp_rp5700_verbs[] = {
10594 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10595 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10596 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10597 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10598 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10599 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10600 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10601 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10603 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10604 {}
10605};
10606
10607static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10608 .num_items = 1,
10609 .items = {
10610 { "Line", 0x1 },
10611 },
10612};
10613
Takashi Iwai42171c12009-05-08 14:11:43 +020010614/* bind hp and internal speaker mute (with plug check) as master switch */
10615static void alc262_hippo_master_update(struct hda_codec *codec)
10616{
10617 struct alc_spec *spec = codec->spec;
10618 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10619 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10620 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10621 unsigned int mute;
10622
10623 /* HP */
10624 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10625 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10626 HDA_AMP_MUTE, mute);
10627 /* mute internal speaker per jack sense */
10628 if (spec->jack_present)
10629 mute = HDA_AMP_MUTE;
10630 if (line_nid)
10631 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10632 HDA_AMP_MUTE, mute);
10633 if (speaker_nid && speaker_nid != line_nid)
10634 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10635 HDA_AMP_MUTE, mute);
10636}
10637
10638#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10639
10640static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10641 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010642{
10643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010644 struct alc_spec *spec = codec->spec;
10645 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010646
Takashi Iwai42171c12009-05-08 14:11:43 +020010647 if (val == spec->master_sw)
10648 return 0;
10649 spec->master_sw = val;
10650 alc262_hippo_master_update(codec);
10651 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010652}
Takashi Iwai5b319542007-07-26 11:49:22 +020010653
Takashi Iwai42171c12009-05-08 14:11:43 +020010654#define ALC262_HIPPO_MASTER_SWITCH \
10655 { \
10656 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10657 .name = "Master Playback Switch", \
10658 .info = snd_ctl_boolean_mono_info, \
10659 .get = alc262_hippo_master_sw_get, \
10660 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010661 }, \
10662 { \
10663 .iface = NID_MAPPING, \
10664 .name = "Master Playback Switch", \
10665 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10666 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010667 }
10668
10669static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10670 ALC262_HIPPO_MASTER_SWITCH,
10671 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10672 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10673 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10674 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10675 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10677 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10678 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10679 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10680 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10681 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10682 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10683 { } /* end */
10684};
10685
10686static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10687 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10688 ALC262_HIPPO_MASTER_SWITCH,
10689 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10690 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10691 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10692 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10693 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10694 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10695 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10696 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10697 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10698 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10699 { } /* end */
10700};
10701
10702/* mute/unmute internal speaker according to the hp jack and mute state */
10703static void alc262_hippo_automute(struct hda_codec *codec)
10704{
10705 struct alc_spec *spec = codec->spec;
10706 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010707
Wu Fengguang864f92b2009-11-18 12:38:02 +080010708 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010709 alc262_hippo_master_update(codec);
10710}
10711
10712static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10713{
10714 if ((res >> 26) != ALC880_HP_EVENT)
10715 return;
10716 alc262_hippo_automute(codec);
10717}
10718
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010719static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010720{
10721 struct alc_spec *spec = codec->spec;
10722
10723 spec->autocfg.hp_pins[0] = 0x15;
10724 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010725}
10726
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010727static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010728{
10729 struct alc_spec *spec = codec->spec;
10730
10731 spec->autocfg.hp_pins[0] = 0x1b;
10732 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010733}
10734
10735
Kailang Yang272a5272007-05-14 11:00:38 +020010736static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010737 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010738 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010739 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10740 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10741 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10742 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10743 { } /* end */
10744};
10745
Kailang Yang83c34212007-07-05 11:43:05 +020010746static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010747 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10748 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010749 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10750 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10751 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10752 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10753 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10754 { } /* end */
10755};
Kailang Yang272a5272007-05-14 11:00:38 +020010756
Tony Vroonba340e82009-02-02 19:01:30 +000010757static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10758 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10759 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10760 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10761 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10762 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10763 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10765 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10766 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10767 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10768 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10769 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10770 { } /* end */
10771};
10772
10773static struct hda_verb alc262_tyan_verbs[] = {
10774 /* Headphone automute */
10775 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10776 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10777 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10778
10779 /* P11 AUX_IN, white 4-pin connector */
10780 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10781 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10782 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10783 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10784
10785 {}
10786};
10787
10788/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010789static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010790{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010791 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010792
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010793 spec->autocfg.hp_pins[0] = 0x1b;
10794 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010795}
10796
Tony Vroonba340e82009-02-02 19:01:30 +000010797
Kailang Yangdf694da2005-12-05 19:42:22 +010010798#define alc262_capture_mixer alc882_capture_mixer
10799#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10800
10801/*
10802 * generic initialization of ADC, input mixers and output mixers
10803 */
10804static struct hda_verb alc262_init_verbs[] = {
10805 /*
10806 * Unmute ADC0-2 and set the default input to mic-in
10807 */
10808 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10809 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10810 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10811 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10812 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10813 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10814
Takashi Iwaicb53c622007-08-10 17:21:45 +020010815 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010816 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010817 * Note: PASD motherboards uses the Line In 2 as the input for
10818 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010819 */
10820 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010821 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10822 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10823 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10824 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10825 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010826
10827 /*
10828 * Set up output mixers (0x0c - 0x0e)
10829 */
10830 /* set vol=0 to output mixers */
10831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10832 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10833 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10834 /* set up input amps for analog loopback */
10835 /* Amp Indices: DAC = 0, mixer = 1 */
10836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10838 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10839 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10840 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10841 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10842
10843 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10845 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10846 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10847 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10848 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10849
10850 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10852 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10853 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10854 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010855
Kailang Yangdf694da2005-12-05 19:42:22 +010010856 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10857 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010858
Kailang Yangdf694da2005-12-05 19:42:22 +010010859 /* FIXME: use matrix-type input source selection */
10860 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10861 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10866 /* Input mixer2 */
10867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10871 /* Input mixer3 */
10872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010876
10877 { }
10878};
10879
Kailang Yang4e555fe2008-08-26 13:05:55 +020010880static struct hda_verb alc262_eapd_verbs[] = {
10881 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10882 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10883 { }
10884};
10885
Kailang Yangccc656c2006-10-17 12:32:26 +020010886static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10887 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10888 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10889 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10890
10891 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10892 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10893 {}
10894};
10895
Kailang Yang272a5272007-05-14 11:00:38 +020010896static struct hda_verb alc262_sony_unsol_verbs[] = {
10897 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10898 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10899 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10900
10901 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10902 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010903 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010904};
10905
Kailang Yang4e555fe2008-08-26 13:05:55 +020010906static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10907 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10908 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10909 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10911 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010912 { } /* end */
10913};
10914
10915static struct hda_verb alc262_toshiba_s06_verbs[] = {
10916 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10917 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10918 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10919 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10920 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10921 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10922 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10923 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10924 {}
10925};
10926
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010927static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010928{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010929 struct alc_spec *spec = codec->spec;
10930
10931 spec->autocfg.hp_pins[0] = 0x15;
10932 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010933 spec->ext_mic.pin = 0x18;
10934 spec->ext_mic.mux_idx = 0;
10935 spec->int_mic.pin = 0x12;
10936 spec->int_mic.mux_idx = 9;
10937 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010938}
10939
Takashi Iwai834be882006-03-01 14:16:17 +010010940/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010941 * nec model
10942 * 0x15 = headphone
10943 * 0x16 = internal speaker
10944 * 0x18 = external mic
10945 */
10946
10947static struct snd_kcontrol_new alc262_nec_mixer[] = {
10948 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10949 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10950
10951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10952 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10953 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10954
10955 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10957 { } /* end */
10958};
10959
10960static struct hda_verb alc262_nec_verbs[] = {
10961 /* Unmute Speaker */
10962 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10963
10964 /* Headphone */
10965 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10966 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10967
10968 /* External mic to headphone */
10969 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10970 /* External mic to speaker */
10971 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10972 {}
10973};
10974
10975/*
Takashi Iwai834be882006-03-01 14:16:17 +010010976 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010977 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10978 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010979 */
10980
10981#define ALC_HP_EVENT 0x37
10982
10983static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10984 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10985 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010986 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10987 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010988 {}
10989};
10990
Jiang zhe0e31daf2008-03-20 12:12:39 +010010991static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10992 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10993 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10994 {}
10995};
10996
Daniel T Chene2595322009-12-19 18:19:02 -050010997static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
10998 /* Front Mic pin: input vref at 50% */
10999 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11000 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11001 {}
11002};
11003
Takashi Iwai834be882006-03-01 14:16:17 +010011004static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011005 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011006 .items = {
11007 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011008 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011009 { "CD", 0x4 },
11010 },
11011};
11012
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011013static struct hda_input_mux alc262_HP_capture_source = {
11014 .num_items = 5,
11015 .items = {
11016 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011017 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011018 { "Line", 0x2 },
11019 { "CD", 0x4 },
11020 { "AUX IN", 0x6 },
11021 },
11022};
11023
zhejiangaccbe492007-08-31 12:36:05 +020011024static struct hda_input_mux alc262_HP_D7000_capture_source = {
11025 .num_items = 4,
11026 .items = {
11027 { "Mic", 0x0 },
11028 { "Front Mic", 0x2 },
11029 { "Line", 0x1 },
11030 { "CD", 0x4 },
11031 },
11032};
11033
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011034/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011035static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11036{
11037 struct alc_spec *spec = codec->spec;
11038 unsigned int mute;
11039
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011040 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011041 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11042 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011043 spec->sense_updated = 1;
11044 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011045 /* unmute internal speaker only if both HPs are unplugged and
11046 * master switch is on
11047 */
11048 if (spec->jack_present)
11049 mute = HDA_AMP_MUTE;
11050 else
Takashi Iwai834be882006-03-01 14:16:17 +010011051 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011052 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11053 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011054}
11055
11056/* unsolicited event for HP jack sensing */
11057static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11058 unsigned int res)
11059{
11060 if ((res >> 26) != ALC_HP_EVENT)
11061 return;
11062 alc262_fujitsu_automute(codec, 1);
11063}
11064
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011065static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11066{
11067 alc262_fujitsu_automute(codec, 1);
11068}
11069
Takashi Iwai834be882006-03-01 14:16:17 +010011070/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011071static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11072 .ops = &snd_hda_bind_vol,
11073 .values = {
11074 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11075 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11076 0
11077 },
11078};
Takashi Iwai834be882006-03-01 14:16:17 +010011079
Jiang zhe0e31daf2008-03-20 12:12:39 +010011080/* mute/unmute internal speaker according to the hp jack and mute state */
11081static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11082{
11083 struct alc_spec *spec = codec->spec;
11084 unsigned int mute;
11085
11086 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011087 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011088 spec->sense_updated = 1;
11089 }
11090 if (spec->jack_present) {
11091 /* mute internal speaker */
11092 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11093 HDA_AMP_MUTE, HDA_AMP_MUTE);
11094 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11095 HDA_AMP_MUTE, HDA_AMP_MUTE);
11096 } else {
11097 /* unmute internal speaker if necessary */
11098 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11099 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11100 HDA_AMP_MUTE, mute);
11101 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11102 HDA_AMP_MUTE, mute);
11103 }
11104}
11105
11106/* unsolicited event for HP jack sensing */
11107static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11108 unsigned int res)
11109{
11110 if ((res >> 26) != ALC_HP_EVENT)
11111 return;
11112 alc262_lenovo_3000_automute(codec, 1);
11113}
11114
Takashi Iwai8de56b72009-07-24 16:51:47 +020011115static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11116 int dir, int idx, long *valp)
11117{
11118 int i, change = 0;
11119
11120 for (i = 0; i < 2; i++, valp++)
11121 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11122 HDA_AMP_MUTE,
11123 *valp ? 0 : HDA_AMP_MUTE);
11124 return change;
11125}
11126
Takashi Iwai834be882006-03-01 14:16:17 +010011127/* bind hp and internal speaker mute (with plug check) */
11128static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11129 struct snd_ctl_elem_value *ucontrol)
11130{
11131 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11132 long *valp = ucontrol->value.integer.value;
11133 int change;
11134
Takashi Iwai8de56b72009-07-24 16:51:47 +020011135 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11136 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011137 if (change)
11138 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011139 return change;
11140}
11141
11142static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011143 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011144 {
11145 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11146 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011147 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011148 .info = snd_hda_mixer_amp_switch_info,
11149 .get = snd_hda_mixer_amp_switch_get,
11150 .put = alc262_fujitsu_master_sw_put,
11151 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11152 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011153 {
11154 .iface = NID_MAPPING,
11155 .name = "Master Playback Switch",
11156 .private_value = 0x1b,
11157 },
Takashi Iwai834be882006-03-01 14:16:17 +010011158 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11159 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11160 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11161 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11162 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011163 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11164 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11165 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011166 { } /* end */
11167};
11168
Jiang zhe0e31daf2008-03-20 12:12:39 +010011169/* bind hp and internal speaker mute (with plug check) */
11170static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11171 struct snd_ctl_elem_value *ucontrol)
11172{
11173 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11174 long *valp = ucontrol->value.integer.value;
11175 int change;
11176
Takashi Iwai8de56b72009-07-24 16:51:47 +020011177 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011178 if (change)
11179 alc262_lenovo_3000_automute(codec, 0);
11180 return change;
11181}
11182
11183static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11184 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11185 {
11186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11187 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011188 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011189 .info = snd_hda_mixer_amp_switch_info,
11190 .get = snd_hda_mixer_amp_switch_get,
11191 .put = alc262_lenovo_3000_master_sw_put,
11192 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11193 },
11194 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11195 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11196 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11198 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11199 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11200 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11201 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11202 { } /* end */
11203};
11204
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011205static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11206 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011207 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011208 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11210 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11211 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11212 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11213 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11214 { } /* end */
11215};
11216
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011217/* additional init verbs for Benq laptops */
11218static struct hda_verb alc262_EAPD_verbs[] = {
11219 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11220 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11221 {}
11222};
11223
Kailang Yang83c34212007-07-05 11:43:05 +020011224static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11225 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11226 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11227
11228 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11229 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11230 {}
11231};
11232
Tobin Davisf651b502007-10-26 12:40:47 +020011233/* Samsung Q1 Ultra Vista model setup */
11234static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011235 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11236 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11238 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11239 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011240 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011241 { } /* end */
11242};
11243
11244static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011245 /* output mixer */
11246 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11247 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11249 /* speaker */
11250 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11251 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11252 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11253 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11254 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011255 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11258 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11259 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11260 /* internal mic */
11261 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11263 /* ADC, choose mic */
11264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11265 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11267 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11270 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11271 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11272 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011274 {}
11275};
11276
Tobin Davisf651b502007-10-26 12:40:47 +020011277/* mute/unmute internal speaker according to the hp jack and mute state */
11278static void alc262_ultra_automute(struct hda_codec *codec)
11279{
11280 struct alc_spec *spec = codec->spec;
11281 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011282
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011283 mute = 0;
11284 /* auto-mute only when HP is used as HP */
11285 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011286 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011287 if (spec->jack_present)
11288 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011289 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011290 /* mute/unmute internal speaker */
11291 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11292 HDA_AMP_MUTE, mute);
11293 /* mute/unmute HP */
11294 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11295 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011296}
11297
11298/* unsolicited event for HP jack sensing */
11299static void alc262_ultra_unsol_event(struct hda_codec *codec,
11300 unsigned int res)
11301{
11302 if ((res >> 26) != ALC880_HP_EVENT)
11303 return;
11304 alc262_ultra_automute(codec);
11305}
11306
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011307static struct hda_input_mux alc262_ultra_capture_source = {
11308 .num_items = 2,
11309 .items = {
11310 { "Mic", 0x1 },
11311 { "Headphone", 0x7 },
11312 },
11313};
11314
11315static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11316 struct snd_ctl_elem_value *ucontrol)
11317{
11318 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11319 struct alc_spec *spec = codec->spec;
11320 int ret;
11321
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011322 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011323 if (!ret)
11324 return 0;
11325 /* reprogram the HP pin as mic or HP according to the input source */
11326 snd_hda_codec_write_cache(codec, 0x15, 0,
11327 AC_VERB_SET_PIN_WIDGET_CONTROL,
11328 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11329 alc262_ultra_automute(codec); /* mute/unmute HP */
11330 return ret;
11331}
11332
11333static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11334 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11335 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11336 {
11337 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11338 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011339 .info = alc_mux_enum_info,
11340 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011341 .put = alc262_ultra_mux_enum_put,
11342 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011343 {
11344 .iface = NID_MAPPING,
11345 .name = "Capture Source",
11346 .private_value = 0x15,
11347 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011348 { } /* end */
11349};
11350
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011351/* We use two mixers depending on the output pin; 0x16 is a mono output
11352 * and thus it's bound with a different mixer.
11353 * This function returns which mixer amp should be used.
11354 */
11355static int alc262_check_volbit(hda_nid_t nid)
11356{
11357 if (!nid)
11358 return 0;
11359 else if (nid == 0x16)
11360 return 2;
11361 else
11362 return 1;
11363}
11364
11365static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11366 const char *pfx, int *vbits)
11367{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011368 unsigned long val;
11369 int vbit;
11370
11371 vbit = alc262_check_volbit(nid);
11372 if (!vbit)
11373 return 0;
11374 if (*vbits & vbit) /* a volume control for this mixer already there */
11375 return 0;
11376 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011377 if (vbit == 2)
11378 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11379 else
11380 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011381 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011382}
11383
11384static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11385 const char *pfx)
11386{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011387 unsigned long val;
11388
11389 if (!nid)
11390 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011391 if (nid == 0x16)
11392 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11393 else
11394 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011395 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011396}
11397
Kailang Yangdf694da2005-12-05 19:42:22 +010011398/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011399static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11400 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011401{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011402 const char *pfx;
11403 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011404 int err;
11405
11406 spec->multiout.num_dacs = 1; /* only use one dac */
11407 spec->multiout.dac_nids = spec->private_dac_nids;
11408 spec->multiout.dac_nids[0] = 2;
11409
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011410 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11411 pfx = "Master";
11412 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11413 pfx = "Speaker";
11414 else
11415 pfx = "Front";
11416 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11417 if (err < 0)
11418 return err;
11419 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11420 if (err < 0)
11421 return err;
11422 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11423 if (err < 0)
11424 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011425
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011426 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11427 alc262_check_volbit(cfg->speaker_pins[0]) |
11428 alc262_check_volbit(cfg->hp_pins[0]);
11429 if (vbits == 1 || vbits == 2)
11430 pfx = "Master"; /* only one mixer is used */
11431 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11432 pfx = "Speaker";
11433 else
11434 pfx = "Front";
11435 vbits = 0;
11436 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11437 if (err < 0)
11438 return err;
11439 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11440 &vbits);
11441 if (err < 0)
11442 return err;
11443 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11444 &vbits);
11445 if (err < 0)
11446 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011447 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011448}
11449
Takashi Iwai05f5f472009-08-25 13:10:18 +020011450#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011451 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011452
11453/*
11454 * generic initialization of ADC, input mixers and output mixers
11455 */
11456static struct hda_verb alc262_volume_init_verbs[] = {
11457 /*
11458 * Unmute ADC0-2 and set the default input to mic-in
11459 */
11460 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11462 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11464 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11465 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11466
Takashi Iwaicb53c622007-08-10 17:21:45 +020011467 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011468 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011469 * Note: PASD motherboards uses the Line In 2 as the input for
11470 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011471 */
11472 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11474 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11475 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11476 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11477 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011478
11479 /*
11480 * Set up output mixers (0x0c - 0x0f)
11481 */
11482 /* set vol=0 to output mixers */
11483 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11484 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11485 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011486
Kailang Yangdf694da2005-12-05 19:42:22 +010011487 /* set up input amps for analog loopback */
11488 /* Amp Indices: DAC = 0, mixer = 1 */
11489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11491 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11492 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11493 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11494 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11495
11496 /* FIXME: use matrix-type input source selection */
11497 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11498 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11500 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11501 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11502 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11503 /* Input mixer2 */
11504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11505 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11506 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11507 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11508 /* Input mixer3 */
11509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11513
11514 { }
11515};
11516
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011517static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11518 /*
11519 * Unmute ADC0-2 and set the default input to mic-in
11520 */
11521 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11523 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11524 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11525 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11526 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11527
Takashi Iwaicb53c622007-08-10 17:21:45 +020011528 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011529 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011530 * Note: PASD motherboards uses the Line In 2 as the input for
11531 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011532 */
11533 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11535 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011541
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011542 /*
11543 * Set up output mixers (0x0c - 0x0e)
11544 */
11545 /* set vol=0 to output mixers */
11546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11548 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11549
11550 /* set up input amps for analog loopback */
11551 /* Amp Indices: DAC = 0, mixer = 1 */
11552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11554 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11555 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11556 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11558
Takashi Iwaice875f02008-01-28 18:17:43 +010011559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011560 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11561 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11562
11563 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11565
11566 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11567 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11568
11569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11570 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11571 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11572 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11573 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11574
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011575 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011576 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11577 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011578 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011579 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11580 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11581
11582
11583 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011584 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11585 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011586 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011587 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11589 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11590 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11591 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11594 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011595 /* Input mixer2 */
11596 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11599 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11600 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11601 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011605 /* Input mixer3 */
11606 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11611 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011615
Takashi Iwaice875f02008-01-28 18:17:43 +010011616 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11617
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011618 { }
11619};
11620
Kailang Yangcd7509a2007-01-26 18:33:17 +010011621static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11622 /*
11623 * Unmute ADC0-2 and set the default input to mic-in
11624 */
11625 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11626 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11627 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11628 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11629 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11630 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11631
Takashi Iwaicb53c622007-08-10 17:21:45 +020011632 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011633 * mixer widget
11634 * Note: PASD motherboards uses the Line In 2 as the input for front
11635 * panel mic (mic 2)
11636 */
11637 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011646 /*
11647 * Set up output mixers (0x0c - 0x0e)
11648 */
11649 /* set vol=0 to output mixers */
11650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11651 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11652 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11653
11654 /* set up input amps for analog loopback */
11655 /* Amp Indices: DAC = 0, mixer = 1 */
11656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11657 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11658 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11659 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11660 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11661 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11662
11663
11664 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11665 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11666 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11667 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11669 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11670 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11671
11672 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11674
11675 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11676 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11677
11678 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11679 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11680 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11681 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11682 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11683 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11684
11685 /* FIXME: use matrix-type input source selection */
11686 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11687 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11688 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11689 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11693 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11694 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11695 /* Input mixer2 */
11696 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11697 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11698 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11699 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11700 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11701 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11702 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11703 /* Input mixer3 */
11704 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11705 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11706 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11707 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11709 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11711
Takashi Iwaice875f02008-01-28 18:17:43 +010011712 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11713
Kailang Yangcd7509a2007-01-26 18:33:17 +010011714 { }
11715};
11716
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011717static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11718
11719 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11720 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11721 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11722
11723 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11724 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11725 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11726 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11727
11728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11729 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11730 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11731 {}
11732};
11733
11734
Takashi Iwaicb53c622007-08-10 17:21:45 +020011735#ifdef CONFIG_SND_HDA_POWER_SAVE
11736#define alc262_loopbacks alc880_loopbacks
11737#endif
11738
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011739/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011740#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11741#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11742#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11743#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11744
11745/*
11746 * BIOS auto configuration
11747 */
11748static int alc262_parse_auto_config(struct hda_codec *codec)
11749{
11750 struct alc_spec *spec = codec->spec;
11751 int err;
11752 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11753
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011754 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11755 alc262_ignore);
11756 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011757 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011758 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011759 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011760 spec->multiout.max_channels = 2;
11761 spec->no_analog = 1;
11762 goto dig_only;
11763 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011764 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011765 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011766 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11767 if (err < 0)
11768 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011769 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011770 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011771 return err;
11772
11773 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11774
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011775 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011776 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011777 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011778 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011779 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011780 if (spec->autocfg.dig_in_pin)
11781 spec->dig_in_nid = ALC262_DIGIN_NID;
11782
Takashi Iwai603c4012008-07-30 15:01:44 +020011783 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011784 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011785
Takashi Iwaid88897e2008-10-31 15:01:37 +010011786 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011787 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011788 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011789
Takashi Iwai776e1842007-08-29 15:07:11 +020011790 err = alc_auto_add_mic_boost(codec);
11791 if (err < 0)
11792 return err;
11793
Kailang Yang6227cdc2010-02-25 08:36:52 +010011794 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011795
Kailang Yangdf694da2005-12-05 19:42:22 +010011796 return 1;
11797}
11798
11799#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11800#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11801#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011802#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011803
11804
11805/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011806static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011807{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011808 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011809 alc262_auto_init_multi_out(codec);
11810 alc262_auto_init_hp_out(codec);
11811 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011812 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011813 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011814 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011815}
11816
11817/*
11818 * configuration and preset
11819 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011820static const char *alc262_models[ALC262_MODEL_LAST] = {
11821 [ALC262_BASIC] = "basic",
11822 [ALC262_HIPPO] = "hippo",
11823 [ALC262_HIPPO_1] = "hippo_1",
11824 [ALC262_FUJITSU] = "fujitsu",
11825 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011826 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011827 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011828 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011829 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011830 [ALC262_BENQ_T31] = "benq-t31",
11831 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011832 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011833 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011834 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011835 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011836 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011837 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011838 [ALC262_AUTO] = "auto",
11839};
11840
11841static struct snd_pci_quirk alc262_cfg_tbl[] = {
11842 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011843 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011844 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11845 ALC262_HP_BPC),
11846 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11847 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011848 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11849 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011850 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011851 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011852 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011853 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011854 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011855 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011856 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011857 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011858 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11859 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11860 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011861 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11862 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011863 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011864 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011865 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011866 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011867 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011868 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011869 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011870 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011871#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011872 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11873 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011874#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011875 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011876 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011877 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011878 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011879 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011880 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011881 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11882 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011883 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011884 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011885 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011886 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011887 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011888 {}
11889};
11890
11891static struct alc_config_preset alc262_presets[] = {
11892 [ALC262_BASIC] = {
11893 .mixers = { alc262_base_mixer },
11894 .init_verbs = { alc262_init_verbs },
11895 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11896 .dac_nids = alc262_dac_nids,
11897 .hp_nid = 0x03,
11898 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11899 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011900 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011901 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011902 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011903 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011904 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011905 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11906 .dac_nids = alc262_dac_nids,
11907 .hp_nid = 0x03,
11908 .dig_out_nid = ALC262_DIGOUT_NID,
11909 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11910 .channel_mode = alc262_modes,
11911 .input_mux = &alc262_capture_source,
11912 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011913 .setup = alc262_hippo_setup,
11914 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011915 },
11916 [ALC262_HIPPO_1] = {
11917 .mixers = { alc262_hippo1_mixer },
11918 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11919 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11920 .dac_nids = alc262_dac_nids,
11921 .hp_nid = 0x02,
11922 .dig_out_nid = ALC262_DIGOUT_NID,
11923 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11924 .channel_mode = alc262_modes,
11925 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011926 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011927 .setup = alc262_hippo1_setup,
11928 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011929 },
Takashi Iwai834be882006-03-01 14:16:17 +010011930 [ALC262_FUJITSU] = {
11931 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011932 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11933 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011934 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11935 .dac_nids = alc262_dac_nids,
11936 .hp_nid = 0x03,
11937 .dig_out_nid = ALC262_DIGOUT_NID,
11938 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11939 .channel_mode = alc262_modes,
11940 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011941 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011942 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011943 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011944 [ALC262_HP_BPC] = {
11945 .mixers = { alc262_HP_BPC_mixer },
11946 .init_verbs = { alc262_HP_BPC_init_verbs },
11947 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11948 .dac_nids = alc262_dac_nids,
11949 .hp_nid = 0x03,
11950 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11951 .channel_mode = alc262_modes,
11952 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011953 .unsol_event = alc262_hp_bpc_unsol_event,
11954 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011955 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011956 [ALC262_HP_BPC_D7000_WF] = {
11957 .mixers = { alc262_HP_BPC_WildWest_mixer },
11958 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11959 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11960 .dac_nids = alc262_dac_nids,
11961 .hp_nid = 0x03,
11962 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11963 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011964 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011965 .unsol_event = alc262_hp_wildwest_unsol_event,
11966 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011967 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011968 [ALC262_HP_BPC_D7000_WL] = {
11969 .mixers = { alc262_HP_BPC_WildWest_mixer,
11970 alc262_HP_BPC_WildWest_option_mixer },
11971 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11972 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11973 .dac_nids = alc262_dac_nids,
11974 .hp_nid = 0x03,
11975 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11976 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011977 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011978 .unsol_event = alc262_hp_wildwest_unsol_event,
11979 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011980 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011981 [ALC262_HP_TC_T5735] = {
11982 .mixers = { alc262_hp_t5735_mixer },
11983 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11984 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11985 .dac_nids = alc262_dac_nids,
11986 .hp_nid = 0x03,
11987 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11988 .channel_mode = alc262_modes,
11989 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010011990 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011991 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010011992 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010011993 },
11994 [ALC262_HP_RP5700] = {
11995 .mixers = { alc262_hp_rp5700_mixer },
11996 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11997 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11998 .dac_nids = alc262_dac_nids,
11999 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12000 .channel_mode = alc262_modes,
12001 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012002 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012003 [ALC262_BENQ_ED8] = {
12004 .mixers = { alc262_base_mixer },
12005 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12006 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12007 .dac_nids = alc262_dac_nids,
12008 .hp_nid = 0x03,
12009 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12010 .channel_mode = alc262_modes,
12011 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012012 },
Kailang Yang272a5272007-05-14 11:00:38 +020012013 [ALC262_SONY_ASSAMD] = {
12014 .mixers = { alc262_sony_mixer },
12015 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12016 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12017 .dac_nids = alc262_dac_nids,
12018 .hp_nid = 0x02,
12019 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12020 .channel_mode = alc262_modes,
12021 .input_mux = &alc262_capture_source,
12022 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012023 .setup = alc262_hippo_setup,
12024 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012025 },
12026 [ALC262_BENQ_T31] = {
12027 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012028 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12029 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012030 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12031 .dac_nids = alc262_dac_nids,
12032 .hp_nid = 0x03,
12033 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12034 .channel_mode = alc262_modes,
12035 .input_mux = &alc262_capture_source,
12036 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012037 .setup = alc262_hippo_setup,
12038 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012039 },
Tobin Davisf651b502007-10-26 12:40:47 +020012040 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012041 .mixers = { alc262_ultra_mixer },
12042 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012043 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012044 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12045 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012046 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12047 .channel_mode = alc262_modes,
12048 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012049 .adc_nids = alc262_adc_nids, /* ADC0 */
12050 .capsrc_nids = alc262_capsrc_nids,
12051 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012052 .unsol_event = alc262_ultra_unsol_event,
12053 .init_hook = alc262_ultra_automute,
12054 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012055 [ALC262_LENOVO_3000] = {
12056 .mixers = { alc262_lenovo_3000_mixer },
12057 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012058 alc262_lenovo_3000_unsol_verbs,
12059 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012060 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12061 .dac_nids = alc262_dac_nids,
12062 .hp_nid = 0x03,
12063 .dig_out_nid = ALC262_DIGOUT_NID,
12064 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12065 .channel_mode = alc262_modes,
12066 .input_mux = &alc262_fujitsu_capture_source,
12067 .unsol_event = alc262_lenovo_3000_unsol_event,
12068 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012069 [ALC262_NEC] = {
12070 .mixers = { alc262_nec_mixer },
12071 .init_verbs = { alc262_nec_verbs },
12072 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12073 .dac_nids = alc262_dac_nids,
12074 .hp_nid = 0x03,
12075 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12076 .channel_mode = alc262_modes,
12077 .input_mux = &alc262_capture_source,
12078 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012079 [ALC262_TOSHIBA_S06] = {
12080 .mixers = { alc262_toshiba_s06_mixer },
12081 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12082 alc262_eapd_verbs },
12083 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12084 .capsrc_nids = alc262_dmic_capsrc_nids,
12085 .dac_nids = alc262_dac_nids,
12086 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012087 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012088 .dig_out_nid = ALC262_DIGOUT_NID,
12089 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12090 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012091 .unsol_event = alc_sku_unsol_event,
12092 .setup = alc262_toshiba_s06_setup,
12093 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012094 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012095 [ALC262_TOSHIBA_RX1] = {
12096 .mixers = { alc262_toshiba_rx1_mixer },
12097 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12098 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12099 .dac_nids = alc262_dac_nids,
12100 .hp_nid = 0x03,
12101 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12102 .channel_mode = alc262_modes,
12103 .input_mux = &alc262_capture_source,
12104 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012105 .setup = alc262_hippo_setup,
12106 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012107 },
Tony Vroonba340e82009-02-02 19:01:30 +000012108 [ALC262_TYAN] = {
12109 .mixers = { alc262_tyan_mixer },
12110 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12111 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12112 .dac_nids = alc262_dac_nids,
12113 .hp_nid = 0x02,
12114 .dig_out_nid = ALC262_DIGOUT_NID,
12115 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12116 .channel_mode = alc262_modes,
12117 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012118 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012119 .setup = alc262_tyan_setup,
12120 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012121 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012122};
12123
12124static int patch_alc262(struct hda_codec *codec)
12125{
12126 struct alc_spec *spec;
12127 int board_config;
12128 int err;
12129
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012130 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012131 if (spec == NULL)
12132 return -ENOMEM;
12133
12134 codec->spec = spec;
12135#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012136 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12137 * under-run
12138 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012139 {
12140 int tmp;
12141 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12142 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12143 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12144 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12145 }
12146#endif
12147
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012148 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12149
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012150 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12151 alc262_models,
12152 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012153
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012154 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012155 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12156 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012157 board_config = ALC262_AUTO;
12158 }
12159
12160 if (board_config == ALC262_AUTO) {
12161 /* automatic parse from the BIOS config */
12162 err = alc262_parse_auto_config(codec);
12163 if (err < 0) {
12164 alc_free(codec);
12165 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012166 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012167 printk(KERN_INFO
12168 "hda_codec: Cannot set up configuration "
12169 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012170 board_config = ALC262_BASIC;
12171 }
12172 }
12173
Takashi Iwai07eba612009-02-19 08:06:35 +010012174 if (!spec->no_analog) {
12175 err = snd_hda_attach_beep_device(codec, 0x1);
12176 if (err < 0) {
12177 alc_free(codec);
12178 return err;
12179 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012180 }
12181
Kailang Yangdf694da2005-12-05 19:42:22 +010012182 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012183 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012184
Kailang Yangdf694da2005-12-05 19:42:22 +010012185 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12186 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012187
Kailang Yangdf694da2005-12-05 19:42:22 +010012188 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12189 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12190
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012191 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012192 int i;
12193 /* check whether the digital-mic has to be supported */
12194 for (i = 0; i < spec->input_mux->num_items; i++) {
12195 if (spec->input_mux->items[i].index >= 9)
12196 break;
12197 }
12198 if (i < spec->input_mux->num_items) {
12199 /* use only ADC0 */
12200 spec->adc_nids = alc262_dmic_adc_nids;
12201 spec->num_adc_nids = 1;
12202 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012203 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012204 /* all analog inputs */
12205 /* check whether NID 0x07 is valid */
12206 unsigned int wcap = get_wcaps(codec, 0x07);
12207
12208 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012209 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012210 if (wcap != AC_WID_AUD_IN) {
12211 spec->adc_nids = alc262_adc_nids_alt;
12212 spec->num_adc_nids =
12213 ARRAY_SIZE(alc262_adc_nids_alt);
12214 spec->capsrc_nids = alc262_capsrc_nids_alt;
12215 } else {
12216 spec->adc_nids = alc262_adc_nids;
12217 spec->num_adc_nids =
12218 ARRAY_SIZE(alc262_adc_nids);
12219 spec->capsrc_nids = alc262_capsrc_nids;
12220 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012221 }
12222 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012223 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012224 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010012225 if (!spec->no_analog)
12226 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012227
Takashi Iwai2134ea42008-01-10 16:53:55 +010012228 spec->vmaster_nid = 0x0c;
12229
Kailang Yangdf694da2005-12-05 19:42:22 +010012230 codec->patch_ops = alc_patch_ops;
12231 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012232 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012233#ifdef CONFIG_SND_HDA_POWER_SAVE
12234 if (!spec->loopback.amplist)
12235 spec->loopback.amplist = alc262_loopbacks;
12236#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012237
Kailang Yangdf694da2005-12-05 19:42:22 +010012238 return 0;
12239}
12240
Kailang Yangdf694da2005-12-05 19:42:22 +010012241/*
Kailang Yanga361d842007-06-05 12:30:55 +020012242 * ALC268 channel source setting (2 channel)
12243 */
12244#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12245#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012246
Kailang Yanga361d842007-06-05 12:30:55 +020012247static hda_nid_t alc268_dac_nids[2] = {
12248 /* front, hp */
12249 0x02, 0x03
12250};
12251
12252static hda_nid_t alc268_adc_nids[2] = {
12253 /* ADC0-1 */
12254 0x08, 0x07
12255};
12256
12257static hda_nid_t alc268_adc_nids_alt[1] = {
12258 /* ADC0 */
12259 0x08
12260};
12261
Takashi Iwaie1406342008-02-11 18:32:32 +010012262static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12263
Kailang Yanga361d842007-06-05 12:30:55 +020012264static struct snd_kcontrol_new alc268_base_mixer[] = {
12265 /* output mixer control */
12266 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12267 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12268 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12269 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012270 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12271 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12272 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012273 { }
12274};
12275
Takashi Iwai42171c12009-05-08 14:11:43 +020012276static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12277 /* output mixer control */
12278 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12279 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12280 ALC262_HIPPO_MASTER_SWITCH,
12281 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12282 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12283 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12284 { }
12285};
12286
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012287/* bind Beep switches of both NID 0x0f and 0x10 */
12288static struct hda_bind_ctls alc268_bind_beep_sw = {
12289 .ops = &snd_hda_bind_sw,
12290 .values = {
12291 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12292 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12293 0
12294 },
12295};
12296
12297static struct snd_kcontrol_new alc268_beep_mixer[] = {
12298 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12299 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12300 { }
12301};
12302
Kailang Yangd1a991a2007-08-15 16:21:59 +020012303static struct hda_verb alc268_eapd_verbs[] = {
12304 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12305 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12306 { }
12307};
12308
Takashi Iwaid2738092007-08-16 14:59:45 +020012309/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012310static struct hda_verb alc268_toshiba_verbs[] = {
12311 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12312 { } /* end */
12313};
12314
12315/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012316/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012317static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12318 .ops = &snd_hda_bind_vol,
12319 .values = {
12320 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12321 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12322 0
12323 },
12324};
12325
Takashi Iwai889c4392007-08-23 18:56:52 +020012326/* mute/unmute internal speaker according to the hp jack and mute state */
12327static void alc268_acer_automute(struct hda_codec *codec, int force)
12328{
12329 struct alc_spec *spec = codec->spec;
12330 unsigned int mute;
12331
12332 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012333 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012334 spec->sense_updated = 1;
12335 }
12336 if (spec->jack_present)
12337 mute = HDA_AMP_MUTE; /* mute internal speaker */
12338 else /* unmute internal speaker if necessary */
12339 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12340 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12341 HDA_AMP_MUTE, mute);
12342}
12343
12344
12345/* bind hp and internal speaker mute (with plug check) */
12346static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12347 struct snd_ctl_elem_value *ucontrol)
12348{
12349 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12350 long *valp = ucontrol->value.integer.value;
12351 int change;
12352
Takashi Iwai8de56b72009-07-24 16:51:47 +020012353 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012354 if (change)
12355 alc268_acer_automute(codec, 0);
12356 return change;
12357}
Takashi Iwaid2738092007-08-16 14:59:45 +020012358
Kailang Yang8ef355d2008-08-26 13:10:22 +020012359static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12360 /* output mixer control */
12361 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12362 {
12363 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12364 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012365 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012366 .info = snd_hda_mixer_amp_switch_info,
12367 .get = snd_hda_mixer_amp_switch_get,
12368 .put = alc268_acer_master_sw_put,
12369 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12370 },
12371 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12372 { }
12373};
12374
Takashi Iwaid2738092007-08-16 14:59:45 +020012375static struct snd_kcontrol_new alc268_acer_mixer[] = {
12376 /* output mixer control */
12377 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12378 {
12379 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12380 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012381 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012382 .info = snd_hda_mixer_amp_switch_info,
12383 .get = snd_hda_mixer_amp_switch_get,
12384 .put = alc268_acer_master_sw_put,
12385 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12386 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012387 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12388 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12389 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012390 { }
12391};
12392
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012393static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12394 /* output mixer control */
12395 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12396 {
12397 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12398 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012399 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012400 .info = snd_hda_mixer_amp_switch_info,
12401 .get = snd_hda_mixer_amp_switch_get,
12402 .put = alc268_acer_master_sw_put,
12403 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12404 },
12405 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12406 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12407 { }
12408};
12409
Kailang Yang8ef355d2008-08-26 13:10:22 +020012410static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12411 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12413 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12414 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12415 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12416 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12417 { }
12418};
12419
Takashi Iwaid2738092007-08-16 14:59:45 +020012420static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012421 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12422 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12424 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012425 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12426 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012427 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12428 { }
12429};
12430
12431/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012432#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012433#define alc268_toshiba_setup alc262_hippo_setup
12434#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012435
12436static void alc268_acer_unsol_event(struct hda_codec *codec,
12437 unsigned int res)
12438{
Takashi Iwai889c4392007-08-23 18:56:52 +020012439 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012440 return;
12441 alc268_acer_automute(codec, 1);
12442}
12443
Takashi Iwai889c4392007-08-23 18:56:52 +020012444static void alc268_acer_init_hook(struct hda_codec *codec)
12445{
12446 alc268_acer_automute(codec, 1);
12447}
12448
Kailang Yang8ef355d2008-08-26 13:10:22 +020012449/* toggle speaker-output according to the hp-jack state */
12450static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12451{
12452 unsigned int present;
12453 unsigned char bits;
12454
Wu Fengguang864f92b2009-11-18 12:38:02 +080012455 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012456 bits = present ? AMP_IN_MUTE(0) : 0;
12457 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12458 AMP_IN_MUTE(0), bits);
12459 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12460 AMP_IN_MUTE(0), bits);
12461}
12462
Kailang Yang8ef355d2008-08-26 13:10:22 +020012463static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12464 unsigned int res)
12465{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012466 switch (res >> 26) {
12467 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012468 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012469 break;
12470 case ALC880_MIC_EVENT:
12471 alc_mic_automute(codec);
12472 break;
12473 }
12474}
12475
12476static void alc268_acer_lc_setup(struct hda_codec *codec)
12477{
12478 struct alc_spec *spec = codec->spec;
12479 spec->ext_mic.pin = 0x18;
12480 spec->ext_mic.mux_idx = 0;
12481 spec->int_mic.pin = 0x12;
12482 spec->int_mic.mux_idx = 6;
12483 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012484}
12485
12486static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12487{
12488 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012489 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012490}
12491
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012492static struct snd_kcontrol_new alc268_dell_mixer[] = {
12493 /* output mixer control */
12494 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12495 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12496 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12497 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12498 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12499 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12500 { }
12501};
12502
12503static struct hda_verb alc268_dell_verbs[] = {
12504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12505 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12506 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012507 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012508 { }
12509};
12510
12511/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012512static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012513{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012514 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012515
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012516 spec->autocfg.hp_pins[0] = 0x15;
12517 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012518 spec->ext_mic.pin = 0x18;
12519 spec->ext_mic.mux_idx = 0;
12520 spec->int_mic.pin = 0x19;
12521 spec->int_mic.mux_idx = 1;
12522 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012523}
12524
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012525static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12526 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12527 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12528 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12529 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12530 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12531 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12532 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12533 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12534 { }
12535};
12536
12537static struct hda_verb alc267_quanta_il1_verbs[] = {
12538 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12539 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12540 { }
12541};
12542
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012543static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012544{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012545 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012546 spec->autocfg.hp_pins[0] = 0x15;
12547 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012548 spec->ext_mic.pin = 0x18;
12549 spec->ext_mic.mux_idx = 0;
12550 spec->int_mic.pin = 0x19;
12551 spec->int_mic.mux_idx = 1;
12552 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012553}
12554
Kailang Yanga361d842007-06-05 12:30:55 +020012555/*
12556 * generic initialization of ADC, input mixers and output mixers
12557 */
12558static struct hda_verb alc268_base_init_verbs[] = {
12559 /* Unmute DAC0-1 and set vol = 0 */
12560 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012561 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012562
12563 /*
12564 * Set up output mixers (0x0c - 0x0e)
12565 */
12566 /* set vol=0 to output mixers */
12567 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012568 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12569
12570 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12571 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12572
12573 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12574 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12575 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12576 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12577 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12578 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12579 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12580 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12581
12582 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12583 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12584 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12585 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012586 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012587
12588 /* set PCBEEP vol = 0, mute connections */
12589 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12590 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12591 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012592
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012593 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012594
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012595 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12596 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12597 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12598 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012599
Kailang Yanga361d842007-06-05 12:30:55 +020012600 { }
12601};
12602
12603/*
12604 * generic initialization of ADC, input mixers and output mixers
12605 */
12606static struct hda_verb alc268_volume_init_verbs[] = {
12607 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012608 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12609 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012610
12611 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12612 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12613 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12614 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12615 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12616
Kailang Yanga361d842007-06-05 12:30:55 +020012617 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012618 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12619 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12620
12621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012622 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012623
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012624 /* set PCBEEP vol = 0, mute connections */
12625 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12626 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12627 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012628
12629 { }
12630};
12631
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012632static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12633 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12634 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12635 { } /* end */
12636};
12637
Kailang Yanga361d842007-06-05 12:30:55 +020012638static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12639 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12640 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012641 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012642 { } /* end */
12643};
12644
12645static struct snd_kcontrol_new alc268_capture_mixer[] = {
12646 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12647 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12648 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12649 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012650 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012651 { } /* end */
12652};
12653
12654static struct hda_input_mux alc268_capture_source = {
12655 .num_items = 4,
12656 .items = {
12657 { "Mic", 0x0 },
12658 { "Front Mic", 0x1 },
12659 { "Line", 0x2 },
12660 { "CD", 0x3 },
12661 },
12662};
12663
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012664static struct hda_input_mux alc268_acer_capture_source = {
12665 .num_items = 3,
12666 .items = {
12667 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012668 { "Internal Mic", 0x1 },
12669 { "Line", 0x2 },
12670 },
12671};
12672
12673static struct hda_input_mux alc268_acer_dmic_capture_source = {
12674 .num_items = 3,
12675 .items = {
12676 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012677 { "Internal Mic", 0x6 },
12678 { "Line", 0x2 },
12679 },
12680};
12681
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012682#ifdef CONFIG_SND_DEBUG
12683static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012684 /* Volume widgets */
12685 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12686 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12687 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12688 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12689 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12690 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12691 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12692 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12693 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12694 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12695 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12696 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12697 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012698 /* The below appears problematic on some hardwares */
12699 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012700 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12701 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12702 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12703 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12704
12705 /* Modes for retasking pin widgets */
12706 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12707 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12708 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12709 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12710
12711 /* Controls for GPIO pins, assuming they are configured as outputs */
12712 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12713 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12714 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12715 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12716
12717 /* Switches to allow the digital SPDIF output pin to be enabled.
12718 * The ALC268 does not have an SPDIF input.
12719 */
12720 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12721
12722 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12723 * this output to turn on an external amplifier.
12724 */
12725 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12726 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12727
12728 { } /* end */
12729};
12730#endif
12731
Kailang Yanga361d842007-06-05 12:30:55 +020012732/* create input playback/capture controls for the given pin */
12733static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12734 const char *ctlname, int idx)
12735{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012736 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012737 int err;
12738
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012739 switch (nid) {
12740 case 0x14:
12741 case 0x16:
12742 dac = 0x02;
12743 break;
12744 case 0x15:
12745 dac = 0x03;
12746 break;
12747 default:
12748 return 0;
12749 }
12750 if (spec->multiout.dac_nids[0] != dac &&
12751 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012752 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012753 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012754 HDA_OUTPUT));
12755 if (err < 0)
12756 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012757 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12758 }
12759
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012760 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012761 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012762 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012763 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012764 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012765 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012766 if (err < 0)
12767 return err;
12768 return 0;
12769}
12770
12771/* add playback controls from the parsed DAC table */
12772static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12773 const struct auto_pin_cfg *cfg)
12774{
12775 hda_nid_t nid;
12776 int err;
12777
Kailang Yanga361d842007-06-05 12:30:55 +020012778 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012779
12780 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012781 if (nid) {
12782 const char *name;
12783 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12784 name = "Speaker";
12785 else
12786 name = "Front";
12787 err = alc268_new_analog_output(spec, nid, name, 0);
12788 if (err < 0)
12789 return err;
12790 }
Kailang Yanga361d842007-06-05 12:30:55 +020012791
12792 nid = cfg->speaker_pins[0];
12793 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012794 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012795 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12796 if (err < 0)
12797 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012798 } else {
12799 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12800 if (err < 0)
12801 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012802 }
12803 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012804 if (nid) {
12805 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12806 if (err < 0)
12807 return err;
12808 }
Kailang Yanga361d842007-06-05 12:30:55 +020012809
12810 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12811 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012812 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012813 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012814 if (err < 0)
12815 return err;
12816 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012817 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012818}
12819
12820/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012821static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012822 const struct auto_pin_cfg *cfg)
12823{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012824 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012825}
12826
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012827static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12828 hda_nid_t nid, int pin_type)
12829{
12830 int idx;
12831
12832 alc_set_pin_output(codec, nid, pin_type);
12833 if (nid == 0x14 || nid == 0x16)
12834 idx = 0;
12835 else
12836 idx = 1;
12837 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12838}
12839
12840static void alc268_auto_init_multi_out(struct hda_codec *codec)
12841{
12842 struct alc_spec *spec = codec->spec;
12843 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12844 if (nid) {
12845 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12846 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12847 }
12848}
12849
12850static void alc268_auto_init_hp_out(struct hda_codec *codec)
12851{
12852 struct alc_spec *spec = codec->spec;
12853 hda_nid_t pin;
12854
12855 pin = spec->autocfg.hp_pins[0];
12856 if (pin)
12857 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12858 pin = spec->autocfg.speaker_pins[0];
12859 if (pin)
12860 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12861}
12862
Kailang Yanga361d842007-06-05 12:30:55 +020012863static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12864{
12865 struct alc_spec *spec = codec->spec;
12866 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12867 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12868 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12869 unsigned int dac_vol1, dac_vol2;
12870
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012871 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012872 snd_hda_codec_write(codec, speaker_nid, 0,
12873 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012874 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012875 snd_hda_codec_write(codec, 0x0f, 0,
12876 AC_VERB_SET_AMP_GAIN_MUTE,
12877 AMP_IN_UNMUTE(1));
12878 snd_hda_codec_write(codec, 0x10, 0,
12879 AC_VERB_SET_AMP_GAIN_MUTE,
12880 AMP_IN_UNMUTE(1));
12881 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012882 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012883 snd_hda_codec_write(codec, 0x0f, 0,
12884 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12885 snd_hda_codec_write(codec, 0x10, 0,
12886 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12887 }
12888
12889 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012890 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012891 dac_vol2 = AMP_OUT_ZERO;
12892 else if (line_nid == 0x15)
12893 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012894 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012895 dac_vol2 = AMP_OUT_ZERO;
12896 else if (hp_nid == 0x15)
12897 dac_vol1 = AMP_OUT_ZERO;
12898 if (line_nid != 0x16 || hp_nid != 0x16 ||
12899 spec->autocfg.line_out_pins[1] != 0x16 ||
12900 spec->autocfg.line_out_pins[2] != 0x16)
12901 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12902
12903 snd_hda_codec_write(codec, 0x02, 0,
12904 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12905 snd_hda_codec_write(codec, 0x03, 0,
12906 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12907}
12908
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012909/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012910#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12911#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012912#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012913#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12914
12915/*
12916 * BIOS auto configuration
12917 */
12918static int alc268_parse_auto_config(struct hda_codec *codec)
12919{
12920 struct alc_spec *spec = codec->spec;
12921 int err;
12922 static hda_nid_t alc268_ignore[] = { 0 };
12923
12924 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12925 alc268_ignore);
12926 if (err < 0)
12927 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012928 if (!spec->autocfg.line_outs) {
12929 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12930 spec->multiout.max_channels = 2;
12931 spec->no_analog = 1;
12932 goto dig_only;
12933 }
Kailang Yanga361d842007-06-05 12:30:55 +020012934 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012935 }
Kailang Yanga361d842007-06-05 12:30:55 +020012936 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12937 if (err < 0)
12938 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012939 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012940 if (err < 0)
12941 return err;
12942
12943 spec->multiout.max_channels = 2;
12944
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012945 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012946 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012947 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012948 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012949 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12950 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012951 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012952 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012953
Takashi Iwai892981f2009-03-02 08:04:35 +010012954 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012955 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012956
Takashi Iwaid88897e2008-10-31 15:01:37 +010012957 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012958 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012959 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012960
Takashi Iwai776e1842007-08-29 15:07:11 +020012961 err = alc_auto_add_mic_boost(codec);
12962 if (err < 0)
12963 return err;
12964
Kailang Yang6227cdc2010-02-25 08:36:52 +010012965 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012966
Kailang Yanga361d842007-06-05 12:30:55 +020012967 return 1;
12968}
12969
Kailang Yanga361d842007-06-05 12:30:55 +020012970#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12971
12972/* init callback for auto-configuration model -- overriding the default init */
12973static void alc268_auto_init(struct hda_codec *codec)
12974{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012975 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012976 alc268_auto_init_multi_out(codec);
12977 alc268_auto_init_hp_out(codec);
12978 alc268_auto_init_mono_speaker_out(codec);
12979 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012980 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012981 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012982}
12983
12984/*
12985 * configuration and preset
12986 */
12987static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012988 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012989 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012990 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012991 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012992 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012993 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012994 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012995 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012996#ifdef CONFIG_SND_DEBUG
12997 [ALC268_TEST] = "test",
12998#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012999 [ALC268_AUTO] = "auto",
13000};
13001
13002static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013003 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013004 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013005 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013006 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013007 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013008 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13009 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013010 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013011 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13012 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013013 /* almost compatible with toshiba but with optional digital outs;
13014 * auto-probing seems working fine
13015 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013016 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013017 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013018 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013019 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013020 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013021 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013022 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013023 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013024 {}
13025};
13026
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013027/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13028static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13029 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13030 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13031 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13032 ALC268_TOSHIBA),
13033 {}
13034};
13035
Kailang Yanga361d842007-06-05 12:30:55 +020013036static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013037 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013038 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13039 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013040 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13041 alc267_quanta_il1_verbs },
13042 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13043 .dac_nids = alc268_dac_nids,
13044 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13045 .adc_nids = alc268_adc_nids_alt,
13046 .hp_nid = 0x03,
13047 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13048 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013049 .unsol_event = alc_sku_unsol_event,
13050 .setup = alc267_quanta_il1_setup,
13051 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013052 },
Kailang Yanga361d842007-06-05 12:30:55 +020013053 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013054 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13055 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013056 .init_verbs = { alc268_base_init_verbs },
13057 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13058 .dac_nids = alc268_dac_nids,
13059 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13060 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013061 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013062 .hp_nid = 0x03,
13063 .dig_out_nid = ALC268_DIGOUT_NID,
13064 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13065 .channel_mode = alc268_modes,
13066 .input_mux = &alc268_capture_source,
13067 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013068 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013069 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013070 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013071 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13072 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013073 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13074 .dac_nids = alc268_dac_nids,
13075 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13076 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013077 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013078 .hp_nid = 0x03,
13079 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13080 .channel_mode = alc268_modes,
13081 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013082 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013083 .setup = alc268_toshiba_setup,
13084 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013085 },
13086 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013087 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013088 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013089 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13090 alc268_acer_verbs },
13091 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13092 .dac_nids = alc268_dac_nids,
13093 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13094 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013095 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013096 .hp_nid = 0x02,
13097 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13098 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013099 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013100 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013101 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013102 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013103 [ALC268_ACER_DMIC] = {
13104 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13105 alc268_beep_mixer },
13106 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13107 alc268_acer_verbs },
13108 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13109 .dac_nids = alc268_dac_nids,
13110 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13111 .adc_nids = alc268_adc_nids_alt,
13112 .capsrc_nids = alc268_capsrc_nids,
13113 .hp_nid = 0x02,
13114 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13115 .channel_mode = alc268_modes,
13116 .input_mux = &alc268_acer_dmic_capture_source,
13117 .unsol_event = alc268_acer_unsol_event,
13118 .init_hook = alc268_acer_init_hook,
13119 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013120 [ALC268_ACER_ASPIRE_ONE] = {
13121 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013122 alc268_beep_mixer,
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013123 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013124 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13125 alc268_acer_aspire_one_verbs },
13126 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13127 .dac_nids = alc268_dac_nids,
13128 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13129 .adc_nids = alc268_adc_nids_alt,
13130 .capsrc_nids = alc268_capsrc_nids,
13131 .hp_nid = 0x03,
13132 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13133 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013134 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013135 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013136 .init_hook = alc268_acer_lc_init_hook,
13137 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013138 [ALC268_DELL] = {
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013139 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13140 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013141 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13142 alc268_dell_verbs },
13143 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13144 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013145 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13146 .adc_nids = alc268_adc_nids_alt,
13147 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013148 .hp_nid = 0x02,
13149 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13150 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013151 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013152 .setup = alc268_dell_setup,
13153 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013154 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013155 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013156 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13157 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013158 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13159 alc268_toshiba_verbs },
13160 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13161 .dac_nids = alc268_dac_nids,
13162 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13163 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013164 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013165 .hp_nid = 0x03,
13166 .dig_out_nid = ALC268_DIGOUT_NID,
13167 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13168 .channel_mode = alc268_modes,
13169 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013170 .setup = alc268_toshiba_setup,
13171 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013172 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013173#ifdef CONFIG_SND_DEBUG
13174 [ALC268_TEST] = {
13175 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13176 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13177 alc268_volume_init_verbs },
13178 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13179 .dac_nids = alc268_dac_nids,
13180 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13181 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013182 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013183 .hp_nid = 0x03,
13184 .dig_out_nid = ALC268_DIGOUT_NID,
13185 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13186 .channel_mode = alc268_modes,
13187 .input_mux = &alc268_capture_source,
13188 },
13189#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013190};
13191
13192static int patch_alc268(struct hda_codec *codec)
13193{
13194 struct alc_spec *spec;
13195 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013196 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013197
Julia Lawallef86f582009-12-19 08:18:03 +010013198 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013199 if (spec == NULL)
13200 return -ENOMEM;
13201
13202 codec->spec = spec;
13203
13204 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13205 alc268_models,
13206 alc268_cfg_tbl);
13207
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013208 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13209 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013210 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013211
Kailang Yanga361d842007-06-05 12:30:55 +020013212 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013213 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13214 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013215 board_config = ALC268_AUTO;
13216 }
13217
13218 if (board_config == ALC268_AUTO) {
13219 /* automatic parse from the BIOS config */
13220 err = alc268_parse_auto_config(codec);
13221 if (err < 0) {
13222 alc_free(codec);
13223 return err;
13224 } else if (!err) {
13225 printk(KERN_INFO
13226 "hda_codec: Cannot set up configuration "
13227 "from BIOS. Using base mode...\n");
13228 board_config = ALC268_3ST;
13229 }
13230 }
13231
13232 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013233 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013234
Kailang Yanga361d842007-06-05 12:30:55 +020013235 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13236 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013237 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013238
Kailang Yanga361d842007-06-05 12:30:55 +020013239 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13240
Takashi Iwai22971e32009-02-10 11:56:44 +010013241 has_beep = 0;
13242 for (i = 0; i < spec->num_mixers; i++) {
13243 if (spec->mixers[i] == alc268_beep_mixer) {
13244 has_beep = 1;
13245 break;
13246 }
13247 }
13248
13249 if (has_beep) {
13250 err = snd_hda_attach_beep_device(codec, 0x1);
13251 if (err < 0) {
13252 alc_free(codec);
13253 return err;
13254 }
13255 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13256 /* override the amp caps for beep generator */
13257 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013258 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13259 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13260 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13261 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013262 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013263
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013264 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013265 /* check whether NID 0x07 is valid */
13266 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013267 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013268
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013269 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013270 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013271 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013272 if (spec->auto_mic ||
13273 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013274 spec->adc_nids = alc268_adc_nids_alt;
13275 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013276 if (spec->auto_mic)
13277 fixup_automic_adc(codec);
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013278 if (spec->auto_mic || spec->input_mux->num_items == 1)
13279 add_mixer(spec, alc268_capture_nosrc_mixer);
13280 else
13281 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013282 } else {
13283 spec->adc_nids = alc268_adc_nids;
13284 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013285 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013286 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013287 /* set default input source */
13288 for (i = 0; i < spec->num_adc_nids; i++)
13289 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13290 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013291 i < spec->num_mux_defs ?
13292 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013293 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013294 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013295
13296 spec->vmaster_nid = 0x02;
13297
Kailang Yanga361d842007-06-05 12:30:55 +020013298 codec->patch_ops = alc_patch_ops;
13299 if (board_config == ALC268_AUTO)
13300 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013301
Kailang Yanga361d842007-06-05 12:30:55 +020013302 return 0;
13303}
13304
13305/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013306 * ALC269 channel source setting (2 channel)
13307 */
13308#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13309
13310#define alc269_dac_nids alc260_dac_nids
13311
13312static hda_nid_t alc269_adc_nids[1] = {
13313 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013314 0x08,
13315};
13316
Takashi Iwaie01bf502008-08-21 16:25:07 +020013317static hda_nid_t alc269_capsrc_nids[1] = {
13318 0x23,
13319};
13320
Kailang Yang84898e82010-02-04 14:16:14 +010013321static hda_nid_t alc269vb_adc_nids[1] = {
13322 /* ADC1 */
13323 0x09,
13324};
13325
13326static hda_nid_t alc269vb_capsrc_nids[1] = {
13327 0x22,
13328};
13329
Takashi Iwaie01bf502008-08-21 16:25:07 +020013330/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
13331 * not a mux!
13332 */
13333
Kailang Yangf6a92242007-12-13 16:52:54 +010013334#define alc269_modes alc260_modes
13335#define alc269_capture_source alc880_lg_lw_capture_source
13336
13337static struct snd_kcontrol_new alc269_base_mixer[] = {
13338 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13339 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13340 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13341 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13342 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13343 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13344 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13345 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13346 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13347 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13348 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13349 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13350 { } /* end */
13351};
13352
Kailang Yang60db6b52008-08-26 13:13:00 +020013353static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13354 /* output mixer control */
13355 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13356 {
13357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13358 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013359 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013360 .info = snd_hda_mixer_amp_switch_info,
13361 .get = snd_hda_mixer_amp_switch_get,
13362 .put = alc268_acer_master_sw_put,
13363 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13364 },
13365 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13366 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13367 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13368 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13369 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13370 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013371 { }
13372};
13373
Tony Vroon64154832008-11-06 15:08:49 +000013374static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13375 /* output mixer control */
13376 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13377 {
13378 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13379 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013380 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013381 .info = snd_hda_mixer_amp_switch_info,
13382 .get = snd_hda_mixer_amp_switch_get,
13383 .put = alc268_acer_master_sw_put,
13384 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13385 },
13386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13387 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13388 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13389 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13390 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13391 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13392 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13393 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13394 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013395 { }
13396};
13397
Kailang Yang84898e82010-02-04 14:16:14 +010013398static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013399 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013400 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013401 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013402 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013403 { } /* end */
13404};
13405
Kailang Yang84898e82010-02-04 14:16:14 +010013406static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13407 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13408 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13409 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13410 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13411 { } /* end */
13412};
13413
Kailang Yangf6a92242007-12-13 16:52:54 +010013414/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013415static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13416 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13417 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13418 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13419 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13420 { } /* end */
13421};
13422
13423static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013424 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13425 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013426 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13427 { } /* end */
13428};
13429
Kailang Yang84898e82010-02-04 14:16:14 +010013430static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13431 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13432 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13433 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13434 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13435 { } /* end */
13436};
13437
13438static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13439 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13440 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13441 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13442 { } /* end */
13443};
13444
Takashi Iwai26f5df22008-11-03 17:39:46 +010013445/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013446#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013447
Kailang Yang60db6b52008-08-26 13:13:00 +020013448static struct hda_verb alc269_quanta_fl1_verbs[] = {
13449 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13450 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13452 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13453 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13454 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13455 { }
13456};
13457
Tony Vroon64154832008-11-06 15:08:49 +000013458static struct hda_verb alc269_lifebook_verbs[] = {
13459 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13460 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13461 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13463 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13464 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13465 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13466 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13467 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13468 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13469 { }
13470};
13471
Kailang Yang60db6b52008-08-26 13:13:00 +020013472/* toggle speaker-output according to the hp-jack state */
13473static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13474{
13475 unsigned int present;
13476 unsigned char bits;
13477
Wu Fengguang864f92b2009-11-18 12:38:02 +080013478 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013479 bits = present ? AMP_IN_MUTE(0) : 0;
13480 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13481 AMP_IN_MUTE(0), bits);
13482 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13483 AMP_IN_MUTE(0), bits);
13484
13485 snd_hda_codec_write(codec, 0x20, 0,
13486 AC_VERB_SET_COEF_INDEX, 0x0c);
13487 snd_hda_codec_write(codec, 0x20, 0,
13488 AC_VERB_SET_PROC_COEF, 0x680);
13489
13490 snd_hda_codec_write(codec, 0x20, 0,
13491 AC_VERB_SET_COEF_INDEX, 0x0c);
13492 snd_hda_codec_write(codec, 0x20, 0,
13493 AC_VERB_SET_PROC_COEF, 0x480);
13494}
13495
Tony Vroon64154832008-11-06 15:08:49 +000013496/* toggle speaker-output according to the hp-jacks state */
13497static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13498{
13499 unsigned int present;
13500 unsigned char bits;
13501
13502 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013503 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013504
13505 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013506 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013507
13508 bits = present ? AMP_IN_MUTE(0) : 0;
13509 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13510 AMP_IN_MUTE(0), bits);
13511 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13512 AMP_IN_MUTE(0), bits);
13513
13514 snd_hda_codec_write(codec, 0x20, 0,
13515 AC_VERB_SET_COEF_INDEX, 0x0c);
13516 snd_hda_codec_write(codec, 0x20, 0,
13517 AC_VERB_SET_PROC_COEF, 0x680);
13518
13519 snd_hda_codec_write(codec, 0x20, 0,
13520 AC_VERB_SET_COEF_INDEX, 0x0c);
13521 snd_hda_codec_write(codec, 0x20, 0,
13522 AC_VERB_SET_PROC_COEF, 0x480);
13523}
13524
Tony Vroon64154832008-11-06 15:08:49 +000013525static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13526{
13527 unsigned int present_laptop;
13528 unsigned int present_dock;
13529
Wu Fengguang864f92b2009-11-18 12:38:02 +080013530 present_laptop = snd_hda_jack_detect(codec, 0x18);
13531 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013532
13533 /* Laptop mic port overrides dock mic port, design decision */
13534 if (present_dock)
13535 snd_hda_codec_write(codec, 0x23, 0,
13536 AC_VERB_SET_CONNECT_SEL, 0x3);
13537 if (present_laptop)
13538 snd_hda_codec_write(codec, 0x23, 0,
13539 AC_VERB_SET_CONNECT_SEL, 0x0);
13540 if (!present_dock && !present_laptop)
13541 snd_hda_codec_write(codec, 0x23, 0,
13542 AC_VERB_SET_CONNECT_SEL, 0x1);
13543}
13544
Kailang Yang60db6b52008-08-26 13:13:00 +020013545static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13546 unsigned int res)
13547{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013548 switch (res >> 26) {
13549 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013550 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013551 break;
13552 case ALC880_MIC_EVENT:
13553 alc_mic_automute(codec);
13554 break;
13555 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013556}
13557
Tony Vroon64154832008-11-06 15:08:49 +000013558static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13559 unsigned int res)
13560{
13561 if ((res >> 26) == ALC880_HP_EVENT)
13562 alc269_lifebook_speaker_automute(codec);
13563 if ((res >> 26) == ALC880_MIC_EVENT)
13564 alc269_lifebook_mic_autoswitch(codec);
13565}
13566
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013567static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13568{
13569 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013570 spec->autocfg.hp_pins[0] = 0x15;
13571 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013572 spec->ext_mic.pin = 0x18;
13573 spec->ext_mic.mux_idx = 0;
13574 spec->int_mic.pin = 0x19;
13575 spec->int_mic.mux_idx = 1;
13576 spec->auto_mic = 1;
13577}
13578
Kailang Yang60db6b52008-08-26 13:13:00 +020013579static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13580{
13581 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013582 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013583}
13584
Tony Vroon64154832008-11-06 15:08:49 +000013585static void alc269_lifebook_init_hook(struct hda_codec *codec)
13586{
13587 alc269_lifebook_speaker_automute(codec);
13588 alc269_lifebook_mic_autoswitch(codec);
13589}
13590
Kailang Yang84898e82010-02-04 14:16:14 +010013591static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013592 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13593 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13594 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13595 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13596 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13597 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13598 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13599 {}
13600};
13601
Kailang Yang84898e82010-02-04 14:16:14 +010013602static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013603 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13604 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13605 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13607 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13608 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13609 {}
13610};
13611
Kailang Yang84898e82010-02-04 14:16:14 +010013612static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13613 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13614 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13615 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13616 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13617 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13618 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13619 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13620 {}
13621};
13622
13623static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13624 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13625 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13626 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13627 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13628 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13629 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13630 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13631 {}
13632};
13633
Kailang Yang60db6b52008-08-26 13:13:00 +020013634/* toggle speaker-output according to the hp-jack state */
13635static void alc269_speaker_automute(struct hda_codec *codec)
13636{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013637 struct alc_spec *spec = codec->spec;
13638 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013639 unsigned int present;
13640 unsigned char bits;
13641
Kailang Yangebb83ee2009-12-17 12:23:00 +010013642 present = snd_hda_jack_detect(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020013643 bits = present ? AMP_IN_MUTE(0) : 0;
13644 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13645 AMP_IN_MUTE(0), bits);
13646 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13647 AMP_IN_MUTE(0), bits);
13648}
13649
Kailang Yang60db6b52008-08-26 13:13:00 +020013650/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013651static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013652 unsigned int res)
13653{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013654 switch (res >> 26) {
13655 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013656 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013657 break;
13658 case ALC880_MIC_EVENT:
13659 alc_mic_automute(codec);
13660 break;
13661 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013662}
13663
Kailang Yang84898e82010-02-04 14:16:14 +010013664static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013665{
13666 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013667 spec->autocfg.hp_pins[0] = 0x15;
13668 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013669 spec->ext_mic.pin = 0x18;
13670 spec->ext_mic.mux_idx = 0;
13671 spec->int_mic.pin = 0x12;
13672 spec->int_mic.mux_idx = 5;
13673 spec->auto_mic = 1;
13674}
13675
Kailang Yang84898e82010-02-04 14:16:14 +010013676static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13677{
13678 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013679 spec->autocfg.hp_pins[0] = 0x15;
13680 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang84898e82010-02-04 14:16:14 +010013681 spec->ext_mic.pin = 0x18;
13682 spec->ext_mic.mux_idx = 0;
13683 spec->int_mic.pin = 0x12;
13684 spec->int_mic.mux_idx = 6;
13685 spec->auto_mic = 1;
13686}
13687
13688static void alc269_laptop_amic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013689{
13690 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013691 spec->autocfg.hp_pins[0] = 0x15;
13692 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013693 spec->ext_mic.pin = 0x18;
13694 spec->ext_mic.mux_idx = 0;
13695 spec->int_mic.pin = 0x19;
13696 spec->int_mic.mux_idx = 1;
13697 spec->auto_mic = 1;
13698}
13699
Kailang Yang84898e82010-02-04 14:16:14 +010013700static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013701{
13702 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013703 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013704}
13705
Kailang Yangf6a92242007-12-13 16:52:54 +010013706/*
13707 * generic initialization of ADC, input mixers and output mixers
13708 */
13709static struct hda_verb alc269_init_verbs[] = {
13710 /*
13711 * Unmute ADC0 and set the default input to mic-in
13712 */
Kailang Yang84898e82010-02-04 14:16:14 +010013713 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013714
13715 /*
Kailang Yang84898e82010-02-04 14:16:14 +010013716 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010013717 */
13718 /* set vol=0 to output mixers */
13719 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13720 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13721
13722 /* set up input amps for analog loopback */
13723 /* Amp Indices: DAC = 0, mixer = 1 */
13724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13727 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13728 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13729 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13730
13731 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13732 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13733 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13734 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13735 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13736 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13737 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13738
13739 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13740 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010013741
Kailang Yang84898e82010-02-04 14:16:14 +010013742 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010013743 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13744 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010013745 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010013746
13747 /* set EAPD */
13748 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010013749 { }
13750};
13751
13752static struct hda_verb alc269vb_init_verbs[] = {
13753 /*
13754 * Unmute ADC0 and set the default input to mic-in
13755 */
13756 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13757
13758 /*
13759 * Set up output mixers (0x02 - 0x03)
13760 */
13761 /* set vol=0 to output mixers */
13762 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13763 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13764
13765 /* set up input amps for analog loopback */
13766 /* Amp Indices: DAC = 0, mixer = 1 */
13767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13769 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13770 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13771 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13772 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13773
13774 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13775 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13776 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13777 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13778 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13779 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13780 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13781
13782 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13783 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13784
13785 /* FIXME: use Mux-type input source selection */
13786 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13787 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13788 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
13789
13790 /* set EAPD */
13791 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010013792 { }
13793};
13794
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013795#define alc269_auto_create_multi_out_ctls \
13796 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013797#define alc269_auto_create_input_ctls \
13798 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013799
13800#ifdef CONFIG_SND_HDA_POWER_SAVE
13801#define alc269_loopbacks alc880_loopbacks
13802#endif
13803
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013804/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013805#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13806#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13807#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13808#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13809
Takashi Iwaif03d3112009-03-05 14:18:16 +010013810static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13811 .substreams = 1,
13812 .channels_min = 2,
13813 .channels_max = 8,
13814 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13815 /* NID is set in alc_build_pcms */
13816 .ops = {
13817 .open = alc880_playback_pcm_open,
13818 .prepare = alc880_playback_pcm_prepare,
13819 .cleanup = alc880_playback_pcm_cleanup
13820 },
13821};
13822
13823static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13824 .substreams = 1,
13825 .channels_min = 2,
13826 .channels_max = 2,
13827 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13828 /* NID is set in alc_build_pcms */
13829};
13830
Kailang Yangf6a92242007-12-13 16:52:54 +010013831/*
13832 * BIOS auto configuration
13833 */
13834static int alc269_parse_auto_config(struct hda_codec *codec)
13835{
13836 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013837 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013838 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
Kailang Yang84898e82010-02-04 14:16:14 +010013839 hda_nid_t real_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010013840
13841 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13842 alc269_ignore);
13843 if (err < 0)
13844 return err;
13845
13846 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13847 if (err < 0)
13848 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013849 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013850 if (err < 0)
13851 return err;
13852
13853 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13854
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013855 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013856 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13857
Takashi Iwai603c4012008-07-30 15:01:44 +020013858 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013859 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013860
Kailang Yang84898e82010-02-04 14:16:14 +010013861 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
13862 add_verb(spec, alc269vb_init_verbs);
13863 real_capsrc_nids = alc269vb_capsrc_nids[0];
Kailang Yang6227cdc2010-02-25 08:36:52 +010013864 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010013865 } else {
13866 add_verb(spec, alc269_init_verbs);
13867 real_capsrc_nids = alc269_capsrc_nids[0];
Kailang Yang6227cdc2010-02-25 08:36:52 +010013868 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010013869 }
13870
Kailang Yangf6a92242007-12-13 16:52:54 +010013871 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013872 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013873 /* set default input source */
Kailang Yang84898e82010-02-04 14:16:14 +010013874 snd_hda_codec_write_cache(codec, real_capsrc_nids,
Takashi Iwaie01bf502008-08-21 16:25:07 +020013875 0, AC_VERB_SET_CONNECT_SEL,
13876 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013877
13878 err = alc_auto_add_mic_boost(codec);
13879 if (err < 0)
13880 return err;
13881
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013882 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013883 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013884
Kailang Yangf6a92242007-12-13 16:52:54 +010013885 return 1;
13886}
13887
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013888#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13889#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013890#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13891
13892
13893/* init callback for auto-configuration model -- overriding the default init */
13894static void alc269_auto_init(struct hda_codec *codec)
13895{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013896 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013897 alc269_auto_init_multi_out(codec);
13898 alc269_auto_init_hp_out(codec);
13899 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013900 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013901 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013902}
13903
13904/*
13905 * configuration and preset
13906 */
13907static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013908 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013909 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010013910 [ALC269_AMIC] = "laptop-amic",
13911 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013912 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013913 [ALC269_LIFEBOOK] = "lifebook",
13914 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013915};
13916
13917static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013918 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013919 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010013920 ALC269_AMIC),
13921 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
13922 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
13923 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
13924 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
13925 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
13926 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
13927 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
13928 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
13929 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
13930 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
13931 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
13932 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
13933 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
13934 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
13935 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
13936 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
13937 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
13938 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
13939 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
13940 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
13941 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
13942 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
13943 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
13944 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
13945 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
13946 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
13947 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
13948 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
13949 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
13950 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
13951 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
13952 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
13953 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
13954 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
13955 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
13956 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020013957 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010013958 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020013959 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010013960 ALC269_DMIC),
13961 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
13962 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010013963 SND_PCI_QUIRK(0x104d, 0x9071, "SONY XTB", ALC269_DMIC),
Tony Vroon64154832008-11-06 15:08:49 +000013964 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010013965 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
13966 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
13967 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
13968 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
13969 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
13970 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010013971 {}
13972};
13973
13974static struct alc_config_preset alc269_presets[] = {
13975 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013976 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013977 .init_verbs = { alc269_init_verbs },
13978 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13979 .dac_nids = alc269_dac_nids,
13980 .hp_nid = 0x03,
13981 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13982 .channel_mode = alc269_modes,
13983 .input_mux = &alc269_capture_source,
13984 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013985 [ALC269_QUANTA_FL1] = {
13986 .mixers = { alc269_quanta_fl1_mixer },
13987 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13988 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13989 .dac_nids = alc269_dac_nids,
13990 .hp_nid = 0x03,
13991 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13992 .channel_mode = alc269_modes,
13993 .input_mux = &alc269_capture_source,
13994 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013995 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013996 .init_hook = alc269_quanta_fl1_init_hook,
13997 },
Kailang Yang84898e82010-02-04 14:16:14 +010013998 [ALC269_AMIC] = {
13999 .mixers = { alc269_laptop_mixer },
14000 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014001 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014002 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014003 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14004 .dac_nids = alc269_dac_nids,
14005 .hp_nid = 0x03,
14006 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14007 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014008 .unsol_event = alc269_laptop_unsol_event,
14009 .setup = alc269_laptop_amic_setup,
14010 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014011 },
Kailang Yang84898e82010-02-04 14:16:14 +010014012 [ALC269_DMIC] = {
14013 .mixers = { alc269_laptop_mixer },
14014 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014015 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014016 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014017 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14018 .dac_nids = alc269_dac_nids,
14019 .hp_nid = 0x03,
14020 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14021 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014022 .unsol_event = alc269_laptop_unsol_event,
14023 .setup = alc269_laptop_dmic_setup,
14024 .init_hook = alc269_laptop_inithook,
14025 },
14026 [ALC269VB_AMIC] = {
14027 .mixers = { alc269vb_laptop_mixer },
14028 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14029 .init_verbs = { alc269vb_init_verbs,
14030 alc269vb_laptop_amic_init_verbs },
14031 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14032 .dac_nids = alc269_dac_nids,
14033 .hp_nid = 0x03,
14034 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14035 .channel_mode = alc269_modes,
14036 .unsol_event = alc269_laptop_unsol_event,
14037 .setup = alc269_laptop_amic_setup,
14038 .init_hook = alc269_laptop_inithook,
14039 },
14040 [ALC269VB_DMIC] = {
14041 .mixers = { alc269vb_laptop_mixer },
14042 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14043 .init_verbs = { alc269vb_init_verbs,
14044 alc269vb_laptop_dmic_init_verbs },
14045 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14046 .dac_nids = alc269_dac_nids,
14047 .hp_nid = 0x03,
14048 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14049 .channel_mode = alc269_modes,
14050 .unsol_event = alc269_laptop_unsol_event,
14051 .setup = alc269vb_laptop_dmic_setup,
14052 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014053 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014054 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014055 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014056 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014057 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014058 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014059 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14060 .dac_nids = alc269_dac_nids,
14061 .hp_nid = 0x03,
14062 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14063 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014064 .unsol_event = alc269_laptop_unsol_event,
14065 .setup = alc269_laptop_dmic_setup,
14066 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014067 },
Tony Vroon64154832008-11-06 15:08:49 +000014068 [ALC269_LIFEBOOK] = {
14069 .mixers = { alc269_lifebook_mixer },
14070 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14071 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14072 .dac_nids = alc269_dac_nids,
14073 .hp_nid = 0x03,
14074 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14075 .channel_mode = alc269_modes,
14076 .input_mux = &alc269_capture_source,
14077 .unsol_event = alc269_lifebook_unsol_event,
14078 .init_hook = alc269_lifebook_init_hook,
14079 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014080};
14081
14082static int patch_alc269(struct hda_codec *codec)
14083{
14084 struct alc_spec *spec;
14085 int board_config;
14086 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014087 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014088
14089 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14090 if (spec == NULL)
14091 return -ENOMEM;
14092
14093 codec->spec = spec;
14094
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014095 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14096
Kailang Yang274693f2009-12-03 10:07:50 +010014097 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
14098 kfree(codec->chip_name);
14099 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014100 if (!codec->chip_name) {
14101 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010014102 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014103 }
Kailang Yang84898e82010-02-04 14:16:14 +010014104 is_alc269vb = 1;
Kailang Yang274693f2009-12-03 10:07:50 +010014105 }
14106
Kailang Yangf6a92242007-12-13 16:52:54 +010014107 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14108 alc269_models,
14109 alc269_cfg_tbl);
14110
14111 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014112 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14113 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014114 board_config = ALC269_AUTO;
14115 }
14116
14117 if (board_config == ALC269_AUTO) {
14118 /* automatic parse from the BIOS config */
14119 err = alc269_parse_auto_config(codec);
14120 if (err < 0) {
14121 alc_free(codec);
14122 return err;
14123 } else if (!err) {
14124 printk(KERN_INFO
14125 "hda_codec: Cannot set up configuration "
14126 "from BIOS. Using base mode...\n");
14127 board_config = ALC269_BASIC;
14128 }
14129 }
14130
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014131 err = snd_hda_attach_beep_device(codec, 0x1);
14132 if (err < 0) {
14133 alc_free(codec);
14134 return err;
14135 }
14136
Kailang Yangf6a92242007-12-13 16:52:54 +010014137 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014138 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014139
Kailang Yang84898e82010-02-04 14:16:14 +010014140 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014141 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14142 * fix the sample rate of analog I/O to 44.1kHz
14143 */
14144 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14145 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14146 } else {
14147 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14148 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14149 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014150 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14151 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14152
Kailang Yang84898e82010-02-04 14:16:14 +010014153 if (!is_alc269vb) {
14154 spec->adc_nids = alc269_adc_nids;
14155 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14156 spec->capsrc_nids = alc269_capsrc_nids;
14157 } else {
14158 spec->adc_nids = alc269vb_adc_nids;
14159 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14160 spec->capsrc_nids = alc269vb_capsrc_nids;
14161 }
14162
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014163 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014164 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014165 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014166
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014167 spec->vmaster_nid = 0x02;
14168
Kailang Yangf6a92242007-12-13 16:52:54 +010014169 codec->patch_ops = alc_patch_ops;
14170 if (board_config == ALC269_AUTO)
14171 spec->init_hook = alc269_auto_init;
14172#ifdef CONFIG_SND_HDA_POWER_SAVE
14173 if (!spec->loopback.amplist)
14174 spec->loopback.amplist = alc269_loopbacks;
14175#endif
14176
14177 return 0;
14178}
14179
14180/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014181 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14182 */
14183
14184/*
14185 * set the path ways for 2 channel output
14186 * need to set the codec line out and mic 1 pin widgets to inputs
14187 */
14188static struct hda_verb alc861_threestack_ch2_init[] = {
14189 /* set pin widget 1Ah (line in) for input */
14190 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014191 /* set pin widget 18h (mic1/2) for input, for mic also enable
14192 * the vref
14193 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014194 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14195
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014196 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14197#if 0
14198 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14199 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14200#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014201 { } /* end */
14202};
14203/*
14204 * 6ch mode
14205 * need to set the codec line out and mic 1 pin widgets to outputs
14206 */
14207static struct hda_verb alc861_threestack_ch6_init[] = {
14208 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14209 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14210 /* set pin widget 18h (mic1) for output (CLFE)*/
14211 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14212
14213 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014214 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014215
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014216 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14217#if 0
14218 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14219 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14220#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014221 { } /* end */
14222};
14223
14224static struct hda_channel_mode alc861_threestack_modes[2] = {
14225 { 2, alc861_threestack_ch2_init },
14226 { 6, alc861_threestack_ch6_init },
14227};
Takashi Iwai22309c32006-08-09 16:57:28 +020014228/* Set mic1 as input and unmute the mixer */
14229static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14230 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14231 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14232 { } /* end */
14233};
14234/* Set mic1 as output and mute mixer */
14235static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14236 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14237 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14238 { } /* end */
14239};
14240
14241static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14242 { 2, alc861_uniwill_m31_ch2_init },
14243 { 4, alc861_uniwill_m31_ch4_init },
14244};
Kailang Yangdf694da2005-12-05 19:42:22 +010014245
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014246/* Set mic1 and line-in as input and unmute the mixer */
14247static struct hda_verb alc861_asus_ch2_init[] = {
14248 /* set pin widget 1Ah (line in) for input */
14249 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014250 /* set pin widget 18h (mic1/2) for input, for mic also enable
14251 * the vref
14252 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014253 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14254
14255 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14256#if 0
14257 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14258 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14259#endif
14260 { } /* end */
14261};
14262/* Set mic1 nad line-in as output and mute mixer */
14263static struct hda_verb alc861_asus_ch6_init[] = {
14264 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14265 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14266 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14267 /* set pin widget 18h (mic1) for output (CLFE)*/
14268 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14269 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14270 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14271 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14272
14273 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14274#if 0
14275 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14276 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14277#endif
14278 { } /* end */
14279};
14280
14281static struct hda_channel_mode alc861_asus_modes[2] = {
14282 { 2, alc861_asus_ch2_init },
14283 { 6, alc861_asus_ch6_init },
14284};
14285
Kailang Yangdf694da2005-12-05 19:42:22 +010014286/* patch-ALC861 */
14287
14288static struct snd_kcontrol_new alc861_base_mixer[] = {
14289 /* output mixer control */
14290 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14291 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14292 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14293 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14294 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14295
14296 /*Input mixer control */
14297 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14298 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14299 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14300 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14301 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14302 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14303 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14304 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14305 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14306 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014307
Kailang Yangdf694da2005-12-05 19:42:22 +010014308 { } /* end */
14309};
14310
14311static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14312 /* output mixer control */
14313 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14314 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14315 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14316 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14317 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14318
14319 /* Input mixer control */
14320 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14321 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14322 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14323 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14324 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14325 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14327 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14328 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14329 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014330
Kailang Yangdf694da2005-12-05 19:42:22 +010014331 {
14332 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14333 .name = "Channel Mode",
14334 .info = alc_ch_mode_info,
14335 .get = alc_ch_mode_get,
14336 .put = alc_ch_mode_put,
14337 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14338 },
14339 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014340};
14341
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014342static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014343 /* output mixer control */
14344 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14345 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14346 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014347
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014348 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014349};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014350
Takashi Iwai22309c32006-08-09 16:57:28 +020014351static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14352 /* output mixer control */
14353 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14354 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14355 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14356 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14357 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14358
14359 /* Input mixer control */
14360 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14361 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14362 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14363 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14364 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14365 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14367 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14368 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14369 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014370
Takashi Iwai22309c32006-08-09 16:57:28 +020014371 {
14372 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14373 .name = "Channel Mode",
14374 .info = alc_ch_mode_info,
14375 .get = alc_ch_mode_get,
14376 .put = alc_ch_mode_put,
14377 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14378 },
14379 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014380};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014381
14382static struct snd_kcontrol_new alc861_asus_mixer[] = {
14383 /* output mixer control */
14384 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14385 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14386 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14387 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14388 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14389
14390 /* Input mixer control */
14391 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14392 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14393 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14394 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14395 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14396 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14397 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14398 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14399 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014400 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14401
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014402 {
14403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14404 .name = "Channel Mode",
14405 .info = alc_ch_mode_info,
14406 .get = alc_ch_mode_get,
14407 .put = alc_ch_mode_put,
14408 .private_value = ARRAY_SIZE(alc861_asus_modes),
14409 },
14410 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014411};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014412
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014413/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014414static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014415 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14416 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014417 { }
14418};
14419
Kailang Yangdf694da2005-12-05 19:42:22 +010014420/*
14421 * generic initialization of ADC, input mixers and output mixers
14422 */
14423static struct hda_verb alc861_base_init_verbs[] = {
14424 /*
14425 * Unmute ADC0 and set the default input to mic-in
14426 */
14427 /* port-A for surround (rear panel) */
14428 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14429 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14430 /* port-B for mic-in (rear panel) with vref */
14431 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14432 /* port-C for line-in (rear panel) */
14433 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14434 /* port-D for Front */
14435 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14436 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14437 /* port-E for HP out (front panel) */
14438 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14439 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014440 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014441 /* port-F for mic-in (front panel) with vref */
14442 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14443 /* port-G for CLFE (rear panel) */
14444 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14445 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14446 /* port-H for side (rear panel) */
14447 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14448 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14449 /* CD-in */
14450 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14451 /* route front mic to ADC1*/
14452 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14453 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014454
Kailang Yangdf694da2005-12-05 19:42:22 +010014455 /* Unmute DAC0~3 & spdif out*/
14456 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14457 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14458 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14459 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014461
Kailang Yangdf694da2005-12-05 19:42:22 +010014462 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14463 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14464 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14465 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14466 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014467
Kailang Yangdf694da2005-12-05 19:42:22 +010014468 /* Unmute Stereo Mixer 15 */
14469 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014473
14474 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14475 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14476 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14477 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14478 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14479 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14480 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14481 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014482 /* hp used DAC 3 (Front) */
14483 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014484 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14485
14486 { }
14487};
14488
14489static struct hda_verb alc861_threestack_init_verbs[] = {
14490 /*
14491 * Unmute ADC0 and set the default input to mic-in
14492 */
14493 /* port-A for surround (rear panel) */
14494 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14495 /* port-B for mic-in (rear panel) with vref */
14496 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14497 /* port-C for line-in (rear panel) */
14498 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14499 /* port-D for Front */
14500 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14501 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14502 /* port-E for HP out (front panel) */
14503 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14504 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014505 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014506 /* port-F for mic-in (front panel) with vref */
14507 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14508 /* port-G for CLFE (rear panel) */
14509 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14510 /* port-H for side (rear panel) */
14511 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14512 /* CD-in */
14513 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14514 /* route front mic to ADC1*/
14515 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14516 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14517 /* Unmute DAC0~3 & spdif out*/
14518 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14519 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14520 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14521 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014523
Kailang Yangdf694da2005-12-05 19:42:22 +010014524 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14525 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14526 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14527 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14528 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014529
Kailang Yangdf694da2005-12-05 19:42:22 +010014530 /* Unmute Stereo Mixer 15 */
14531 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14532 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14533 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014534 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014535
14536 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14537 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14538 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14539 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14540 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14541 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14542 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14543 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014544 /* hp used DAC 3 (Front) */
14545 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014546 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14547 { }
14548};
Takashi Iwai22309c32006-08-09 16:57:28 +020014549
14550static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14551 /*
14552 * Unmute ADC0 and set the default input to mic-in
14553 */
14554 /* port-A for surround (rear panel) */
14555 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14556 /* port-B for mic-in (rear panel) with vref */
14557 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14558 /* port-C for line-in (rear panel) */
14559 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14560 /* port-D for Front */
14561 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14562 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14563 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014564 /* this has to be set to VREF80 */
14565 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014566 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014567 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014568 /* port-F for mic-in (front panel) with vref */
14569 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14570 /* port-G for CLFE (rear panel) */
14571 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14572 /* port-H for side (rear panel) */
14573 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14574 /* CD-in */
14575 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14576 /* route front mic to ADC1*/
14577 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14578 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14579 /* Unmute DAC0~3 & spdif out*/
14580 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14581 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14582 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14583 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14584 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014585
Takashi Iwai22309c32006-08-09 16:57:28 +020014586 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14587 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14588 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14589 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14590 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014591
Takashi Iwai22309c32006-08-09 16:57:28 +020014592 /* Unmute Stereo Mixer 15 */
14593 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14594 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14595 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014596 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014597
14598 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14599 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14600 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14601 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14602 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14603 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14604 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14605 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014606 /* hp used DAC 3 (Front) */
14607 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014608 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14609 { }
14610};
14611
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014612static struct hda_verb alc861_asus_init_verbs[] = {
14613 /*
14614 * Unmute ADC0 and set the default input to mic-in
14615 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014616 /* port-A for surround (rear panel)
14617 * according to codec#0 this is the HP jack
14618 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014619 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14620 /* route front PCM to HP */
14621 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14622 /* port-B for mic-in (rear panel) with vref */
14623 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14624 /* port-C for line-in (rear panel) */
14625 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14626 /* port-D for Front */
14627 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14628 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14629 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014630 /* this has to be set to VREF80 */
14631 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014632 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014633 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014634 /* port-F for mic-in (front panel) with vref */
14635 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14636 /* port-G for CLFE (rear panel) */
14637 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14638 /* port-H for side (rear panel) */
14639 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14640 /* CD-in */
14641 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14642 /* route front mic to ADC1*/
14643 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14644 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14645 /* Unmute DAC0~3 & spdif out*/
14646 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14647 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14648 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14649 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14651 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14652 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14653 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14654 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14655 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014656
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014657 /* Unmute Stereo Mixer 15 */
14658 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14659 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014662
14663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14664 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14665 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14666 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14667 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14668 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14669 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14670 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014671 /* hp used DAC 3 (Front) */
14672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014673 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14674 { }
14675};
14676
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014677/* additional init verbs for ASUS laptops */
14678static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14679 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14680 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14681 { }
14682};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014683
Kailang Yangdf694da2005-12-05 19:42:22 +010014684/*
14685 * generic initialization of ADC, input mixers and output mixers
14686 */
14687static struct hda_verb alc861_auto_init_verbs[] = {
14688 /*
14689 * Unmute ADC0 and set the default input to mic-in
14690 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014691 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014692 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014693
Kailang Yangdf694da2005-12-05 19:42:22 +010014694 /* Unmute DAC0~3 & spdif out*/
14695 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14696 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14697 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14698 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014700
Kailang Yangdf694da2005-12-05 19:42:22 +010014701 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14702 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14703 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14704 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14705 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014706
Kailang Yangdf694da2005-12-05 19:42:22 +010014707 /* Unmute Stereo Mixer 15 */
14708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14712
Takashi Iwai1c209302009-07-22 15:17:45 +020014713 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14714 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14715 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14716 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14717 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14718 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14719 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14720 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014721
14722 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014724 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014726 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14727 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014728 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14729 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014730
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014731 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014732
14733 { }
14734};
14735
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014736static struct hda_verb alc861_toshiba_init_verbs[] = {
14737 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014738
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014739 { }
14740};
14741
14742/* toggle speaker-output according to the hp-jack state */
14743static void alc861_toshiba_automute(struct hda_codec *codec)
14744{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014745 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014746
Takashi Iwai47fd8302007-08-10 17:11:07 +020014747 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14748 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14749 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14750 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014751}
14752
14753static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14754 unsigned int res)
14755{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014756 if ((res >> 26) == ALC880_HP_EVENT)
14757 alc861_toshiba_automute(codec);
14758}
14759
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014760/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014761#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14762#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14763#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14764#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14765
14766
14767#define ALC861_DIGOUT_NID 0x07
14768
14769static struct hda_channel_mode alc861_8ch_modes[1] = {
14770 { 8, NULL }
14771};
14772
14773static hda_nid_t alc861_dac_nids[4] = {
14774 /* front, surround, clfe, side */
14775 0x03, 0x06, 0x05, 0x04
14776};
14777
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014778static hda_nid_t alc660_dac_nids[3] = {
14779 /* front, clfe, surround */
14780 0x03, 0x05, 0x06
14781};
14782
Kailang Yangdf694da2005-12-05 19:42:22 +010014783static hda_nid_t alc861_adc_nids[1] = {
14784 /* ADC0-2 */
14785 0x08,
14786};
14787
14788static struct hda_input_mux alc861_capture_source = {
14789 .num_items = 5,
14790 .items = {
14791 { "Mic", 0x0 },
14792 { "Front Mic", 0x3 },
14793 { "Line", 0x1 },
14794 { "CD", 0x4 },
14795 { "Mixer", 0x5 },
14796 },
14797};
14798
Takashi Iwai1c209302009-07-22 15:17:45 +020014799static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14800{
14801 struct alc_spec *spec = codec->spec;
14802 hda_nid_t mix, srcs[5];
14803 int i, j, num;
14804
14805 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14806 return 0;
14807 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14808 if (num < 0)
14809 return 0;
14810 for (i = 0; i < num; i++) {
14811 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014812 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014813 if (type != AC_WID_AUD_OUT)
14814 continue;
14815 for (j = 0; j < spec->multiout.num_dacs; j++)
14816 if (spec->multiout.dac_nids[j] == srcs[i])
14817 break;
14818 if (j >= spec->multiout.num_dacs)
14819 return srcs[i];
14820 }
14821 return 0;
14822}
14823
Kailang Yangdf694da2005-12-05 19:42:22 +010014824/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014825static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014826 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014827{
Takashi Iwai1c209302009-07-22 15:17:45 +020014828 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014829 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014830 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014831
14832 spec->multiout.dac_nids = spec->private_dac_nids;
14833 for (i = 0; i < cfg->line_outs; i++) {
14834 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014835 dac = alc861_look_for_dac(codec, nid);
14836 if (!dac)
14837 continue;
14838 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014839 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014840 return 0;
14841}
14842
Takashi Iwai1c209302009-07-22 15:17:45 +020014843static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14844 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014845{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014846 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014847 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14848}
14849
14850/* add playback controls from the parsed DAC table */
14851static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14852 const struct auto_pin_cfg *cfg)
14853{
14854 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014855 static const char *chname[4] = {
14856 "Front", "Surround", NULL /*CLFE*/, "Side"
14857 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014858 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014859 int i, err;
14860
14861 if (cfg->line_outs == 1) {
14862 const char *pfx = NULL;
14863 if (!cfg->hp_outs)
14864 pfx = "Master";
14865 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14866 pfx = "Speaker";
14867 if (pfx) {
14868 nid = spec->multiout.dac_nids[0];
14869 return alc861_create_out_sw(codec, pfx, nid, 3);
14870 }
14871 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014872
14873 for (i = 0; i < cfg->line_outs; i++) {
14874 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014875 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014876 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014877 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014878 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014879 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014880 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014881 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014882 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014883 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014884 return err;
14885 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014886 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014887 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014888 return err;
14889 }
14890 }
14891 return 0;
14892}
14893
Takashi Iwai1c209302009-07-22 15:17:45 +020014894static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014895{
Takashi Iwai1c209302009-07-22 15:17:45 +020014896 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014897 int err;
14898 hda_nid_t nid;
14899
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014900 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014901 return 0;
14902
14903 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014904 nid = alc861_look_for_dac(codec, pin);
14905 if (nid) {
14906 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14907 if (err < 0)
14908 return err;
14909 spec->multiout.hp_nid = nid;
14910 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014911 }
14912 return 0;
14913}
14914
14915/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014916static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014917 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014918{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014919 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014920}
14921
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014922static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14923 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014924 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014925{
Takashi Iwai1c209302009-07-22 15:17:45 +020014926 hda_nid_t mix, srcs[5];
14927 int i, num;
14928
Jacek Luczak564c5be2008-05-03 18:41:23 +020014929 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14930 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014931 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014932 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014933 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14934 return;
14935 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14936 if (num < 0)
14937 return;
14938 for (i = 0; i < num; i++) {
14939 unsigned int mute;
14940 if (srcs[i] == dac || srcs[i] == 0x15)
14941 mute = AMP_IN_UNMUTE(i);
14942 else
14943 mute = AMP_IN_MUTE(i);
14944 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14945 mute);
14946 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014947}
14948
14949static void alc861_auto_init_multi_out(struct hda_codec *codec)
14950{
14951 struct alc_spec *spec = codec->spec;
14952 int i;
14953
14954 for (i = 0; i < spec->autocfg.line_outs; i++) {
14955 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014956 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014957 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014958 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014959 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014960 }
14961}
14962
14963static void alc861_auto_init_hp_out(struct hda_codec *codec)
14964{
14965 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014966
Takashi Iwai15870f02009-10-05 08:25:13 +020014967 if (spec->autocfg.hp_outs)
14968 alc861_auto_set_output_and_unmute(codec,
14969 spec->autocfg.hp_pins[0],
14970 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014971 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014972 if (spec->autocfg.speaker_outs)
14973 alc861_auto_set_output_and_unmute(codec,
14974 spec->autocfg.speaker_pins[0],
14975 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014976 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014977}
14978
14979static void alc861_auto_init_analog_input(struct hda_codec *codec)
14980{
14981 struct alc_spec *spec = codec->spec;
14982 int i;
14983
14984 for (i = 0; i < AUTO_PIN_LAST; i++) {
14985 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014986 if (nid >= 0x0c && nid <= 0x11)
14987 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014988 }
14989}
14990
14991/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014992/* return 1 if successful, 0 if the proper config is not found,
14993 * or a negative error code
14994 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014995static int alc861_parse_auto_config(struct hda_codec *codec)
14996{
14997 struct alc_spec *spec = codec->spec;
14998 int err;
14999 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15000
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015001 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15002 alc861_ignore);
15003 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015004 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015005 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015006 return 0; /* can't find valid BIOS pin config */
15007
Takashi Iwai1c209302009-07-22 15:17:45 +020015008 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015009 if (err < 0)
15010 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015011 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015012 if (err < 0)
15013 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015014 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015015 if (err < 0)
15016 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015017 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015018 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015019 return err;
15020
15021 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15022
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015023 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015024 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15025
Takashi Iwai603c4012008-07-30 15:01:44 +020015026 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015027 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015028
Takashi Iwaid88897e2008-10-31 15:01:37 +010015029 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015030
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015031 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015032 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015033
15034 spec->adc_nids = alc861_adc_nids;
15035 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015036 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015037
Kailang Yang6227cdc2010-02-25 08:36:52 +010015038 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015039
Kailang Yangdf694da2005-12-05 19:42:22 +010015040 return 1;
15041}
15042
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015043/* additional initialization for auto-configuration model */
15044static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015045{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015046 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015047 alc861_auto_init_multi_out(codec);
15048 alc861_auto_init_hp_out(codec);
15049 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015050 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015051 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015052}
15053
Takashi Iwaicb53c622007-08-10 17:21:45 +020015054#ifdef CONFIG_SND_HDA_POWER_SAVE
15055static struct hda_amp_list alc861_loopbacks[] = {
15056 { 0x15, HDA_INPUT, 0 },
15057 { 0x15, HDA_INPUT, 1 },
15058 { 0x15, HDA_INPUT, 2 },
15059 { 0x15, HDA_INPUT, 3 },
15060 { } /* end */
15061};
15062#endif
15063
Kailang Yangdf694da2005-12-05 19:42:22 +010015064
15065/*
15066 * configuration and preset
15067 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015068static const char *alc861_models[ALC861_MODEL_LAST] = {
15069 [ALC861_3ST] = "3stack",
15070 [ALC660_3ST] = "3stack-660",
15071 [ALC861_3ST_DIG] = "3stack-dig",
15072 [ALC861_6ST_DIG] = "6stack-dig",
15073 [ALC861_UNIWILL_M31] = "uniwill-m31",
15074 [ALC861_TOSHIBA] = "toshiba",
15075 [ALC861_ASUS] = "asus",
15076 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15077 [ALC861_AUTO] = "auto",
15078};
15079
15080static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015081 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015082 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15083 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15084 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015085 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015086 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015087 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015088 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15089 * Any other models that need this preset?
15090 */
15091 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015092 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15093 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015094 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15095 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15096 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15097 /* FIXME: the below seems conflict */
15098 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15099 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15100 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015101 {}
15102};
15103
15104static struct alc_config_preset alc861_presets[] = {
15105 [ALC861_3ST] = {
15106 .mixers = { alc861_3ST_mixer },
15107 .init_verbs = { alc861_threestack_init_verbs },
15108 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15109 .dac_nids = alc861_dac_nids,
15110 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15111 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015112 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015113 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15114 .adc_nids = alc861_adc_nids,
15115 .input_mux = &alc861_capture_source,
15116 },
15117 [ALC861_3ST_DIG] = {
15118 .mixers = { alc861_base_mixer },
15119 .init_verbs = { alc861_threestack_init_verbs },
15120 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15121 .dac_nids = alc861_dac_nids,
15122 .dig_out_nid = ALC861_DIGOUT_NID,
15123 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15124 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015125 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015126 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15127 .adc_nids = alc861_adc_nids,
15128 .input_mux = &alc861_capture_source,
15129 },
15130 [ALC861_6ST_DIG] = {
15131 .mixers = { alc861_base_mixer },
15132 .init_verbs = { alc861_base_init_verbs },
15133 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15134 .dac_nids = alc861_dac_nids,
15135 .dig_out_nid = ALC861_DIGOUT_NID,
15136 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15137 .channel_mode = alc861_8ch_modes,
15138 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15139 .adc_nids = alc861_adc_nids,
15140 .input_mux = &alc861_capture_source,
15141 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015142 [ALC660_3ST] = {
15143 .mixers = { alc861_3ST_mixer },
15144 .init_verbs = { alc861_threestack_init_verbs },
15145 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15146 .dac_nids = alc660_dac_nids,
15147 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15148 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015149 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015150 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15151 .adc_nids = alc861_adc_nids,
15152 .input_mux = &alc861_capture_source,
15153 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015154 [ALC861_UNIWILL_M31] = {
15155 .mixers = { alc861_uniwill_m31_mixer },
15156 .init_verbs = { alc861_uniwill_m31_init_verbs },
15157 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15158 .dac_nids = alc861_dac_nids,
15159 .dig_out_nid = ALC861_DIGOUT_NID,
15160 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15161 .channel_mode = alc861_uniwill_m31_modes,
15162 .need_dac_fix = 1,
15163 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15164 .adc_nids = alc861_adc_nids,
15165 .input_mux = &alc861_capture_source,
15166 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015167 [ALC861_TOSHIBA] = {
15168 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015169 .init_verbs = { alc861_base_init_verbs,
15170 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015171 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15172 .dac_nids = alc861_dac_nids,
15173 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15174 .channel_mode = alc883_3ST_2ch_modes,
15175 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15176 .adc_nids = alc861_adc_nids,
15177 .input_mux = &alc861_capture_source,
15178 .unsol_event = alc861_toshiba_unsol_event,
15179 .init_hook = alc861_toshiba_automute,
15180 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015181 [ALC861_ASUS] = {
15182 .mixers = { alc861_asus_mixer },
15183 .init_verbs = { alc861_asus_init_verbs },
15184 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15185 .dac_nids = alc861_dac_nids,
15186 .dig_out_nid = ALC861_DIGOUT_NID,
15187 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15188 .channel_mode = alc861_asus_modes,
15189 .need_dac_fix = 1,
15190 .hp_nid = 0x06,
15191 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15192 .adc_nids = alc861_adc_nids,
15193 .input_mux = &alc861_capture_source,
15194 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015195 [ALC861_ASUS_LAPTOP] = {
15196 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15197 .init_verbs = { alc861_asus_init_verbs,
15198 alc861_asus_laptop_init_verbs },
15199 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15200 .dac_nids = alc861_dac_nids,
15201 .dig_out_nid = ALC861_DIGOUT_NID,
15202 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15203 .channel_mode = alc883_3ST_2ch_modes,
15204 .need_dac_fix = 1,
15205 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15206 .adc_nids = alc861_adc_nids,
15207 .input_mux = &alc861_capture_source,
15208 },
15209};
Kailang Yangdf694da2005-12-05 19:42:22 +010015210
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015211/* Pin config fixes */
15212enum {
15213 PINFIX_FSC_AMILO_PI1505,
15214};
15215
15216static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15217 { 0x0b, 0x0221101f }, /* HP */
15218 { 0x0f, 0x90170310 }, /* speaker */
15219 { }
15220};
15221
15222static const struct alc_fixup alc861_fixups[] = {
15223 [PINFIX_FSC_AMILO_PI1505] = {
15224 .pins = alc861_fsc_amilo_pi1505_pinfix
15225 },
15226};
15227
15228static struct snd_pci_quirk alc861_fixup_tbl[] = {
15229 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15230 {}
15231};
Kailang Yangdf694da2005-12-05 19:42:22 +010015232
15233static int patch_alc861(struct hda_codec *codec)
15234{
15235 struct alc_spec *spec;
15236 int board_config;
15237 int err;
15238
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015239 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015240 if (spec == NULL)
15241 return -ENOMEM;
15242
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015243 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015244
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015245 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15246 alc861_models,
15247 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015248
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015249 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015250 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15251 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015252 board_config = ALC861_AUTO;
15253 }
15254
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015255 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
15256
Kailang Yangdf694da2005-12-05 19:42:22 +010015257 if (board_config == ALC861_AUTO) {
15258 /* automatic parse from the BIOS config */
15259 err = alc861_parse_auto_config(codec);
15260 if (err < 0) {
15261 alc_free(codec);
15262 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015263 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015264 printk(KERN_INFO
15265 "hda_codec: Cannot set up configuration "
15266 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015267 board_config = ALC861_3ST_DIG;
15268 }
15269 }
15270
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015271 err = snd_hda_attach_beep_device(codec, 0x23);
15272 if (err < 0) {
15273 alc_free(codec);
15274 return err;
15275 }
15276
Kailang Yangdf694da2005-12-05 19:42:22 +010015277 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015278 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015279
Kailang Yangdf694da2005-12-05 19:42:22 +010015280 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15281 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15282
Kailang Yangdf694da2005-12-05 19:42:22 +010015283 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15284 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15285
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015286 if (!spec->cap_mixer)
15287 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015288 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15289
Takashi Iwai2134ea42008-01-10 16:53:55 +010015290 spec->vmaster_nid = 0x03;
15291
Kailang Yangdf694da2005-12-05 19:42:22 +010015292 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015293 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015294 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015295#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015296 spec->power_hook = alc_power_eapd;
15297#endif
15298 }
15299#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015300 if (!spec->loopback.amplist)
15301 spec->loopback.amplist = alc861_loopbacks;
15302#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015303
Kailang Yangdf694da2005-12-05 19:42:22 +010015304 return 0;
15305}
15306
15307/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015308 * ALC861-VD support
15309 *
15310 * Based on ALC882
15311 *
15312 * In addition, an independent DAC
15313 */
15314#define ALC861VD_DIGOUT_NID 0x06
15315
15316static hda_nid_t alc861vd_dac_nids[4] = {
15317 /* front, surr, clfe, side surr */
15318 0x02, 0x03, 0x04, 0x05
15319};
15320
15321/* dac_nids for ALC660vd are in a different order - according to
15322 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015323 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015324 * of ALC660vd codecs, but for now there is only 3stack mixer
15325 * - and it is the same as in 861vd.
15326 * adc_nids in ALC660vd are (is) the same as in 861vd
15327 */
15328static hda_nid_t alc660vd_dac_nids[3] = {
15329 /* front, rear, clfe, rear_surr */
15330 0x02, 0x04, 0x03
15331};
15332
15333static hda_nid_t alc861vd_adc_nids[1] = {
15334 /* ADC0 */
15335 0x09,
15336};
15337
Takashi Iwaie1406342008-02-11 18:32:32 +010015338static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15339
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015340/* input MUX */
15341/* FIXME: should be a matrix-type input source selection */
15342static struct hda_input_mux alc861vd_capture_source = {
15343 .num_items = 4,
15344 .items = {
15345 { "Mic", 0x0 },
15346 { "Front Mic", 0x1 },
15347 { "Line", 0x2 },
15348 { "CD", 0x4 },
15349 },
15350};
15351
Kailang Yang272a5272007-05-14 11:00:38 +020015352static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015353 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015354 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015355 { "Ext Mic", 0x0 },
15356 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015357 },
15358};
15359
Kailang Yangd1a991a2007-08-15 16:21:59 +020015360static struct hda_input_mux alc861vd_hp_capture_source = {
15361 .num_items = 2,
15362 .items = {
15363 { "Front Mic", 0x0 },
15364 { "ATAPI Mic", 0x1 },
15365 },
15366};
15367
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015368/*
15369 * 2ch mode
15370 */
15371static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15372 { 2, NULL }
15373};
15374
15375/*
15376 * 6ch mode
15377 */
15378static struct hda_verb alc861vd_6stack_ch6_init[] = {
15379 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15380 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15381 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15382 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15383 { } /* end */
15384};
15385
15386/*
15387 * 8ch mode
15388 */
15389static struct hda_verb alc861vd_6stack_ch8_init[] = {
15390 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15391 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15392 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15393 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15394 { } /* end */
15395};
15396
15397static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15398 { 6, alc861vd_6stack_ch6_init },
15399 { 8, alc861vd_6stack_ch8_init },
15400};
15401
15402static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15403 {
15404 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15405 .name = "Channel Mode",
15406 .info = alc_ch_mode_info,
15407 .get = alc_ch_mode_get,
15408 .put = alc_ch_mode_put,
15409 },
15410 { } /* end */
15411};
15412
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015413/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15414 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15415 */
15416static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15417 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15418 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15419
15420 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15421 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15422
15423 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15424 HDA_OUTPUT),
15425 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15426 HDA_OUTPUT),
15427 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15428 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15429
15430 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15431 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15432
15433 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15434
15435 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15436 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15437 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15438
15439 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15440 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15441 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15442
15443 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15444 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15445
15446 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15447 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15448
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015449 { } /* end */
15450};
15451
15452static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15453 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15454 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15455
15456 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15457
15458 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15460 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15461
15462 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15463 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15464 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15465
15466 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15467 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15468
15469 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15470 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15471
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015472 { } /* end */
15473};
15474
Kailang Yangbdd148a2007-05-08 15:19:08 +020015475static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15476 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15477 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15478 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15479
15480 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15481
15482 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15484 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15485
15486 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15487 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15488 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15489
15490 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15491 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15492
15493 { } /* end */
15494};
15495
Tobin Davisb419f342008-03-07 11:57:51 +010015496/* Pin assignment: Speaker=0x14, HP = 0x15,
15497 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015498 */
15499static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015500 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15501 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015502 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15503 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015504 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15505 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15506 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15507 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15508 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15509 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015510 { } /* end */
15511};
15512
Kailang Yangd1a991a2007-08-15 16:21:59 +020015513/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15514 * Front Mic=0x18, ATAPI Mic = 0x19,
15515 */
15516static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15517 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15518 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15520 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15521 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15522 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15523 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15524 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015525
Kailang Yangd1a991a2007-08-15 16:21:59 +020015526 { } /* end */
15527};
15528
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015529/*
15530 * generic initialization of ADC, input mixers and output mixers
15531 */
15532static struct hda_verb alc861vd_volume_init_verbs[] = {
15533 /*
15534 * Unmute ADC0 and set the default input to mic-in
15535 */
15536 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15538
15539 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15540 * the analog-loopback mixer widget
15541 */
15542 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015548
15549 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015550 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15551 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15552 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015553 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015554
15555 /*
15556 * Set up output mixers (0x02 - 0x05)
15557 */
15558 /* set vol=0 to output mixers */
15559 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15560 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15561 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15562 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15563
15564 /* set up input amps for analog loopback */
15565 /* Amp Indices: DAC = 0, mixer = 1 */
15566 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15567 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15568 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15569 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15570 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15571 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15572 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15573 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15574
15575 { }
15576};
15577
15578/*
15579 * 3-stack pin configuration:
15580 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15581 */
15582static struct hda_verb alc861vd_3stack_init_verbs[] = {
15583 /*
15584 * Set pin mode and muting
15585 */
15586 /* set front pin widgets 0x14 for output */
15587 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15588 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15589 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15590
15591 /* Mic (rear) pin: input vref at 80% */
15592 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15593 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15594 /* Front Mic pin: input vref at 80% */
15595 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15596 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15597 /* Line In pin: input */
15598 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15599 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15600 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15601 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15602 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15603 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15604 /* CD pin widget for input */
15605 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15606
15607 { }
15608};
15609
15610/*
15611 * 6-stack pin configuration:
15612 */
15613static struct hda_verb alc861vd_6stack_init_verbs[] = {
15614 /*
15615 * Set pin mode and muting
15616 */
15617 /* set front pin widgets 0x14 for output */
15618 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15619 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15620 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15621
15622 /* Rear Pin: output 1 (0x0d) */
15623 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15625 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15626 /* CLFE Pin: output 2 (0x0e) */
15627 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15628 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15629 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15630 /* Side Pin: output 3 (0x0f) */
15631 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15632 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15633 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15634
15635 /* Mic (rear) pin: input vref at 80% */
15636 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15637 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15638 /* Front Mic pin: input vref at 80% */
15639 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15640 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15641 /* Line In pin: input */
15642 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15643 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15644 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15645 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15646 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15647 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15648 /* CD pin widget for input */
15649 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15650
15651 { }
15652};
15653
Kailang Yangbdd148a2007-05-08 15:19:08 +020015654static struct hda_verb alc861vd_eapd_verbs[] = {
15655 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15656 { }
15657};
15658
Kailang Yangf9423e72008-05-27 12:32:25 +020015659static struct hda_verb alc660vd_eapd_verbs[] = {
15660 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15661 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15662 { }
15663};
15664
Kailang Yangbdd148a2007-05-08 15:19:08 +020015665static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15666 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15667 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15668 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15669 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015670 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015671 {}
15672};
15673
Kailang Yangbdd148a2007-05-08 15:19:08 +020015674static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15675{
15676 unsigned int present;
15677 unsigned char bits;
15678
Wu Fengguang864f92b2009-11-18 12:38:02 +080015679 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015680 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015681
Takashi Iwai47fd8302007-08-10 17:11:07 +020015682 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15683 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015684}
15685
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015686static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015687{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015688 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015689 spec->autocfg.hp_pins[0] = 0x1b;
15690 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015691}
15692
15693static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15694{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015695 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015696 alc861vd_lenovo_mic_automute(codec);
15697}
15698
15699static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15700 unsigned int res)
15701{
15702 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015703 case ALC880_MIC_EVENT:
15704 alc861vd_lenovo_mic_automute(codec);
15705 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015706 default:
15707 alc_automute_amp_unsol_event(codec, res);
15708 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015709 }
15710}
15711
Kailang Yang272a5272007-05-14 11:00:38 +020015712static struct hda_verb alc861vd_dallas_verbs[] = {
15713 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15714 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15715 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15716 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15717
15718 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15720 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15721 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15722 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15723 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15724 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15725 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015726
Kailang Yang272a5272007-05-14 11:00:38 +020015727 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15729 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15732 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15733 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15734 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15735
15736 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15737 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15738 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15739 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15740 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15741 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15742 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15743 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15744
15745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15747 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15749
15750 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015751 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015752 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15753
15754 { } /* end */
15755};
15756
15757/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015758static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015759{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015760 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015761
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015762 spec->autocfg.hp_pins[0] = 0x15;
15763 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015764}
15765
Takashi Iwaicb53c622007-08-10 17:21:45 +020015766#ifdef CONFIG_SND_HDA_POWER_SAVE
15767#define alc861vd_loopbacks alc880_loopbacks
15768#endif
15769
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015770/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015771#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15772#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15773#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15774#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15775
15776/*
15777 * configuration and preset
15778 */
15779static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15780 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015781 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015782 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015783 [ALC861VD_3ST] = "3stack",
15784 [ALC861VD_3ST_DIG] = "3stack-digout",
15785 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015786 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015787 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015788 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015789 [ALC861VD_AUTO] = "auto",
15790};
15791
15792static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015793 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15794 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015795 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015796 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015797 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015798 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015799 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015800 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015801 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015802 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015803 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015804 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015805 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015806 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015807 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015808 {}
15809};
15810
15811static struct alc_config_preset alc861vd_presets[] = {
15812 [ALC660VD_3ST] = {
15813 .mixers = { alc861vd_3st_mixer },
15814 .init_verbs = { alc861vd_volume_init_verbs,
15815 alc861vd_3stack_init_verbs },
15816 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15817 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015818 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15819 .channel_mode = alc861vd_3stack_2ch_modes,
15820 .input_mux = &alc861vd_capture_source,
15821 },
Mike Crash6963f842007-06-25 12:12:51 +020015822 [ALC660VD_3ST_DIG] = {
15823 .mixers = { alc861vd_3st_mixer },
15824 .init_verbs = { alc861vd_volume_init_verbs,
15825 alc861vd_3stack_init_verbs },
15826 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15827 .dac_nids = alc660vd_dac_nids,
15828 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015829 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15830 .channel_mode = alc861vd_3stack_2ch_modes,
15831 .input_mux = &alc861vd_capture_source,
15832 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015833 [ALC861VD_3ST] = {
15834 .mixers = { alc861vd_3st_mixer },
15835 .init_verbs = { alc861vd_volume_init_verbs,
15836 alc861vd_3stack_init_verbs },
15837 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15838 .dac_nids = alc861vd_dac_nids,
15839 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15840 .channel_mode = alc861vd_3stack_2ch_modes,
15841 .input_mux = &alc861vd_capture_source,
15842 },
15843 [ALC861VD_3ST_DIG] = {
15844 .mixers = { alc861vd_3st_mixer },
15845 .init_verbs = { alc861vd_volume_init_verbs,
15846 alc861vd_3stack_init_verbs },
15847 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15848 .dac_nids = alc861vd_dac_nids,
15849 .dig_out_nid = ALC861VD_DIGOUT_NID,
15850 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15851 .channel_mode = alc861vd_3stack_2ch_modes,
15852 .input_mux = &alc861vd_capture_source,
15853 },
15854 [ALC861VD_6ST_DIG] = {
15855 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15856 .init_verbs = { alc861vd_volume_init_verbs,
15857 alc861vd_6stack_init_verbs },
15858 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15859 .dac_nids = alc861vd_dac_nids,
15860 .dig_out_nid = ALC861VD_DIGOUT_NID,
15861 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15862 .channel_mode = alc861vd_6stack_modes,
15863 .input_mux = &alc861vd_capture_source,
15864 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015865 [ALC861VD_LENOVO] = {
15866 .mixers = { alc861vd_lenovo_mixer },
15867 .init_verbs = { alc861vd_volume_init_verbs,
15868 alc861vd_3stack_init_verbs,
15869 alc861vd_eapd_verbs,
15870 alc861vd_lenovo_unsol_verbs },
15871 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15872 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015873 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15874 .channel_mode = alc861vd_3stack_2ch_modes,
15875 .input_mux = &alc861vd_capture_source,
15876 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015877 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015878 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015879 },
Kailang Yang272a5272007-05-14 11:00:38 +020015880 [ALC861VD_DALLAS] = {
15881 .mixers = { alc861vd_dallas_mixer },
15882 .init_verbs = { alc861vd_dallas_verbs },
15883 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15884 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015885 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15886 .channel_mode = alc861vd_3stack_2ch_modes,
15887 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015888 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015889 .setup = alc861vd_dallas_setup,
15890 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015891 },
15892 [ALC861VD_HP] = {
15893 .mixers = { alc861vd_hp_mixer },
15894 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15895 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15896 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015897 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015898 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15899 .channel_mode = alc861vd_3stack_2ch_modes,
15900 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015901 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015902 .setup = alc861vd_dallas_setup,
15903 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015904 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015905 [ALC660VD_ASUS_V1S] = {
15906 .mixers = { alc861vd_lenovo_mixer },
15907 .init_verbs = { alc861vd_volume_init_verbs,
15908 alc861vd_3stack_init_verbs,
15909 alc861vd_eapd_verbs,
15910 alc861vd_lenovo_unsol_verbs },
15911 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15912 .dac_nids = alc660vd_dac_nids,
15913 .dig_out_nid = ALC861VD_DIGOUT_NID,
15914 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15915 .channel_mode = alc861vd_3stack_2ch_modes,
15916 .input_mux = &alc861vd_capture_source,
15917 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015918 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015919 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015920 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015921};
15922
15923/*
15924 * BIOS auto configuration
15925 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015926static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15927 const struct auto_pin_cfg *cfg)
15928{
Kailang Yang6227cdc2010-02-25 08:36:52 +010015929 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020015930}
15931
15932
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015933static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15934 hda_nid_t nid, int pin_type, int dac_idx)
15935{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015936 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015937}
15938
15939static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15940{
15941 struct alc_spec *spec = codec->spec;
15942 int i;
15943
15944 for (i = 0; i <= HDA_SIDE; i++) {
15945 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015946 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015947 if (nid)
15948 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015949 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015950 }
15951}
15952
15953
15954static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15955{
15956 struct alc_spec *spec = codec->spec;
15957 hda_nid_t pin;
15958
15959 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015960 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015961 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015962 pin = spec->autocfg.speaker_pins[0];
15963 if (pin)
15964 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015965}
15966
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015967#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15968
15969static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15970{
15971 struct alc_spec *spec = codec->spec;
15972 int i;
15973
15974 for (i = 0; i < AUTO_PIN_LAST; i++) {
15975 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015976 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015977 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015978 if (nid != ALC861VD_PIN_CD_NID &&
15979 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015980 snd_hda_codec_write(codec, nid, 0,
15981 AC_VERB_SET_AMP_GAIN_MUTE,
15982 AMP_OUT_MUTE);
15983 }
15984 }
15985}
15986
Takashi Iwaif511b012008-08-15 16:46:42 +020015987#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15988
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015989#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15990#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15991
15992/* add playback controls from the parsed DAC table */
15993/* Based on ALC880 version. But ALC861VD has separate,
15994 * different NIDs for mute/unmute switch and volume control */
15995static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15996 const struct auto_pin_cfg *cfg)
15997{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015998 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15999 hda_nid_t nid_v, nid_s;
16000 int i, err;
16001
16002 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016003 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016004 continue;
16005 nid_v = alc861vd_idx_to_mixer_vol(
16006 alc880_dac_to_idx(
16007 spec->multiout.dac_nids[i]));
16008 nid_s = alc861vd_idx_to_mixer_switch(
16009 alc880_dac_to_idx(
16010 spec->multiout.dac_nids[i]));
16011
16012 if (i == 2) {
16013 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016014 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16015 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016016 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16017 HDA_OUTPUT));
16018 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016019 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016020 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16021 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016022 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16023 HDA_OUTPUT));
16024 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016025 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016026 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16027 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016028 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16029 HDA_INPUT));
16030 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016031 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016032 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16033 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016034 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16035 HDA_INPUT));
16036 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016037 return err;
16038 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016039 const char *pfx;
16040 if (cfg->line_outs == 1 &&
16041 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16042 if (!cfg->hp_pins)
16043 pfx = "Speaker";
16044 else
16045 pfx = "PCM";
16046 } else
16047 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016048 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016049 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16050 HDA_OUTPUT));
16051 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016052 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016053 if (cfg->line_outs == 1 &&
16054 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16055 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016056 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016057 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016058 HDA_INPUT));
16059 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016060 return err;
16061 }
16062 }
16063 return 0;
16064}
16065
16066/* add playback controls for speaker and HP outputs */
16067/* Based on ALC880 version. But ALC861VD has separate,
16068 * different NIDs for mute/unmute switch and volume control */
16069static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16070 hda_nid_t pin, const char *pfx)
16071{
16072 hda_nid_t nid_v, nid_s;
16073 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016074
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016075 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016076 return 0;
16077
16078 if (alc880_is_fixed_pin(pin)) {
16079 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16080 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016081 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016082 spec->multiout.hp_nid = nid_v;
16083 else
16084 spec->multiout.extra_out_nid[0] = nid_v;
16085 /* control HP volume/switch on the output mixer amp */
16086 nid_v = alc861vd_idx_to_mixer_vol(
16087 alc880_fixed_pin_idx(pin));
16088 nid_s = alc861vd_idx_to_mixer_switch(
16089 alc880_fixed_pin_idx(pin));
16090
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016091 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016092 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16093 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016094 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016095 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016096 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16097 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016098 return err;
16099 } else if (alc880_is_multi_pin(pin)) {
16100 /* set manual connection */
16101 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016102 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016103 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16104 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016105 return err;
16106 }
16107 return 0;
16108}
16109
16110/* parse the BIOS configuration and set up the alc_spec
16111 * return 1 if successful, 0 if the proper config is not found,
16112 * or a negative error code
16113 * Based on ALC880 version - had to change it to override
16114 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16115static int alc861vd_parse_auto_config(struct hda_codec *codec)
16116{
16117 struct alc_spec *spec = codec->spec;
16118 int err;
16119 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16120
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016121 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16122 alc861vd_ignore);
16123 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016124 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016125 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016126 return 0; /* can't find valid BIOS pin config */
16127
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016128 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16129 if (err < 0)
16130 return err;
16131 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16132 if (err < 0)
16133 return err;
16134 err = alc861vd_auto_create_extra_out(spec,
16135 spec->autocfg.speaker_pins[0],
16136 "Speaker");
16137 if (err < 0)
16138 return err;
16139 err = alc861vd_auto_create_extra_out(spec,
16140 spec->autocfg.hp_pins[0],
16141 "Headphone");
16142 if (err < 0)
16143 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016144 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016145 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016146 return err;
16147
16148 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16149
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016150 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016151 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16152
Takashi Iwai603c4012008-07-30 15:01:44 +020016153 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016154 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016155
Takashi Iwaid88897e2008-10-31 15:01:37 +010016156 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016157
16158 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016159 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016160
Takashi Iwai776e1842007-08-29 15:07:11 +020016161 err = alc_auto_add_mic_boost(codec);
16162 if (err < 0)
16163 return err;
16164
Kailang Yang6227cdc2010-02-25 08:36:52 +010016165 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016166
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016167 return 1;
16168}
16169
16170/* additional initialization for auto-configuration model */
16171static void alc861vd_auto_init(struct hda_codec *codec)
16172{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016173 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016174 alc861vd_auto_init_multi_out(codec);
16175 alc861vd_auto_init_hp_out(codec);
16176 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016177 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016178 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016179 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016180}
16181
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016182enum {
16183 ALC660VD_FIX_ASUS_GPIO1
16184};
16185
16186/* reset GPIO1 */
16187static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16188 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16189 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16190 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16191 { }
16192};
16193
16194static const struct alc_fixup alc861vd_fixups[] = {
16195 [ALC660VD_FIX_ASUS_GPIO1] = {
16196 .verbs = alc660vd_fix_asus_gpio1_verbs,
16197 },
16198};
16199
16200static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16201 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16202 {}
16203};
16204
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016205static int patch_alc861vd(struct hda_codec *codec)
16206{
16207 struct alc_spec *spec;
16208 int err, board_config;
16209
16210 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16211 if (spec == NULL)
16212 return -ENOMEM;
16213
16214 codec->spec = spec;
16215
16216 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16217 alc861vd_models,
16218 alc861vd_cfg_tbl);
16219
16220 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016221 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16222 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016223 board_config = ALC861VD_AUTO;
16224 }
16225
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016226 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
16227
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016228 if (board_config == ALC861VD_AUTO) {
16229 /* automatic parse from the BIOS config */
16230 err = alc861vd_parse_auto_config(codec);
16231 if (err < 0) {
16232 alc_free(codec);
16233 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016234 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016235 printk(KERN_INFO
16236 "hda_codec: Cannot set up configuration "
16237 "from BIOS. Using base mode...\n");
16238 board_config = ALC861VD_3ST;
16239 }
16240 }
16241
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016242 err = snd_hda_attach_beep_device(codec, 0x23);
16243 if (err < 0) {
16244 alc_free(codec);
16245 return err;
16246 }
16247
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016248 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016249 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016250
Kailang Yang2f893282008-05-27 12:14:47 +020016251 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016252 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016253 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016254 }
16255
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016256 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16257 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16258
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016259 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16260 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16261
Takashi Iwaidd704692009-08-11 08:45:11 +020016262 if (!spec->adc_nids) {
16263 spec->adc_nids = alc861vd_adc_nids;
16264 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16265 }
16266 if (!spec->capsrc_nids)
16267 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016268
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016269 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016270 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016271
Takashi Iwai2134ea42008-01-10 16:53:55 +010016272 spec->vmaster_nid = 0x02;
16273
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016274 codec->patch_ops = alc_patch_ops;
16275
16276 if (board_config == ALC861VD_AUTO)
16277 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016278#ifdef CONFIG_SND_HDA_POWER_SAVE
16279 if (!spec->loopback.amplist)
16280 spec->loopback.amplist = alc861vd_loopbacks;
16281#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016282
16283 return 0;
16284}
16285
16286/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016287 * ALC662 support
16288 *
16289 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16290 * configuration. Each pin widget can choose any input DACs and a mixer.
16291 * Each ADC is connected from a mixer of all inputs. This makes possible
16292 * 6-channel independent captures.
16293 *
16294 * In addition, an independent DAC for the multi-playback (not used in this
16295 * driver yet).
16296 */
16297#define ALC662_DIGOUT_NID 0x06
16298#define ALC662_DIGIN_NID 0x0a
16299
16300static hda_nid_t alc662_dac_nids[4] = {
16301 /* front, rear, clfe, rear_surr */
16302 0x02, 0x03, 0x04
16303};
16304
Kailang Yang622e84c2009-04-21 07:39:04 +020016305static hda_nid_t alc272_dac_nids[2] = {
16306 0x02, 0x03
16307};
16308
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016309static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016310 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016311 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016312};
Takashi Iwaie1406342008-02-11 18:32:32 +010016313
Kailang Yang622e84c2009-04-21 07:39:04 +020016314static hda_nid_t alc272_adc_nids[1] = {
16315 /* ADC1-2 */
16316 0x08,
16317};
16318
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016319static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016320static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16321
Takashi Iwaie1406342008-02-11 18:32:32 +010016322
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016323/* input MUX */
16324/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016325static struct hda_input_mux alc662_capture_source = {
16326 .num_items = 4,
16327 .items = {
16328 { "Mic", 0x0 },
16329 { "Front Mic", 0x1 },
16330 { "Line", 0x2 },
16331 { "CD", 0x4 },
16332 },
16333};
16334
16335static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16336 .num_items = 2,
16337 .items = {
16338 { "Mic", 0x1 },
16339 { "Line", 0x2 },
16340 },
16341};
Kailang Yang291702f2007-10-16 14:28:03 +020016342
Kailang Yang6dda9f42008-05-27 12:05:31 +020016343static struct hda_input_mux alc663_capture_source = {
16344 .num_items = 3,
16345 .items = {
16346 { "Mic", 0x0 },
16347 { "Front Mic", 0x1 },
16348 { "Line", 0x2 },
16349 },
16350};
16351
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016352#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016353static struct hda_input_mux alc272_nc10_capture_source = {
16354 .num_items = 16,
16355 .items = {
16356 { "Autoselect Mic", 0x0 },
16357 { "Internal Mic", 0x1 },
16358 { "In-0x02", 0x2 },
16359 { "In-0x03", 0x3 },
16360 { "In-0x04", 0x4 },
16361 { "In-0x05", 0x5 },
16362 { "In-0x06", 0x6 },
16363 { "In-0x07", 0x7 },
16364 { "In-0x08", 0x8 },
16365 { "In-0x09", 0x9 },
16366 { "In-0x0a", 0x0a },
16367 { "In-0x0b", 0x0b },
16368 { "In-0x0c", 0x0c },
16369 { "In-0x0d", 0x0d },
16370 { "In-0x0e", 0x0e },
16371 { "In-0x0f", 0x0f },
16372 },
16373};
16374#endif
16375
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016376/*
16377 * 2ch mode
16378 */
16379static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16380 { 2, NULL }
16381};
16382
16383/*
16384 * 2ch mode
16385 */
16386static struct hda_verb alc662_3ST_ch2_init[] = {
16387 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16388 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16389 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16390 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16391 { } /* end */
16392};
16393
16394/*
16395 * 6ch mode
16396 */
16397static struct hda_verb alc662_3ST_ch6_init[] = {
16398 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16399 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16400 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16401 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16402 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16403 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16404 { } /* end */
16405};
16406
16407static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16408 { 2, alc662_3ST_ch2_init },
16409 { 6, alc662_3ST_ch6_init },
16410};
16411
16412/*
16413 * 2ch mode
16414 */
16415static struct hda_verb alc662_sixstack_ch6_init[] = {
16416 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16417 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16418 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16419 { } /* end */
16420};
16421
16422/*
16423 * 6ch mode
16424 */
16425static struct hda_verb alc662_sixstack_ch8_init[] = {
16426 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16427 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16428 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16429 { } /* end */
16430};
16431
16432static struct hda_channel_mode alc662_5stack_modes[2] = {
16433 { 2, alc662_sixstack_ch6_init },
16434 { 6, alc662_sixstack_ch8_init },
16435};
16436
16437/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16438 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16439 */
16440
16441static struct snd_kcontrol_new alc662_base_mixer[] = {
16442 /* output mixer control */
16443 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016444 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016445 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016446 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016447 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16448 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016449 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16450 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016451 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16452
16453 /*Input mixer control */
16454 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16455 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16456 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16457 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16458 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16459 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16460 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16461 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016462 { } /* end */
16463};
16464
16465static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16466 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016467 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016468 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16469 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16470 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16471 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16472 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16473 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16474 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16475 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16476 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016477 { } /* end */
16478};
16479
16480static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16481 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016482 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016483 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016484 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016485 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16486 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016487 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16488 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016489 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16490 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16491 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16492 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16493 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16494 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16495 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16496 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16497 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016498 { } /* end */
16499};
16500
16501static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16502 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16503 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016504 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16505 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016506 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16507 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16508 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16509 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16510 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016511 { } /* end */
16512};
16513
Kailang Yang291702f2007-10-16 14:28:03 +020016514static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016515 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16516 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016517
16518 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16519 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16520 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16521
16522 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16523 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16524 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16525 { } /* end */
16526};
16527
Kailang Yang8c427222008-01-10 13:03:59 +010016528static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016529 ALC262_HIPPO_MASTER_SWITCH,
16530 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016531 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016532 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16533 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016534 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16535 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16536 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16538 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16539 { } /* end */
16540};
16541
Kailang Yangf1d4e282008-08-26 14:03:29 +020016542static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16543 .ops = &snd_hda_bind_vol,
16544 .values = {
16545 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16546 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16547 0
16548 },
16549};
16550
16551static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16552 .ops = &snd_hda_bind_sw,
16553 .values = {
16554 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16555 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16556 0
16557 },
16558};
16559
Kailang Yang6dda9f42008-05-27 12:05:31 +020016560static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016561 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16562 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16564 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16565 { } /* end */
16566};
16567
16568static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16569 .ops = &snd_hda_bind_sw,
16570 .values = {
16571 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16572 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16573 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16574 0
16575 },
16576};
16577
16578static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16579 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16580 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16581 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16582 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16583 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16584 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16585
16586 { } /* end */
16587};
16588
16589static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16590 .ops = &snd_hda_bind_sw,
16591 .values = {
16592 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16593 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16594 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16595 0
16596 },
16597};
16598
16599static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16600 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16601 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16603 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16604 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16605 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16606 { } /* end */
16607};
16608
16609static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016610 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16611 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016612 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16613 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16614 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16615 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16616 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16617 { } /* end */
16618};
16619
16620static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16621 .ops = &snd_hda_bind_vol,
16622 .values = {
16623 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16624 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16625 0
16626 },
16627};
16628
16629static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16630 .ops = &snd_hda_bind_sw,
16631 .values = {
16632 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16633 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16634 0
16635 },
16636};
16637
16638static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16639 HDA_BIND_VOL("Master Playback Volume",
16640 &alc663_asus_two_bind_master_vol),
16641 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16642 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16644 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16645 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016646 { } /* end */
16647};
16648
16649static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16650 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16651 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16652 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16653 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16655 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016656 { } /* end */
16657};
16658
16659static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16660 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16661 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16662 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16663 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16664 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16665
16666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16667 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16668 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16669 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16670 { } /* end */
16671};
16672
16673static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16674 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16675 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16676 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16677
16678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16679 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16680 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16681 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16682 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16683 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16684 { } /* end */
16685};
16686
Kailang Yangebb83ee2009-12-17 12:23:00 +010016687static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16688 .ops = &snd_hda_bind_sw,
16689 .values = {
16690 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16691 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16692 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16693 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16694 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16695 0
16696 },
16697};
16698
16699static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16700 .ops = &snd_hda_bind_sw,
16701 .values = {
16702 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16703 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16704 0
16705 },
16706};
16707
16708static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16709 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16710 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16711 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16712 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16713 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16714 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16715 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16717 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16718 { } /* end */
16719};
16720
16721static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16722 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16723 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16724 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16725 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16726 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16727 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16728 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16729 { } /* end */
16730};
16731
16732
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016733static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16734 {
16735 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16736 .name = "Channel Mode",
16737 .info = alc_ch_mode_info,
16738 .get = alc_ch_mode_get,
16739 .put = alc_ch_mode_put,
16740 },
16741 { } /* end */
16742};
16743
16744static struct hda_verb alc662_init_verbs[] = {
16745 /* ADC: mute amp left and right */
16746 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16747 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016748
Kailang Yangb60dd392007-09-20 12:50:29 +020016749 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16751 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16753 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016755
16756 /* Front Pin: output 0 (0x0c) */
16757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16758 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16759
16760 /* Rear Pin: output 1 (0x0d) */
16761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16763
16764 /* CLFE Pin: output 2 (0x0e) */
16765 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16766 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16767
16768 /* Mic (rear) pin: input vref at 80% */
16769 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16770 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16771 /* Front Mic pin: input vref at 80% */
16772 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16773 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16774 /* Line In pin: input */
16775 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16776 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16777 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16778 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16779 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16780 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16781 /* CD pin widget for input */
16782 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16783
16784 /* FIXME: use matrix-type input source selection */
16785 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16786 /* Input mixer */
16787 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016788 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016789
16790 /* always trun on EAPD */
16791 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16792 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16793
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016794 { }
16795};
16796
Kailang Yangcec27c82010-02-04 14:18:18 +010016797static struct hda_verb alc663_init_verbs[] = {
16798 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16799 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16800 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16801 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16802 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16803 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16804 { }
16805};
16806
16807static struct hda_verb alc272_init_verbs[] = {
16808 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16809 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16810 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16811 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16812 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16813 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16814 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16815 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16816 { }
16817};
16818
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016819static struct hda_verb alc662_sue_init_verbs[] = {
16820 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16821 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016822 {}
16823};
16824
16825static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16826 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16827 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16828 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016829};
16830
Kailang Yang8c427222008-01-10 13:03:59 +010016831/* Set Unsolicited Event*/
16832static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16833 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16834 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16835 {}
16836};
16837
Kailang Yang6dda9f42008-05-27 12:05:31 +020016838static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016839 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16840 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016841 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16842 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016843 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16844 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016846 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16847 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16848 {}
16849};
16850
Kailang Yangf1d4e282008-08-26 14:03:29 +020016851static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16852 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16853 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16854 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16855 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16857 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16858 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16859 {}
16860};
16861
16862static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16863 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16864 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16865 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16866 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16869 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16870 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16871 {}
16872};
16873
16874static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16875 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16876 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16877 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16880 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16881 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16882 {}
16883};
16884
16885static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16886 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16887 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16888 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16889 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16890 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16891 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16892 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16893 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16895 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16896 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16897 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16898 {}
16899};
16900
16901static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16902 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16903 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16904 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16905 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16906 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16907 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16908 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16910 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16911 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16912 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16913 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16914 {}
16915};
16916
Kailang Yang6dda9f42008-05-27 12:05:31 +020016917static struct hda_verb alc663_g71v_init_verbs[] = {
16918 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16919 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16920 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16921
16922 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16923 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16924 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16925
16926 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16927 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16928 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16929 {}
16930};
16931
16932static struct hda_verb alc663_g50v_init_verbs[] = {
16933 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16934 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16935 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16936
16937 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16938 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16939 {}
16940};
16941
Kailang Yangf1d4e282008-08-26 14:03:29 +020016942static struct hda_verb alc662_ecs_init_verbs[] = {
16943 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16944 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16945 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16946 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16947 {}
16948};
16949
Kailang Yang622e84c2009-04-21 07:39:04 +020016950static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16951 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16952 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16953 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16954 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16955 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16956 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16957 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16958 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16959 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16960 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16961 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16962 {}
16963};
16964
16965static struct hda_verb alc272_dell_init_verbs[] = {
16966 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16967 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16969 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16970 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16971 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16972 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16973 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16974 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16975 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16976 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16977 {}
16978};
16979
Kailang Yangebb83ee2009-12-17 12:23:00 +010016980static struct hda_verb alc663_mode7_init_verbs[] = {
16981 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16982 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16983 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16984 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16985 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16986 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16987 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
16988 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16989 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16990 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16991 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16993 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16994 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16995 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16996 {}
16997};
16998
16999static struct hda_verb alc663_mode8_init_verbs[] = {
17000 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17001 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17002 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17003 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17004 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17005 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17006 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17007 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17008 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17009 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17010 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17012 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17013 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17014 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17015 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17016 {}
17017};
17018
Kailang Yangf1d4e282008-08-26 14:03:29 +020017019static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17020 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17021 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17022 { } /* end */
17023};
17024
Kailang Yang622e84c2009-04-21 07:39:04 +020017025static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17026 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17027 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17028 { } /* end */
17029};
17030
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017031static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17032{
17033 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017034 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017035
Wu Fengguang864f92b2009-11-18 12:38:02 +080017036 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017037 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017038
Takashi Iwai47fd8302007-08-10 17:11:07 +020017039 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17040 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017041}
17042
17043static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17044{
17045 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017046 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017047
Wu Fengguang864f92b2009-11-18 12:38:02 +080017048 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017049 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017050
Takashi Iwai47fd8302007-08-10 17:11:07 +020017051 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17052 HDA_AMP_MUTE, bits);
17053 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17054 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017055}
17056
17057static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17058 unsigned int res)
17059{
17060 if ((res >> 26) == ALC880_HP_EVENT)
17061 alc662_lenovo_101e_all_automute(codec);
17062 if ((res >> 26) == ALC880_FRONT_EVENT)
17063 alc662_lenovo_101e_ispeaker_automute(codec);
17064}
17065
Kailang Yang291702f2007-10-16 14:28:03 +020017066/* unsolicited event for HP jack sensing */
17067static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17068 unsigned int res)
17069{
Kailang Yang291702f2007-10-16 14:28:03 +020017070 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017071 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017072 else
17073 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017074}
17075
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017076static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017077{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017078 struct alc_spec *spec = codec->spec;
17079
17080 alc262_hippo1_setup(codec);
17081 spec->ext_mic.pin = 0x18;
17082 spec->ext_mic.mux_idx = 0;
17083 spec->int_mic.pin = 0x19;
17084 spec->int_mic.mux_idx = 1;
17085 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017086}
17087
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017088static void alc662_eeepc_inithook(struct hda_codec *codec)
17089{
17090 alc262_hippo_automute(codec);
17091 alc_mic_automute(codec);
17092}
17093
17094static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017095{
Takashi Iwai42171c12009-05-08 14:11:43 +020017096 struct alc_spec *spec = codec->spec;
17097
17098 spec->autocfg.hp_pins[0] = 0x14;
17099 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017100}
17101
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017102#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17103
Kailang Yang6dda9f42008-05-27 12:05:31 +020017104static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17105{
17106 unsigned int present;
17107 unsigned char bits;
17108
Wu Fengguang864f92b2009-11-18 12:38:02 +080017109 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017110 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017111 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17112 AMP_IN_MUTE(0), bits);
17113 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17114 AMP_IN_MUTE(0), bits);
17115}
17116
17117static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17118{
17119 unsigned int present;
17120 unsigned char bits;
17121
Wu Fengguang864f92b2009-11-18 12:38:02 +080017122 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017123 bits = present ? HDA_AMP_MUTE : 0;
17124 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17125 AMP_IN_MUTE(0), bits);
17126 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17127 AMP_IN_MUTE(0), bits);
17128 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
17129 AMP_IN_MUTE(0), bits);
17130 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
17131 AMP_IN_MUTE(0), bits);
17132}
17133
17134static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17135{
17136 unsigned int present;
17137 unsigned char bits;
17138
Wu Fengguang864f92b2009-11-18 12:38:02 +080017139 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017140 bits = present ? HDA_AMP_MUTE : 0;
17141 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17142 AMP_IN_MUTE(0), bits);
17143 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17144 AMP_IN_MUTE(0), bits);
17145 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
17146 AMP_IN_MUTE(0), bits);
17147 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
17148 AMP_IN_MUTE(0), bits);
17149}
17150
17151static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17152{
17153 unsigned int present;
17154 unsigned char bits;
17155
Wu Fengguang864f92b2009-11-18 12:38:02 +080017156 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017157 bits = present ? 0 : PIN_OUT;
17158 snd_hda_codec_write(codec, 0x14, 0,
17159 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17160}
17161
17162static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17163{
17164 unsigned int present1, present2;
17165
Wu Fengguang864f92b2009-11-18 12:38:02 +080017166 present1 = snd_hda_jack_detect(codec, 0x21);
17167 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017168
17169 if (present1 || present2) {
17170 snd_hda_codec_write_cache(codec, 0x14, 0,
17171 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17172 } else {
17173 snd_hda_codec_write_cache(codec, 0x14, 0,
17174 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17175 }
17176}
17177
17178static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17179{
17180 unsigned int present1, present2;
17181
Wu Fengguang864f92b2009-11-18 12:38:02 +080017182 present1 = snd_hda_jack_detect(codec, 0x1b);
17183 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017184
17185 if (present1 || present2) {
17186 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17187 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
17188 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17189 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
17190 } else {
17191 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17192 AMP_IN_MUTE(0), 0);
17193 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17194 AMP_IN_MUTE(0), 0);
17195 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017196}
17197
Kailang Yangebb83ee2009-12-17 12:23:00 +010017198static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17199{
17200 unsigned int present1, present2;
17201
17202 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17203 AC_VERB_GET_PIN_SENSE, 0)
17204 & AC_PINSENSE_PRESENCE;
17205 present2 = snd_hda_codec_read(codec, 0x21, 0,
17206 AC_VERB_GET_PIN_SENSE, 0)
17207 & AC_PINSENSE_PRESENCE;
17208
17209 if (present1 || present2) {
17210 snd_hda_codec_write_cache(codec, 0x14, 0,
17211 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17212 snd_hda_codec_write_cache(codec, 0x17, 0,
17213 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17214 } else {
17215 snd_hda_codec_write_cache(codec, 0x14, 0,
17216 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17217 snd_hda_codec_write_cache(codec, 0x17, 0,
17218 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17219 }
17220}
17221
17222static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17223{
17224 unsigned int present1, present2;
17225
17226 present1 = snd_hda_codec_read(codec, 0x21, 0,
17227 AC_VERB_GET_PIN_SENSE, 0)
17228 & AC_PINSENSE_PRESENCE;
17229 present2 = snd_hda_codec_read(codec, 0x15, 0,
17230 AC_VERB_GET_PIN_SENSE, 0)
17231 & AC_PINSENSE_PRESENCE;
17232
17233 if (present1 || present2) {
17234 snd_hda_codec_write_cache(codec, 0x14, 0,
17235 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17236 snd_hda_codec_write_cache(codec, 0x17, 0,
17237 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17238 } else {
17239 snd_hda_codec_write_cache(codec, 0x14, 0,
17240 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17241 snd_hda_codec_write_cache(codec, 0x17, 0,
17242 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17243 }
17244}
17245
Kailang Yang6dda9f42008-05-27 12:05:31 +020017246static void alc663_m51va_unsol_event(struct hda_codec *codec,
17247 unsigned int res)
17248{
17249 switch (res >> 26) {
17250 case ALC880_HP_EVENT:
17251 alc663_m51va_speaker_automute(codec);
17252 break;
17253 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017254 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017255 break;
17256 }
17257}
17258
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017259static void alc663_m51va_setup(struct hda_codec *codec)
17260{
17261 struct alc_spec *spec = codec->spec;
17262 spec->ext_mic.pin = 0x18;
17263 spec->ext_mic.mux_idx = 0;
17264 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017265 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017266 spec->auto_mic = 1;
17267}
17268
Kailang Yang6dda9f42008-05-27 12:05:31 +020017269static void alc663_m51va_inithook(struct hda_codec *codec)
17270{
17271 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017272 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017273}
17274
Kailang Yangf1d4e282008-08-26 14:03:29 +020017275/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017276#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017277
17278static void alc663_mode1_setup(struct hda_codec *codec)
17279{
17280 struct alc_spec *spec = codec->spec;
17281 spec->ext_mic.pin = 0x18;
17282 spec->ext_mic.mux_idx = 0;
17283 spec->int_mic.pin = 0x19;
17284 spec->int_mic.mux_idx = 1;
17285 spec->auto_mic = 1;
17286}
17287
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017288#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017289
Kailang Yangf1d4e282008-08-26 14:03:29 +020017290/* ***************** Mode2 ******************************/
17291static void alc662_mode2_unsol_event(struct hda_codec *codec,
17292 unsigned int res)
17293{
17294 switch (res >> 26) {
17295 case ALC880_HP_EVENT:
17296 alc662_f5z_speaker_automute(codec);
17297 break;
17298 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017299 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017300 break;
17301 }
17302}
17303
Kailang Yangebb83ee2009-12-17 12:23:00 +010017304#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017305
Kailang Yangf1d4e282008-08-26 14:03:29 +020017306static void alc662_mode2_inithook(struct hda_codec *codec)
17307{
17308 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017309 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017310}
17311/* ***************** Mode3 ******************************/
17312static void alc663_mode3_unsol_event(struct hda_codec *codec,
17313 unsigned int res)
17314{
17315 switch (res >> 26) {
17316 case ALC880_HP_EVENT:
17317 alc663_two_hp_m1_speaker_automute(codec);
17318 break;
17319 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017320 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017321 break;
17322 }
17323}
17324
Kailang Yangebb83ee2009-12-17 12:23:00 +010017325#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017326
Kailang Yangf1d4e282008-08-26 14:03:29 +020017327static void alc663_mode3_inithook(struct hda_codec *codec)
17328{
17329 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017330 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017331}
17332/* ***************** Mode4 ******************************/
17333static void alc663_mode4_unsol_event(struct hda_codec *codec,
17334 unsigned int res)
17335{
17336 switch (res >> 26) {
17337 case ALC880_HP_EVENT:
17338 alc663_21jd_two_speaker_automute(codec);
17339 break;
17340 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017341 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017342 break;
17343 }
17344}
17345
Kailang Yangebb83ee2009-12-17 12:23:00 +010017346#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017347
Kailang Yangf1d4e282008-08-26 14:03:29 +020017348static void alc663_mode4_inithook(struct hda_codec *codec)
17349{
17350 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017351 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017352}
17353/* ***************** Mode5 ******************************/
17354static void alc663_mode5_unsol_event(struct hda_codec *codec,
17355 unsigned int res)
17356{
17357 switch (res >> 26) {
17358 case ALC880_HP_EVENT:
17359 alc663_15jd_two_speaker_automute(codec);
17360 break;
17361 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017362 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017363 break;
17364 }
17365}
17366
Kailang Yangebb83ee2009-12-17 12:23:00 +010017367#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017368
Kailang Yangf1d4e282008-08-26 14:03:29 +020017369static void alc663_mode5_inithook(struct hda_codec *codec)
17370{
17371 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017372 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017373}
17374/* ***************** Mode6 ******************************/
17375static void alc663_mode6_unsol_event(struct hda_codec *codec,
17376 unsigned int res)
17377{
17378 switch (res >> 26) {
17379 case ALC880_HP_EVENT:
17380 alc663_two_hp_m2_speaker_automute(codec);
17381 break;
17382 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017383 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017384 break;
17385 }
17386}
17387
Kailang Yangebb83ee2009-12-17 12:23:00 +010017388#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017389
Kailang Yangf1d4e282008-08-26 14:03:29 +020017390static void alc663_mode6_inithook(struct hda_codec *codec)
17391{
17392 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017393 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017394}
17395
Kailang Yangebb83ee2009-12-17 12:23:00 +010017396/* ***************** Mode7 ******************************/
17397static void alc663_mode7_unsol_event(struct hda_codec *codec,
17398 unsigned int res)
17399{
17400 switch (res >> 26) {
17401 case ALC880_HP_EVENT:
17402 alc663_two_hp_m7_speaker_automute(codec);
17403 break;
17404 case ALC880_MIC_EVENT:
17405 alc_mic_automute(codec);
17406 break;
17407 }
17408}
17409
17410#define alc663_mode7_setup alc663_mode1_setup
17411
17412static void alc663_mode7_inithook(struct hda_codec *codec)
17413{
17414 alc663_two_hp_m7_speaker_automute(codec);
17415 alc_mic_automute(codec);
17416}
17417
17418/* ***************** Mode8 ******************************/
17419static void alc663_mode8_unsol_event(struct hda_codec *codec,
17420 unsigned int res)
17421{
17422 switch (res >> 26) {
17423 case ALC880_HP_EVENT:
17424 alc663_two_hp_m8_speaker_automute(codec);
17425 break;
17426 case ALC880_MIC_EVENT:
17427 alc_mic_automute(codec);
17428 break;
17429 }
17430}
17431
17432#define alc663_mode8_setup alc663_m51va_setup
17433
17434static void alc663_mode8_inithook(struct hda_codec *codec)
17435{
17436 alc663_two_hp_m8_speaker_automute(codec);
17437 alc_mic_automute(codec);
17438}
17439
Kailang Yang6dda9f42008-05-27 12:05:31 +020017440static void alc663_g71v_hp_automute(struct hda_codec *codec)
17441{
17442 unsigned int present;
17443 unsigned char bits;
17444
Wu Fengguang864f92b2009-11-18 12:38:02 +080017445 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017446 bits = present ? HDA_AMP_MUTE : 0;
17447 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17448 HDA_AMP_MUTE, bits);
17449 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17450 HDA_AMP_MUTE, bits);
17451}
17452
17453static void alc663_g71v_front_automute(struct hda_codec *codec)
17454{
17455 unsigned int present;
17456 unsigned char bits;
17457
Wu Fengguang864f92b2009-11-18 12:38:02 +080017458 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017459 bits = present ? HDA_AMP_MUTE : 0;
17460 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17461 HDA_AMP_MUTE, bits);
17462}
17463
17464static void alc663_g71v_unsol_event(struct hda_codec *codec,
17465 unsigned int res)
17466{
17467 switch (res >> 26) {
17468 case ALC880_HP_EVENT:
17469 alc663_g71v_hp_automute(codec);
17470 break;
17471 case ALC880_FRONT_EVENT:
17472 alc663_g71v_front_automute(codec);
17473 break;
17474 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017475 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017476 break;
17477 }
17478}
17479
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017480#define alc663_g71v_setup alc663_m51va_setup
17481
Kailang Yang6dda9f42008-05-27 12:05:31 +020017482static void alc663_g71v_inithook(struct hda_codec *codec)
17483{
17484 alc663_g71v_front_automute(codec);
17485 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017486 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017487}
17488
17489static void alc663_g50v_unsol_event(struct hda_codec *codec,
17490 unsigned int res)
17491{
17492 switch (res >> 26) {
17493 case ALC880_HP_EVENT:
17494 alc663_m51va_speaker_automute(codec);
17495 break;
17496 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017497 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017498 break;
17499 }
17500}
17501
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017502#define alc663_g50v_setup alc663_m51va_setup
17503
Kailang Yang6dda9f42008-05-27 12:05:31 +020017504static void alc663_g50v_inithook(struct hda_codec *codec)
17505{
17506 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017507 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017508}
17509
Kailang Yangf1d4e282008-08-26 14:03:29 +020017510static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17511 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017512 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017513
17514 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17515 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17516 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17517
17518 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17519 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17520 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17521 { } /* end */
17522};
17523
Chris Pockelé9541ba12009-05-12 08:08:53 +020017524static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17525 /* Master Playback automatically created from Speaker and Headphone */
17526 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17527 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17528 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17529 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17530
17531 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17532 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17533 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17534
17535 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17536 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17537 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17538 { } /* end */
17539};
17540
Takashi Iwaicb53c622007-08-10 17:21:45 +020017541#ifdef CONFIG_SND_HDA_POWER_SAVE
17542#define alc662_loopbacks alc880_loopbacks
17543#endif
17544
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017545
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017546/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017547#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17548#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17549#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17550#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17551
17552/*
17553 * configuration and preset
17554 */
17555static const char *alc662_models[ALC662_MODEL_LAST] = {
17556 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17557 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17558 [ALC662_3ST_6ch] = "3stack-6ch",
17559 [ALC662_5ST_DIG] = "6stack-dig",
17560 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017561 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017562 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017563 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017564 [ALC663_ASUS_M51VA] = "m51va",
17565 [ALC663_ASUS_G71V] = "g71v",
17566 [ALC663_ASUS_H13] = "h13",
17567 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017568 [ALC663_ASUS_MODE1] = "asus-mode1",
17569 [ALC662_ASUS_MODE2] = "asus-mode2",
17570 [ALC663_ASUS_MODE3] = "asus-mode3",
17571 [ALC663_ASUS_MODE4] = "asus-mode4",
17572 [ALC663_ASUS_MODE5] = "asus-mode5",
17573 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017574 [ALC663_ASUS_MODE7] = "asus-mode7",
17575 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017576 [ALC272_DELL] = "dell",
17577 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017578 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017579 [ALC662_AUTO] = "auto",
17580};
17581
17582static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017583 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017584 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17585 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017586 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17587 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017588 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017589 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17590 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17591 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17592 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017593 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17594 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017595 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017596 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17597 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17598 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17599 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17600 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017601 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017602 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17603 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017604 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17605 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17606 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17607 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017608 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017609 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17610 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17611 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017612 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17613 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17614 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17615 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017616 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017617 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17618 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017619 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017620 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17621 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17622 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017623 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017624 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017625 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17626 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017627 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17628 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17629 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017630 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017631 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17632 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017633 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017634 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017635 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017636 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17637 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17638 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017639 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017640 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17641 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017642 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017643 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017644 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017645 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017646 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17647 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017648 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017649 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017650 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17651 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010017652 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017653 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017654 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017655 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017656 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017657 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017658 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17659 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017660 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017661 {}
17662};
17663
17664static struct alc_config_preset alc662_presets[] = {
17665 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017666 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017667 .init_verbs = { alc662_init_verbs },
17668 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17669 .dac_nids = alc662_dac_nids,
17670 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017671 .dig_in_nid = ALC662_DIGIN_NID,
17672 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17673 .channel_mode = alc662_3ST_2ch_modes,
17674 .input_mux = &alc662_capture_source,
17675 },
17676 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017677 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017678 .init_verbs = { alc662_init_verbs },
17679 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17680 .dac_nids = alc662_dac_nids,
17681 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017682 .dig_in_nid = ALC662_DIGIN_NID,
17683 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17684 .channel_mode = alc662_3ST_6ch_modes,
17685 .need_dac_fix = 1,
17686 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017687 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017688 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017689 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017690 .init_verbs = { alc662_init_verbs },
17691 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17692 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017693 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17694 .channel_mode = alc662_3ST_6ch_modes,
17695 .need_dac_fix = 1,
17696 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017697 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017698 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017699 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017700 .init_verbs = { alc662_init_verbs },
17701 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17702 .dac_nids = alc662_dac_nids,
17703 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017704 .dig_in_nid = ALC662_DIGIN_NID,
17705 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17706 .channel_mode = alc662_5stack_modes,
17707 .input_mux = &alc662_capture_source,
17708 },
17709 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017710 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017711 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17712 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17713 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017714 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17715 .channel_mode = alc662_3ST_2ch_modes,
17716 .input_mux = &alc662_lenovo_101e_capture_source,
17717 .unsol_event = alc662_lenovo_101e_unsol_event,
17718 .init_hook = alc662_lenovo_101e_all_automute,
17719 },
Kailang Yang291702f2007-10-16 14:28:03 +020017720 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017721 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017722 .init_verbs = { alc662_init_verbs,
17723 alc662_eeepc_sue_init_verbs },
17724 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17725 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017726 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17727 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017728 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017729 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017730 .init_hook = alc662_eeepc_inithook,
17731 },
Kailang Yang8c427222008-01-10 13:03:59 +010017732 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017733 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017734 alc662_chmode_mixer },
17735 .init_verbs = { alc662_init_verbs,
17736 alc662_eeepc_ep20_sue_init_verbs },
17737 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17738 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017739 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17740 .channel_mode = alc662_3ST_6ch_modes,
17741 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017742 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017743 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017744 .init_hook = alc662_eeepc_ep20_inithook,
17745 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017746 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017747 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017748 .init_verbs = { alc662_init_verbs,
17749 alc662_ecs_init_verbs },
17750 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17751 .dac_nids = alc662_dac_nids,
17752 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17753 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017754 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017755 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017756 .init_hook = alc662_eeepc_inithook,
17757 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017758 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017759 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017760 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17761 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17762 .dac_nids = alc662_dac_nids,
17763 .dig_out_nid = ALC662_DIGOUT_NID,
17764 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17765 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017766 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017767 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017768 .init_hook = alc663_m51va_inithook,
17769 },
17770 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017771 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017772 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17773 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17774 .dac_nids = alc662_dac_nids,
17775 .dig_out_nid = ALC662_DIGOUT_NID,
17776 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17777 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017778 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017779 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017780 .init_hook = alc663_g71v_inithook,
17781 },
17782 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017783 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017784 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17785 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17786 .dac_nids = alc662_dac_nids,
17787 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17788 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017789 .unsol_event = alc663_m51va_unsol_event,
17790 .init_hook = alc663_m51va_inithook,
17791 },
17792 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017793 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017794 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17795 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17796 .dac_nids = alc662_dac_nids,
17797 .dig_out_nid = ALC662_DIGOUT_NID,
17798 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17799 .channel_mode = alc662_3ST_6ch_modes,
17800 .input_mux = &alc663_capture_source,
17801 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017802 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017803 .init_hook = alc663_g50v_inithook,
17804 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017805 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017806 .mixers = { alc663_m51va_mixer },
17807 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017808 .init_verbs = { alc662_init_verbs,
17809 alc663_21jd_amic_init_verbs },
17810 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17811 .hp_nid = 0x03,
17812 .dac_nids = alc662_dac_nids,
17813 .dig_out_nid = ALC662_DIGOUT_NID,
17814 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17815 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017816 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017817 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017818 .init_hook = alc663_mode1_inithook,
17819 },
17820 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017821 .mixers = { alc662_1bjd_mixer },
17822 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017823 .init_verbs = { alc662_init_verbs,
17824 alc662_1bjd_amic_init_verbs },
17825 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17826 .dac_nids = alc662_dac_nids,
17827 .dig_out_nid = ALC662_DIGOUT_NID,
17828 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17829 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017830 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017831 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017832 .init_hook = alc662_mode2_inithook,
17833 },
17834 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017835 .mixers = { alc663_two_hp_m1_mixer },
17836 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017837 .init_verbs = { alc662_init_verbs,
17838 alc663_two_hp_amic_m1_init_verbs },
17839 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17840 .hp_nid = 0x03,
17841 .dac_nids = alc662_dac_nids,
17842 .dig_out_nid = ALC662_DIGOUT_NID,
17843 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17844 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017845 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017846 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017847 .init_hook = alc663_mode3_inithook,
17848 },
17849 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017850 .mixers = { alc663_asus_21jd_clfe_mixer },
17851 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017852 .init_verbs = { alc662_init_verbs,
17853 alc663_21jd_amic_init_verbs},
17854 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17855 .hp_nid = 0x03,
17856 .dac_nids = alc662_dac_nids,
17857 .dig_out_nid = ALC662_DIGOUT_NID,
17858 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17859 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017860 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017861 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017862 .init_hook = alc663_mode4_inithook,
17863 },
17864 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017865 .mixers = { alc663_asus_15jd_clfe_mixer },
17866 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017867 .init_verbs = { alc662_init_verbs,
17868 alc663_15jd_amic_init_verbs },
17869 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17870 .hp_nid = 0x03,
17871 .dac_nids = alc662_dac_nids,
17872 .dig_out_nid = ALC662_DIGOUT_NID,
17873 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17874 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017875 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017876 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017877 .init_hook = alc663_mode5_inithook,
17878 },
17879 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017880 .mixers = { alc663_two_hp_m2_mixer },
17881 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017882 .init_verbs = { alc662_init_verbs,
17883 alc663_two_hp_amic_m2_init_verbs },
17884 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17885 .hp_nid = 0x03,
17886 .dac_nids = alc662_dac_nids,
17887 .dig_out_nid = ALC662_DIGOUT_NID,
17888 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17889 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017890 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017891 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017892 .init_hook = alc663_mode6_inithook,
17893 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017894 [ALC663_ASUS_MODE7] = {
17895 .mixers = { alc663_mode7_mixer },
17896 .cap_mixer = alc662_auto_capture_mixer,
17897 .init_verbs = { alc662_init_verbs,
17898 alc663_mode7_init_verbs },
17899 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17900 .hp_nid = 0x03,
17901 .dac_nids = alc662_dac_nids,
17902 .dig_out_nid = ALC662_DIGOUT_NID,
17903 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17904 .channel_mode = alc662_3ST_2ch_modes,
17905 .unsol_event = alc663_mode7_unsol_event,
17906 .setup = alc663_mode7_setup,
17907 .init_hook = alc663_mode7_inithook,
17908 },
17909 [ALC663_ASUS_MODE8] = {
17910 .mixers = { alc663_mode8_mixer },
17911 .cap_mixer = alc662_auto_capture_mixer,
17912 .init_verbs = { alc662_init_verbs,
17913 alc663_mode8_init_verbs },
17914 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17915 .hp_nid = 0x03,
17916 .dac_nids = alc662_dac_nids,
17917 .dig_out_nid = ALC662_DIGOUT_NID,
17918 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17919 .channel_mode = alc662_3ST_2ch_modes,
17920 .unsol_event = alc663_mode8_unsol_event,
17921 .setup = alc663_mode8_setup,
17922 .init_hook = alc663_mode8_inithook,
17923 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017924 [ALC272_DELL] = {
17925 .mixers = { alc663_m51va_mixer },
17926 .cap_mixer = alc272_auto_capture_mixer,
17927 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17928 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17929 .dac_nids = alc662_dac_nids,
17930 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17931 .adc_nids = alc272_adc_nids,
17932 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17933 .capsrc_nids = alc272_capsrc_nids,
17934 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017935 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017936 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017937 .init_hook = alc663_m51va_inithook,
17938 },
17939 [ALC272_DELL_ZM1] = {
17940 .mixers = { alc663_m51va_mixer },
17941 .cap_mixer = alc662_auto_capture_mixer,
17942 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17943 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17944 .dac_nids = alc662_dac_nids,
17945 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17946 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017947 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017948 .capsrc_nids = alc662_capsrc_nids,
17949 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017950 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017951 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017952 .init_hook = alc663_m51va_inithook,
17953 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017954 [ALC272_SAMSUNG_NC10] = {
17955 .mixers = { alc272_nc10_mixer },
17956 .init_verbs = { alc662_init_verbs,
17957 alc663_21jd_amic_init_verbs },
17958 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17959 .dac_nids = alc272_dac_nids,
17960 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17961 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017962 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017963 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017964 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017965 .init_hook = alc663_mode4_inithook,
17966 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017967};
17968
17969
17970/*
17971 * BIOS auto configuration
17972 */
17973
Takashi Iwai7085ec12009-10-02 09:03:58 +020017974/* convert from MIX nid to DAC */
17975static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17976{
17977 if (nid == 0x0f)
17978 return 0x02;
17979 else if (nid >= 0x0c && nid <= 0x0e)
17980 return nid - 0x0c + 0x02;
17981 else
17982 return 0;
17983}
17984
17985/* get MIX nid connected to the given pin targeted to DAC */
17986static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17987 hda_nid_t dac)
17988{
17989 hda_nid_t mix[4];
17990 int i, num;
17991
17992 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17993 for (i = 0; i < num; i++) {
17994 if (alc662_mix_to_dac(mix[i]) == dac)
17995 return mix[i];
17996 }
17997 return 0;
17998}
17999
18000/* look for an empty DAC slot */
18001static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18002{
18003 struct alc_spec *spec = codec->spec;
18004 hda_nid_t srcs[5];
18005 int i, j, num;
18006
18007 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18008 if (num < 0)
18009 return 0;
18010 for (i = 0; i < num; i++) {
18011 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18012 if (!nid)
18013 continue;
18014 for (j = 0; j < spec->multiout.num_dacs; j++)
18015 if (spec->multiout.dac_nids[j] == nid)
18016 break;
18017 if (j >= spec->multiout.num_dacs)
18018 return nid;
18019 }
18020 return 0;
18021}
18022
18023/* fill in the dac_nids table from the parsed pin configuration */
18024static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18025 const struct auto_pin_cfg *cfg)
18026{
18027 struct alc_spec *spec = codec->spec;
18028 int i;
18029 hda_nid_t dac;
18030
18031 spec->multiout.dac_nids = spec->private_dac_nids;
18032 for (i = 0; i < cfg->line_outs; i++) {
18033 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18034 if (!dac)
18035 continue;
18036 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18037 }
18038 return 0;
18039}
18040
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018041static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018042 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018043{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018044 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018045 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18046}
18047
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018048static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018049 hda_nid_t nid, unsigned int chs)
18050{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018051 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018052 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18053}
18054
18055#define alc662_add_stereo_vol(spec, pfx, nid) \
18056 alc662_add_vol_ctl(spec, pfx, nid, 3)
18057#define alc662_add_stereo_sw(spec, pfx, nid) \
18058 alc662_add_sw_ctl(spec, pfx, nid, 3)
18059
18060/* add playback controls from the parsed DAC table */
18061static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18062 const struct auto_pin_cfg *cfg)
18063{
18064 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018065 static const char *chname[4] = {
18066 "Front", "Surround", NULL /*CLFE*/, "Side"
18067 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018068 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018069 int i, err;
18070
18071 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018072 nid = spec->multiout.dac_nids[i];
18073 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018074 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018075 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18076 if (!mix)
18077 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018078 if (i == 2) {
18079 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018080 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018081 if (err < 0)
18082 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018083 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018084 if (err < 0)
18085 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018086 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018087 if (err < 0)
18088 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018089 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018090 if (err < 0)
18091 return err;
18092 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018093 const char *pfx;
18094 if (cfg->line_outs == 1 &&
18095 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018096 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018097 pfx = "Speaker";
18098 else
18099 pfx = "PCM";
18100 } else
18101 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018102 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018103 if (err < 0)
18104 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018105 if (cfg->line_outs == 1 &&
18106 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18107 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018108 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018109 if (err < 0)
18110 return err;
18111 }
18112 }
18113 return 0;
18114}
18115
18116/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018117/* return DAC nid if any new DAC is assigned */
18118static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018119 const char *pfx)
18120{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018121 struct alc_spec *spec = codec->spec;
18122 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018123 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018124
18125 if (!pin)
18126 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018127 nid = alc662_look_for_dac(codec, pin);
18128 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018129 /* the corresponding DAC is already occupied */
18130 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18131 return 0; /* no way */
18132 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018133 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018134 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18135 }
18136
18137 mix = alc662_dac_to_mix(codec, pin, nid);
18138 if (!mix)
18139 return 0;
18140 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18141 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018142 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018143 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18144 if (err < 0)
18145 return err;
18146 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018147}
18148
18149/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018150#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018151 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018152
18153static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18154 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018155 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018156{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018157 int i, num;
18158 hda_nid_t srcs[4];
18159
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018160 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018161 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018162 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18163 if (num <= 1)
18164 return;
18165 for (i = 0; i < num; i++) {
18166 if (alc662_mix_to_dac(srcs[i]) != dac)
18167 continue;
18168 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18169 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018170 }
18171}
18172
18173static void alc662_auto_init_multi_out(struct hda_codec *codec)
18174{
18175 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018176 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018177 int i;
18178
18179 for (i = 0; i <= HDA_SIDE; i++) {
18180 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18181 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018182 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018183 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018184 }
18185}
18186
18187static void alc662_auto_init_hp_out(struct hda_codec *codec)
18188{
18189 struct alc_spec *spec = codec->spec;
18190 hda_nid_t pin;
18191
18192 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018193 if (pin)
18194 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18195 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018196 pin = spec->autocfg.speaker_pins[0];
18197 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018198 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18199 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018200}
18201
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018202#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18203
18204static void alc662_auto_init_analog_input(struct hda_codec *codec)
18205{
18206 struct alc_spec *spec = codec->spec;
18207 int i;
18208
18209 for (i = 0; i < AUTO_PIN_LAST; i++) {
18210 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018211 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018212 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018213 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018214 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018215 snd_hda_codec_write(codec, nid, 0,
18216 AC_VERB_SET_AMP_GAIN_MUTE,
18217 AMP_OUT_MUTE);
18218 }
18219 }
18220}
18221
Takashi Iwaif511b012008-08-15 16:46:42 +020018222#define alc662_auto_init_input_src alc882_auto_init_input_src
18223
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018224static int alc662_parse_auto_config(struct hda_codec *codec)
18225{
18226 struct alc_spec *spec = codec->spec;
18227 int err;
18228 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18229
18230 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18231 alc662_ignore);
18232 if (err < 0)
18233 return err;
18234 if (!spec->autocfg.line_outs)
18235 return 0; /* can't find valid BIOS pin config */
18236
Takashi Iwai7085ec12009-10-02 09:03:58 +020018237 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018238 if (err < 0)
18239 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018240 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018241 if (err < 0)
18242 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018243 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018244 spec->autocfg.speaker_pins[0],
18245 "Speaker");
18246 if (err < 0)
18247 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018248 if (err)
18249 spec->multiout.extra_out_nid[0] = err;
18250 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018251 "Headphone");
18252 if (err < 0)
18253 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018254 if (err)
18255 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018256 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018257 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018258 return err;
18259
18260 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18261
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018262 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018263 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18264
Takashi Iwai603c4012008-07-30 15:01:44 +020018265 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018266 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018267
18268 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018269 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018270
Kailang Yangcec27c82010-02-04 14:18:18 +010018271 add_verb(spec, alc662_init_verbs);
18272 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18273 codec->vendor_id == 0x10ec0665)
18274 add_verb(spec, alc663_init_verbs);
18275
18276 if (codec->vendor_id == 0x10ec0272)
18277 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018278
18279 err = alc_auto_add_mic_boost(codec);
18280 if (err < 0)
18281 return err;
18282
Kailang Yang6227cdc2010-02-25 08:36:52 +010018283 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18284 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18285 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18286 else
18287 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018288
Takashi Iwai8c872862007-06-19 12:11:16 +020018289 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018290}
18291
18292/* additional initialization for auto-configuration model */
18293static void alc662_auto_init(struct hda_codec *codec)
18294{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018295 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018296 alc662_auto_init_multi_out(codec);
18297 alc662_auto_init_hp_out(codec);
18298 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018299 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018300 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018301 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018302}
18303
18304static int patch_alc662(struct hda_codec *codec)
18305{
18306 struct alc_spec *spec;
18307 int err, board_config;
18308
18309 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18310 if (!spec)
18311 return -ENOMEM;
18312
18313 codec->spec = spec;
18314
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018315 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18316
Kailang Yang274693f2009-12-03 10:07:50 +010018317 if (alc_read_coef_idx(codec, 0)==0x8020){
18318 kfree(codec->chip_name);
18319 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018320 if (!codec->chip_name) {
18321 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018322 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018323 }
Kailang Yang274693f2009-12-03 10:07:50 +010018324 }
18325
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018326 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18327 alc662_models,
18328 alc662_cfg_tbl);
18329 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018330 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18331 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018332 board_config = ALC662_AUTO;
18333 }
18334
18335 if (board_config == ALC662_AUTO) {
18336 /* automatic parse from the BIOS config */
18337 err = alc662_parse_auto_config(codec);
18338 if (err < 0) {
18339 alc_free(codec);
18340 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020018341 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018342 printk(KERN_INFO
18343 "hda_codec: Cannot set up configuration "
18344 "from BIOS. Using base mode...\n");
18345 board_config = ALC662_3ST_2ch_DIG;
18346 }
18347 }
18348
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018349 err = snd_hda_attach_beep_device(codec, 0x1);
18350 if (err < 0) {
18351 alc_free(codec);
18352 return err;
18353 }
18354
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018355 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018356 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018357
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018358 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18359 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18360
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018361 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18362 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18363
Takashi Iwaidd704692009-08-11 08:45:11 +020018364 if (!spec->adc_nids) {
18365 spec->adc_nids = alc662_adc_nids;
18366 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18367 }
18368 if (!spec->capsrc_nids)
18369 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018370
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018371 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018372 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018373
Kailang Yangcec27c82010-02-04 14:18:18 +010018374 switch (codec->vendor_id) {
18375 case 0x10ec0662:
18376 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18377 break;
18378 case 0x10ec0272:
18379 case 0x10ec0663:
18380 case 0x10ec0665:
18381 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18382 break;
18383 case 0x10ec0273:
18384 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18385 break;
18386 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018387 spec->vmaster_nid = 0x02;
18388
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018389 codec->patch_ops = alc_patch_ops;
18390 if (board_config == ALC662_AUTO)
18391 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018392#ifdef CONFIG_SND_HDA_POWER_SAVE
18393 if (!spec->loopback.amplist)
18394 spec->loopback.amplist = alc662_loopbacks;
18395#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018396
18397 return 0;
18398}
18399
Kailang Yang274693f2009-12-03 10:07:50 +010018400static int patch_alc888(struct hda_codec *codec)
18401{
18402 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18403 kfree(codec->chip_name);
18404 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018405 if (!codec->chip_name) {
18406 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018407 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018408 }
18409 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018410 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018411 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018412}
18413
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018414/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018415 * patch entries
18416 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018417static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018418 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018419 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018420 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018421 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018422 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018423 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018424 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018425 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018426 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018427 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018428 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18429 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18430 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018431 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai49535502009-06-30 15:28:30 +020018432 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018433 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18434 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018435 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018436 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010018437 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018438 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018439 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai49535502009-06-30 15:28:30 +020018440 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018441 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai49535502009-06-30 15:28:30 +020018442 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018443 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai49535502009-06-30 15:28:30 +020018444 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018445 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai49535502009-06-30 15:28:30 +020018446 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018447 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai49535502009-06-30 15:28:30 +020018448 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018449 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai49535502009-06-30 15:28:30 +020018450 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018451 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018452 {} /* terminator */
18453};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018454
18455MODULE_ALIAS("snd-hda-codec-id:10ec*");
18456
18457MODULE_LICENSE("GPL");
18458MODULE_DESCRIPTION("Realtek HD-audio codec");
18459
18460static struct hda_codec_preset_list realtek_list = {
18461 .preset = snd_hda_preset_realtek,
18462 .owner = THIS_MODULE,
18463};
18464
18465static int __init patch_realtek_init(void)
18466{
18467 return snd_hda_add_codec_preset(&realtek_list);
18468}
18469
18470static void __exit patch_realtek_exit(void)
18471{
18472 snd_hda_delete_codec_preset(&realtek_list);
18473}
18474
18475module_init(patch_realtek_init)
18476module_exit(patch_realtek_exit)