blob: d0d14ed7ce815d7ae3f7f727cb8d8ab2672b38c3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
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 Woithe7cf51e482006-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 Yangf53281e2008-07-18 12:36:43 +0200134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yang622e84c2009-04-21 07:39:04 +0200191 ALC272_DELL,
192 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200193 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC662_AUTO,
195 ALC662_MODEL_LAST,
196};
197
Kailang Yangdf694da2005-12-05 19:42:22 +0100198/* ALC882 models */
199enum {
200 ALC882_3ST_DIG,
201 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200202 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200203 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC882_TARGA,
205 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200206 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100207 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200208 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200209 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200210 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800211 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200212 ALC883_3ST_2ch_DIG,
213 ALC883_3ST_6ch_DIG,
214 ALC883_3ST_6ch,
215 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200216 ALC883_TARGA_DIG,
217 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200218 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200219 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200220 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800221 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100222 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200223 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200224 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200225 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200226 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100227 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200228 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200229 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200230 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200231 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200232 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200233 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100234 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100235 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430236 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100237 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100238 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800239 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200240 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200241 ALC889A_INTEL,
242 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200243 ALC888_ASUS_M90V,
244 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200245 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100246 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200247 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200248 ALC882_AUTO,
249 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200250};
251
Kailang Yangdf694da2005-12-05 19:42:22 +0100252/* for GPIO Poll */
253#define GPIO_MASK 0x03
254
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200255/* extra amp-initialization sequence types */
256enum {
257 ALC_INIT_NONE,
258 ALC_INIT_DEFAULT,
259 ALC_INIT_GPIO1,
260 ALC_INIT_GPIO2,
261 ALC_INIT_GPIO3,
262};
263
Takashi Iwai6c819492009-08-10 18:47:44 +0200264struct alc_mic_route {
265 hda_nid_t pin;
266 unsigned char mux_idx;
267 unsigned char amix_idx;
268};
269
270#define MUX_IDX_UNDEF ((unsigned char)-1)
271
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272struct alc_spec {
273 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100274 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100276 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100277 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200279 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200280 * don't forget NULL
281 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200282 */
283 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200285 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 struct hda_pcm_stream *stream_analog_playback;
287 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100288 struct hda_pcm_stream *stream_analog_alt_playback;
289 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200291 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 struct hda_pcm_stream *stream_digital_playback;
293 struct hda_pcm_stream *stream_digital_capture;
294
295 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200296 struct hda_multi_out multiout; /* playback set-up
297 * max_channels, dacs must be set
298 * dig_out_nid and hp_nid are optional
299 */
Takashi Iwai63300792008-01-24 15:31:36 +0100300 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100301 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100302 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
304 /* capture */
305 unsigned int num_adc_nids;
306 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100307 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200308 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200311 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 const struct hda_input_mux *input_mux;
313 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200314 struct alc_mic_route ext_mic;
315 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316
317 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100318 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200320 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200321 int const_channel_count;
322 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
324 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100325 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200326
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200327 /* dynamic controls, init_verbs and input_mux */
328 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200329 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200330 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200331 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200332 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
333 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100334
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100335 /* hooks */
336 void (*init_hook)(struct hda_codec *codec);
337 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
338
Takashi Iwai834be882006-03-01 14:16:17 +0100339 /* for pin sensing */
340 unsigned int sense_updated: 1;
341 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100342 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200343 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200344
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100345 /* other flags */
346 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200347 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100348
Takashi Iwai2134ea42008-01-10 16:53:55 +0100349 /* for virtual master */
350 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200351#ifdef CONFIG_SND_HDA_POWER_SAVE
352 struct hda_loopback_check loopback;
353#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200354
355 /* for PLL fix */
356 hda_nid_t pll_nid;
357 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100358};
359
360/*
361 * configuration template - to be copied to the spec instance
362 */
363struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200364 struct snd_kcontrol_new *mixers[5]; /* should be identical size
365 * with spec
366 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100367 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100368 const struct hda_verb *init_verbs[5];
369 unsigned int num_dacs;
370 hda_nid_t *dac_nids;
371 hda_nid_t dig_out_nid; /* optional */
372 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800373 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100374 unsigned int num_adc_nids;
375 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100376 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100377 hda_nid_t dig_in_nid;
378 unsigned int num_channel_mode;
379 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200380 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200381 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200382 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100383 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100384 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200385 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100386 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200387#ifdef CONFIG_SND_HDA_POWER_SAVE
388 struct hda_amp_list *loopbacks;
389#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390};
391
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392
393/*
394 * input MUX handling
395 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200396static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
397 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398{
399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
400 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200401 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
402 if (mux_idx >= spec->num_mux_defs)
403 mux_idx = 0;
404 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405}
406
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200407static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
408 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409{
410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
411 struct alc_spec *spec = codec->spec;
412 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
413
414 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
415 return 0;
416}
417
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200418static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
419 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420{
421 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
422 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100423 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100425 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100426 hda_nid_t nid = spec->capsrc_nids ?
427 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200428 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429
Takashi Iwaicd896c32008-11-18 12:36:33 +0100430 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
431 imux = &spec->input_mux[mux_idx];
432
Takashi Iwaia22d5432009-07-27 12:54:26 +0200433 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200434 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100435 /* Matrix-mixer style (e.g. ALC882) */
436 unsigned int *cur_val = &spec->cur_mux[adc_idx];
437 unsigned int i, idx;
438
439 idx = ucontrol->value.enumerated.item[0];
440 if (idx >= imux->num_items)
441 idx = imux->num_items - 1;
442 if (*cur_val == idx)
443 return 0;
444 for (i = 0; i < imux->num_items; i++) {
445 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
446 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
447 imux->items[i].index,
448 HDA_AMP_MUTE, v);
449 }
450 *cur_val = idx;
451 return 1;
452 } else {
453 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100454 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100455 &spec->cur_mux[adc_idx]);
456 }
457}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200458
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459/*
460 * channel mode setting
461 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200462static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
463 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464{
465 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
466 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100467 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
468 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469}
470
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200471static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
472 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473{
474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
475 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100476 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200477 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200478 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479}
480
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200481static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
482 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483{
484 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
485 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200486 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
487 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200488 &spec->ext_channel_count);
489 if (err >= 0 && !spec->const_channel_count) {
490 spec->multiout.max_channels = spec->ext_channel_count;
491 if (spec->need_dac_fix)
492 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
493 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200494 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495}
496
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100498 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200499 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100500 * being part of a format specifier. Maximum allowed length of a value is
501 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100502 *
503 * Note: some retasking pin complexes seem to ignore requests for input
504 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
505 * are requested. Therefore order this list so that this behaviour will not
506 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200507 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
508 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200509 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100511 "Mic 50pc bias", "Mic 80pc bias",
512 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100513};
514static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100515 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100516};
517/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200518 * in the pin being assumed to be exclusively an input or an output pin. In
519 * addition, "input" pins may or may not process the mic bias option
520 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
521 * accept requests for bias as of chip versions up to March 2006) and/or
522 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100523 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200524#define ALC_PIN_DIR_IN 0x00
525#define ALC_PIN_DIR_OUT 0x01
526#define ALC_PIN_DIR_INOUT 0x02
527#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
528#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100529
Kailang Yangea1fb292008-08-26 12:58:38 +0200530/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531 * For each direction the minimum and maximum values are given.
532 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200533static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100534 { 0, 2 }, /* ALC_PIN_DIR_IN */
535 { 3, 4 }, /* ALC_PIN_DIR_OUT */
536 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200537 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
538 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100539};
540#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
541#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
542#define alc_pin_mode_n_items(_dir) \
543 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
544
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200545static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200547{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100548 unsigned int item_num = uinfo->value.enumerated.item;
549 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
550
551 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200552 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
554
555 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
556 item_num = alc_pin_mode_min(dir);
557 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200558 return 0;
559}
560
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200561static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
562 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200563{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100564 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200565 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
566 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200568 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200569 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
570 AC_VERB_GET_PIN_WIDGET_CONTROL,
571 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200572
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100573 /* Find enumerated value for current pinctl setting */
574 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200575 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200577 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100578 return 0;
579}
580
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200581static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
582 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100583{
584 signed int change;
585 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
586 hda_nid_t nid = kcontrol->private_value & 0xffff;
587 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
588 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200589 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
590 AC_VERB_GET_PIN_WIDGET_CONTROL,
591 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200593 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100594 val = alc_pin_mode_min(dir);
595
596 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100597 if (change) {
598 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200599 snd_hda_codec_write_cache(codec, nid, 0,
600 AC_VERB_SET_PIN_WIDGET_CONTROL,
601 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100602
Kailang Yangea1fb292008-08-26 12:58:38 +0200603 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100604 * for the requested pin mode. Enum values of 2 or less are
605 * input modes.
606 *
607 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200608 * reduces noise slightly (particularly on input) so we'll
609 * do it. However, having both input and output buffers
610 * enabled simultaneously doesn't seem to be problematic if
611 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100612 */
613 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200614 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
615 HDA_AMP_MUTE, HDA_AMP_MUTE);
616 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
617 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100618 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200619 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
620 HDA_AMP_MUTE, HDA_AMP_MUTE);
621 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
622 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100623 }
624 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200625 return change;
626}
627
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100628#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200629 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100630 .info = alc_pin_mode_info, \
631 .get = alc_pin_mode_get, \
632 .put = alc_pin_mode_put, \
633 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100634
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100635/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
636 * together using a mask with more than one bit set. This control is
637 * currently used only by the ALC260 test model. At this stage they are not
638 * needed for any "production" models.
639 */
640#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200641#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200642
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200643static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
644 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100645{
646 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
647 hda_nid_t nid = kcontrol->private_value & 0xffff;
648 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
649 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200650 unsigned int val = snd_hda_codec_read(codec, nid, 0,
651 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100652
653 *valp = (val & mask) != 0;
654 return 0;
655}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200656static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
657 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100658{
659 signed int change;
660 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
661 hda_nid_t nid = kcontrol->private_value & 0xffff;
662 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
663 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200664 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
665 AC_VERB_GET_GPIO_DATA,
666 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100667
668 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200669 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
670 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100671 gpio_data &= ~mask;
672 else
673 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200674 snd_hda_codec_write_cache(codec, nid, 0,
675 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100676
677 return change;
678}
679#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
680 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
681 .info = alc_gpio_data_info, \
682 .get = alc_gpio_data_get, \
683 .put = alc_gpio_data_put, \
684 .private_value = nid | (mask<<16) }
685#endif /* CONFIG_SND_DEBUG */
686
Jonathan Woithe92621f12006-02-28 11:47:47 +0100687/* A switch control to allow the enabling of the digital IO pins on the
688 * ALC260. This is incredibly simplistic; the intention of this control is
689 * to provide something in the test model allowing digital outputs to be
690 * identified if present. If models are found which can utilise these
691 * outputs a more complete mixer control can be devised for those models if
692 * necessary.
693 */
694#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200695#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200696
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200697static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
698 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100699{
700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
701 hda_nid_t nid = kcontrol->private_value & 0xffff;
702 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
703 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200704 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100705 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100706
707 *valp = (val & mask) != 0;
708 return 0;
709}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200710static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
711 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100712{
713 signed int change;
714 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
715 hda_nid_t nid = kcontrol->private_value & 0xffff;
716 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
717 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200718 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100719 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200720 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100721
722 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200723 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100724 if (val==0)
725 ctrl_data &= ~mask;
726 else
727 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200728 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
729 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100730
731 return change;
732}
733#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
734 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
735 .info = alc_spdif_ctrl_info, \
736 .get = alc_spdif_ctrl_get, \
737 .put = alc_spdif_ctrl_put, \
738 .private_value = nid | (mask<<16) }
739#endif /* CONFIG_SND_DEBUG */
740
Jonathan Woithef8225f62008-01-08 12:16:54 +0100741/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
742 * Again, this is only used in the ALC26x test models to help identify when
743 * the EAPD line must be asserted for features to work.
744 */
745#ifdef CONFIG_SND_DEBUG
746#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
747
748static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
749 struct snd_ctl_elem_value *ucontrol)
750{
751 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
752 hda_nid_t nid = kcontrol->private_value & 0xffff;
753 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
754 long *valp = ucontrol->value.integer.value;
755 unsigned int val = snd_hda_codec_read(codec, nid, 0,
756 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
757
758 *valp = (val & mask) != 0;
759 return 0;
760}
761
762static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
763 struct snd_ctl_elem_value *ucontrol)
764{
765 int change;
766 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
767 hda_nid_t nid = kcontrol->private_value & 0xffff;
768 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
769 long val = *ucontrol->value.integer.value;
770 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
771 AC_VERB_GET_EAPD_BTLENABLE,
772 0x00);
773
774 /* Set/unset the masked control bit(s) as needed */
775 change = (!val ? 0 : mask) != (ctrl_data & mask);
776 if (!val)
777 ctrl_data &= ~mask;
778 else
779 ctrl_data |= mask;
780 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
781 ctrl_data);
782
783 return change;
784}
785
786#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
787 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
788 .info = alc_eapd_ctrl_info, \
789 .get = alc_eapd_ctrl_get, \
790 .put = alc_eapd_ctrl_put, \
791 .private_value = nid | (mask<<16) }
792#endif /* CONFIG_SND_DEBUG */
793
Kailang Yangdf694da2005-12-05 19:42:22 +0100794/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100795 * set up the input pin config (depending on the given auto-pin type)
796 */
797static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
798 int auto_pin_type)
799{
800 unsigned int val = PIN_IN;
801
802 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
803 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100804 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100805 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
806 if (pincap & AC_PINCAP_VREF_80)
807 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200808 else if (pincap & AC_PINCAP_VREF_50)
809 val = PIN_VREF50;
810 else if (pincap & AC_PINCAP_VREF_100)
811 val = PIN_VREF100;
812 else if (pincap & AC_PINCAP_VREF_GRD)
813 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100814 }
815 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
816}
817
818/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100819 */
820static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
821{
822 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
823 return;
824 spec->mixers[spec->num_mixers++] = mix;
825}
826
827static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
828{
829 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
830 return;
831 spec->init_verbs[spec->num_init_verbs++] = verb;
832}
833
Takashi Iwaidaead532008-11-28 12:55:36 +0100834#ifdef CONFIG_PROC_FS
835/*
836 * hook for proc
837 */
838static void print_realtek_coef(struct snd_info_buffer *buffer,
839 struct hda_codec *codec, hda_nid_t nid)
840{
841 int coeff;
842
843 if (nid != 0x20)
844 return;
845 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
846 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
847 coeff = snd_hda_codec_read(codec, nid, 0,
848 AC_VERB_GET_COEF_INDEX, 0);
849 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
850}
851#else
852#define print_realtek_coef NULL
853#endif
854
Takashi Iwaid88897e2008-10-31 15:01:37 +0100855/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100856 * set up from the preset table
857 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200858static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200859 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100860{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200861 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100862 int i;
863
864 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100865 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100866 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200867 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
868 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100869 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200870
Kailang Yangdf694da2005-12-05 19:42:22 +0100871 spec->channel_mode = preset->channel_mode;
872 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200873 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200874 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100875
Hector Martin3b315d72009-06-02 10:54:19 +0200876 if (preset->const_channel_count)
877 spec->multiout.max_channels = preset->const_channel_count;
878 else
879 spec->multiout.max_channels = spec->channel_mode[0].channels;
880 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100881
882 spec->multiout.num_dacs = preset->num_dacs;
883 spec->multiout.dac_nids = preset->dac_nids;
884 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800885 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100886 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200887
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200888 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200889 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200890 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100891 spec->input_mux = preset->input_mux;
892
893 spec->num_adc_nids = preset->num_adc_nids;
894 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100895 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100896 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100897
898 spec->unsol_event = preset->unsol_event;
899 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200900#ifdef CONFIG_SND_HDA_POWER_SAVE
901 spec->loopback.amplist = preset->loopbacks;
902#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200903
904 if (preset->setup)
905 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100906}
907
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200908/* Enable GPIO mask and set output */
909static struct hda_verb alc_gpio1_init_verbs[] = {
910 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
911 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
912 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
913 { }
914};
915
916static struct hda_verb alc_gpio2_init_verbs[] = {
917 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
918 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
919 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
920 { }
921};
922
Kailang Yangbdd148a2007-05-08 15:19:08 +0200923static struct hda_verb alc_gpio3_init_verbs[] = {
924 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
925 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
926 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
927 { }
928};
929
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200930/*
931 * Fix hardware PLL issue
932 * On some codecs, the analog PLL gating control must be off while
933 * the default value is 1.
934 */
935static void alc_fix_pll(struct hda_codec *codec)
936{
937 struct alc_spec *spec = codec->spec;
938 unsigned int val;
939
940 if (!spec->pll_nid)
941 return;
942 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
943 spec->pll_coef_idx);
944 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
945 AC_VERB_GET_PROC_COEF, 0);
946 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
947 spec->pll_coef_idx);
948 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
949 val & ~(1 << spec->pll_coef_bit));
950}
951
952static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
953 unsigned int coef_idx, unsigned int coef_bit)
954{
955 struct alc_spec *spec = codec->spec;
956 spec->pll_nid = nid;
957 spec->pll_coef_idx = coef_idx;
958 spec->pll_coef_bit = coef_bit;
959 alc_fix_pll(codec);
960}
961
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200962static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200963{
964 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200965 unsigned int nid = spec->autocfg.hp_pins[0];
966 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200967
Takashi Iwaiad87c642009-11-02 14:23:15 +0100968 if (!nid)
969 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800970 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200971 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
972 nid = spec->autocfg.speaker_pins[i];
973 if (!nid)
974 break;
975 snd_hda_codec_write(codec, nid, 0,
976 AC_VERB_SET_PIN_WIDGET_CONTROL,
977 spec->jack_present ? 0 : PIN_OUT);
978 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200979}
980
Takashi Iwai6c819492009-08-10 18:47:44 +0200981static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
982 hda_nid_t nid)
983{
984 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
985 int i, nums;
986
987 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
988 for (i = 0; i < nums; i++)
989 if (conn[i] == nid)
990 return i;
991 return -1;
992}
993
Kailang Yang7fb0d782008-10-15 11:12:35 +0200994static void alc_mic_automute(struct hda_codec *codec)
995{
996 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200997 struct alc_mic_route *dead, *alive;
998 unsigned int present, type;
999 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001000
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001001 if (!spec->auto_mic)
1002 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001003 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1004 return;
1005 if (snd_BUG_ON(!spec->adc_nids))
1006 return;
1007
1008 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1009
Wu Fengguang864f92b2009-11-18 12:38:02 +08001010 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001011 if (present) {
1012 alive = &spec->ext_mic;
1013 dead = &spec->int_mic;
1014 } else {
1015 alive = &spec->int_mic;
1016 dead = &spec->ext_mic;
1017 }
1018
Takashi Iwai6c819492009-08-10 18:47:44 +02001019 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1020 if (type == AC_WID_AUD_MIX) {
1021 /* Matrix-mixer style (e.g. ALC882) */
1022 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1023 alive->mux_idx,
1024 HDA_AMP_MUTE, 0);
1025 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1026 dead->mux_idx,
1027 HDA_AMP_MUTE, HDA_AMP_MUTE);
1028 } else {
1029 /* MUX style (e.g. ALC880) */
1030 snd_hda_codec_write_cache(codec, cap_nid, 0,
1031 AC_VERB_SET_CONNECT_SEL,
1032 alive->mux_idx);
1033 }
1034
1035 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001036}
1037
Kailang Yangc9b58002007-10-16 14:30:01 +02001038/* unsolicited event for HP jack sensing */
1039static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1040{
1041 if (codec->vendor_id == 0x10ec0880)
1042 res >>= 28;
1043 else
1044 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001045 switch (res) {
1046 case ALC880_HP_EVENT:
1047 alc_automute_pin(codec);
1048 break;
1049 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001050 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001051 break;
1052 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001053}
1054
1055static void alc_inithook(struct hda_codec *codec)
1056{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001057 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001058 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001059}
1060
Kailang Yangf9423e72008-05-27 12:32:25 +02001061/* additional initialization for ALC888 variants */
1062static void alc888_coef_init(struct hda_codec *codec)
1063{
1064 unsigned int tmp;
1065
1066 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1067 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1068 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001069 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001070 /* alc888S-VC */
1071 snd_hda_codec_read(codec, 0x20, 0,
1072 AC_VERB_SET_PROC_COEF, 0x830);
1073 else
1074 /* alc888-VB */
1075 snd_hda_codec_read(codec, 0x20, 0,
1076 AC_VERB_SET_PROC_COEF, 0x3030);
1077}
1078
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001079static void alc889_coef_init(struct hda_codec *codec)
1080{
1081 unsigned int tmp;
1082
1083 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1084 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1085 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1086 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1087}
1088
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001089static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001090{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001091 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001092
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001093 switch (type) {
1094 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001095 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1096 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001097 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001098 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1099 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001100 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001101 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1102 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001103 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001104 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001105 case 0x10ec0260:
1106 snd_hda_codec_write(codec, 0x0f, 0,
1107 AC_VERB_SET_EAPD_BTLENABLE, 2);
1108 snd_hda_codec_write(codec, 0x10, 0,
1109 AC_VERB_SET_EAPD_BTLENABLE, 2);
1110 break;
1111 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001112 case 0x10ec0267:
1113 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001114 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001115 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001116 case 0x10ec0660:
1117 case 0x10ec0662:
1118 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001119 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001120 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001121 snd_hda_codec_write(codec, 0x14, 0,
1122 AC_VERB_SET_EAPD_BTLENABLE, 2);
1123 snd_hda_codec_write(codec, 0x15, 0,
1124 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001125 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001126 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001127 switch (codec->vendor_id) {
1128 case 0x10ec0260:
1129 snd_hda_codec_write(codec, 0x1a, 0,
1130 AC_VERB_SET_COEF_INDEX, 7);
1131 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1132 AC_VERB_GET_PROC_COEF, 0);
1133 snd_hda_codec_write(codec, 0x1a, 0,
1134 AC_VERB_SET_COEF_INDEX, 7);
1135 snd_hda_codec_write(codec, 0x1a, 0,
1136 AC_VERB_SET_PROC_COEF,
1137 tmp | 0x2010);
1138 break;
1139 case 0x10ec0262:
1140 case 0x10ec0880:
1141 case 0x10ec0882:
1142 case 0x10ec0883:
1143 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001144 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001145 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001146 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001147 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001148 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001149 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001150 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001151 case 0x10ec0267:
1152 case 0x10ec0268:
1153 snd_hda_codec_write(codec, 0x20, 0,
1154 AC_VERB_SET_COEF_INDEX, 7);
1155 tmp = snd_hda_codec_read(codec, 0x20, 0,
1156 AC_VERB_GET_PROC_COEF, 0);
1157 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001158 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001159 snd_hda_codec_write(codec, 0x20, 0,
1160 AC_VERB_SET_PROC_COEF,
1161 tmp | 0x3000);
1162 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001163 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001164 break;
1165 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001166}
Kailang Yangea1fb292008-08-26 12:58:38 +02001167
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001168static void alc_init_auto_hp(struct hda_codec *codec)
1169{
1170 struct alc_spec *spec = codec->spec;
1171
1172 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001173 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001174
Kailang Yangc9b58002007-10-16 14:30:01 +02001175 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001176 if (spec->autocfg.line_out_pins[0] &&
1177 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001178 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001179 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001180 else
1181 return;
1182 }
1183
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001184 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1185 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001186 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1187 AC_VERB_SET_UNSOLICITED_ENABLE,
1188 AC_USRSP_EN | ALC880_HP_EVENT);
1189 spec->unsol_event = alc_sku_unsol_event;
1190}
1191
Takashi Iwai6c819492009-08-10 18:47:44 +02001192static void alc_init_auto_mic(struct hda_codec *codec)
1193{
1194 struct alc_spec *spec = codec->spec;
1195 struct auto_pin_cfg *cfg = &spec->autocfg;
1196 hda_nid_t fixed, ext;
1197 int i;
1198
1199 /* there must be only two mic inputs exclusively */
1200 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1201 if (cfg->input_pins[i])
1202 return;
1203
1204 fixed = ext = 0;
1205 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1206 hda_nid_t nid = cfg->input_pins[i];
1207 unsigned int defcfg;
1208 if (!nid)
1209 return;
1210 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1211 switch (get_defcfg_connect(defcfg)) {
1212 case AC_JACK_PORT_FIXED:
1213 if (fixed)
1214 return; /* already occupied */
1215 fixed = nid;
1216 break;
1217 case AC_JACK_PORT_COMPLEX:
1218 if (ext)
1219 return; /* already occupied */
1220 ext = nid;
1221 break;
1222 default:
1223 return; /* invalid entry */
1224 }
1225 }
1226 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1227 return; /* no unsol support */
1228 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1229 ext, fixed);
1230 spec->ext_mic.pin = ext;
1231 spec->int_mic.pin = fixed;
1232 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1233 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1234 spec->auto_mic = 1;
1235 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1236 AC_VERB_SET_UNSOLICITED_ENABLE,
1237 AC_USRSP_EN | ALC880_MIC_EVENT);
1238 spec->unsol_event = alc_sku_unsol_event;
1239}
1240
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001241/* check subsystem ID and set up device-specific initialization;
1242 * return 1 if initialized, 0 if invalid SSID
1243 */
1244/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1245 * 31 ~ 16 : Manufacture ID
1246 * 15 ~ 8 : SKU ID
1247 * 7 ~ 0 : Assembly ID
1248 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1249 */
1250static int alc_subsystem_id(struct hda_codec *codec,
1251 hda_nid_t porta, hda_nid_t porte,
1252 hda_nid_t portd)
1253{
1254 unsigned int ass, tmp, i;
1255 unsigned nid;
1256 struct alc_spec *spec = codec->spec;
1257
1258 ass = codec->subsystem_id & 0xffff;
1259 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1260 goto do_sku;
1261
1262 /* invalid SSID, check the special NID pin defcfg instead */
1263 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001264 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001265 * 29~21 : reserve
1266 * 20 : PCBEEP input
1267 * 19~16 : Check sum (15:1)
1268 * 15~1 : Custom
1269 * 0 : override
1270 */
1271 nid = 0x1d;
1272 if (codec->vendor_id == 0x10ec0260)
1273 nid = 0x17;
1274 ass = snd_hda_codec_get_pincfg(codec, nid);
1275 snd_printd("realtek: No valid SSID, "
1276 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001277 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001278 if (!(ass & 1) && !(ass & 0x100000))
1279 return 0;
1280 if ((ass >> 30) != 1) /* no physical connection */
1281 return 0;
1282
1283 /* check sum */
1284 tmp = 0;
1285 for (i = 1; i < 16; i++) {
1286 if ((ass >> i) & 1)
1287 tmp++;
1288 }
1289 if (((ass >> 16) & 0xf) != tmp)
1290 return 0;
1291do_sku:
1292 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1293 ass & 0xffff, codec->vendor_id);
1294 /*
1295 * 0 : override
1296 * 1 : Swap Jack
1297 * 2 : 0 --> Desktop, 1 --> Laptop
1298 * 3~5 : External Amplifier control
1299 * 7~6 : Reserved
1300 */
1301 tmp = (ass & 0x38) >> 3; /* external Amp control */
1302 switch (tmp) {
1303 case 1:
1304 spec->init_amp = ALC_INIT_GPIO1;
1305 break;
1306 case 3:
1307 spec->init_amp = ALC_INIT_GPIO2;
1308 break;
1309 case 7:
1310 spec->init_amp = ALC_INIT_GPIO3;
1311 break;
1312 case 5:
1313 spec->init_amp = ALC_INIT_DEFAULT;
1314 break;
1315 }
1316
1317 /* is laptop or Desktop and enable the function "Mute internal speaker
1318 * when the external headphone out jack is plugged"
1319 */
1320 if (!(ass & 0x8000))
1321 return 1;
1322 /*
1323 * 10~8 : Jack location
1324 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1325 * 14~13: Resvered
1326 * 15 : 1 --> enable the function "Mute internal speaker
1327 * when the external headphone out jack is plugged"
1328 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001329 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001330 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001331 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1332 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001333 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001334 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001335 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001336 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001337 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001339 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001340 for (i = 0; i < spec->autocfg.line_outs; i++)
1341 if (spec->autocfg.line_out_pins[i] == nid)
1342 return 1;
1343 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001344 }
1345
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001346 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001347 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001348 return 1;
1349}
Kailang Yangea1fb292008-08-26 12:58:38 +02001350
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001351static void alc_ssid_check(struct hda_codec *codec,
1352 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1353{
1354 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1355 struct alc_spec *spec = codec->spec;
1356 snd_printd("realtek: "
1357 "Enable default setup for auto mode as fallback\n");
1358 spec->init_amp = ALC_INIT_DEFAULT;
1359 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001360 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001361 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001362}
1363
Takashi Iwai41e41f12005-06-08 14:48:49 +02001364/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001365 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001366 */
1367
1368struct alc_pincfg {
1369 hda_nid_t nid;
1370 u32 val;
1371};
1372
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001373struct alc_fixup {
1374 const struct alc_pincfg *pins;
1375 const struct hda_verb *verbs;
1376};
1377
1378static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001379 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001380 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001381{
1382 const struct alc_pincfg *cfg;
1383
1384 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1385 if (!quirk)
1386 return;
1387
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001388 fix += quirk->value;
1389 cfg = fix->pins;
1390 if (cfg) {
1391 for (; cfg->nid; cfg++)
1392 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1393 }
1394 if (fix->verbs)
1395 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001396}
1397
Kailang Yang274693f2009-12-03 10:07:50 +01001398static int alc_read_coef_idx(struct hda_codec *codec,
1399 unsigned int coef_idx)
1400{
1401 unsigned int val;
1402 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1403 coef_idx);
1404 val = snd_hda_codec_read(codec, 0x20, 0,
1405 AC_VERB_GET_PROC_COEF, 0);
1406 return val;
1407}
1408
Takashi Iwaif95474e2007-07-10 00:47:43 +02001409/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001410 * ALC888
1411 */
1412
1413/*
1414 * 2ch mode
1415 */
1416static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1417/* Mic-in jack as mic in */
1418 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1419 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1420/* Line-in jack as Line in */
1421 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1422 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1423/* Line-Out as Front */
1424 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1425 { } /* end */
1426};
1427
1428/*
1429 * 4ch mode
1430 */
1431static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1432/* Mic-in jack as mic in */
1433 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1434 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1435/* Line-in jack as Surround */
1436 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1437 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1438/* Line-Out as Front */
1439 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1440 { } /* end */
1441};
1442
1443/*
1444 * 6ch mode
1445 */
1446static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1447/* Mic-in jack as CLFE */
1448 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1449 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1450/* Line-in jack as Surround */
1451 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1452 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1453/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1454 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1455 { } /* end */
1456};
1457
1458/*
1459 * 8ch mode
1460 */
1461static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1462/* Mic-in jack as CLFE */
1463 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1464 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1465/* Line-in jack as Surround */
1466 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1467 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1468/* Line-Out as Side */
1469 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1470 { } /* end */
1471};
1472
1473static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1474 { 2, alc888_4ST_ch2_intel_init },
1475 { 4, alc888_4ST_ch4_intel_init },
1476 { 6, alc888_4ST_ch6_intel_init },
1477 { 8, alc888_4ST_ch8_intel_init },
1478};
1479
1480/*
1481 * ALC888 Fujitsu Siemens Amillo xa3530
1482 */
1483
1484static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1485/* Front Mic: set to PIN_IN (empty by default) */
1486 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1487/* Connect Internal HP to Front */
1488 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1489 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1490 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1491/* Connect Bass HP to Front */
1492 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1493 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1494 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1495/* Connect Line-Out side jack (SPDIF) to Side */
1496 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1497 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1499/* Connect Mic jack to CLFE */
1500 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1503/* Connect Line-in jack to Surround */
1504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1505 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1506 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1507/* Connect HP out jack to Front */
1508 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1509 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1510 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1511/* Enable unsolicited event for HP jack and Line-out jack */
1512 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1513 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1514 {}
1515};
1516
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001517static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001518{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001519 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001520 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001521 hda_nid_t nid;
1522 int i;
1523
1524 spec->jack_present = 0;
1525 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1526 nid = spec->autocfg.hp_pins[i];
1527 if (!nid)
1528 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001529 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001530 spec->jack_present = 1;
1531 break;
1532 }
1533 }
1534
1535 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001536 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001537 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1538 nid = spec->autocfg.speaker_pins[i];
1539 if (!nid)
1540 break;
1541 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1542 HDA_AMP_MUTE, mute);
1543 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001544}
1545
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001546static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1547 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001548{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001549 if (codec->vendor_id == 0x10ec0880)
1550 res >>= 28;
1551 else
1552 res >>= 26;
1553 if (res == ALC880_HP_EVENT)
1554 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001555}
1556
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001557static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001558{
1559 struct alc_spec *spec = codec->spec;
1560
1561 spec->autocfg.hp_pins[0] = 0x15;
1562 spec->autocfg.speaker_pins[0] = 0x14;
1563 spec->autocfg.speaker_pins[1] = 0x16;
1564 spec->autocfg.speaker_pins[2] = 0x17;
1565 spec->autocfg.speaker_pins[3] = 0x19;
1566 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001567}
1568
1569static void alc889_intel_init_hook(struct hda_codec *codec)
1570{
1571 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001572 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001573}
1574
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001575static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001576{
1577 struct alc_spec *spec = codec->spec;
1578
1579 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1580 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1581 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1582 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001583}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001584
1585/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001586 * ALC888 Acer Aspire 4930G model
1587 */
1588
1589static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1590/* Front Mic: set to PIN_IN (empty by default) */
1591 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1592/* Unselect Front Mic by default in input mixer 3 */
1593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001594/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001595 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1596/* Connect Internal HP to front */
1597 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1598 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1599 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1600/* Connect HP out to front */
1601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1602 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1603 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1604 { }
1605};
1606
Hector Martin3b315d72009-06-02 10:54:19 +02001607/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001608 * ALC888 Acer Aspire 6530G model
1609 */
1610
1611static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1612/* Bias voltage on for external mic port */
1613 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001614/* Front Mic: set to PIN_IN (empty by default) */
1615 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1616/* Unselect Front Mic by default in input mixer 3 */
1617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001618/* Enable unsolicited event for HP jack */
1619 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1620/* Enable speaker output */
1621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1622 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1623/* Enable headphone output */
1624 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1626 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1627 { }
1628};
1629
1630/*
Hector Martin018df412009-06-04 00:13:40 +02001631 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001632 */
1633
Hector Martin018df412009-06-04 00:13:40 +02001634static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001635/* Front Mic: set to PIN_IN (empty by default) */
1636 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1637/* Unselect Front Mic by default in input mixer 3 */
1638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1639/* Enable unsolicited event for HP jack */
1640 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1641/* Connect Internal Front to Front */
1642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1644 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1645/* Connect Internal Rear to Rear */
1646 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1647 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1648 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1649/* Connect Internal CLFE to CLFE */
1650 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1651 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1652 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1653/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001654 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001655 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1656 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1657/* Enable all DACs */
1658/* DAC DISABLE/MUTE 1? */
1659/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1660 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1661 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1662/* DAC DISABLE/MUTE 2? */
1663/* some bit here disables the other DACs. Init=0x4900 */
1664 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1665 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1666/* Enable amplifiers */
1667 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1668 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001669/* DMIC fix
1670 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1671 * which makes the stereo useless. However, either the mic or the ALC889
1672 * makes the signal become a difference/sum signal instead of standard
1673 * stereo, which is annoying. So instead we flip this bit which makes the
1674 * codec replicate the sum signal to both channels, turning it into a
1675 * normal mono mic.
1676 */
1677/* DMIC_CONTROL? Init value = 0x0001 */
1678 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1679 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001680 { }
1681};
1682
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001683static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001684 /* Front mic only available on one ADC */
1685 {
1686 .num_items = 4,
1687 .items = {
1688 { "Mic", 0x0 },
1689 { "Line", 0x2 },
1690 { "CD", 0x4 },
1691 { "Front Mic", 0xb },
1692 },
1693 },
1694 {
1695 .num_items = 3,
1696 .items = {
1697 { "Mic", 0x0 },
1698 { "Line", 0x2 },
1699 { "CD", 0x4 },
1700 },
1701 }
1702};
1703
Tony Vroond2fd4b02009-06-21 00:40:10 +01001704static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1705 /* Interal mic only available on one ADC */
1706 {
Tony Vroon684a8842009-06-26 09:27:50 +01001707 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001708 .items = {
1709 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001710 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001711 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001712 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001713 { "Int Mic", 0xb },
1714 },
1715 },
1716 {
Tony Vroon684a8842009-06-26 09:27:50 +01001717 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001718 .items = {
1719 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001720 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001721 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001722 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001723 },
1724 }
1725};
1726
Hector Martin018df412009-06-04 00:13:40 +02001727static struct hda_input_mux alc889_capture_sources[3] = {
1728 /* Digital mic only available on first "ADC" */
1729 {
1730 .num_items = 5,
1731 .items = {
1732 { "Mic", 0x0 },
1733 { "Line", 0x2 },
1734 { "CD", 0x4 },
1735 { "Front Mic", 0xb },
1736 { "Input Mix", 0xa },
1737 },
1738 },
1739 {
1740 .num_items = 4,
1741 .items = {
1742 { "Mic", 0x0 },
1743 { "Line", 0x2 },
1744 { "CD", 0x4 },
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
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001759static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001760 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1761 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1762 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1763 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1764 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1765 HDA_OUTPUT),
1766 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1767 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1768 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1769 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1770 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1771 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1772 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1776 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001778 { } /* end */
1779};
1780
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001781static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001782{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001783 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001784
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001785 spec->autocfg.hp_pins[0] = 0x15;
1786 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001787 spec->autocfg.speaker_pins[1] = 0x16;
1788 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001789}
1790
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001791static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001792{
1793 struct alc_spec *spec = codec->spec;
1794
1795 spec->autocfg.hp_pins[0] = 0x15;
1796 spec->autocfg.speaker_pins[0] = 0x14;
1797 spec->autocfg.speaker_pins[1] = 0x16;
1798 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001799}
1800
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001801static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001802{
1803 struct alc_spec *spec = codec->spec;
1804
1805 spec->autocfg.hp_pins[0] = 0x15;
1806 spec->autocfg.speaker_pins[0] = 0x14;
1807 spec->autocfg.speaker_pins[1] = 0x16;
1808 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001809}
1810
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001811/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001812 * ALC880 3-stack model
1813 *
1814 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001815 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1816 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001817 */
1818
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001819static hda_nid_t alc880_dac_nids[4] = {
1820 /* front, rear, clfe, rear_surr */
1821 0x02, 0x05, 0x04, 0x03
1822};
1823
1824static hda_nid_t alc880_adc_nids[3] = {
1825 /* ADC0-2 */
1826 0x07, 0x08, 0x09,
1827};
1828
1829/* The datasheet says the node 0x07 is connected from inputs,
1830 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001831 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001832 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001833static hda_nid_t alc880_adc_nids_alt[2] = {
1834 /* ADC1-2 */
1835 0x08, 0x09,
1836};
1837
1838#define ALC880_DIGOUT_NID 0x06
1839#define ALC880_DIGIN_NID 0x0a
1840
1841static struct hda_input_mux alc880_capture_source = {
1842 .num_items = 4,
1843 .items = {
1844 { "Mic", 0x0 },
1845 { "Front Mic", 0x3 },
1846 { "Line", 0x2 },
1847 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001848 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001849};
1850
1851/* channel source setting (2/6 channel selection for 3-stack) */
1852/* 2ch mode */
1853static struct hda_verb alc880_threestack_ch2_init[] = {
1854 /* set line-in to input, mute it */
1855 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1856 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1857 /* set mic-in to input vref 80%, mute it */
1858 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1859 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860 { } /* end */
1861};
1862
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001863/* 6ch mode */
1864static struct hda_verb alc880_threestack_ch6_init[] = {
1865 /* set line-in to output, unmute it */
1866 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1867 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1868 /* set mic-in to output, unmute it */
1869 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1870 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1871 { } /* end */
1872};
1873
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001874static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001875 { 2, alc880_threestack_ch2_init },
1876 { 6, alc880_threestack_ch6_init },
1877};
1878
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001879static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001880 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001881 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001882 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001883 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001884 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1885 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001886 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1887 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1889 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1890 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1891 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1895 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001896 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001897 {
1898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1899 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001900 .info = alc_ch_mode_info,
1901 .get = alc_ch_mode_get,
1902 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001903 },
1904 { } /* end */
1905};
1906
1907/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001908static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1909 struct snd_ctl_elem_info *uinfo)
1910{
1911 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1912 struct alc_spec *spec = codec->spec;
1913 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001914
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001915 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001916 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1917 HDA_INPUT);
1918 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001919 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001920 return err;
1921}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001922
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001923static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1924 unsigned int size, unsigned int __user *tlv)
1925{
1926 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1927 struct alc_spec *spec = codec->spec;
1928 int err;
1929
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001930 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001931 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1932 HDA_INPUT);
1933 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001934 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001935 return err;
1936}
1937
1938typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1939 struct snd_ctl_elem_value *ucontrol);
1940
1941static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1942 struct snd_ctl_elem_value *ucontrol,
1943 getput_call_t func)
1944{
1945 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1946 struct alc_spec *spec = codec->spec;
1947 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1948 int err;
1949
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001950 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001951 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1952 3, 0, HDA_INPUT);
1953 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001954 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001955 return err;
1956}
1957
1958static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1959 struct snd_ctl_elem_value *ucontrol)
1960{
1961 return alc_cap_getput_caller(kcontrol, ucontrol,
1962 snd_hda_mixer_amp_volume_get);
1963}
1964
1965static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1966 struct snd_ctl_elem_value *ucontrol)
1967{
1968 return alc_cap_getput_caller(kcontrol, ucontrol,
1969 snd_hda_mixer_amp_volume_put);
1970}
1971
1972/* capture mixer elements */
1973#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1974
1975static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1976 struct snd_ctl_elem_value *ucontrol)
1977{
1978 return alc_cap_getput_caller(kcontrol, ucontrol,
1979 snd_hda_mixer_amp_switch_get);
1980}
1981
1982static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1983 struct snd_ctl_elem_value *ucontrol)
1984{
1985 return alc_cap_getput_caller(kcontrol, ucontrol,
1986 snd_hda_mixer_amp_switch_put);
1987}
1988
Takashi Iwaia23b6882009-03-23 15:21:36 +01001989#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001990 { \
1991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1992 .name = "Capture Switch", \
1993 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1994 .count = num, \
1995 .info = alc_cap_sw_info, \
1996 .get = alc_cap_sw_get, \
1997 .put = alc_cap_sw_put, \
1998 }, \
1999 { \
2000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2001 .name = "Capture Volume", \
2002 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2003 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2004 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2005 .count = num, \
2006 .info = alc_cap_vol_info, \
2007 .get = alc_cap_vol_get, \
2008 .put = alc_cap_vol_put, \
2009 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002010 }
2011
2012#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002013 { \
2014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2015 /* .name = "Capture Source", */ \
2016 .name = "Input Source", \
2017 .count = num, \
2018 .info = alc_mux_enum_info, \
2019 .get = alc_mux_enum_get, \
2020 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002021 }
2022
2023#define DEFINE_CAPMIX(num) \
2024static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2025 _DEFINE_CAPMIX(num), \
2026 _DEFINE_CAPSRC(num), \
2027 { } /* end */ \
2028}
2029
2030#define DEFINE_CAPMIX_NOSRC(num) \
2031static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2032 _DEFINE_CAPMIX(num), \
2033 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002034}
2035
2036/* up to three ADCs */
2037DEFINE_CAPMIX(1);
2038DEFINE_CAPMIX(2);
2039DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002040DEFINE_CAPMIX_NOSRC(1);
2041DEFINE_CAPMIX_NOSRC(2);
2042DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002043
2044/*
2045 * ALC880 5-stack model
2046 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002047 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2048 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002049 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2050 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2051 */
2052
2053/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002054static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002055 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002056 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002057 { } /* end */
2058};
2059
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002060/* channel source setting (6/8 channel selection for 5-stack) */
2061/* 6ch mode */
2062static struct hda_verb alc880_fivestack_ch6_init[] = {
2063 /* set line-in to input, mute it */
2064 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2065 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002066 { } /* end */
2067};
2068
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002069/* 8ch mode */
2070static struct hda_verb alc880_fivestack_ch8_init[] = {
2071 /* set line-in to output, unmute it */
2072 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2073 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2074 { } /* end */
2075};
2076
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002077static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002078 { 6, alc880_fivestack_ch6_init },
2079 { 8, alc880_fivestack_ch8_init },
2080};
2081
2082
2083/*
2084 * ALC880 6-stack model
2085 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002086 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2087 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002088 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2089 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2090 */
2091
2092static hda_nid_t alc880_6st_dac_nids[4] = {
2093 /* front, rear, clfe, rear_surr */
2094 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002095};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002096
2097static struct hda_input_mux alc880_6stack_capture_source = {
2098 .num_items = 4,
2099 .items = {
2100 { "Mic", 0x0 },
2101 { "Front Mic", 0x1 },
2102 { "Line", 0x2 },
2103 { "CD", 0x4 },
2104 },
2105};
2106
2107/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002108static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002109 { 8, NULL },
2110};
2111
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002112static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002114 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002115 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002116 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002117 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2118 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002119 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2120 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002121 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002122 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002123 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2124 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2128 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2129 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2130 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002131 {
2132 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2133 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002134 .info = alc_ch_mode_info,
2135 .get = alc_ch_mode_get,
2136 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002137 },
2138 { } /* end */
2139};
2140
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002141
2142/*
2143 * ALC880 W810 model
2144 *
2145 * W810 has rear IO for:
2146 * Front (DAC 02)
2147 * Surround (DAC 03)
2148 * Center/LFE (DAC 04)
2149 * Digital out (06)
2150 *
2151 * The system also has a pair of internal speakers, and a headphone jack.
2152 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002153 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002154 * There is a variable resistor to control the speaker or headphone
2155 * volume. This is a hardware-only device without a software API.
2156 *
2157 * Plugging headphones in will disable the internal speakers. This is
2158 * implemented in hardware, not via the driver using jack sense. In
2159 * a similar fashion, plugging into the rear socket marked "front" will
2160 * disable both the speakers and headphones.
2161 *
2162 * For input, there's a microphone jack, and an "audio in" jack.
2163 * These may not do anything useful with this driver yet, because I
2164 * haven't setup any initialization verbs for these yet...
2165 */
2166
2167static hda_nid_t alc880_w810_dac_nids[3] = {
2168 /* front, rear/surround, clfe */
2169 0x02, 0x03, 0x04
2170};
2171
2172/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002173static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002174 { 6, NULL }
2175};
2176
2177/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002178static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002179 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002180 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002181 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002182 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002183 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2184 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002185 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2186 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2188 { } /* end */
2189};
2190
2191
2192/*
2193 * Z710V model
2194 *
2195 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002196 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2197 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002198 */
2199
2200static hda_nid_t alc880_z71v_dac_nids[1] = {
2201 0x02
2202};
2203#define ALC880_Z71V_HP_DAC 0x03
2204
2205/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002206static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207 { 2, NULL }
2208};
2209
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002210static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002211 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002212 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002213 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002214 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002215 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2216 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2219 { } /* end */
2220};
2221
2222
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002223/*
2224 * ALC880 F1734 model
2225 *
2226 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2227 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2228 */
2229
2230static hda_nid_t alc880_f1734_dac_nids[1] = {
2231 0x03
2232};
2233#define ALC880_F1734_HP_DAC 0x02
2234
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002235static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002236 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002237 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002238 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2239 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002240 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2241 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2243 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002244 { } /* end */
2245};
2246
Takashi Iwai937b4162008-02-11 14:52:36 +01002247static struct hda_input_mux alc880_f1734_capture_source = {
2248 .num_items = 2,
2249 .items = {
2250 { "Mic", 0x1 },
2251 { "CD", 0x4 },
2252 },
2253};
2254
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002255
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002256/*
2257 * ALC880 ASUS model
2258 *
2259 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2260 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2261 * Mic = 0x18, Line = 0x1a
2262 */
2263
2264#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2265#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2266
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002267static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002268 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002269 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002270 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002271 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2273 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002274 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2275 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2278 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2279 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002282 {
2283 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2284 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002285 .info = alc_ch_mode_info,
2286 .get = alc_ch_mode_get,
2287 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002288 },
2289 { } /* end */
2290};
2291
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002292/*
2293 * ALC880 ASUS W1V model
2294 *
2295 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2296 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2297 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2298 */
2299
2300/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002301static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002302 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2303 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002304 { } /* end */
2305};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002306
Kailang Yangdf694da2005-12-05 19:42:22 +01002307/* TCL S700 */
2308static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2309 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2310 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2311 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2313 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2315 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2317 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002318 { } /* end */
2319};
2320
Kailang Yangccc656c2006-10-17 12:32:26 +02002321/* Uniwill */
2322static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002323 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2324 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2325 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2326 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002327 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2328 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2329 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2330 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2331 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2332 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2334 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002339 {
2340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2341 .name = "Channel Mode",
2342 .info = alc_ch_mode_info,
2343 .get = alc_ch_mode_get,
2344 .put = alc_ch_mode_put,
2345 },
2346 { } /* end */
2347};
2348
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002349static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2350 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2351 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2352 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2353 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2356 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2357 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2358 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2359 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2360 { } /* end */
2361};
2362
Kailang Yangccc656c2006-10-17 12:32:26 +02002363static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002364 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2365 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2366 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2367 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2370 { } /* end */
2371};
2372
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002374 * virtual master controls
2375 */
2376
2377/*
2378 * slave controls for virtual master
2379 */
2380static const char *alc_slave_vols[] = {
2381 "Front Playback Volume",
2382 "Surround Playback Volume",
2383 "Center Playback Volume",
2384 "LFE Playback Volume",
2385 "Side Playback Volume",
2386 "Headphone Playback Volume",
2387 "Speaker Playback Volume",
2388 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002389 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002390 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002391 NULL,
2392};
2393
2394static const char *alc_slave_sws[] = {
2395 "Front Playback Switch",
2396 "Surround Playback Switch",
2397 "Center Playback Switch",
2398 "LFE Playback Switch",
2399 "Side Playback Switch",
2400 "Headphone Playback Switch",
2401 "Speaker Playback Switch",
2402 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002403 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002404 NULL,
2405};
2406
2407/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002408 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002409 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002410
2411static void alc_free_kctls(struct hda_codec *codec);
2412
Takashi Iwai67d634c2009-11-16 15:35:59 +01002413#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002414/* additional beep mixers; the actual parameters are overwritten at build */
2415static struct snd_kcontrol_new alc_beep_mixer[] = {
2416 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002417 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002418 { } /* end */
2419};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002420#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002421
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422static int alc_build_controls(struct hda_codec *codec)
2423{
2424 struct alc_spec *spec = codec->spec;
2425 int err;
2426 int i;
2427
2428 for (i = 0; i < spec->num_mixers; i++) {
2429 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2430 if (err < 0)
2431 return err;
2432 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002433 if (spec->cap_mixer) {
2434 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2435 if (err < 0)
2436 return err;
2437 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002439 err = snd_hda_create_spdif_out_ctls(codec,
2440 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002441 if (err < 0)
2442 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002443 if (!spec->no_analog) {
2444 err = snd_hda_create_spdif_share_sw(codec,
2445 &spec->multiout);
2446 if (err < 0)
2447 return err;
2448 spec->multiout.share_spdif = 1;
2449 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450 }
2451 if (spec->dig_in_nid) {
2452 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2453 if (err < 0)
2454 return err;
2455 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002456
Takashi Iwai67d634c2009-11-16 15:35:59 +01002457#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002458 /* create beep controls if needed */
2459 if (spec->beep_amp) {
2460 struct snd_kcontrol_new *knew;
2461 for (knew = alc_beep_mixer; knew->name; knew++) {
2462 struct snd_kcontrol *kctl;
2463 kctl = snd_ctl_new1(knew, codec);
2464 if (!kctl)
2465 return -ENOMEM;
2466 kctl->private_value = spec->beep_amp;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01002467 err = snd_hda_ctl_add(codec,
2468 get_amp_nid_(spec->beep_amp), kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002469 if (err < 0)
2470 return err;
2471 }
2472 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002473#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002474
Takashi Iwai2134ea42008-01-10 16:53:55 +01002475 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002476 if (!spec->no_analog &&
2477 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002478 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002479 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002480 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002481 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002482 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002483 if (err < 0)
2484 return err;
2485 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002486 if (!spec->no_analog &&
2487 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002488 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2489 NULL, alc_slave_sws);
2490 if (err < 0)
2491 return err;
2492 }
2493
Takashi Iwai603c4012008-07-30 15:01:44 +02002494 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002495 return 0;
2496}
2497
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002498
Linus Torvalds1da177e2005-04-16 15:20:36 -07002499/*
2500 * initialize the codec volumes, etc
2501 */
2502
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002503/*
2504 * generic initialization of ADC, input mixers and output mixers
2505 */
2506static struct hda_verb alc880_volume_init_verbs[] = {
2507 /*
2508 * Unmute ADC0-2 and set the default input to mic-in
2509 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002510 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002512 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002513 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002514 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002515 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002517 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2518 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002519 * Note: PASD motherboards uses the Line In 2 as the input for front
2520 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002521 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002522 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002530
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002531 /*
2532 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002533 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002534 /* set vol=0 to output mixers */
2535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2536 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2537 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2538 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2539 /* set up input amps for analog loopback */
2540 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2542 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002543 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2544 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002545 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2546 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002547 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2548 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002549
2550 { }
2551};
2552
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002553/*
2554 * 3-stack pin configuration:
2555 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2556 */
2557static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2558 /*
2559 * preset connection lists of input pins
2560 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2561 */
2562 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2563 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2564 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2565
2566 /*
2567 * Set pin mode and muting
2568 */
2569 /* set front pin widgets 0x14 for output */
2570 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2571 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2572 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2573 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2574 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2575 /* Mic2 (as headphone out) for HP output */
2576 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2577 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2578 /* Line In pin widget for input */
2579 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2580 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2581 /* Line2 (as front mic) pin widget for input and vref at 80% */
2582 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2583 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2584 /* CD pin widget for input */
2585 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2586
2587 { }
2588};
2589
2590/*
2591 * 5-stack pin configuration:
2592 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2593 * line-in/side = 0x1a, f-mic = 0x1b
2594 */
2595static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2596 /*
2597 * preset connection lists of input pins
2598 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2599 */
2600 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2601 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2602
2603 /*
2604 * Set pin mode and muting
2605 */
2606 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2608 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2609 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2610 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002611 /* unmute pins for output (no gain on this amp) */
2612 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2613 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2614 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2615 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2616
Linus Torvalds1da177e2005-04-16 15:20:36 -07002617 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002618 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002619 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2620 /* Mic2 (as headphone out) for HP output */
2621 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002622 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002623 /* Line In pin widget for input */
2624 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2625 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2626 /* Line2 (as front mic) pin widget for input and vref at 80% */
2627 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2628 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2629 /* CD pin widget for input */
2630 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631
2632 { }
2633};
2634
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002635/*
2636 * W810 pin configuration:
2637 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2638 */
2639static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640 /* hphone/speaker input selector: front DAC */
2641 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2642
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2647 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2648 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2649
2650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002651 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652
Linus Torvalds1da177e2005-04-16 15:20:36 -07002653 { }
2654};
2655
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002656/*
2657 * Z71V pin configuration:
2658 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2659 */
2660static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002661 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002663 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002665
Takashi Iwai16ded522005-06-10 19:58:24 +02002666 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002667 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002668 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002669 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002670
2671 { }
2672};
2673
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002674/*
2675 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002676 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2677 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678 */
2679static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2680 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2681
Takashi Iwai16ded522005-06-10 19:58:24 +02002682 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002683 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002684 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002685 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002686 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002687 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002688 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002689 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2690
Takashi Iwai16ded522005-06-10 19:58:24 +02002691 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002692 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002693 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002694 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002695 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002696 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002697 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002698 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002699 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002700
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002701 { }
2702};
Takashi Iwai16ded522005-06-10 19:58:24 +02002703
Kailang Yangccc656c2006-10-17 12:32:26 +02002704/*
2705 * Uniwill pin configuration:
2706 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2707 * line = 0x1a
2708 */
2709static struct hda_verb alc880_uniwill_init_verbs[] = {
2710 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2711
2712 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2713 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2714 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2715 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2716 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2717 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2718 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2719 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2722 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2723 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2724 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2725 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2726
2727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2729 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2730 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2731 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2732 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2733 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2734 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2735 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2736
2737 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2738 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2739
2740 { }
2741};
2742
2743/*
2744* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002745* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002746 */
2747static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2748 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2749
2750 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2751 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2752 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2753 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2754 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2755 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2756 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2757 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2758 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2759 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2760 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2761 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2762
2763 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2764 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2765 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2766 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2767 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2768 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2769
2770 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2771 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2772
2773 { }
2774};
2775
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002776static struct hda_verb alc880_beep_init_verbs[] = {
2777 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2778 { }
2779};
2780
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002781/* auto-toggle front mic */
2782static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2783{
2784 unsigned int present;
2785 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002786
Wu Fengguang864f92b2009-11-18 12:38:02 +08002787 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002788 bits = present ? HDA_AMP_MUTE : 0;
2789 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002790}
2791
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002792static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002793{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002794 struct alc_spec *spec = codec->spec;
2795
2796 spec->autocfg.hp_pins[0] = 0x14;
2797 spec->autocfg.speaker_pins[0] = 0x15;
2798 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002799}
2800
2801static void alc880_uniwill_init_hook(struct hda_codec *codec)
2802{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002803 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002804 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002805}
2806
2807static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2808 unsigned int res)
2809{
2810 /* Looks like the unsol event is incompatible with the standard
2811 * definition. 4bit tag is placed at 28 bit!
2812 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002813 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002814 case ALC880_MIC_EVENT:
2815 alc880_uniwill_mic_automute(codec);
2816 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002817 default:
2818 alc_automute_amp_unsol_event(codec, res);
2819 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002820 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002821}
2822
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002823static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002824{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002825 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002826
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002827 spec->autocfg.hp_pins[0] = 0x14;
2828 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002829}
2830
2831static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2832{
2833 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002834
Kailang Yangccc656c2006-10-17 12:32:26 +02002835 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002836 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2837 present &= HDA_AMP_VOLMASK;
2838 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2839 HDA_AMP_VOLMASK, present);
2840 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2841 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002842}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002843
Kailang Yangccc656c2006-10-17 12:32:26 +02002844static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2845 unsigned int res)
2846{
2847 /* Looks like the unsol event is incompatible with the standard
2848 * definition. 4bit tag is placed at 28 bit!
2849 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002850 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002851 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002852 else
2853 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002854}
2855
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002856/*
2857 * F1734 pin configuration:
2858 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2859 */
2860static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002861 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002862 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2863 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2864 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2865 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2866
2867 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2868 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2869 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2870 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2871
2872 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2873 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002874 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002875 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2876 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2877 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2878 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2879 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2880 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002881
Takashi Iwai937b4162008-02-11 14:52:36 +01002882 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2883 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2884
Takashi Iwai16ded522005-06-10 19:58:24 +02002885 { }
2886};
2887
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002888/*
2889 * ASUS pin configuration:
2890 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2891 */
2892static struct hda_verb alc880_pin_asus_init_verbs[] = {
2893 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2894 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2895 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2896 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2897
2898 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2899 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2900 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2902 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2903 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2904 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2905 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2906
2907 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2909 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2911 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2913 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2914 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2915 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002916
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002917 { }
2918};
2919
2920/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002921#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2922#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002923#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002924
Kailang Yangdf694da2005-12-05 19:42:22 +01002925/* Clevo m520g init */
2926static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2927 /* headphone output */
2928 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2929 /* line-out */
2930 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2931 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2932 /* Line-in */
2933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2934 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2935 /* CD */
2936 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2937 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2938 /* Mic1 (rear panel) */
2939 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2940 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2941 /* Mic2 (front panel) */
2942 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2943 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2944 /* headphone */
2945 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2946 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2947 /* change to EAPD mode */
2948 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2949 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2950
2951 { }
2952};
2953
2954static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002955 /* change to EAPD mode */
2956 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2957 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2958
Kailang Yangdf694da2005-12-05 19:42:22 +01002959 /* Headphone output */
2960 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2961 /* Front output*/
2962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2963 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2964
2965 /* Line In pin widget for input */
2966 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2967 /* CD pin widget for input */
2968 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2969 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2971
2972 /* change to EAPD mode */
2973 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2974 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2975
2976 { }
2977};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002978
2979/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002980 * LG m1 express dual
2981 *
2982 * Pin assignment:
2983 * Rear Line-In/Out (blue): 0x14
2984 * Build-in Mic-In: 0x15
2985 * Speaker-out: 0x17
2986 * HP-Out (green): 0x1b
2987 * Mic-In/Out (red): 0x19
2988 * SPDIF-Out: 0x1e
2989 */
2990
2991/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2992static hda_nid_t alc880_lg_dac_nids[3] = {
2993 0x05, 0x02, 0x03
2994};
2995
2996/* seems analog CD is not working */
2997static struct hda_input_mux alc880_lg_capture_source = {
2998 .num_items = 3,
2999 .items = {
3000 { "Mic", 0x1 },
3001 { "Line", 0x5 },
3002 { "Internal Mic", 0x6 },
3003 },
3004};
3005
3006/* 2,4,6 channel modes */
3007static struct hda_verb alc880_lg_ch2_init[] = {
3008 /* set line-in and mic-in to input */
3009 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3010 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3011 { }
3012};
3013
3014static struct hda_verb alc880_lg_ch4_init[] = {
3015 /* set line-in to out and mic-in to input */
3016 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3017 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3018 { }
3019};
3020
3021static struct hda_verb alc880_lg_ch6_init[] = {
3022 /* set line-in and mic-in to output */
3023 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3024 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3025 { }
3026};
3027
3028static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3029 { 2, alc880_lg_ch2_init },
3030 { 4, alc880_lg_ch4_init },
3031 { 6, alc880_lg_ch6_init },
3032};
3033
3034static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003035 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3036 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003037 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3038 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3039 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3040 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3041 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3042 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3046 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3047 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3048 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3049 {
3050 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3051 .name = "Channel Mode",
3052 .info = alc_ch_mode_info,
3053 .get = alc_ch_mode_get,
3054 .put = alc_ch_mode_put,
3055 },
3056 { } /* end */
3057};
3058
3059static struct hda_verb alc880_lg_init_verbs[] = {
3060 /* set capture source to mic-in */
3061 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3062 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3063 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3064 /* mute all amp mixer inputs */
3065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003068 /* line-in to input */
3069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3070 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3071 /* built-in mic */
3072 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3074 /* speaker-out */
3075 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3076 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3077 /* mic-in to input */
3078 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3079 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3080 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3081 /* HP-out */
3082 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3083 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3084 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3085 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003086 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003087 { }
3088};
3089
3090/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003091static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003092{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003093 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003094
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003095 spec->autocfg.hp_pins[0] = 0x1b;
3096 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003097}
3098
3099/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003100 * LG LW20
3101 *
3102 * Pin assignment:
3103 * Speaker-out: 0x14
3104 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003105 * Built-in Mic-In: 0x19
3106 * Line-In: 0x1b
3107 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003108 * SPDIF-Out: 0x1e
3109 */
3110
Takashi Iwaid6815182006-03-23 16:06:23 +01003111static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003112 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003113 .items = {
3114 { "Mic", 0x0 },
3115 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003116 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003117 },
3118};
3119
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003120#define alc880_lg_lw_modes alc880_threestack_modes
3121
Takashi Iwaid6815182006-03-23 16:06:23 +01003122static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3124 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3125 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3126 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3127 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3128 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3129 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3130 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3131 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3132 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3134 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3135 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3136 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003137 {
3138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3139 .name = "Channel Mode",
3140 .info = alc_ch_mode_info,
3141 .get = alc_ch_mode_get,
3142 .put = alc_ch_mode_put,
3143 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003144 { } /* end */
3145};
3146
3147static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003148 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3149 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3150 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3151
Takashi Iwaid6815182006-03-23 16:06:23 +01003152 /* set capture source to mic-in */
3153 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3154 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3155 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003156 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003157 /* speaker-out */
3158 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3159 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3160 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003161 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3162 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3163 /* mic-in to input */
3164 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3165 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3166 /* built-in mic */
3167 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3168 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3169 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003170 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003171 { }
3172};
3173
3174/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003175static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003176{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003177 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003178
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003179 spec->autocfg.hp_pins[0] = 0x1b;
3180 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003181}
3182
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003183static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3184 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3185 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3186 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3187 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3188 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3189 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3190 { } /* end */
3191};
3192
3193static struct hda_input_mux alc880_medion_rim_capture_source = {
3194 .num_items = 2,
3195 .items = {
3196 { "Mic", 0x0 },
3197 { "Internal Mic", 0x1 },
3198 },
3199};
3200
3201static struct hda_verb alc880_medion_rim_init_verbs[] = {
3202 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3203
3204 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3205 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3206
3207 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3208 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3209 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3210 /* Mic2 (as headphone out) for HP output */
3211 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3212 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3213 /* Internal Speaker */
3214 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3215 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3216
3217 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3218 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3219
3220 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3221 { }
3222};
3223
3224/* toggle speaker-output according to the hp-jack state */
3225static void alc880_medion_rim_automute(struct hda_codec *codec)
3226{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003227 struct alc_spec *spec = codec->spec;
3228 alc_automute_amp(codec);
3229 /* toggle EAPD */
3230 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003231 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3232 else
3233 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3234}
3235
3236static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3237 unsigned int res)
3238{
3239 /* Looks like the unsol event is incompatible with the standard
3240 * definition. 4bit tag is placed at 28 bit!
3241 */
3242 if ((res >> 28) == ALC880_HP_EVENT)
3243 alc880_medion_rim_automute(codec);
3244}
3245
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003246static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003247{
3248 struct alc_spec *spec = codec->spec;
3249
3250 spec->autocfg.hp_pins[0] = 0x14;
3251 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003252}
3253
Takashi Iwaicb53c622007-08-10 17:21:45 +02003254#ifdef CONFIG_SND_HDA_POWER_SAVE
3255static struct hda_amp_list alc880_loopbacks[] = {
3256 { 0x0b, HDA_INPUT, 0 },
3257 { 0x0b, HDA_INPUT, 1 },
3258 { 0x0b, HDA_INPUT, 2 },
3259 { 0x0b, HDA_INPUT, 3 },
3260 { 0x0b, HDA_INPUT, 4 },
3261 { } /* end */
3262};
3263
3264static struct hda_amp_list alc880_lg_loopbacks[] = {
3265 { 0x0b, HDA_INPUT, 1 },
3266 { 0x0b, HDA_INPUT, 6 },
3267 { 0x0b, HDA_INPUT, 7 },
3268 { } /* end */
3269};
3270#endif
3271
Takashi Iwaid6815182006-03-23 16:06:23 +01003272/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003273 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003274 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003275
Linus Torvalds1da177e2005-04-16 15:20:36 -07003276static int alc_init(struct hda_codec *codec)
3277{
3278 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003279 unsigned int i;
3280
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003281 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003282 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003283
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003284 for (i = 0; i < spec->num_init_verbs; i++)
3285 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003286
3287 if (spec->init_hook)
3288 spec->init_hook(codec);
3289
Linus Torvalds1da177e2005-04-16 15:20:36 -07003290 return 0;
3291}
3292
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003293static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3294{
3295 struct alc_spec *spec = codec->spec;
3296
3297 if (spec->unsol_event)
3298 spec->unsol_event(codec, res);
3299}
3300
Takashi Iwaicb53c622007-08-10 17:21:45 +02003301#ifdef CONFIG_SND_HDA_POWER_SAVE
3302static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3303{
3304 struct alc_spec *spec = codec->spec;
3305 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3306}
3307#endif
3308
Linus Torvalds1da177e2005-04-16 15:20:36 -07003309/*
3310 * Analog playback callbacks
3311 */
3312static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3313 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003314 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003315{
3316 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003317 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3318 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003319}
3320
3321static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3322 struct hda_codec *codec,
3323 unsigned int stream_tag,
3324 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003325 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003326{
3327 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003328 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3329 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003330}
3331
3332static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3333 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003334 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003335{
3336 struct alc_spec *spec = codec->spec;
3337 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3338}
3339
3340/*
3341 * Digital out
3342 */
3343static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3344 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003345 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003346{
3347 struct alc_spec *spec = codec->spec;
3348 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3349}
3350
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003351static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3352 struct hda_codec *codec,
3353 unsigned int stream_tag,
3354 unsigned int format,
3355 struct snd_pcm_substream *substream)
3356{
3357 struct alc_spec *spec = codec->spec;
3358 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3359 stream_tag, format, substream);
3360}
3361
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003362static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3363 struct hda_codec *codec,
3364 struct snd_pcm_substream *substream)
3365{
3366 struct alc_spec *spec = codec->spec;
3367 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3368}
3369
Linus Torvalds1da177e2005-04-16 15:20:36 -07003370static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3371 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003372 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003373{
3374 struct alc_spec *spec = codec->spec;
3375 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3376}
3377
3378/*
3379 * Analog capture
3380 */
Takashi Iwai63300792008-01-24 15:31:36 +01003381static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003382 struct hda_codec *codec,
3383 unsigned int stream_tag,
3384 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003385 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003386{
3387 struct alc_spec *spec = codec->spec;
3388
Takashi Iwai63300792008-01-24 15:31:36 +01003389 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003390 stream_tag, 0, format);
3391 return 0;
3392}
3393
Takashi Iwai63300792008-01-24 15:31:36 +01003394static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003395 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003396 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003397{
3398 struct alc_spec *spec = codec->spec;
3399
Takashi Iwai888afa12008-03-18 09:57:50 +01003400 snd_hda_codec_cleanup_stream(codec,
3401 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003402 return 0;
3403}
3404
3405
3406/*
3407 */
3408static struct hda_pcm_stream alc880_pcm_analog_playback = {
3409 .substreams = 1,
3410 .channels_min = 2,
3411 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003412 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003413 .ops = {
3414 .open = alc880_playback_pcm_open,
3415 .prepare = alc880_playback_pcm_prepare,
3416 .cleanup = alc880_playback_pcm_cleanup
3417 },
3418};
3419
3420static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003421 .substreams = 1,
3422 .channels_min = 2,
3423 .channels_max = 2,
3424 /* NID is set in alc_build_pcms */
3425};
3426
3427static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3428 .substreams = 1,
3429 .channels_min = 2,
3430 .channels_max = 2,
3431 /* NID is set in alc_build_pcms */
3432};
3433
3434static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3435 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003436 .channels_min = 2,
3437 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003438 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003439 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003440 .prepare = alc880_alt_capture_pcm_prepare,
3441 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003442 },
3443};
3444
3445static struct hda_pcm_stream alc880_pcm_digital_playback = {
3446 .substreams = 1,
3447 .channels_min = 2,
3448 .channels_max = 2,
3449 /* NID is set in alc_build_pcms */
3450 .ops = {
3451 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003452 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003453 .prepare = alc880_dig_playback_pcm_prepare,
3454 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003455 },
3456};
3457
3458static struct hda_pcm_stream alc880_pcm_digital_capture = {
3459 .substreams = 1,
3460 .channels_min = 2,
3461 .channels_max = 2,
3462 /* NID is set in alc_build_pcms */
3463};
3464
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003465/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003466static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003467 .substreams = 0,
3468 .channels_min = 0,
3469 .channels_max = 0,
3470};
3471
Linus Torvalds1da177e2005-04-16 15:20:36 -07003472static int alc_build_pcms(struct hda_codec *codec)
3473{
3474 struct alc_spec *spec = codec->spec;
3475 struct hda_pcm *info = spec->pcm_rec;
3476 int i;
3477
3478 codec->num_pcms = 1;
3479 codec->pcm_info = info;
3480
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003481 if (spec->no_analog)
3482 goto skip_analog;
3483
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003484 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3485 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003486 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003487
Takashi Iwai4a471b72005-12-07 13:56:29 +01003488 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003489 if (snd_BUG_ON(!spec->multiout.dac_nids))
3490 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003491 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3492 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3493 }
3494 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003495 if (snd_BUG_ON(!spec->adc_nids))
3496 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003497 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3498 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3499 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003500
Takashi Iwai4a471b72005-12-07 13:56:29 +01003501 if (spec->channel_mode) {
3502 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3503 for (i = 0; i < spec->num_channel_mode; i++) {
3504 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3505 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3506 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003507 }
3508 }
3509
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003510 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003511 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003512 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003513 snprintf(spec->stream_name_digital,
3514 sizeof(spec->stream_name_digital),
3515 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003516 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003517 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003518 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003519 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003520 if (spec->dig_out_type)
3521 info->pcm_type = spec->dig_out_type;
3522 else
3523 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003524 if (spec->multiout.dig_out_nid &&
3525 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003526 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3527 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3528 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003529 if (spec->dig_in_nid &&
3530 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003531 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3532 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3533 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003534 /* FIXME: do we need this for all Realtek codec models? */
3535 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003536 }
3537
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003538 if (spec->no_analog)
3539 return 0;
3540
Takashi Iwaie08a0072006-09-07 17:52:14 +02003541 /* If the use of more than one ADC is requested for the current
3542 * model, configure a second analog capture-only PCM.
3543 */
3544 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003545 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3546 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003547 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003548 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003549 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003550 if (spec->alt_dac_nid) {
3551 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3552 *spec->stream_analog_alt_playback;
3553 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3554 spec->alt_dac_nid;
3555 } else {
3556 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3557 alc_pcm_null_stream;
3558 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3559 }
3560 if (spec->num_adc_nids > 1) {
3561 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3562 *spec->stream_analog_alt_capture;
3563 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3564 spec->adc_nids[1];
3565 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3566 spec->num_adc_nids - 1;
3567 } else {
3568 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3569 alc_pcm_null_stream;
3570 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003571 }
3572 }
3573
Linus Torvalds1da177e2005-04-16 15:20:36 -07003574 return 0;
3575}
3576
Takashi Iwai603c4012008-07-30 15:01:44 +02003577static void alc_free_kctls(struct hda_codec *codec)
3578{
3579 struct alc_spec *spec = codec->spec;
3580
3581 if (spec->kctls.list) {
3582 struct snd_kcontrol_new *kctl = spec->kctls.list;
3583 int i;
3584 for (i = 0; i < spec->kctls.used; i++)
3585 kfree(kctl[i].name);
3586 }
3587 snd_array_free(&spec->kctls);
3588}
3589
Linus Torvalds1da177e2005-04-16 15:20:36 -07003590static void alc_free(struct hda_codec *codec)
3591{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003592 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003593
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003594 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003595 return;
3596
Takashi Iwai603c4012008-07-30 15:01:44 +02003597 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003598 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003599 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003600}
3601
Takashi Iwaie044c392008-10-27 16:56:24 +01003602#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003603static int alc_resume(struct hda_codec *codec)
3604{
Takashi Iwaie044c392008-10-27 16:56:24 +01003605 codec->patch_ops.init(codec);
3606 snd_hda_codec_resume_amp(codec);
3607 snd_hda_codec_resume_cache(codec);
3608 return 0;
3609}
Takashi Iwaie044c392008-10-27 16:56:24 +01003610#endif
3611
Linus Torvalds1da177e2005-04-16 15:20:36 -07003612/*
3613 */
3614static struct hda_codec_ops alc_patch_ops = {
3615 .build_controls = alc_build_controls,
3616 .build_pcms = alc_build_pcms,
3617 .init = alc_init,
3618 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003619 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003620#ifdef SND_HDA_NEEDS_RESUME
3621 .resume = alc_resume,
3622#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003623#ifdef CONFIG_SND_HDA_POWER_SAVE
3624 .check_power_status = alc_check_power_status,
3625#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003626};
3627
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003628
3629/*
3630 * Test configuration for debugging
3631 *
3632 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3633 * enum controls.
3634 */
3635#ifdef CONFIG_SND_DEBUG
3636static hda_nid_t alc880_test_dac_nids[4] = {
3637 0x02, 0x03, 0x04, 0x05
3638};
3639
3640static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003641 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003642 .items = {
3643 { "In-1", 0x0 },
3644 { "In-2", 0x1 },
3645 { "In-3", 0x2 },
3646 { "In-4", 0x3 },
3647 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003648 { "Front", 0x5 },
3649 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003650 },
3651};
3652
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003653static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003654 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003655 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003656 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003657 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003658};
3659
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003660static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3661 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003662{
3663 static char *texts[] = {
3664 "N/A", "Line Out", "HP Out",
3665 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3666 };
3667 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3668 uinfo->count = 1;
3669 uinfo->value.enumerated.items = 8;
3670 if (uinfo->value.enumerated.item >= 8)
3671 uinfo->value.enumerated.item = 7;
3672 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3673 return 0;
3674}
3675
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003676static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3677 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003678{
3679 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3680 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3681 unsigned int pin_ctl, item = 0;
3682
3683 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3684 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3685 if (pin_ctl & AC_PINCTL_OUT_EN) {
3686 if (pin_ctl & AC_PINCTL_HP_EN)
3687 item = 2;
3688 else
3689 item = 1;
3690 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3691 switch (pin_ctl & AC_PINCTL_VREFEN) {
3692 case AC_PINCTL_VREF_HIZ: item = 3; break;
3693 case AC_PINCTL_VREF_50: item = 4; break;
3694 case AC_PINCTL_VREF_GRD: item = 5; break;
3695 case AC_PINCTL_VREF_80: item = 6; break;
3696 case AC_PINCTL_VREF_100: item = 7; break;
3697 }
3698 }
3699 ucontrol->value.enumerated.item[0] = item;
3700 return 0;
3701}
3702
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003703static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3704 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003705{
3706 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3707 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3708 static unsigned int ctls[] = {
3709 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3710 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3711 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3712 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3713 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3714 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3715 };
3716 unsigned int old_ctl, new_ctl;
3717
3718 old_ctl = snd_hda_codec_read(codec, nid, 0,
3719 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3720 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3721 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003722 int val;
3723 snd_hda_codec_write_cache(codec, nid, 0,
3724 AC_VERB_SET_PIN_WIDGET_CONTROL,
3725 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003726 val = ucontrol->value.enumerated.item[0] >= 3 ?
3727 HDA_AMP_MUTE : 0;
3728 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3729 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003730 return 1;
3731 }
3732 return 0;
3733}
3734
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003735static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3736 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003737{
3738 static char *texts[] = {
3739 "Front", "Surround", "CLFE", "Side"
3740 };
3741 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3742 uinfo->count = 1;
3743 uinfo->value.enumerated.items = 4;
3744 if (uinfo->value.enumerated.item >= 4)
3745 uinfo->value.enumerated.item = 3;
3746 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3747 return 0;
3748}
3749
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003750static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3751 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003752{
3753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3754 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3755 unsigned int sel;
3756
3757 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3758 ucontrol->value.enumerated.item[0] = sel & 3;
3759 return 0;
3760}
3761
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003762static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3763 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003764{
3765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3766 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3767 unsigned int sel;
3768
3769 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3770 if (ucontrol->value.enumerated.item[0] != sel) {
3771 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003772 snd_hda_codec_write_cache(codec, nid, 0,
3773 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003774 return 1;
3775 }
3776 return 0;
3777}
3778
3779#define PIN_CTL_TEST(xname,nid) { \
3780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3781 .name = xname, \
3782 .info = alc_test_pin_ctl_info, \
3783 .get = alc_test_pin_ctl_get, \
3784 .put = alc_test_pin_ctl_put, \
3785 .private_value = nid \
3786 }
3787
3788#define PIN_SRC_TEST(xname,nid) { \
3789 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3790 .name = xname, \
3791 .info = alc_test_pin_src_info, \
3792 .get = alc_test_pin_src_get, \
3793 .put = alc_test_pin_src_put, \
3794 .private_value = nid \
3795 }
3796
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003797static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003798 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3799 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3800 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3801 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003802 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3803 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3804 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3805 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003806 PIN_CTL_TEST("Front Pin Mode", 0x14),
3807 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3808 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3809 PIN_CTL_TEST("Side Pin Mode", 0x17),
3810 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3811 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3812 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3813 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3814 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3815 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3816 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3817 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3818 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3819 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3820 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3821 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3822 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3823 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3824 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3825 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3826 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3827 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003828 {
3829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3830 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003831 .info = alc_ch_mode_info,
3832 .get = alc_ch_mode_get,
3833 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003834 },
3835 { } /* end */
3836};
3837
3838static struct hda_verb alc880_test_init_verbs[] = {
3839 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3843 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3844 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3845 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3846 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3847 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003848 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003849 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3850 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3851 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3852 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003853 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003854 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3856 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3857 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003858 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003859 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3861 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3862 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003863 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003864 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3865 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003866 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3867 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3868 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003869 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003870 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3871 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3872 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3873 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003874 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003876 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003877 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003878 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003879 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003880 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003881 /* Analog input/passthru */
3882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3884 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003887 { }
3888};
3889#endif
3890
Linus Torvalds1da177e2005-04-16 15:20:36 -07003891/*
3892 */
3893
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003894static const char *alc880_models[ALC880_MODEL_LAST] = {
3895 [ALC880_3ST] = "3stack",
3896 [ALC880_TCL_S700] = "tcl",
3897 [ALC880_3ST_DIG] = "3stack-digout",
3898 [ALC880_CLEVO] = "clevo",
3899 [ALC880_5ST] = "5stack",
3900 [ALC880_5ST_DIG] = "5stack-digout",
3901 [ALC880_W810] = "w810",
3902 [ALC880_Z71V] = "z71v",
3903 [ALC880_6ST] = "6stack",
3904 [ALC880_6ST_DIG] = "6stack-digout",
3905 [ALC880_ASUS] = "asus",
3906 [ALC880_ASUS_W1V] = "asus-w1v",
3907 [ALC880_ASUS_DIG] = "asus-dig",
3908 [ALC880_ASUS_DIG2] = "asus-dig2",
3909 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003910 [ALC880_UNIWILL_P53] = "uniwill-p53",
3911 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003912 [ALC880_F1734] = "F1734",
3913 [ALC880_LG] = "lg",
3914 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003915 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003916#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003917 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003918#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003919 [ALC880_AUTO] = "auto",
3920};
3921
3922static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003923 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003924 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3925 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3926 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3927 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3928 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3929 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3930 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3931 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003932 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3933 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003934 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3935 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3936 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3937 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3938 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3939 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3940 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3941 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3942 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3943 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003944 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003945 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3946 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3947 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003948 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003949 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003950 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3951 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003952 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3953 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003954 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3955 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3956 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3957 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003958 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3959 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003960 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003961 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003962 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003963 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003964 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3965 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003966 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003967 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003968 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003969 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003970 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003971 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003972 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003973 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003974 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003975 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3976 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003977 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003978 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3979 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3980 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3981 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003982 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3983 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003984 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003985 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003986 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3987 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003988 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3989 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3990 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003991 /* default Intel */
3992 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003993 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3994 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003995 {}
3996};
3997
Takashi Iwai16ded522005-06-10 19:58:24 +02003998/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003999 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004000 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004001static struct alc_config_preset alc880_presets[] = {
4002 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004003 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004004 .init_verbs = { alc880_volume_init_verbs,
4005 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004006 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004007 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004008 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4009 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004010 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004011 .input_mux = &alc880_capture_source,
4012 },
4013 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004014 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004015 .init_verbs = { alc880_volume_init_verbs,
4016 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004017 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004018 .dac_nids = alc880_dac_nids,
4019 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004020 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4021 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004022 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004023 .input_mux = &alc880_capture_source,
4024 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004025 [ALC880_TCL_S700] = {
4026 .mixers = { alc880_tcl_s700_mixer },
4027 .init_verbs = { alc880_volume_init_verbs,
4028 alc880_pin_tcl_S700_init_verbs,
4029 alc880_gpio2_init_verbs },
4030 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4031 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004032 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4033 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004034 .hp_nid = 0x03,
4035 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4036 .channel_mode = alc880_2_jack_modes,
4037 .input_mux = &alc880_capture_source,
4038 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004039 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004040 .mixers = { alc880_three_stack_mixer,
4041 alc880_five_stack_mixer},
4042 .init_verbs = { alc880_volume_init_verbs,
4043 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004044 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4045 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004046 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4047 .channel_mode = alc880_fivestack_modes,
4048 .input_mux = &alc880_capture_source,
4049 },
4050 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004051 .mixers = { alc880_three_stack_mixer,
4052 alc880_five_stack_mixer },
4053 .init_verbs = { alc880_volume_init_verbs,
4054 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004055 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4056 .dac_nids = alc880_dac_nids,
4057 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004058 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4059 .channel_mode = alc880_fivestack_modes,
4060 .input_mux = &alc880_capture_source,
4061 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004062 [ALC880_6ST] = {
4063 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004064 .init_verbs = { alc880_volume_init_verbs,
4065 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004066 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4067 .dac_nids = alc880_6st_dac_nids,
4068 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4069 .channel_mode = alc880_sixstack_modes,
4070 .input_mux = &alc880_6stack_capture_source,
4071 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004072 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004073 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004074 .init_verbs = { alc880_volume_init_verbs,
4075 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004076 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4077 .dac_nids = alc880_6st_dac_nids,
4078 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004079 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4080 .channel_mode = alc880_sixstack_modes,
4081 .input_mux = &alc880_6stack_capture_source,
4082 },
4083 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004084 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004085 .init_verbs = { alc880_volume_init_verbs,
4086 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004087 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004088 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4089 .dac_nids = alc880_w810_dac_nids,
4090 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004091 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4092 .channel_mode = alc880_w810_modes,
4093 .input_mux = &alc880_capture_source,
4094 },
4095 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004096 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004097 .init_verbs = { alc880_volume_init_verbs,
4098 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004099 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4100 .dac_nids = alc880_z71v_dac_nids,
4101 .dig_out_nid = ALC880_DIGOUT_NID,
4102 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004103 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4104 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004105 .input_mux = &alc880_capture_source,
4106 },
4107 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004108 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004109 .init_verbs = { alc880_volume_init_verbs,
4110 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004111 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4112 .dac_nids = alc880_f1734_dac_nids,
4113 .hp_nid = 0x02,
4114 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4115 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004116 .input_mux = &alc880_f1734_capture_source,
4117 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004118 .setup = alc880_uniwill_p53_setup,
4119 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004120 },
4121 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004122 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004123 .init_verbs = { alc880_volume_init_verbs,
4124 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004125 alc880_gpio1_init_verbs },
4126 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4127 .dac_nids = alc880_asus_dac_nids,
4128 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4129 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004130 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004131 .input_mux = &alc880_capture_source,
4132 },
4133 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004134 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004135 .init_verbs = { alc880_volume_init_verbs,
4136 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004137 alc880_gpio1_init_verbs },
4138 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4139 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004140 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004141 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4142 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004143 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004144 .input_mux = &alc880_capture_source,
4145 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004146 [ALC880_ASUS_DIG2] = {
4147 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004148 .init_verbs = { alc880_volume_init_verbs,
4149 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004150 alc880_gpio2_init_verbs }, /* use GPIO2 */
4151 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4152 .dac_nids = alc880_asus_dac_nids,
4153 .dig_out_nid = ALC880_DIGOUT_NID,
4154 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4155 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004156 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004157 .input_mux = &alc880_capture_source,
4158 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004159 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004160 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004161 .init_verbs = { alc880_volume_init_verbs,
4162 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004163 alc880_gpio1_init_verbs },
4164 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4165 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004166 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004167 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4168 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004169 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004170 .input_mux = &alc880_capture_source,
4171 },
4172 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004173 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004174 .init_verbs = { alc880_volume_init_verbs,
4175 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004176 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4177 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004178 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004179 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4180 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004181 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004182 .input_mux = &alc880_capture_source,
4183 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004184 [ALC880_UNIWILL] = {
4185 .mixers = { alc880_uniwill_mixer },
4186 .init_verbs = { alc880_volume_init_verbs,
4187 alc880_uniwill_init_verbs },
4188 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4189 .dac_nids = alc880_asus_dac_nids,
4190 .dig_out_nid = ALC880_DIGOUT_NID,
4191 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4192 .channel_mode = alc880_threestack_modes,
4193 .need_dac_fix = 1,
4194 .input_mux = &alc880_capture_source,
4195 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004196 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004197 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004198 },
4199 [ALC880_UNIWILL_P53] = {
4200 .mixers = { alc880_uniwill_p53_mixer },
4201 .init_verbs = { alc880_volume_init_verbs,
4202 alc880_uniwill_p53_init_verbs },
4203 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4204 .dac_nids = alc880_asus_dac_nids,
4205 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004206 .channel_mode = alc880_threestack_modes,
4207 .input_mux = &alc880_capture_source,
4208 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004209 .setup = alc880_uniwill_p53_setup,
4210 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004211 },
4212 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004213 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004214 .init_verbs = { alc880_volume_init_verbs,
4215 alc880_uniwill_p53_init_verbs,
4216 alc880_beep_init_verbs },
4217 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4218 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004219 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004220 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4221 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004222 .input_mux = &alc880_capture_source,
4223 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004224 .setup = alc880_uniwill_p53_setup,
4225 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004226 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004227 [ALC880_CLEVO] = {
4228 .mixers = { alc880_three_stack_mixer },
4229 .init_verbs = { alc880_volume_init_verbs,
4230 alc880_pin_clevo_init_verbs },
4231 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4232 .dac_nids = alc880_dac_nids,
4233 .hp_nid = 0x03,
4234 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4235 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004236 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004237 .input_mux = &alc880_capture_source,
4238 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004239 [ALC880_LG] = {
4240 .mixers = { alc880_lg_mixer },
4241 .init_verbs = { alc880_volume_init_verbs,
4242 alc880_lg_init_verbs },
4243 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4244 .dac_nids = alc880_lg_dac_nids,
4245 .dig_out_nid = ALC880_DIGOUT_NID,
4246 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4247 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004248 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004249 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004250 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004251 .setup = alc880_lg_setup,
4252 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004253#ifdef CONFIG_SND_HDA_POWER_SAVE
4254 .loopbacks = alc880_lg_loopbacks,
4255#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004256 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004257 [ALC880_LG_LW] = {
4258 .mixers = { alc880_lg_lw_mixer },
4259 .init_verbs = { alc880_volume_init_verbs,
4260 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004261 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004262 .dac_nids = alc880_dac_nids,
4263 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004264 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4265 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004266 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004267 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004268 .setup = alc880_lg_lw_setup,
4269 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004270 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004271 [ALC880_MEDION_RIM] = {
4272 .mixers = { alc880_medion_rim_mixer },
4273 .init_verbs = { alc880_volume_init_verbs,
4274 alc880_medion_rim_init_verbs,
4275 alc_gpio2_init_verbs },
4276 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4277 .dac_nids = alc880_dac_nids,
4278 .dig_out_nid = ALC880_DIGOUT_NID,
4279 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4280 .channel_mode = alc880_2_jack_modes,
4281 .input_mux = &alc880_medion_rim_capture_source,
4282 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004283 .setup = alc880_medion_rim_setup,
4284 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004285 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004286#ifdef CONFIG_SND_DEBUG
4287 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004288 .mixers = { alc880_test_mixer },
4289 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004290 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4291 .dac_nids = alc880_test_dac_nids,
4292 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004293 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4294 .channel_mode = alc880_test_modes,
4295 .input_mux = &alc880_test_capture_source,
4296 },
4297#endif
4298};
4299
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004300/*
4301 * Automatic parse of I/O pins from the BIOS configuration
4302 */
4303
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004304enum {
4305 ALC_CTL_WIDGET_VOL,
4306 ALC_CTL_WIDGET_MUTE,
4307 ALC_CTL_BIND_MUTE,
4308};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004309static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004310 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4311 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004312 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004313};
4314
4315/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004316static int add_control(struct alc_spec *spec, int type, const char *name,
4317 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004318{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004319 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004320
Takashi Iwai603c4012008-07-30 15:01:44 +02004321 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4322 knew = snd_array_new(&spec->kctls);
4323 if (!knew)
4324 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004325 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004326 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004327 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004328 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004329 if (get_amp_nid_(val))
Takashi Iwai9c96fa52009-11-16 11:25:33 +01004330 knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004331 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004332 return 0;
4333}
4334
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004335static int add_control_with_pfx(struct alc_spec *spec, int type,
4336 const char *pfx, const char *dir,
4337 const char *sfx, unsigned long val)
4338{
4339 char name[32];
4340 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4341 return add_control(spec, type, name, val);
4342}
4343
4344#define add_pb_vol_ctrl(spec, type, pfx, val) \
4345 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4346#define add_pb_sw_ctrl(spec, type, pfx, val) \
4347 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4348
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004349#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4350#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4351#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4352#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004353#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4354#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4355#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4356#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4357#define ALC880_PIN_CD_NID 0x1c
4358
4359/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004360static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4361 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004362{
4363 hda_nid_t nid;
4364 int assigned[4];
4365 int i, j;
4366
4367 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004368 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004369
4370 /* check the pins hardwired to audio widget */
4371 for (i = 0; i < cfg->line_outs; i++) {
4372 nid = cfg->line_out_pins[i];
4373 if (alc880_is_fixed_pin(nid)) {
4374 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004375 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004376 assigned[idx] = 1;
4377 }
4378 }
4379 /* left pins can be connect to any audio widget */
4380 for (i = 0; i < cfg->line_outs; i++) {
4381 nid = cfg->line_out_pins[i];
4382 if (alc880_is_fixed_pin(nid))
4383 continue;
4384 /* search for an empty channel */
4385 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004386 if (!assigned[j]) {
4387 spec->multiout.dac_nids[i] =
4388 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004389 assigned[j] = 1;
4390 break;
4391 }
4392 }
4393 }
4394 spec->multiout.num_dacs = cfg->line_outs;
4395 return 0;
4396}
4397
4398/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004399static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4400 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004401{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004402 static const char *chname[4] = {
4403 "Front", "Surround", NULL /*CLFE*/, "Side"
4404 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004405 hda_nid_t nid;
4406 int i, err;
4407
4408 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004409 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004410 continue;
4411 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4412 if (i == 2) {
4413 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004414 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4415 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004416 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4417 HDA_OUTPUT));
4418 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004419 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004420 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4421 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004422 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4423 HDA_OUTPUT));
4424 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004425 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004426 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4427 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004428 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4429 HDA_INPUT));
4430 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004431 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004432 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4433 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004434 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4435 HDA_INPUT));
4436 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004437 return err;
4438 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004439 const char *pfx;
4440 if (cfg->line_outs == 1 &&
4441 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4442 pfx = "Speaker";
4443 else
4444 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004445 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004446 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4447 HDA_OUTPUT));
4448 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004450 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004451 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4452 HDA_INPUT));
4453 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004454 return err;
4455 }
4456 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457 return 0;
4458}
4459
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004460/* add playback controls for speaker and HP outputs */
4461static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4462 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004463{
4464 hda_nid_t nid;
4465 int err;
4466
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004467 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004468 return 0;
4469
4470 if (alc880_is_fixed_pin(pin)) {
4471 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004472 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004473 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004475 else
4476 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004477 /* control HP volume/switch on the output mixer amp */
4478 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004479 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004480 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4481 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004482 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004483 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004484 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4485 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004486 return err;
4487 } else if (alc880_is_multi_pin(pin)) {
4488 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004489 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004490 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004491 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4492 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004493 return err;
4494 }
4495 return 0;
4496}
4497
4498/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004499static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4500 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004501 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004502{
Kailang Yangdf694da2005-12-05 19:42:22 +01004503 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004504
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004505 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004506 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4507 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004508 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004509 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004510 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4511 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004512 return err;
4513 return 0;
4514}
4515
Takashi Iwai05f5f472009-08-25 13:10:18 +02004516static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004517{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004518 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4519 return (pincap & AC_PINCAP_IN) != 0;
4520}
4521
4522/* create playback/capture controls for input pins */
4523static int alc_auto_create_input_ctls(struct hda_codec *codec,
4524 const struct auto_pin_cfg *cfg,
4525 hda_nid_t mixer,
4526 hda_nid_t cap1, hda_nid_t cap2)
4527{
4528 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004529 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004530 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004531
4532 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004533 hda_nid_t pin;
4534
4535 pin = cfg->input_pins[i];
4536 if (!alc_is_input_pin(codec, pin))
4537 continue;
4538
4539 if (mixer) {
4540 idx = get_connection_index(codec, mixer, pin);
4541 if (idx >= 0) {
4542 err = new_analog_input(spec, pin,
4543 auto_pin_cfg_labels[i],
4544 idx, mixer);
4545 if (err < 0)
4546 return err;
4547 }
4548 }
4549
4550 if (!cap1)
4551 continue;
4552 idx = get_connection_index(codec, cap1, pin);
4553 if (idx < 0 && cap2)
4554 idx = get_connection_index(codec, cap2, pin);
4555 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004556 imux->items[imux->num_items].label =
4557 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004558 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004559 imux->num_items++;
4560 }
4561 }
4562 return 0;
4563}
4564
Takashi Iwai05f5f472009-08-25 13:10:18 +02004565static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4566 const struct auto_pin_cfg *cfg)
4567{
4568 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4569}
4570
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004571static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4572 unsigned int pin_type)
4573{
4574 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4575 pin_type);
4576 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004577 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4578 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004579}
4580
Kailang Yangdf694da2005-12-05 19:42:22 +01004581static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4582 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004583 int dac_idx)
4584{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004585 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004586 /* need the manual connection? */
4587 if (alc880_is_multi_pin(nid)) {
4588 struct alc_spec *spec = codec->spec;
4589 int idx = alc880_multi_pin_idx(nid);
4590 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4591 AC_VERB_SET_CONNECT_SEL,
4592 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4593 }
4594}
4595
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004596static int get_pin_type(int line_out_type)
4597{
4598 if (line_out_type == AUTO_PIN_HP_OUT)
4599 return PIN_HP;
4600 else
4601 return PIN_OUT;
4602}
4603
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004604static void alc880_auto_init_multi_out(struct hda_codec *codec)
4605{
4606 struct alc_spec *spec = codec->spec;
4607 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004608
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004609 for (i = 0; i < spec->autocfg.line_outs; i++) {
4610 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004611 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4612 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004613 }
4614}
4615
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004616static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004617{
4618 struct alc_spec *spec = codec->spec;
4619 hda_nid_t pin;
4620
Takashi Iwai82bc9552006-03-21 11:24:42 +01004621 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004622 if (pin) /* connect to front */
4623 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004624 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004625 if (pin) /* connect to front */
4626 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4627}
4628
4629static void alc880_auto_init_analog_input(struct hda_codec *codec)
4630{
4631 struct alc_spec *spec = codec->spec;
4632 int i;
4633
4634 for (i = 0; i < AUTO_PIN_LAST; i++) {
4635 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004636 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004637 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004638 if (nid != ALC880_PIN_CD_NID &&
4639 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004640 snd_hda_codec_write(codec, nid, 0,
4641 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004642 AMP_OUT_MUTE);
4643 }
4644 }
4645}
4646
4647/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004648/* return 1 if successful, 0 if the proper config is not found,
4649 * or a negative error code
4650 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004651static int alc880_parse_auto_config(struct hda_codec *codec)
4652{
4653 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004654 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004655 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004656
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004657 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4658 alc880_ignore);
4659 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004660 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004661 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004662 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004663
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004664 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4665 if (err < 0)
4666 return err;
4667 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4668 if (err < 0)
4669 return err;
4670 err = alc880_auto_create_extra_out(spec,
4671 spec->autocfg.speaker_pins[0],
4672 "Speaker");
4673 if (err < 0)
4674 return err;
4675 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4676 "Headphone");
4677 if (err < 0)
4678 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004679 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004680 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004681 return err;
4682
4683 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4684
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004685 /* check multiple SPDIF-out (for recent codecs) */
4686 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4687 hda_nid_t dig_nid;
4688 err = snd_hda_get_connections(codec,
4689 spec->autocfg.dig_out_pins[i],
4690 &dig_nid, 1);
4691 if (err < 0)
4692 continue;
4693 if (!i)
4694 spec->multiout.dig_out_nid = dig_nid;
4695 else {
4696 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004697 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004698 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004699 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004700 }
4701 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004702 if (spec->autocfg.dig_in_pin)
4703 spec->dig_in_nid = ALC880_DIGIN_NID;
4704
Takashi Iwai603c4012008-07-30 15:01:44 +02004705 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004706 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004707
Takashi Iwaid88897e2008-10-31 15:01:37 +01004708 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004709
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004710 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004711 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004712
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004713 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4714
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004715 return 1;
4716}
4717
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004718/* additional initialization for auto-configuration model */
4719static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004720{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004721 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004722 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004723 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004724 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004725 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004726 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004727}
4728
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004729/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4730 * one of two digital mic pins, e.g. on ALC272
4731 */
4732static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004733{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004734 struct alc_spec *spec = codec->spec;
4735 int i;
4736
4737 for (i = 0; i < spec->num_adc_nids; i++) {
4738 hda_nid_t cap = spec->capsrc_nids ?
4739 spec->capsrc_nids[i] : spec->adc_nids[i];
4740 int iidx, eidx;
4741
4742 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4743 if (iidx < 0)
4744 continue;
4745 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4746 if (eidx < 0)
4747 continue;
4748 spec->int_mic.mux_idx = iidx;
4749 spec->ext_mic.mux_idx = eidx;
4750 if (spec->capsrc_nids)
4751 spec->capsrc_nids += i;
4752 spec->adc_nids += i;
4753 spec->num_adc_nids = 1;
4754 return;
4755 }
4756 snd_printd(KERN_INFO "hda_codec: %s: "
4757 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4758 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4759 spec->auto_mic = 0; /* disable auto-mic to be sure */
4760}
4761
4762static void set_capture_mixer(struct hda_codec *codec)
4763{
4764 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004765 static struct snd_kcontrol_new *caps[2][3] = {
4766 { alc_capture_mixer_nosrc1,
4767 alc_capture_mixer_nosrc2,
4768 alc_capture_mixer_nosrc3 },
4769 { alc_capture_mixer1,
4770 alc_capture_mixer2,
4771 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004772 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004773 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4774 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004775 if (spec->auto_mic) {
4776 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004777 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004778 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004779 mux = 1;
4780 else
4781 mux = 0;
4782 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4783 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004784}
4785
Takashi Iwai67d634c2009-11-16 15:35:59 +01004786#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004787#define set_beep_amp(spec, nid, idx, dir) \
4788 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004789#else
4790#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4791#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004792
4793/*
4794 * OK, here we have finally the patch for ALC880
4795 */
4796
Linus Torvalds1da177e2005-04-16 15:20:36 -07004797static int patch_alc880(struct hda_codec *codec)
4798{
4799 struct alc_spec *spec;
4800 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004801 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004802
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004803 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004804 if (spec == NULL)
4805 return -ENOMEM;
4806
4807 codec->spec = spec;
4808
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004809 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4810 alc880_models,
4811 alc880_cfg_tbl);
4812 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004813 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4814 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004815 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004816 }
4817
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004818 if (board_config == ALC880_AUTO) {
4819 /* automatic parse from the BIOS config */
4820 err = alc880_parse_auto_config(codec);
4821 if (err < 0) {
4822 alc_free(codec);
4823 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004824 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004825 printk(KERN_INFO
4826 "hda_codec: Cannot set up configuration "
4827 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004828 board_config = ALC880_3ST;
4829 }
4830 }
4831
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004832 err = snd_hda_attach_beep_device(codec, 0x1);
4833 if (err < 0) {
4834 alc_free(codec);
4835 return err;
4836 }
4837
Kailang Yangdf694da2005-12-05 19:42:22 +01004838 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004839 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004840
Linus Torvalds1da177e2005-04-16 15:20:36 -07004841 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4842 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004843 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004844
Linus Torvalds1da177e2005-04-16 15:20:36 -07004845 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4846 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4847
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004848 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004849 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004850 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004851 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004852 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004853 if (wcap != AC_WID_AUD_IN) {
4854 spec->adc_nids = alc880_adc_nids_alt;
4855 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004856 } else {
4857 spec->adc_nids = alc880_adc_nids;
4858 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004859 }
4860 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004861 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004862 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004863
Takashi Iwai2134ea42008-01-10 16:53:55 +01004864 spec->vmaster_nid = 0x0c;
4865
Linus Torvalds1da177e2005-04-16 15:20:36 -07004866 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004867 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004868 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004869#ifdef CONFIG_SND_HDA_POWER_SAVE
4870 if (!spec->loopback.amplist)
4871 spec->loopback.amplist = alc880_loopbacks;
4872#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004873 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004874
4875 return 0;
4876}
4877
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004878
Linus Torvalds1da177e2005-04-16 15:20:36 -07004879/*
4880 * ALC260 support
4881 */
4882
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004883static hda_nid_t alc260_dac_nids[1] = {
4884 /* front */
4885 0x02,
4886};
4887
4888static hda_nid_t alc260_adc_nids[1] = {
4889 /* ADC0 */
4890 0x04,
4891};
4892
Kailang Yangdf694da2005-12-05 19:42:22 +01004893static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004894 /* ADC1 */
4895 0x05,
4896};
4897
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004898/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4899 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4900 */
4901static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004902 /* ADC0, ADC1 */
4903 0x04, 0x05
4904};
4905
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004906#define ALC260_DIGOUT_NID 0x03
4907#define ALC260_DIGIN_NID 0x06
4908
4909static struct hda_input_mux alc260_capture_source = {
4910 .num_items = 4,
4911 .items = {
4912 { "Mic", 0x0 },
4913 { "Front Mic", 0x1 },
4914 { "Line", 0x2 },
4915 { "CD", 0x4 },
4916 },
4917};
4918
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004919/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004920 * headphone jack and the internal CD lines since these are the only pins at
4921 * which audio can appear. For flexibility, also allow the option of
4922 * recording the mixer output on the second ADC (ADC0 doesn't have a
4923 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004924 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004925static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4926 {
4927 .num_items = 3,
4928 .items = {
4929 { "Mic/Line", 0x0 },
4930 { "CD", 0x4 },
4931 { "Headphone", 0x2 },
4932 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004933 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004934 {
4935 .num_items = 4,
4936 .items = {
4937 { "Mic/Line", 0x0 },
4938 { "CD", 0x4 },
4939 { "Headphone", 0x2 },
4940 { "Mixer", 0x5 },
4941 },
4942 },
4943
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004944};
4945
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004946/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4947 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004948 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004949static struct hda_input_mux alc260_acer_capture_sources[2] = {
4950 {
4951 .num_items = 4,
4952 .items = {
4953 { "Mic", 0x0 },
4954 { "Line", 0x2 },
4955 { "CD", 0x4 },
4956 { "Headphone", 0x5 },
4957 },
4958 },
4959 {
4960 .num_items = 5,
4961 .items = {
4962 { "Mic", 0x0 },
4963 { "Line", 0x2 },
4964 { "CD", 0x4 },
4965 { "Headphone", 0x6 },
4966 { "Mixer", 0x5 },
4967 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004968 },
4969};
Michael Schwingencc959482009-02-22 18:58:45 +01004970
4971/* Maxdata Favorit 100XS */
4972static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4973 {
4974 .num_items = 2,
4975 .items = {
4976 { "Line/Mic", 0x0 },
4977 { "CD", 0x4 },
4978 },
4979 },
4980 {
4981 .num_items = 3,
4982 .items = {
4983 { "Line/Mic", 0x0 },
4984 { "CD", 0x4 },
4985 { "Mixer", 0x5 },
4986 },
4987 },
4988};
4989
Linus Torvalds1da177e2005-04-16 15:20:36 -07004990/*
4991 * This is just place-holder, so there's something for alc_build_pcms to look
4992 * at when it calculates the maximum number of channels. ALC260 has no mixer
4993 * element which allows changing the channel mode, so the verb list is
4994 * never used.
4995 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004996static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004997 { 2, NULL },
4998};
4999
Kailang Yangdf694da2005-12-05 19:42:22 +01005000
5001/* Mixer combinations
5002 *
5003 * basic: base_output + input + pc_beep + capture
5004 * HP: base_output + input + capture_alt
5005 * HP_3013: hp_3013 + input + capture
5006 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005007 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005008 */
5009
5010static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005011 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005012 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005013 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5014 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5015 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5016 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5017 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005018};
Kailang Yangdf694da2005-12-05 19:42:22 +01005019
5020static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005021 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5022 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5023 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5024 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5026 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5027 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5028 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005029 { } /* end */
5030};
5031
Takashi Iwaibec15c32008-01-28 18:16:30 +01005032/* update HP, line and mono out pins according to the master switch */
5033static void alc260_hp_master_update(struct hda_codec *codec,
5034 hda_nid_t hp, hda_nid_t line,
5035 hda_nid_t mono)
5036{
5037 struct alc_spec *spec = codec->spec;
5038 unsigned int val = spec->master_sw ? PIN_HP : 0;
5039 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005040 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005041 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005042 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005043 val);
5044 /* mono (speaker) depending on the HP jack sense */
5045 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005046 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005047 val);
5048}
5049
5050static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5051 struct snd_ctl_elem_value *ucontrol)
5052{
5053 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5054 struct alc_spec *spec = codec->spec;
5055 *ucontrol->value.integer.value = spec->master_sw;
5056 return 0;
5057}
5058
5059static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5060 struct snd_ctl_elem_value *ucontrol)
5061{
5062 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5063 struct alc_spec *spec = codec->spec;
5064 int val = !!*ucontrol->value.integer.value;
5065 hda_nid_t hp, line, mono;
5066
5067 if (val == spec->master_sw)
5068 return 0;
5069 spec->master_sw = val;
5070 hp = (kcontrol->private_value >> 16) & 0xff;
5071 line = (kcontrol->private_value >> 8) & 0xff;
5072 mono = kcontrol->private_value & 0xff;
5073 alc260_hp_master_update(codec, hp, line, mono);
5074 return 1;
5075}
5076
5077static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5078 {
5079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5080 .name = "Master Playback Switch",
5081 .info = snd_ctl_boolean_mono_info,
5082 .get = alc260_hp_master_sw_get,
5083 .put = alc260_hp_master_sw_put,
5084 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5085 },
5086 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5087 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5088 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5089 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5090 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5091 HDA_OUTPUT),
5092 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5093 { } /* end */
5094};
5095
5096static struct hda_verb alc260_hp_unsol_verbs[] = {
5097 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5098 {},
5099};
5100
5101static void alc260_hp_automute(struct hda_codec *codec)
5102{
5103 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005104
Wu Fengguang864f92b2009-11-18 12:38:02 +08005105 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005106 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5107}
5108
5109static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5110{
5111 if ((res >> 26) == ALC880_HP_EVENT)
5112 alc260_hp_automute(codec);
5113}
5114
Kailang Yangdf694da2005-12-05 19:42:22 +01005115static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005116 {
5117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5118 .name = "Master Playback Switch",
5119 .info = snd_ctl_boolean_mono_info,
5120 .get = alc260_hp_master_sw_get,
5121 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005122 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005123 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005124 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5125 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5126 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5127 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5128 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5129 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005130 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5131 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005132 { } /* end */
5133};
5134
Kailang Yang3f878302008-08-26 13:02:23 +02005135static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5136 .ops = &snd_hda_bind_vol,
5137 .values = {
5138 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5139 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5140 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5141 0
5142 },
5143};
5144
5145static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5146 .ops = &snd_hda_bind_sw,
5147 .values = {
5148 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5149 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5150 0
5151 },
5152};
5153
5154static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5155 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5156 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5157 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5158 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5159 { } /* end */
5160};
5161
Takashi Iwaibec15c32008-01-28 18:16:30 +01005162static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5163 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5164 {},
5165};
5166
5167static void alc260_hp_3013_automute(struct hda_codec *codec)
5168{
5169 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005170
Wu Fengguang864f92b2009-11-18 12:38:02 +08005171 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005172 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005173}
5174
5175static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5176 unsigned int res)
5177{
5178 if ((res >> 26) == ALC880_HP_EVENT)
5179 alc260_hp_3013_automute(codec);
5180}
5181
Kailang Yang3f878302008-08-26 13:02:23 +02005182static void alc260_hp_3012_automute(struct hda_codec *codec)
5183{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005184 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005185
Kailang Yang3f878302008-08-26 13:02:23 +02005186 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5187 bits);
5188 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5189 bits);
5190 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5191 bits);
5192}
5193
5194static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5195 unsigned int res)
5196{
5197 if ((res >> 26) == ALC880_HP_EVENT)
5198 alc260_hp_3012_automute(codec);
5199}
5200
5201/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005202 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5203 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005204static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005205 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005206 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005207 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005208 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5209 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5210 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5211 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005212 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005213 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5214 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005215 { } /* end */
5216};
5217
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005218/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5219 * versions of the ALC260 don't act on requests to enable mic bias from NID
5220 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5221 * datasheet doesn't mention this restriction. At this stage it's not clear
5222 * whether this behaviour is intentional or is a hardware bug in chip
5223 * revisions available in early 2006. Therefore for now allow the
5224 * "Headphone Jack Mode" control to span all choices, but if it turns out
5225 * that the lack of mic bias for this NID is intentional we could change the
5226 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5227 *
5228 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5229 * don't appear to make the mic bias available from the "line" jack, even
5230 * though the NID used for this jack (0x14) can supply it. The theory is
5231 * that perhaps Acer have included blocking capacitors between the ALC260
5232 * and the output jack. If this turns out to be the case for all such
5233 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5234 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005235 *
5236 * The C20x Tablet series have a mono internal speaker which is controlled
5237 * via the chip's Mono sum widget and pin complex, so include the necessary
5238 * controls for such models. On models without a "mono speaker" the control
5239 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005240 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005241static struct snd_kcontrol_new alc260_acer_mixer[] = {
5242 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5243 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005244 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005245 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005246 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005247 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005248 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005249 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5250 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5252 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5253 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5254 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5255 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5256 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005257 { } /* end */
5258};
5259
Michael Schwingencc959482009-02-22 18:58:45 +01005260/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5261 */
5262static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5263 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5264 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5265 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5266 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5267 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5268 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5269 { } /* end */
5270};
5271
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005272/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5273 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5274 */
5275static struct snd_kcontrol_new alc260_will_mixer[] = {
5276 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5277 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5278 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5279 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5280 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5281 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5282 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5283 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5284 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5285 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005286 { } /* end */
5287};
5288
5289/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5290 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5291 */
5292static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5293 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5294 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5296 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5297 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5298 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5299 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5300 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5301 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5302 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5303 { } /* end */
5304};
5305
Kailang Yangdf694da2005-12-05 19:42:22 +01005306/*
5307 * initialization verbs
5308 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005309static struct hda_verb alc260_init_verbs[] = {
5310 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005311 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005312 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005313 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005314 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005315 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005316 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005317 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005318 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005319 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005320 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005321 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005322 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005323 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005324 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005325 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005326 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005327 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5328 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005329 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005330 /* set connection select to line in (default select for this ADC) */
5331 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005332 /* mute capture amp left and right */
5333 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5334 /* set connection select to line in (default select for this ADC) */
5335 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005336 /* set vol=0 Line-Out mixer amp left and right */
5337 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5338 /* unmute pin widget amp left and right (no gain on this amp) */
5339 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5340 /* set vol=0 HP mixer amp left and right */
5341 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5342 /* unmute pin widget amp left and right (no gain on this amp) */
5343 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5344 /* set vol=0 Mono mixer amp left and right */
5345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5346 /* unmute pin widget amp left and right (no gain on this amp) */
5347 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5348 /* unmute LINE-2 out pin */
5349 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005350 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5351 * Line In 2 = 0x03
5352 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005353 /* mute analog inputs */
5354 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5355 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5357 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5358 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005359 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005360 /* mute Front out path */
5361 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5362 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5363 /* mute Headphone out path */
5364 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5365 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5366 /* mute Mono out path */
5367 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5368 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005369 { }
5370};
5371
Takashi Iwai474167d2006-05-17 17:17:43 +02005372#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005373static struct hda_verb alc260_hp_init_verbs[] = {
5374 /* Headphone and output */
5375 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5376 /* mono output */
5377 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5378 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5379 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5380 /* Mic2 (front panel) pin widget for input and vref at 80% */
5381 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5382 /* Line In pin widget for input */
5383 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5384 /* Line-2 pin widget for output */
5385 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5386 /* CD pin widget for input */
5387 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5388 /* unmute amp left and right */
5389 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5390 /* set connection select to line in (default select for this ADC) */
5391 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5392 /* unmute Line-Out mixer amp left and right (volume = 0) */
5393 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5394 /* mute pin widget amp left and right (no gain on this amp) */
5395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5396 /* unmute HP mixer amp left and right (volume = 0) */
5397 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5398 /* mute pin widget amp left and right (no gain on this amp) */
5399 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005400 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5401 * Line In 2 = 0x03
5402 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005403 /* mute analog inputs */
5404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5405 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5406 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5407 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005409 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5410 /* Unmute Front out path */
5411 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5412 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5413 /* Unmute Headphone out path */
5414 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5415 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5416 /* Unmute Mono out path */
5417 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5418 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5419 { }
5420};
Takashi Iwai474167d2006-05-17 17:17:43 +02005421#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005422
5423static struct hda_verb alc260_hp_3013_init_verbs[] = {
5424 /* Line out and output */
5425 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5426 /* mono output */
5427 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5428 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5429 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5430 /* Mic2 (front panel) pin widget for input and vref at 80% */
5431 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5432 /* Line In pin widget for input */
5433 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5434 /* Headphone pin widget for output */
5435 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5436 /* CD pin widget for input */
5437 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5438 /* unmute amp left and right */
5439 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5440 /* set connection select to line in (default select for this ADC) */
5441 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5442 /* unmute Line-Out mixer amp left and right (volume = 0) */
5443 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5444 /* mute pin widget amp left and right (no gain on this amp) */
5445 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5446 /* unmute HP mixer amp left and right (volume = 0) */
5447 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5448 /* mute pin widget amp left and right (no gain on this amp) */
5449 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005450 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5451 * Line In 2 = 0x03
5452 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005453 /* mute analog inputs */
5454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005459 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5460 /* Unmute Front out path */
5461 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5463 /* Unmute Headphone out path */
5464 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5465 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5466 /* Unmute Mono out path */
5467 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5468 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5469 { }
5470};
5471
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005472/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005473 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5474 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005475 */
5476static struct hda_verb alc260_fujitsu_init_verbs[] = {
5477 /* Disable all GPIOs */
5478 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5479 /* Internal speaker is connected to headphone pin */
5480 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5481 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005483 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5484 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5485 /* Ensure all other unused pins are disabled and muted. */
5486 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5487 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005488 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005489 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005490 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005491 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5492 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5493 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005494
Jonathan Woithef7ace402006-02-28 11:46:14 +01005495 /* Disable digital (SPDIF) pins */
5496 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5497 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005498
Kailang Yangea1fb292008-08-26 12:58:38 +02005499 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005500 * when acting as an output.
5501 */
5502 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5503
5504 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005505 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5506 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5507 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5509 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5510 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5511 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5512 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5513 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005514
Jonathan Woithef7ace402006-02-28 11:46:14 +01005515 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5516 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5517 /* Unmute Line1 pin widget output buffer since it starts as an output.
5518 * If the pin mode is changed by the user the pin mode control will
5519 * take care of enabling the pin's input/output buffers as needed.
5520 * Therefore there's no need to enable the input buffer at this
5521 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005522 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005523 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005524 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005525 * mixer ctrl)
5526 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005527 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005528
Jonathan Woithef7ace402006-02-28 11:46:14 +01005529 /* Mute capture amp left and right */
5530 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005531 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005532 * in (on mic1 pin)
5533 */
5534 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005535
Jonathan Woithef7ace402006-02-28 11:46:14 +01005536 /* Do the same for the second ADC: mute capture input amp and
5537 * set ADC connection to line in (on mic1 pin)
5538 */
5539 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5540 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005541
Jonathan Woithef7ace402006-02-28 11:46:14 +01005542 /* Mute all inputs to mixer widget (even unconnected ones) */
5543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005551
5552 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005553};
5554
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005555/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5556 * similar laptops (adapted from Fujitsu init verbs).
5557 */
5558static struct hda_verb alc260_acer_init_verbs[] = {
5559 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5560 * the headphone jack. Turn this on and rely on the standard mute
5561 * methods whenever the user wants to turn these outputs off.
5562 */
5563 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5564 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5565 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5566 /* Internal speaker/Headphone jack is connected to Line-out pin */
5567 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5568 /* Internal microphone/Mic jack is connected to Mic1 pin */
5569 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5570 /* Line In jack is connected to Line1 pin */
5571 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005572 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5573 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005574 /* Ensure all other unused pins are disabled and muted. */
5575 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5576 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005577 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5578 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5579 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5580 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5581 /* Disable digital (SPDIF) pins */
5582 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5583 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5584
Kailang Yangea1fb292008-08-26 12:58:38 +02005585 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005586 * bus when acting as outputs.
5587 */
5588 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5589 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5590
5591 /* Start with output sum widgets muted and their output gains at min */
5592 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5593 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5595 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5596 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5597 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5598 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5599 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5600 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5601
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005602 /* Unmute Line-out pin widget amp left and right
5603 * (no equiv mixer ctrl)
5604 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005605 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005606 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5607 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005608 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5609 * inputs. If the pin mode is changed by the user the pin mode control
5610 * will take care of enabling the pin's input/output buffers as needed.
5611 * Therefore there's no need to enable the input buffer at this
5612 * stage.
5613 */
5614 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5615 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5616
5617 /* Mute capture amp left and right */
5618 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5619 /* Set ADC connection select to match default mixer setting - mic
5620 * (on mic1 pin)
5621 */
5622 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5623
5624 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005625 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005626 */
5627 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005628 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005629
5630 /* Mute all inputs to mixer widget (even unconnected ones) */
5631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5633 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5636 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5637 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5638 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5639
5640 { }
5641};
5642
Michael Schwingencc959482009-02-22 18:58:45 +01005643/* Initialisation sequence for Maxdata Favorit 100XS
5644 * (adapted from Acer init verbs).
5645 */
5646static struct hda_verb alc260_favorit100_init_verbs[] = {
5647 /* GPIO 0 enables the output jack.
5648 * Turn this on and rely on the standard mute
5649 * methods whenever the user wants to turn these outputs off.
5650 */
5651 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5652 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5653 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5654 /* Line/Mic input jack is connected to Mic1 pin */
5655 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5656 /* Ensure all other unused pins are disabled and muted. */
5657 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5658 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5659 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5660 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5661 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5662 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5664 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5665 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5666 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5667 /* Disable digital (SPDIF) pins */
5668 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5669 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5670
5671 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5672 * bus when acting as outputs.
5673 */
5674 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5675 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5676
5677 /* Start with output sum widgets muted and their output gains at min */
5678 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5679 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5680 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5682 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5683 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5684 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5685 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5686 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5687
5688 /* Unmute Line-out pin widget amp left and right
5689 * (no equiv mixer ctrl)
5690 */
5691 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5692 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5693 * inputs. If the pin mode is changed by the user the pin mode control
5694 * will take care of enabling the pin's input/output buffers as needed.
5695 * Therefore there's no need to enable the input buffer at this
5696 * stage.
5697 */
5698 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5699
5700 /* Mute capture amp left and right */
5701 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5702 /* Set ADC connection select to match default mixer setting - mic
5703 * (on mic1 pin)
5704 */
5705 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5706
5707 /* Do similar with the second ADC: mute capture input amp and
5708 * set ADC connection to mic to match ALSA's default state.
5709 */
5710 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5711 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5712
5713 /* Mute all inputs to mixer widget (even unconnected ones) */
5714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5717 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5718 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5719 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5720 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5721 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5722
5723 { }
5724};
5725
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005726static struct hda_verb alc260_will_verbs[] = {
5727 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5728 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5729 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5730 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5731 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5732 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5733 {}
5734};
5735
5736static struct hda_verb alc260_replacer_672v_verbs[] = {
5737 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5738 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5739 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5740
5741 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5742 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5743 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5744
5745 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5746 {}
5747};
5748
5749/* toggle speaker-output according to the hp-jack state */
5750static void alc260_replacer_672v_automute(struct hda_codec *codec)
5751{
5752 unsigned int present;
5753
5754 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005755 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005756 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005757 snd_hda_codec_write_cache(codec, 0x01, 0,
5758 AC_VERB_SET_GPIO_DATA, 1);
5759 snd_hda_codec_write_cache(codec, 0x0f, 0,
5760 AC_VERB_SET_PIN_WIDGET_CONTROL,
5761 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005762 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005763 snd_hda_codec_write_cache(codec, 0x01, 0,
5764 AC_VERB_SET_GPIO_DATA, 0);
5765 snd_hda_codec_write_cache(codec, 0x0f, 0,
5766 AC_VERB_SET_PIN_WIDGET_CONTROL,
5767 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005768 }
5769}
5770
5771static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5772 unsigned int res)
5773{
5774 if ((res >> 26) == ALC880_HP_EVENT)
5775 alc260_replacer_672v_automute(codec);
5776}
5777
Kailang Yang3f878302008-08-26 13:02:23 +02005778static struct hda_verb alc260_hp_dc7600_verbs[] = {
5779 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5780 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5781 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5782 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5783 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5784 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5785 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5786 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5787 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5788 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5789 {}
5790};
5791
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005792/* Test configuration for debugging, modelled after the ALC880 test
5793 * configuration.
5794 */
5795#ifdef CONFIG_SND_DEBUG
5796static hda_nid_t alc260_test_dac_nids[1] = {
5797 0x02,
5798};
5799static hda_nid_t alc260_test_adc_nids[2] = {
5800 0x04, 0x05,
5801};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005802/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005803 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005804 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005805 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005806static struct hda_input_mux alc260_test_capture_sources[2] = {
5807 {
5808 .num_items = 7,
5809 .items = {
5810 { "MIC1 pin", 0x0 },
5811 { "MIC2 pin", 0x1 },
5812 { "LINE1 pin", 0x2 },
5813 { "LINE2 pin", 0x3 },
5814 { "CD pin", 0x4 },
5815 { "LINE-OUT pin", 0x5 },
5816 { "HP-OUT pin", 0x6 },
5817 },
5818 },
5819 {
5820 .num_items = 8,
5821 .items = {
5822 { "MIC1 pin", 0x0 },
5823 { "MIC2 pin", 0x1 },
5824 { "LINE1 pin", 0x2 },
5825 { "LINE2 pin", 0x3 },
5826 { "CD pin", 0x4 },
5827 { "Mixer", 0x5 },
5828 { "LINE-OUT pin", 0x6 },
5829 { "HP-OUT pin", 0x7 },
5830 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005831 },
5832};
5833static struct snd_kcontrol_new alc260_test_mixer[] = {
5834 /* Output driver widgets */
5835 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5836 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5837 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5838 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5839 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5840 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5841
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005842 /* Modes for retasking pin widgets
5843 * Note: the ALC260 doesn't seem to act on requests to enable mic
5844 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5845 * mention this restriction. At this stage it's not clear whether
5846 * this behaviour is intentional or is a hardware bug in chip
5847 * revisions available at least up until early 2006. Therefore for
5848 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5849 * choices, but if it turns out that the lack of mic bias for these
5850 * NIDs is intentional we could change their modes from
5851 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5852 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005853 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5854 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5855 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5856 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5857 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5858 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5859
5860 /* Loopback mixer controls */
5861 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5862 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5863 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5864 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5865 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5866 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5867 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5868 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5869 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5870 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005871 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5872 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5873 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5874 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005875
5876 /* Controls for GPIO pins, assuming they are configured as outputs */
5877 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5878 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5879 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5880 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5881
Jonathan Woithe92621f12006-02-28 11:47:47 +01005882 /* Switches to allow the digital IO pins to be enabled. The datasheet
5883 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005884 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005885 */
5886 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5887 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5888
Jonathan Woithef8225f62008-01-08 12:16:54 +01005889 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5890 * this output to turn on an external amplifier.
5891 */
5892 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5893 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5894
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005895 { } /* end */
5896};
5897static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005898 /* Enable all GPIOs as outputs with an initial value of 0 */
5899 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5900 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5901 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5902
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005903 /* Enable retasking pins as output, initially without power amp */
5904 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5905 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5906 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5908 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5909 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5910
Jonathan Woithe92621f12006-02-28 11:47:47 +01005911 /* Disable digital (SPDIF) pins initially, but users can enable
5912 * them via a mixer switch. In the case of SPDIF-out, this initverb
5913 * payload also sets the generation to 0, output to be in "consumer"
5914 * PCM format, copyright asserted, no pre-emphasis and no validity
5915 * control.
5916 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005917 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5918 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5919
Kailang Yangea1fb292008-08-26 12:58:38 +02005920 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005921 * OUT1 sum bus when acting as an output.
5922 */
5923 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5924 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5925 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5926 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5927
5928 /* Start with output sum widgets muted and their output gains at min */
5929 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5930 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5931 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5932 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5933 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5934 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5935 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5936 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5937 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5938
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005939 /* Unmute retasking pin widget output buffers since the default
5940 * state appears to be output. As the pin mode is changed by the
5941 * user the pin mode control will take care of enabling the pin's
5942 * input/output buffers as needed.
5943 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005944 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5945 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5946 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5947 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5948 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5949 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5950 /* Also unmute the mono-out pin widget */
5951 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5952
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005953 /* Mute capture amp left and right */
5954 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005955 /* Set ADC connection select to match default mixer setting (mic1
5956 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005957 */
5958 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5959
5960 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005961 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005962 */
5963 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5964 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5965
5966 /* Mute all inputs to mixer widget (even unconnected ones) */
5967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5974 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5975
5976 { }
5977};
5978#endif
5979
Takashi Iwai63300792008-01-24 15:31:36 +01005980#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5981#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005982
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005983#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5984#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5985
Kailang Yangdf694da2005-12-05 19:42:22 +01005986/*
5987 * for BIOS auto-configuration
5988 */
5989
5990static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005991 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005992{
5993 hda_nid_t nid_vol;
5994 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01005995 int err;
5996
5997 if (nid >= 0x0f && nid < 0x11) {
5998 nid_vol = nid - 0x7;
5999 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6000 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6001 } else if (nid == 0x11) {
6002 nid_vol = nid - 0x7;
6003 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6004 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6005 } else if (nid >= 0x12 && nid <= 0x15) {
6006 nid_vol = 0x08;
6007 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6008 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6009 } else
6010 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006011
Takashi Iwai863b4512008-10-21 17:01:47 +02006012 if (!(*vol_bits & (1 << nid_vol))) {
6013 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006014 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006015 if (err < 0)
6016 return err;
6017 *vol_bits |= (1 << nid_vol);
6018 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006019 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006020 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006021 return err;
6022 return 1;
6023}
6024
6025/* add playback controls from the parsed DAC table */
6026static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6027 const struct auto_pin_cfg *cfg)
6028{
6029 hda_nid_t nid;
6030 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006031 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006032
6033 spec->multiout.num_dacs = 1;
6034 spec->multiout.dac_nids = spec->private_dac_nids;
6035 spec->multiout.dac_nids[0] = 0x02;
6036
6037 nid = cfg->line_out_pins[0];
6038 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006039 const char *pfx;
6040 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6041 pfx = "Master";
6042 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6043 pfx = "Speaker";
6044 else
6045 pfx = "Front";
6046 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006047 if (err < 0)
6048 return err;
6049 }
6050
Takashi Iwai82bc9552006-03-21 11:24:42 +01006051 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006052 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006053 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006054 if (err < 0)
6055 return err;
6056 }
6057
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006058 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006059 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006060 err = alc260_add_playback_controls(spec, nid, "Headphone",
6061 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006062 if (err < 0)
6063 return err;
6064 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006065 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006066}
6067
6068/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006069static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006070 const struct auto_pin_cfg *cfg)
6071{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006072 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006073}
6074
6075static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6076 hda_nid_t nid, int pin_type,
6077 int sel_idx)
6078{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006079 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006080 /* need the manual connection? */
6081 if (nid >= 0x12) {
6082 int idx = nid - 0x12;
6083 snd_hda_codec_write(codec, idx + 0x0b, 0,
6084 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006085 }
6086}
6087
6088static void alc260_auto_init_multi_out(struct hda_codec *codec)
6089{
6090 struct alc_spec *spec = codec->spec;
6091 hda_nid_t nid;
6092
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006093 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006094 if (nid) {
6095 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6096 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6097 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006098
Takashi Iwai82bc9552006-03-21 11:24:42 +01006099 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006100 if (nid)
6101 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6102
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006103 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006104 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006105 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006106}
Kailang Yangdf694da2005-12-05 19:42:22 +01006107
6108#define ALC260_PIN_CD_NID 0x16
6109static void alc260_auto_init_analog_input(struct hda_codec *codec)
6110{
6111 struct alc_spec *spec = codec->spec;
6112 int i;
6113
6114 for (i = 0; i < AUTO_PIN_LAST; i++) {
6115 hda_nid_t nid = spec->autocfg.input_pins[i];
6116 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006117 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006118 if (nid != ALC260_PIN_CD_NID &&
6119 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006120 snd_hda_codec_write(codec, nid, 0,
6121 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006122 AMP_OUT_MUTE);
6123 }
6124 }
6125}
6126
6127/*
6128 * generic initialization of ADC, input mixers and output mixers
6129 */
6130static struct hda_verb alc260_volume_init_verbs[] = {
6131 /*
6132 * Unmute ADC0-1 and set the default input to mic-in
6133 */
6134 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6135 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6136 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6137 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006138
Kailang Yangdf694da2005-12-05 19:42:22 +01006139 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6140 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006141 * Note: PASD motherboards uses the Line In 2 as the input for
6142 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006143 */
6144 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006145 /* mute analog inputs */
6146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006151
6152 /*
6153 * Set up output mixers (0x08 - 0x0a)
6154 */
6155 /* set vol=0 to output mixers */
6156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6157 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6158 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6159 /* set up input amps for analog loopback */
6160 /* Amp Indices: DAC = 0, mixer = 1 */
6161 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6162 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6163 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6164 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6165 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6166 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006167
Kailang Yangdf694da2005-12-05 19:42:22 +01006168 { }
6169};
6170
6171static int alc260_parse_auto_config(struct hda_codec *codec)
6172{
6173 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006174 int err;
6175 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6176
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006177 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6178 alc260_ignore);
6179 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006180 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006181 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6182 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006183 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006184 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006185 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006186 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006187 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006188 return err;
6189
6190 spec->multiout.max_channels = 2;
6191
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006192 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006193 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006194 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006195 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006196
Takashi Iwaid88897e2008-10-31 15:01:37 +01006197 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006198
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006199 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006200 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006201
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006202 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6203
Kailang Yangdf694da2005-12-05 19:42:22 +01006204 return 1;
6205}
6206
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006207/* additional initialization for auto-configuration model */
6208static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006209{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006210 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006211 alc260_auto_init_multi_out(codec);
6212 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006213 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006214 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006215}
6216
Takashi Iwaicb53c622007-08-10 17:21:45 +02006217#ifdef CONFIG_SND_HDA_POWER_SAVE
6218static struct hda_amp_list alc260_loopbacks[] = {
6219 { 0x07, HDA_INPUT, 0 },
6220 { 0x07, HDA_INPUT, 1 },
6221 { 0x07, HDA_INPUT, 2 },
6222 { 0x07, HDA_INPUT, 3 },
6223 { 0x07, HDA_INPUT, 4 },
6224 { } /* end */
6225};
6226#endif
6227
Kailang Yangdf694da2005-12-05 19:42:22 +01006228/*
6229 * ALC260 configurations
6230 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006231static const char *alc260_models[ALC260_MODEL_LAST] = {
6232 [ALC260_BASIC] = "basic",
6233 [ALC260_HP] = "hp",
6234 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006235 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006236 [ALC260_FUJITSU_S702X] = "fujitsu",
6237 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006238 [ALC260_WILL] = "will",
6239 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006240 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006241#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006242 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006243#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006244 [ALC260_AUTO] = "auto",
6245};
6246
6247static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006248 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006249 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006250 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006251 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006252 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006253 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006254 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006255 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006256 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6257 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6258 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6259 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6260 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6261 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6262 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6263 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6264 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006265 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006266 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006267 {}
6268};
6269
Kailang Yangdf694da2005-12-05 19:42:22 +01006270static struct alc_config_preset alc260_presets[] = {
6271 [ALC260_BASIC] = {
6272 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006273 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006274 .init_verbs = { alc260_init_verbs },
6275 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6276 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006277 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006278 .adc_nids = alc260_adc_nids,
6279 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6280 .channel_mode = alc260_modes,
6281 .input_mux = &alc260_capture_source,
6282 },
6283 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006284 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006285 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006286 .init_verbs = { alc260_init_verbs,
6287 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006288 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6289 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006290 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6291 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006292 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6293 .channel_mode = alc260_modes,
6294 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006295 .unsol_event = alc260_hp_unsol_event,
6296 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006297 },
Kailang Yang3f878302008-08-26 13:02:23 +02006298 [ALC260_HP_DC7600] = {
6299 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006300 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006301 .init_verbs = { alc260_init_verbs,
6302 alc260_hp_dc7600_verbs },
6303 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6304 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006305 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6306 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006307 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6308 .channel_mode = alc260_modes,
6309 .input_mux = &alc260_capture_source,
6310 .unsol_event = alc260_hp_3012_unsol_event,
6311 .init_hook = alc260_hp_3012_automute,
6312 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006313 [ALC260_HP_3013] = {
6314 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006315 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006316 .init_verbs = { alc260_hp_3013_init_verbs,
6317 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006318 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6319 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006320 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6321 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006322 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6323 .channel_mode = alc260_modes,
6324 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006325 .unsol_event = alc260_hp_3013_unsol_event,
6326 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006327 },
6328 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006329 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006330 .init_verbs = { alc260_fujitsu_init_verbs },
6331 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6332 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006333 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6334 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006335 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6336 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006337 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6338 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006339 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006340 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006341 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006342 .init_verbs = { alc260_acer_init_verbs },
6343 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6344 .dac_nids = alc260_dac_nids,
6345 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6346 .adc_nids = alc260_dual_adc_nids,
6347 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6348 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006349 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6350 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006351 },
Michael Schwingencc959482009-02-22 18:58:45 +01006352 [ALC260_FAVORIT100] = {
6353 .mixers = { alc260_favorit100_mixer },
6354 .init_verbs = { alc260_favorit100_init_verbs },
6355 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6356 .dac_nids = alc260_dac_nids,
6357 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6358 .adc_nids = alc260_dual_adc_nids,
6359 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6360 .channel_mode = alc260_modes,
6361 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6362 .input_mux = alc260_favorit100_capture_sources,
6363 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006364 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006365 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006366 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6367 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6368 .dac_nids = alc260_dac_nids,
6369 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6370 .adc_nids = alc260_adc_nids,
6371 .dig_out_nid = ALC260_DIGOUT_NID,
6372 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6373 .channel_mode = alc260_modes,
6374 .input_mux = &alc260_capture_source,
6375 },
6376 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006377 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006378 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6379 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6380 .dac_nids = alc260_dac_nids,
6381 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6382 .adc_nids = alc260_adc_nids,
6383 .dig_out_nid = ALC260_DIGOUT_NID,
6384 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6385 .channel_mode = alc260_modes,
6386 .input_mux = &alc260_capture_source,
6387 .unsol_event = alc260_replacer_672v_unsol_event,
6388 .init_hook = alc260_replacer_672v_automute,
6389 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006390#ifdef CONFIG_SND_DEBUG
6391 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006392 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006393 .init_verbs = { alc260_test_init_verbs },
6394 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6395 .dac_nids = alc260_test_dac_nids,
6396 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6397 .adc_nids = alc260_test_adc_nids,
6398 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6399 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006400 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6401 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006402 },
6403#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006404};
6405
Linus Torvalds1da177e2005-04-16 15:20:36 -07006406static int patch_alc260(struct hda_codec *codec)
6407{
6408 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006409 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006410
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006411 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006412 if (spec == NULL)
6413 return -ENOMEM;
6414
6415 codec->spec = spec;
6416
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006417 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6418 alc260_models,
6419 alc260_cfg_tbl);
6420 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006421 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006422 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006423 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006424 }
6425
Kailang Yangdf694da2005-12-05 19:42:22 +01006426 if (board_config == ALC260_AUTO) {
6427 /* automatic parse from the BIOS config */
6428 err = alc260_parse_auto_config(codec);
6429 if (err < 0) {
6430 alc_free(codec);
6431 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006432 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006433 printk(KERN_INFO
6434 "hda_codec: Cannot set up configuration "
6435 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006436 board_config = ALC260_BASIC;
6437 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006438 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006439
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006440 err = snd_hda_attach_beep_device(codec, 0x1);
6441 if (err < 0) {
6442 alc_free(codec);
6443 return err;
6444 }
6445
Kailang Yangdf694da2005-12-05 19:42:22 +01006446 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006447 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006448
Linus Torvalds1da177e2005-04-16 15:20:36 -07006449 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6450 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6451
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006452 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6453 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6454
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006455 if (!spec->adc_nids && spec->input_mux) {
6456 /* check whether NID 0x04 is valid */
6457 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006458 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006459 /* get type */
6460 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6461 spec->adc_nids = alc260_adc_nids_alt;
6462 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6463 } else {
6464 spec->adc_nids = alc260_adc_nids;
6465 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6466 }
6467 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006468 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006469 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006470
Takashi Iwai2134ea42008-01-10 16:53:55 +01006471 spec->vmaster_nid = 0x08;
6472
Linus Torvalds1da177e2005-04-16 15:20:36 -07006473 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006474 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006475 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006476#ifdef CONFIG_SND_HDA_POWER_SAVE
6477 if (!spec->loopback.amplist)
6478 spec->loopback.amplist = alc260_loopbacks;
6479#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006480 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006481
6482 return 0;
6483}
6484
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006485
Linus Torvalds1da177e2005-04-16 15:20:36 -07006486/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006487 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006488 *
6489 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6490 * configuration. Each pin widget can choose any input DACs and a mixer.
6491 * Each ADC is connected from a mixer of all inputs. This makes possible
6492 * 6-channel independent captures.
6493 *
6494 * In addition, an independent DAC for the multi-playback (not used in this
6495 * driver yet).
6496 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006497#define ALC882_DIGOUT_NID 0x06
6498#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006499#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6500#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6501#define ALC1200_DIGOUT_NID 0x10
6502
Linus Torvalds1da177e2005-04-16 15:20:36 -07006503
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006504static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006505 { 8, NULL }
6506};
6507
Takashi Iwai4953550a2009-06-30 15:28:30 +02006508/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006509static hda_nid_t alc882_dac_nids[4] = {
6510 /* front, rear, clfe, rear_surr */
6511 0x02, 0x03, 0x04, 0x05
6512};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006513#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006514
Takashi Iwai4953550a2009-06-30 15:28:30 +02006515/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006516#define alc882_adc_nids alc880_adc_nids
6517#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006518#define alc883_adc_nids alc882_adc_nids_alt
6519static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6520static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6521#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006522
Takashi Iwaie1406342008-02-11 18:32:32 +01006523static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6524static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006525#define alc883_capsrc_nids alc882_capsrc_nids_alt
6526static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6527#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006528
Linus Torvalds1da177e2005-04-16 15:20:36 -07006529/* input MUX */
6530/* FIXME: should be a matrix-type input source selection */
6531
6532static struct hda_input_mux alc882_capture_source = {
6533 .num_items = 4,
6534 .items = {
6535 { "Mic", 0x0 },
6536 { "Front Mic", 0x1 },
6537 { "Line", 0x2 },
6538 { "CD", 0x4 },
6539 },
6540};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006541
Takashi Iwai4953550a2009-06-30 15:28:30 +02006542#define alc883_capture_source alc882_capture_source
6543
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006544static struct hda_input_mux alc889_capture_source = {
6545 .num_items = 3,
6546 .items = {
6547 { "Front Mic", 0x0 },
6548 { "Mic", 0x3 },
6549 { "Line", 0x2 },
6550 },
6551};
6552
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006553static struct hda_input_mux mb5_capture_source = {
6554 .num_items = 3,
6555 .items = {
6556 { "Mic", 0x1 },
6557 { "Line", 0x2 },
6558 { "CD", 0x4 },
6559 },
6560};
6561
Takashi Iwai4953550a2009-06-30 15:28:30 +02006562static struct hda_input_mux alc883_3stack_6ch_intel = {
6563 .num_items = 4,
6564 .items = {
6565 { "Mic", 0x1 },
6566 { "Front Mic", 0x0 },
6567 { "Line", 0x2 },
6568 { "CD", 0x4 },
6569 },
6570};
6571
6572static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6573 .num_items = 2,
6574 .items = {
6575 { "Mic", 0x1 },
6576 { "Line", 0x2 },
6577 },
6578};
6579
6580static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6581 .num_items = 4,
6582 .items = {
6583 { "Mic", 0x0 },
6584 { "iMic", 0x1 },
6585 { "Line", 0x2 },
6586 { "CD", 0x4 },
6587 },
6588};
6589
6590static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6591 .num_items = 2,
6592 .items = {
6593 { "Mic", 0x0 },
6594 { "Int Mic", 0x1 },
6595 },
6596};
6597
6598static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6599 .num_items = 3,
6600 .items = {
6601 { "Mic", 0x0 },
6602 { "Front Mic", 0x1 },
6603 { "Line", 0x4 },
6604 },
6605};
6606
6607static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6608 .num_items = 2,
6609 .items = {
6610 { "Mic", 0x0 },
6611 { "Line", 0x2 },
6612 },
6613};
6614
6615static struct hda_input_mux alc889A_mb31_capture_source = {
6616 .num_items = 2,
6617 .items = {
6618 { "Mic", 0x0 },
6619 /* Front Mic (0x01) unused */
6620 { "Line", 0x2 },
6621 /* Line 2 (0x03) unused */
6622 /* CD (0x04) unsused? */
6623 },
6624};
6625
6626/*
6627 * 2ch mode
6628 */
6629static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6630 { 2, NULL }
6631};
6632
Kailang Yangdf694da2005-12-05 19:42:22 +01006633/*
Kailang Yang272a5272007-05-14 11:00:38 +02006634 * 2ch mode
6635 */
6636static struct hda_verb alc882_3ST_ch2_init[] = {
6637 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6638 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6639 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6640 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6641 { } /* end */
6642};
6643
6644/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006645 * 4ch mode
6646 */
6647static struct hda_verb alc882_3ST_ch4_init[] = {
6648 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6649 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6650 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6651 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6652 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6653 { } /* end */
6654};
6655
6656/*
Kailang Yang272a5272007-05-14 11:00:38 +02006657 * 6ch mode
6658 */
6659static struct hda_verb alc882_3ST_ch6_init[] = {
6660 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6661 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6662 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6663 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6664 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6665 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6666 { } /* end */
6667};
6668
Takashi Iwai4953550a2009-06-30 15:28:30 +02006669static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006670 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006671 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006672 { 6, alc882_3ST_ch6_init },
6673};
6674
Takashi Iwai4953550a2009-06-30 15:28:30 +02006675#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6676
Kailang Yang272a5272007-05-14 11:00:38 +02006677/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306678 * 2ch mode
6679 */
6680static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6681 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6682 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6683 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6684 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6685 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6686 { } /* end */
6687};
6688
6689/*
6690 * 4ch mode
6691 */
6692static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6693 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6694 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6695 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6696 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6697 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6698 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6699 { } /* end */
6700};
6701
6702/*
6703 * 6ch mode
6704 */
6705static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6706 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6707 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6708 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6709 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6710 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6711 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6712 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6713 { } /* end */
6714};
6715
6716static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6717 { 2, alc883_3ST_ch2_clevo_init },
6718 { 4, alc883_3ST_ch4_clevo_init },
6719 { 6, alc883_3ST_ch6_clevo_init },
6720};
6721
6722
6723/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006724 * 6ch mode
6725 */
6726static struct hda_verb alc882_sixstack_ch6_init[] = {
6727 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6728 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6729 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6730 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6731 { } /* end */
6732};
6733
6734/*
6735 * 8ch mode
6736 */
6737static struct hda_verb alc882_sixstack_ch8_init[] = {
6738 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6739 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6740 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6741 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6742 { } /* end */
6743};
6744
6745static struct hda_channel_mode alc882_sixstack_modes[2] = {
6746 { 6, alc882_sixstack_ch6_init },
6747 { 8, alc882_sixstack_ch8_init },
6748};
6749
Takashi Iwai87350ad2007-08-16 18:19:38 +02006750/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006751 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006752 */
6753
6754/*
6755 * 2ch mode
6756 */
6757static struct hda_verb alc885_mbp_ch2_init[] = {
6758 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6759 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6760 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6761 { } /* end */
6762};
6763
6764/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006765 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006766 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006767static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006768 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6769 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6770 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6771 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6772 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6773 { } /* end */
6774};
6775
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006776static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006777 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006778 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006779};
6780
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006781/*
6782 * 2ch
6783 * Speakers/Woofer/HP = Front
6784 * LineIn = Input
6785 */
6786static struct hda_verb alc885_mb5_ch2_init[] = {
6787 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6789 { } /* end */
6790};
6791
6792/*
6793 * 6ch mode
6794 * Speakers/HP = Front
6795 * Woofer = LFE
6796 * LineIn = Surround
6797 */
6798static struct hda_verb alc885_mb5_ch6_init[] = {
6799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6801 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6802 { } /* end */
6803};
6804
6805static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6806 { 2, alc885_mb5_ch2_init },
6807 { 6, alc885_mb5_ch6_init },
6808};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006809
Takashi Iwai4953550a2009-06-30 15:28:30 +02006810
6811/*
6812 * 2ch mode
6813 */
6814static struct hda_verb alc883_4ST_ch2_init[] = {
6815 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6816 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6817 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6818 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6819 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6820 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6821 { } /* end */
6822};
6823
6824/*
6825 * 4ch mode
6826 */
6827static struct hda_verb alc883_4ST_ch4_init[] = {
6828 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6829 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6830 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6831 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6832 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6833 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6834 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6835 { } /* end */
6836};
6837
6838/*
6839 * 6ch mode
6840 */
6841static struct hda_verb alc883_4ST_ch6_init[] = {
6842 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6843 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6844 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6845 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6846 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6847 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6848 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6849 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6850 { } /* end */
6851};
6852
6853/*
6854 * 8ch mode
6855 */
6856static struct hda_verb alc883_4ST_ch8_init[] = {
6857 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6858 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6859 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6860 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6861 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6862 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6865 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6866 { } /* end */
6867};
6868
6869static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6870 { 2, alc883_4ST_ch2_init },
6871 { 4, alc883_4ST_ch4_init },
6872 { 6, alc883_4ST_ch6_init },
6873 { 8, alc883_4ST_ch8_init },
6874};
6875
6876
6877/*
6878 * 2ch mode
6879 */
6880static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6881 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6882 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6883 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6884 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6885 { } /* end */
6886};
6887
6888/*
6889 * 4ch mode
6890 */
6891static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6892 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6893 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6894 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6895 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6896 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6897 { } /* end */
6898};
6899
6900/*
6901 * 6ch mode
6902 */
6903static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6904 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6905 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6906 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6907 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6908 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6909 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6910 { } /* end */
6911};
6912
6913static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6914 { 2, alc883_3ST_ch2_intel_init },
6915 { 4, alc883_3ST_ch4_intel_init },
6916 { 6, alc883_3ST_ch6_intel_init },
6917};
6918
6919/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006920 * 2ch mode
6921 */
6922static struct hda_verb alc889_ch2_intel_init[] = {
6923 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6924 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6925 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6926 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6927 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6928 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6929 { } /* end */
6930};
6931
6932/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006933 * 6ch mode
6934 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006935static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006936 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6937 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6938 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6939 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6940 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006941 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6942 { } /* end */
6943};
6944
6945/*
6946 * 8ch mode
6947 */
6948static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006949 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6950 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6951 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6952 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6953 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006954 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6955 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006956 { } /* end */
6957};
6958
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006959static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6960 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006961 { 6, alc889_ch6_intel_init },
6962 { 8, alc889_ch8_intel_init },
6963};
6964
6965/*
6966 * 6ch mode
6967 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006968static struct hda_verb alc883_sixstack_ch6_init[] = {
6969 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6970 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6971 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6972 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6973 { } /* end */
6974};
6975
6976/*
6977 * 8ch mode
6978 */
6979static struct hda_verb alc883_sixstack_ch8_init[] = {
6980 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6981 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6982 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6983 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6984 { } /* end */
6985};
6986
6987static struct hda_channel_mode alc883_sixstack_modes[2] = {
6988 { 6, alc883_sixstack_ch6_init },
6989 { 8, alc883_sixstack_ch8_init },
6990};
6991
6992
Linus Torvalds1da177e2005-04-16 15:20:36 -07006993/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6994 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6995 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006996static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006997 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006998 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006999 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007000 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007001 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7002 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007003 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7004 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007005 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007006 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007007 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7009 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7011 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007013 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7015 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007016 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007018 { } /* end */
7019};
7020
Takashi Iwai87350ad2007-08-16 18:19:38 +02007021static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007022 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7023 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7025 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7026 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7028 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7030 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007031 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007032 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7033 { } /* end */
7034};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007035
7036static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7038 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7039 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7040 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7041 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7042 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7043 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7044 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7046 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7048 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7049 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7050 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7051 { } /* end */
7052};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007053
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007054static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7055 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7056 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7057 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7058 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7060 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7062 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7063 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7064 { } /* end */
7065};
7066
7067
Kailang Yangbdd148a2007-05-08 15:19:08 +02007068static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7069 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7070 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7071 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7072 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7073 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7074 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7076 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007078 { } /* end */
7079};
7080
Kailang Yang272a5272007-05-14 11:00:38 +02007081static struct snd_kcontrol_new alc882_targa_mixer[] = {
7082 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7083 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7084 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7085 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7086 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7087 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7088 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7089 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7090 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007091 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007092 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7093 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007094 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007095 { } /* end */
7096};
7097
7098/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7099 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7100 */
7101static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7102 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7103 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7104 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7105 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7108 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7109 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7110 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7111 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007114 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007115 { } /* end */
7116};
7117
Takashi Iwai914759b2007-09-06 14:52:04 +02007118static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7119 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7120 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7124 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7125 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7126 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7127 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7128 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007129 { } /* end */
7130};
7131
Kailang Yangdf694da2005-12-05 19:42:22 +01007132static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7133 {
7134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7135 .name = "Channel Mode",
7136 .info = alc_ch_mode_info,
7137 .get = alc_ch_mode_get,
7138 .put = alc_ch_mode_put,
7139 },
7140 { } /* end */
7141};
7142
Takashi Iwai4953550a2009-06-30 15:28:30 +02007143static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007144 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007148 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007149 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7150 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7151 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007152 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007153 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7154 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7155 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007156 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007157 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7158 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7159 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007160
Takashi Iwaicb638122009-07-03 10:56:10 +02007161 /* mute analog input loopbacks */
7162 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7163 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7164 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7165 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7166 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7167
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007168 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007169 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007170 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007171 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007172 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007173 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007174 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007175 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007176 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007177 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007178 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007179 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007180 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007181 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007182 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007183 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007184 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007185 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007186 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7187 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007188 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007189 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7190 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007191 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007192 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7193 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7194 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7195 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7196 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007197 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007198 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007199
7200 /* FIXME: use matrix-type input source selection */
7201 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007202 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007203 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7204 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7205 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7206 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007207 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7209 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7210 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007212 /* ADC2: mute amp left and right */
7213 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007214 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007215 /* ADC3: mute amp left and right */
7216 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007217 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007218
7219 { }
7220};
7221
Takashi Iwai4953550a2009-06-30 15:28:30 +02007222static struct hda_verb alc882_adc1_init_verbs[] = {
7223 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7224 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7225 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7226 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7228 /* ADC1: mute amp left and right */
7229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7230 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7231 { }
7232};
7233
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007234static struct hda_verb alc882_eapd_verbs[] = {
7235 /* change to EAPD mode */
7236 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007237 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007238 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007239};
7240
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007241static struct hda_verb alc889_eapd_verbs[] = {
7242 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7243 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7244 { }
7245};
7246
Wu Fengguang6732bd02009-07-30 09:19:14 +02007247static struct hda_verb alc_hp15_unsol_verbs[] = {
7248 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7250 {}
7251};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007252
7253static struct hda_verb alc885_init_verbs[] = {
7254 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7255 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7256 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7258 /* Rear mixer */
7259 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7260 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7262 /* CLFE mixer */
7263 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7265 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7266 /* Side mixer */
7267 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7268 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7269 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7270
7271 /* mute analog input loopbacks */
7272 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7275
7276 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007277 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7279 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7280 /* Front Pin: output 0 (0x0c) */
7281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7282 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7283 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7284 /* Rear Pin: output 1 (0x0d) */
7285 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7286 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7287 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7288 /* CLFE Pin: output 2 (0x0e) */
7289 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7290 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7291 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7292 /* Side Pin: output 3 (0x0f) */
7293 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7294 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7295 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7296 /* Mic (rear) pin: input vref at 80% */
7297 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7298 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7299 /* Front Mic pin: input vref at 80% */
7300 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7301 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7302 /* Line In pin: input */
7303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7305
7306 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7307 /* Input mixer1 */
7308 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7309 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7310 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7311 /* Input mixer2 */
7312 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7313 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7314 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7315 /* Input mixer3 */
7316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7319 /* ADC2: mute amp left and right */
7320 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7321 /* ADC3: mute amp left and right */
7322 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7323
7324 { }
7325};
7326
7327static struct hda_verb alc885_init_input_verbs[] = {
7328 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7329 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7331 { }
7332};
7333
7334
7335/* Unmute Selector 24h and set the default input to front mic */
7336static struct hda_verb alc889_init_input_verbs[] = {
7337 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7339 { }
7340};
7341
7342
Takashi Iwai4953550a2009-06-30 15:28:30 +02007343#define alc883_init_verbs alc882_base_init_verbs
7344
Tobin Davis9102cd12006-12-15 10:02:12 +01007345/* Mac Pro test */
7346static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7347 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7348 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7349 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007352 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007353 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7354 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007355 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007356 { } /* end */
7357};
7358
7359static struct hda_verb alc882_macpro_init_verbs[] = {
7360 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7364 /* Front Pin: output 0 (0x0c) */
7365 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7366 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7367 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7368 /* Front Mic pin: input vref at 80% */
7369 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7370 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7371 /* Speaker: output */
7372 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7373 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7374 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7375 /* Headphone output (output 0 - 0x0c) */
7376 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7377 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7378 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7379
7380 /* FIXME: use matrix-type input source selection */
7381 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7382 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7383 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7384 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7385 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7386 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7387 /* Input mixer2 */
7388 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7389 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7390 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7391 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7392 /* Input mixer3 */
7393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7394 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7397 /* ADC1: mute amp left and right */
7398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7399 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7400 /* ADC2: mute amp left and right */
7401 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7402 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7403 /* ADC3: mute amp left and right */
7404 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7405 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7406
7407 { }
7408};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007409
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007410/* Macbook 5,1 */
7411static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007412 /* DACs */
7413 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7414 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7415 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7416 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007417 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007418 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7419 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7420 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007421 /* Surround mixer */
7422 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7423 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7424 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7425 /* LFE mixer */
7426 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7427 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7428 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7429 /* HP mixer */
7430 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7431 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7432 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7433 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007434 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7435 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007436 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7437 /* LFE Pin (0x0e) */
7438 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7439 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7440 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7441 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7443 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007444 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007445 /* Front Mic pin: input vref at 80% */
7446 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7447 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7448 /* Line In pin */
7449 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7451
7452 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7453 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7456 { }
7457};
7458
Takashi Iwai87350ad2007-08-16 18:19:38 +02007459/* Macbook Pro rev3 */
7460static struct hda_verb alc885_mbp3_init_verbs[] = {
7461 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7465 /* Rear mixer */
7466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7467 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7468 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007469 /* HP mixer */
7470 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7471 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7472 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007473 /* Front Pin: output 0 (0x0c) */
7474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7476 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007477 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007478 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007479 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7480 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007481 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7482 /* Mic (rear) pin: input vref at 80% */
7483 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7484 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7485 /* Front Mic pin: input vref at 80% */
7486 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7487 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7488 /* Line In pin: use output 1 when in LineOut mode */
7489 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7490 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7491 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7492
7493 /* FIXME: use matrix-type input source selection */
7494 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7495 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7497 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7500 /* Input mixer2 */
7501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7502 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7505 /* Input mixer3 */
7506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7510 /* ADC1: mute amp left and right */
7511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7512 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7513 /* ADC2: mute amp left and right */
7514 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7515 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7516 /* ADC3: mute amp left and right */
7517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7518 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7519
7520 { }
7521};
7522
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007523/* iMac 9,1 */
7524static struct hda_verb alc885_imac91_init_verbs[] = {
7525 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7527 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7529 /* Rear mixer */
7530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7532 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7533 /* HP Pin: output 0 (0x0c) */
7534 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7535 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7536 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7537 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7538 /* Internal Speakers: output 0 (0x0d) */
7539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7540 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7541 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7542 /* Mic (rear) pin: input vref at 80% */
7543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7544 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7545 /* Front Mic pin: input vref at 80% */
7546 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7547 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7548 /* Line In pin: use output 1 when in LineOut mode */
7549 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7550 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7551 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7552
7553 /* FIXME: use matrix-type input source selection */
7554 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7555 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7556 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7557 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7558 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7559 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7560 /* Input mixer2 */
7561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7563 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7564 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7565 /* Input mixer3 */
7566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7568 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7569 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7570 /* ADC1: mute amp left and right */
7571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7572 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7573 /* ADC2: mute amp left and right */
7574 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7575 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7576 /* ADC3: mute amp left and right */
7577 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7578 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7579
7580 { }
7581};
7582
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007583/* iMac 24 mixer. */
7584static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7585 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7586 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7587 { } /* end */
7588};
7589
7590/* iMac 24 init verbs. */
7591static struct hda_verb alc885_imac24_init_verbs[] = {
7592 /* Internal speakers: output 0 (0x0c) */
7593 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7594 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7595 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7596 /* Internal speakers: output 0 (0x0c) */
7597 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7598 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7599 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7600 /* Headphone: output 0 (0x0c) */
7601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7602 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7603 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7604 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7605 /* Front Mic: input vref at 80% */
7606 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7607 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7608 { }
7609};
7610
7611/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007612static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007613{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007614 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007615
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007616 spec->autocfg.hp_pins[0] = 0x14;
7617 spec->autocfg.speaker_pins[0] = 0x18;
7618 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007619}
7620
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007621static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007622{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007623 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007624
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007625 spec->autocfg.hp_pins[0] = 0x15;
7626 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007627}
7628
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007629static void alc885_imac91_automute(struct hda_codec *codec)
7630{
7631 unsigned int present;
7632
7633 present = snd_hda_codec_read(codec, 0x14, 0,
7634 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7635 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7636 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7637 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7638 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7639
7640}
7641
7642static void alc885_imac91_unsol_event(struct hda_codec *codec,
7643 unsigned int res)
7644{
7645 /* Headphone insertion or removal. */
7646 if ((res >> 26) == ALC880_HP_EVENT)
7647 alc885_imac91_automute(codec);
7648}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007649
Kailang Yang272a5272007-05-14 11:00:38 +02007650static struct hda_verb alc882_targa_verbs[] = {
7651 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7653
7654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7655 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007656
Kailang Yang272a5272007-05-14 11:00:38 +02007657 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7658 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7659 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7660
7661 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007662 { } /* end */
7663};
7664
7665/* toggle speaker-output according to the hp-jack state */
7666static void alc882_targa_automute(struct hda_codec *codec)
7667{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007668 struct alc_spec *spec = codec->spec;
7669 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007670 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007671 spec->jack_present ? 1 : 3);
7672}
7673
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007674static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007675{
7676 struct alc_spec *spec = codec->spec;
7677
7678 spec->autocfg.hp_pins[0] = 0x14;
7679 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007680}
7681
7682static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7683{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007684 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007685 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007686}
7687
7688static struct hda_verb alc882_asus_a7j_verbs[] = {
7689 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7690 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7691
7692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7693 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7694 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007695
Kailang Yang272a5272007-05-14 11:00:38 +02007696 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7697 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7698 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7699
7700 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7701 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7702 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7703 { } /* end */
7704};
7705
Takashi Iwai914759b2007-09-06 14:52:04 +02007706static struct hda_verb alc882_asus_a7m_verbs[] = {
7707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7709
7710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7711 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7712 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007713
Takashi Iwai914759b2007-09-06 14:52:04 +02007714 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7715 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7716 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7717
7718 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7719 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7720 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7721 { } /* end */
7722};
7723
Tobin Davis9102cd12006-12-15 10:02:12 +01007724static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7725{
7726 unsigned int gpiostate, gpiomask, gpiodir;
7727
7728 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7729 AC_VERB_GET_GPIO_DATA, 0);
7730
7731 if (!muted)
7732 gpiostate |= (1 << pin);
7733 else
7734 gpiostate &= ~(1 << pin);
7735
7736 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7737 AC_VERB_GET_GPIO_MASK, 0);
7738 gpiomask |= (1 << pin);
7739
7740 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7741 AC_VERB_GET_GPIO_DIRECTION, 0);
7742 gpiodir |= (1 << pin);
7743
7744
7745 snd_hda_codec_write(codec, codec->afg, 0,
7746 AC_VERB_SET_GPIO_MASK, gpiomask);
7747 snd_hda_codec_write(codec, codec->afg, 0,
7748 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7749
7750 msleep(1);
7751
7752 snd_hda_codec_write(codec, codec->afg, 0,
7753 AC_VERB_SET_GPIO_DATA, gpiostate);
7754}
7755
Takashi Iwai7debbe52007-08-16 15:01:03 +02007756/* set up GPIO at initialization */
7757static void alc885_macpro_init_hook(struct hda_codec *codec)
7758{
7759 alc882_gpio_mute(codec, 0, 0);
7760 alc882_gpio_mute(codec, 1, 0);
7761}
7762
7763/* set up GPIO and update auto-muting at initialization */
7764static void alc885_imac24_init_hook(struct hda_codec *codec)
7765{
7766 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007767 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007768}
7769
Kailang Yangdf694da2005-12-05 19:42:22 +01007770/*
7771 * generic initialization of ADC, input mixers and output mixers
7772 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007773static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007774 /*
7775 * Unmute ADC0-2 and set the default input to mic-in
7776 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007777 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7778 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7779 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7780 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7781
Takashi Iwaicb53c622007-08-10 17:21:45 +02007782 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007783 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007784 * Note: PASD motherboards uses the Line In 2 as the input for
7785 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007786 */
7787 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007788 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7789 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7790 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7791 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7792 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007793
7794 /*
7795 * Set up output mixers (0x0c - 0x0f)
7796 */
7797 /* set vol=0 to output mixers */
7798 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7799 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7800 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7801 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7802 /* set up input amps for analog loopback */
7803 /* Amp Indices: DAC = 0, mixer = 1 */
7804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7807 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7808 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7809 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7810 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7811 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7812 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7813 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7814
7815 /* FIXME: use matrix-type input source selection */
7816 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007817 /* Input mixer2 */
7818 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7819 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7820 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7821 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7822 /* Input mixer3 */
7823 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7824 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7825 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7826 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7827
7828 { }
7829};
7830
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007831/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7832static struct hda_verb alc889A_mb31_ch2_init[] = {
7833 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7834 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7835 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7836 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7837 { } /* end */
7838};
7839
7840/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7841static struct hda_verb alc889A_mb31_ch4_init[] = {
7842 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7843 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7844 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7845 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7846 { } /* end */
7847};
7848
7849/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7850static struct hda_verb alc889A_mb31_ch5_init[] = {
7851 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7852 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7853 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7854 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7855 { } /* end */
7856};
7857
7858/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7859static struct hda_verb alc889A_mb31_ch6_init[] = {
7860 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7861 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7862 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7863 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7864 { } /* end */
7865};
7866
7867static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7868 { 2, alc889A_mb31_ch2_init },
7869 { 4, alc889A_mb31_ch4_init },
7870 { 5, alc889A_mb31_ch5_init },
7871 { 6, alc889A_mb31_ch6_init },
7872};
7873
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007874static struct hda_verb alc883_medion_eapd_verbs[] = {
7875 /* eanable EAPD on medion laptop */
7876 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7877 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7878 { }
7879};
7880
Takashi Iwai4953550a2009-06-30 15:28:30 +02007881#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007882
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007883static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7884 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7885 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7886 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7887 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7888 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7889 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7890 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7892 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7895 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7896 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007897 { } /* end */
7898};
7899
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007900static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007901 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7902 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7903 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7904 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7906 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7907 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7908 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7909 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7910 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007911 { } /* end */
7912};
7913
Jiang zhefb97dc62008-03-06 11:07:11 +01007914static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7915 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7916 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7917 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7918 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7920 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7922 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7923 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7924 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007925 { } /* end */
7926};
7927
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007928static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7929 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7930 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7932 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7933 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7934 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7935 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007937 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7939 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007940 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007941 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007942 { } /* end */
7943};
7944
7945static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7947 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7948 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7949 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7950 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7951 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7952 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7953 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7954 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7955 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7956 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7957 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7958 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007960 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7962 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007963 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007964 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007965 { } /* end */
7966};
7967
Jiang zhe17bba1b2008-06-04 12:11:07 +02007968static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7969 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7970 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7971 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7972 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7973 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7974 HDA_OUTPUT),
7975 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7976 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7977 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7979 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7980 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7981 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7982 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7984 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7986 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7987 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7988 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007989 { } /* end */
7990};
7991
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007992static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7993 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7994 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7995 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7996 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7997 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7998 HDA_OUTPUT),
7999 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8000 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8001 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8002 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8003 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8005 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8006 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8008 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8009 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8010 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8011 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8012 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8013 { } /* end */
8014};
8015
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008016static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008017 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008018 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008019 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008020 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008021 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8022 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008023 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8024 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008025 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8026 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8027 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8028 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8029 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008031 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008032 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8033 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008034 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008035 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008036 { } /* end */
8037};
8038
Sasha Alexandrc2592492009-06-16 14:52:54 -04008039static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008040 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008041 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008042 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008043 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008044 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8045 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8046 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8047 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8048 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8049 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8050 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8051 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8052 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8053 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8054 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008055 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008056 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008057 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008058};
Kailang Yangccc656c2006-10-17 12:32:26 +02008059
Sasha Alexandrc2592492009-06-16 14:52:54 -04008060static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008061 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008062 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008063 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008064 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008065 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8066 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8067 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008068 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008069 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008070 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8071 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8072 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008073 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008074};
Kailang Yangccc656c2006-10-17 12:32:26 +02008075
Takashi Iwaib99dba32009-09-17 18:23:00 +02008076static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8077 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8078 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8079 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8080 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8081 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8082 { } /* end */
8083};
8084
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008085static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8086 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8087 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008088 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8089 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8092 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8093 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008094 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008095};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008096
Kailang Yang272a5272007-05-14 11:00:38 +02008097static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8098 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8099 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8101 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8102 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8103 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8104 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8105 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8106 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008107 { } /* end */
8108};
8109
8110static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8111 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8113 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8114 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8115 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8117 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8118 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8119 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008120 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008121};
Kailang Yang272a5272007-05-14 11:00:38 +02008122
Tobin Davis2880a862007-08-07 11:50:26 +02008123static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8125 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008126 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8130 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8131 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008132 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008133};
Tobin Davis2880a862007-08-07 11:50:26 +02008134
Tony Vroond2fd4b02009-06-21 00:40:10 +01008135static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8136 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8137 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8138 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8139 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008140 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8141 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008142 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8143 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8145 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8146 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8147 { } /* end */
8148};
8149
Kailang Yange2757d52008-08-26 13:17:46 +02008150static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8151 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8152 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8153 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8154 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8155 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8156 0x0d, 1, 0x0, HDA_OUTPUT),
8157 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8158 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8159 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8160 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8161 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008162 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8163 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8164 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8165 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8166 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8167 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8168 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8169 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8170 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8171 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008172 { } /* end */
8173};
8174
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008175static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8176 /* Output mixers */
8177 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8178 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8179 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8180 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8181 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8182 HDA_OUTPUT),
8183 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8184 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8185 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8186 /* Output switches */
8187 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8188 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8189 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8190 /* Boost mixers */
8191 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8192 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8193 /* Input mixers */
8194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8195 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8196 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8197 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8198 { } /* end */
8199};
8200
Guido Günther3e1647c2009-06-05 00:47:26 +02008201static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8202 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8203 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8204 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8206 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8207 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8208 { } /* end */
8209};
8210
Kailang Yange2757d52008-08-26 13:17:46 +02008211static struct hda_bind_ctls alc883_bind_cap_vol = {
8212 .ops = &snd_hda_bind_vol,
8213 .values = {
8214 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8215 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8216 0
8217 },
8218};
8219
8220static struct hda_bind_ctls alc883_bind_cap_switch = {
8221 .ops = &snd_hda_bind_sw,
8222 .values = {
8223 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8224 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8225 0
8226 },
8227};
8228
8229static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8230 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8231 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8232 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8233 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8234 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8235 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8236 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8237 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008238 { } /* end */
8239};
8240
8241static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008242 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8243 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8244 {
8245 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8246 /* .name = "Capture Source", */
8247 .name = "Input Source",
8248 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008249 .info = alc_mux_enum_info,
8250 .get = alc_mux_enum_get,
8251 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008252 },
8253 { } /* end */
8254};
8255
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008256static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8257 {
8258 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8259 .name = "Channel Mode",
8260 .info = alc_ch_mode_info,
8261 .get = alc_ch_mode_get,
8262 .put = alc_ch_mode_put,
8263 },
8264 { } /* end */
8265};
8266
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008267/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008268static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008269{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008270 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008271
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008272 spec->autocfg.hp_pins[0] = 0x15;
8273 spec->autocfg.speaker_pins[0] = 0x14;
8274 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008275}
8276
8277/* auto-toggle front mic */
8278/*
8279static void alc883_mitac_mic_automute(struct hda_codec *codec)
8280{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008281 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008282
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008283 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8284}
8285*/
8286
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008287static struct hda_verb alc883_mitac_verbs[] = {
8288 /* HP */
8289 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8290 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8291 /* Subwoofer */
8292 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8293 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8294
8295 /* enable unsolicited event */
8296 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8297 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8298
8299 { } /* end */
8300};
8301
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308302static struct hda_verb alc883_clevo_m540r_verbs[] = {
8303 /* HP */
8304 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8305 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8306 /* Int speaker */
8307 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8308
8309 /* enable unsolicited event */
8310 /*
8311 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8312 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8313 */
8314
8315 { } /* end */
8316};
8317
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008318static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008319 /* HP */
8320 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8321 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8322 /* Int speaker */
8323 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8325
8326 /* enable unsolicited event */
8327 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008328 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008329
8330 { } /* end */
8331};
8332
Jiang zhefb97dc62008-03-06 11:07:11 +01008333static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8334 /* HP */
8335 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8337 /* Subwoofer */
8338 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8339 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8340
8341 /* enable unsolicited event */
8342 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8343
8344 { } /* end */
8345};
8346
Sasha Alexandrc2592492009-06-16 14:52:54 -04008347static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008348 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8350
8351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8352 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008353
David Heidelberger64a8be72009-06-08 16:15:18 +02008354/* Connect Line-Out side jack (SPDIF) to Side */
8355 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8356 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8357 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8358/* Connect Mic jack to CLFE */
8359 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8360 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8361 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8362/* Connect Line-in jack to Surround */
8363 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8364 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8365 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8366/* Connect HP out jack to Front */
8367 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8368 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8369 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008370
8371 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008372
8373 { } /* end */
8374};
8375
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008376static struct hda_verb alc883_lenovo_101e_verbs[] = {
8377 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8378 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8379 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8380 { } /* end */
8381};
8382
Kailang Yang272a5272007-05-14 11:00:38 +02008383static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8384 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8385 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8386 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8388 { } /* end */
8389};
8390
8391static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8394 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8395 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8396 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8397 { } /* end */
8398};
8399
Kailang Yang189609a2007-08-20 11:31:23 +02008400static struct hda_verb alc883_haier_w66_verbs[] = {
8401 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8402 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8403
8404 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8405
8406 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8407 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8408 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8409 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8410 { } /* end */
8411};
8412
Kailang Yange2757d52008-08-26 13:17:46 +02008413static struct hda_verb alc888_lenovo_sky_verbs[] = {
8414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8416 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8417 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8418 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8419 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8420 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8421 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8422 { } /* end */
8423};
8424
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008425static struct hda_verb alc888_6st_dell_verbs[] = {
8426 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8427 { }
8428};
8429
Guido Günther3e1647c2009-06-05 00:47:26 +02008430static struct hda_verb alc883_vaiott_verbs[] = {
8431 /* HP */
8432 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8433 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8434
8435 /* enable unsolicited event */
8436 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8437
8438 { } /* end */
8439};
8440
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008441static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008442{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008443 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008444
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008445 spec->autocfg.hp_pins[0] = 0x1b;
8446 spec->autocfg.speaker_pins[0] = 0x14;
8447 spec->autocfg.speaker_pins[1] = 0x16;
8448 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008449}
8450
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008451static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008452 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008453 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8454 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008455 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008456 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008457};
8458
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008459/*
8460 * 2ch mode
8461 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008462static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008463 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8464 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8465 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8466 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008467 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008468};
8469
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008470/*
8471 * 4ch mode
8472 */
8473static struct hda_verb alc888_3st_hp_4ch_init[] = {
8474 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8475 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8476 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8477 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8478 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8479 { } /* end */
8480};
8481
8482/*
8483 * 6ch mode
8484 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008485static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008486 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8487 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008488 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008489 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8490 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008491 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8492 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008493};
8494
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008495static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008496 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008497 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008498 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008499};
8500
Kailang Yang272a5272007-05-14 11:00:38 +02008501/* toggle front-jack and RCA according to the hp-jack state */
8502static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8503{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008504 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008505
Takashi Iwai47fd8302007-08-10 17:11:07 +02008506 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8507 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8508 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8509 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008510}
8511
8512/* toggle RCA according to the front-jack state */
8513static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8514{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008515 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008516
Takashi Iwai47fd8302007-08-10 17:11:07 +02008517 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8518 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008519}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008520
Kailang Yang272a5272007-05-14 11:00:38 +02008521static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8522 unsigned int res)
8523{
8524 if ((res >> 26) == ALC880_HP_EVENT)
8525 alc888_lenovo_ms7195_front_automute(codec);
8526 if ((res >> 26) == ALC880_FRONT_EVENT)
8527 alc888_lenovo_ms7195_rca_automute(codec);
8528}
8529
8530static struct hda_verb alc883_medion_md2_verbs[] = {
8531 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8532 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8533
8534 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8535
8536 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8537 { } /* end */
8538};
8539
8540/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008541static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008542{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008543 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008544
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008545 spec->autocfg.hp_pins[0] = 0x14;
8546 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008547}
8548
Kailang Yangccc656c2006-10-17 12:32:26 +02008549/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008550#define alc883_targa_init_hook alc882_targa_init_hook
8551#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008552
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008553static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8554{
8555 unsigned int present;
8556
Takashi Iwaid56757a2009-11-18 08:00:14 +01008557 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008558 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8559 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8560}
8561
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008562static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008563{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008564 struct alc_spec *spec = codec->spec;
8565
8566 spec->autocfg.hp_pins[0] = 0x15;
8567 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008568}
8569
8570static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8571{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008572 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008573 alc883_clevo_m720_mic_automute(codec);
8574}
8575
8576static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008577 unsigned int res)
8578{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008579 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008580 case ALC880_MIC_EVENT:
8581 alc883_clevo_m720_mic_automute(codec);
8582 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008583 default:
8584 alc_automute_amp_unsol_event(codec, res);
8585 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008586 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008587}
8588
Jiang zhefb97dc62008-03-06 11:07:11 +01008589/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008590static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008591{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008592 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008593
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008594 spec->autocfg.hp_pins[0] = 0x14;
8595 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008596}
8597
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008598static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008599{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008600 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008601
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008602 spec->autocfg.hp_pins[0] = 0x1b;
8603 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008604}
8605
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008606static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8607{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008608 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008609
Takashi Iwai47fd8302007-08-10 17:11:07 +02008610 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8611 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008612}
8613
8614static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8615{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008616 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008617
Takashi Iwai47fd8302007-08-10 17:11:07 +02008618 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8619 HDA_AMP_MUTE, bits);
8620 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8621 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008622}
8623
8624static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8625 unsigned int res)
8626{
8627 if ((res >> 26) == ALC880_HP_EVENT)
8628 alc883_lenovo_101e_all_automute(codec);
8629 if ((res >> 26) == ALC880_FRONT_EVENT)
8630 alc883_lenovo_101e_ispeaker_automute(codec);
8631}
8632
Takashi Iwai676a9b52007-08-16 15:23:35 +02008633/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008634static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008635{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008636 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008637
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008638 spec->autocfg.hp_pins[0] = 0x14;
8639 spec->autocfg.speaker_pins[0] = 0x15;
8640 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008641}
8642
Kailang Yangd1a991a2007-08-15 16:21:59 +02008643static struct hda_verb alc883_acer_eapd_verbs[] = {
8644 /* HP Pin: output 0 (0x0c) */
8645 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8646 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8647 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8648 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008649 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8650 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008651 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008652 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8653 /* eanable EAPD on medion laptop */
8654 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8655 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008656 /* enable unsolicited event */
8657 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008658 { }
8659};
8660
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008661static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8662 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8663 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8664 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8665 { } /* end */
8666};
8667
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008668static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008669{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008670 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008671
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008672 spec->autocfg.hp_pins[0] = 0x1b;
8673 spec->autocfg.speaker_pins[0] = 0x14;
8674 spec->autocfg.speaker_pins[1] = 0x15;
8675 spec->autocfg.speaker_pins[2] = 0x16;
8676 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008677}
8678
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008679static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008680{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008681 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008682
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008683 spec->autocfg.hp_pins[0] = 0x1b;
8684 spec->autocfg.speaker_pins[0] = 0x14;
8685 spec->autocfg.speaker_pins[1] = 0x15;
8686 spec->autocfg.speaker_pins[2] = 0x16;
8687 spec->autocfg.speaker_pins[3] = 0x17;
8688 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008689}
8690
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008691static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008692{
8693 struct alc_spec *spec = codec->spec;
8694
8695 spec->autocfg.hp_pins[0] = 0x15;
8696 spec->autocfg.speaker_pins[0] = 0x14;
8697 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008698}
8699
Kailang Yange2757d52008-08-26 13:17:46 +02008700static struct hda_verb alc888_asus_m90v_verbs[] = {
8701 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8702 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8703 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8704 /* enable unsolicited event */
8705 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8706 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8707 { } /* end */
8708};
8709
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008710static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008711{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008712 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008713
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008714 spec->autocfg.hp_pins[0] = 0x1b;
8715 spec->autocfg.speaker_pins[0] = 0x14;
8716 spec->autocfg.speaker_pins[1] = 0x15;
8717 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008718 spec->ext_mic.pin = 0x18;
8719 spec->int_mic.pin = 0x19;
8720 spec->ext_mic.mux_idx = 0;
8721 spec->int_mic.mux_idx = 1;
8722 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008723}
8724
8725static struct hda_verb alc888_asus_eee1601_verbs[] = {
8726 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8727 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8729 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8730 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8731 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8732 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8733 /* enable unsolicited event */
8734 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8735 { } /* end */
8736};
8737
Kailang Yange2757d52008-08-26 13:17:46 +02008738static void alc883_eee1601_inithook(struct hda_codec *codec)
8739{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008740 struct alc_spec *spec = codec->spec;
8741
8742 spec->autocfg.hp_pins[0] = 0x14;
8743 spec->autocfg.speaker_pins[0] = 0x1b;
8744 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008745}
8746
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008747static struct hda_verb alc889A_mb31_verbs[] = {
8748 /* Init rear pin (used as headphone output) */
8749 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8750 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8751 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8752 /* Init line pin (used as output in 4ch and 6ch mode) */
8753 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8754 /* Init line 2 pin (used as headphone out by default) */
8755 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8756 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8757 { } /* end */
8758};
8759
8760/* Mute speakers according to the headphone jack state */
8761static void alc889A_mb31_automute(struct hda_codec *codec)
8762{
8763 unsigned int present;
8764
8765 /* Mute only in 2ch or 4ch mode */
8766 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8767 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08008768 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +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, 0x16, HDA_OUTPUT, 0,
8772 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8773 }
8774}
8775
8776static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8777{
8778 if ((res >> 26) == ALC880_HP_EVENT)
8779 alc889A_mb31_automute(codec);
8780}
8781
Takashi Iwai4953550a2009-06-30 15:28:30 +02008782
Takashi Iwaicb53c622007-08-10 17:21:45 +02008783#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008784#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008785#endif
8786
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008787/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008788#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8789#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8790#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8791#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8792
8793static hda_nid_t alc883_slave_dig_outs[] = {
8794 ALC1200_DIGOUT_NID, 0,
8795};
8796
8797static hda_nid_t alc1200_slave_dig_outs[] = {
8798 ALC883_DIGOUT_NID, 0,
8799};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008800
8801/*
8802 * configuration and preset
8803 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008804static const char *alc882_models[ALC882_MODEL_LAST] = {
8805 [ALC882_3ST_DIG] = "3stack-dig",
8806 [ALC882_6ST_DIG] = "6stack-dig",
8807 [ALC882_ARIMA] = "arima",
8808 [ALC882_W2JC] = "w2jc",
8809 [ALC882_TARGA] = "targa",
8810 [ALC882_ASUS_A7J] = "asus-a7j",
8811 [ALC882_ASUS_A7M] = "asus-a7m",
8812 [ALC885_MACPRO] = "macpro",
8813 [ALC885_MB5] = "mb5",
8814 [ALC885_MBP3] = "mbp3",
8815 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008816 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008817 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008818 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8819 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008820 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008821 [ALC883_TARGA_DIG] = "targa-dig",
8822 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008823 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008824 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008825 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008826 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008827 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008828 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008829 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008830 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008831 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008832 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008833 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008834 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8835 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008836 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008837 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008838 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008839 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008840 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308841 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008842 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008843 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008844 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008845 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008846 [ALC889A_INTEL] = "intel-alc889a",
8847 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008848 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008849 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008850 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008851 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008852};
8853
Takashi Iwai4953550a2009-06-30 15:28:30 +02008854static struct snd_pci_quirk alc882_cfg_tbl[] = {
8855 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8856
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008857 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008858 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008859 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008860 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8861 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008862 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008863 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8864 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008865 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01008866 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008867 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8868 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008869 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8870 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008871 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8872 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008873 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008874 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008875 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008876 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008877 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8878 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008879 /* default Acer -- disabled as it causes more problems.
8880 * model=auto should work fine now
8881 */
8882 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008883
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008884 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008885
Tobin Davisfebe3372007-06-12 11:27:46 +02008886 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008887 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8888 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008889 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008890 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008891 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008892
8893 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8894 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8895 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008896 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008897 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8898 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8899 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008900 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008901 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008902 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008903 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008904
8905 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008906 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008907 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008908 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008909 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8910 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008911 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008912 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008913 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8914
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008915 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8916 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8917 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008918 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008919 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008920 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008921 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008922 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008923 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8924 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8925 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8926 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8927 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8928 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008929 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008930 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8931 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8932 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008933 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008934 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8935 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008936 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008937 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008938 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008939 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008940 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008941 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008942 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008943 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008944
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008945 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008946 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8947 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308948 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008949 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008950 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008951 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008952 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008953 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008954 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008955 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008956 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008957 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008958 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008959 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8960 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008961 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008962 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008963 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008964 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008965 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008966
Jiang zhe17bba1b2008-06-04 12:11:07 +02008967 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8968 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008969 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008970 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8971 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8972 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008973 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008974
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008975 {}
8976};
8977
Takashi Iwai4953550a2009-06-30 15:28:30 +02008978/* codec SSID table for Intel Mac */
8979static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8980 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8981 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8982 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8983 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8984 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8985 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8986 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8987 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8988 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8989 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008990 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008991 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05008992 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
8993 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02008994 */
8995 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05008996 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008997 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008998};
8999
Takashi Iwai4953550a2009-06-30 15:28:30 +02009000static struct alc_config_preset alc882_presets[] = {
9001 [ALC882_3ST_DIG] = {
9002 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009003 .init_verbs = { alc882_base_init_verbs,
9004 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009005 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9006 .dac_nids = alc882_dac_nids,
9007 .dig_out_nid = ALC882_DIGOUT_NID,
9008 .dig_in_nid = ALC882_DIGIN_NID,
9009 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9010 .channel_mode = alc882_ch_modes,
9011 .need_dac_fix = 1,
9012 .input_mux = &alc882_capture_source,
9013 },
9014 [ALC882_6ST_DIG] = {
9015 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009016 .init_verbs = { alc882_base_init_verbs,
9017 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009018 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9019 .dac_nids = alc882_dac_nids,
9020 .dig_out_nid = ALC882_DIGOUT_NID,
9021 .dig_in_nid = ALC882_DIGIN_NID,
9022 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9023 .channel_mode = alc882_sixstack_modes,
9024 .input_mux = &alc882_capture_source,
9025 },
9026 [ALC882_ARIMA] = {
9027 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009028 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9029 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009030 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9031 .dac_nids = alc882_dac_nids,
9032 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9033 .channel_mode = alc882_sixstack_modes,
9034 .input_mux = &alc882_capture_source,
9035 },
9036 [ALC882_W2JC] = {
9037 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009038 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9039 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009040 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9041 .dac_nids = alc882_dac_nids,
9042 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9043 .channel_mode = alc880_threestack_modes,
9044 .need_dac_fix = 1,
9045 .input_mux = &alc882_capture_source,
9046 .dig_out_nid = ALC882_DIGOUT_NID,
9047 },
9048 [ALC885_MBP3] = {
9049 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9050 .init_verbs = { alc885_mbp3_init_verbs,
9051 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009052 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009053 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009054 .hp_nid = 0x04,
9055 .channel_mode = alc885_mbp_4ch_modes,
9056 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009057 .input_mux = &alc882_capture_source,
9058 .dig_out_nid = ALC882_DIGOUT_NID,
9059 .dig_in_nid = ALC882_DIGIN_NID,
9060 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009061 .setup = alc885_mbp3_setup,
9062 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009063 },
9064 [ALC885_MB5] = {
9065 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9066 .init_verbs = { alc885_mb5_init_verbs,
9067 alc880_gpio1_init_verbs },
9068 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9069 .dac_nids = alc882_dac_nids,
9070 .channel_mode = alc885_mb5_6ch_modes,
9071 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9072 .input_mux = &mb5_capture_source,
9073 .dig_out_nid = ALC882_DIGOUT_NID,
9074 .dig_in_nid = ALC882_DIGIN_NID,
9075 },
9076 [ALC885_MACPRO] = {
9077 .mixers = { alc882_macpro_mixer },
9078 .init_verbs = { alc882_macpro_init_verbs },
9079 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9080 .dac_nids = alc882_dac_nids,
9081 .dig_out_nid = ALC882_DIGOUT_NID,
9082 .dig_in_nid = ALC882_DIGIN_NID,
9083 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9084 .channel_mode = alc882_ch_modes,
9085 .input_mux = &alc882_capture_source,
9086 .init_hook = alc885_macpro_init_hook,
9087 },
9088 [ALC885_IMAC24] = {
9089 .mixers = { alc885_imac24_mixer },
9090 .init_verbs = { alc885_imac24_init_verbs },
9091 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9092 .dac_nids = alc882_dac_nids,
9093 .dig_out_nid = ALC882_DIGOUT_NID,
9094 .dig_in_nid = ALC882_DIGIN_NID,
9095 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9096 .channel_mode = alc882_ch_modes,
9097 .input_mux = &alc882_capture_source,
9098 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009099 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009100 .init_hook = alc885_imac24_init_hook,
9101 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009102 [ALC885_IMAC91] = {
9103 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9104 .init_verbs = { alc885_imac91_init_verbs,
9105 alc880_gpio1_init_verbs },
9106 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9107 .dac_nids = alc882_dac_nids,
9108 .channel_mode = alc885_mbp_4ch_modes,
9109 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9110 .input_mux = &alc882_capture_source,
9111 .dig_out_nid = ALC882_DIGOUT_NID,
9112 .dig_in_nid = ALC882_DIGIN_NID,
9113 .unsol_event = alc885_imac91_unsol_event,
9114 .init_hook = alc885_imac91_automute,
9115 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009116 [ALC882_TARGA] = {
9117 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009118 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009119 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009120 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9121 .dac_nids = alc882_dac_nids,
9122 .dig_out_nid = ALC882_DIGOUT_NID,
9123 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9124 .adc_nids = alc882_adc_nids,
9125 .capsrc_nids = alc882_capsrc_nids,
9126 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9127 .channel_mode = alc882_3ST_6ch_modes,
9128 .need_dac_fix = 1,
9129 .input_mux = &alc882_capture_source,
9130 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009131 .setup = alc882_targa_setup,
9132 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009133 },
9134 [ALC882_ASUS_A7J] = {
9135 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009136 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9137 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009138 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9139 .dac_nids = alc882_dac_nids,
9140 .dig_out_nid = ALC882_DIGOUT_NID,
9141 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9142 .adc_nids = alc882_adc_nids,
9143 .capsrc_nids = alc882_capsrc_nids,
9144 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9145 .channel_mode = alc882_3ST_6ch_modes,
9146 .need_dac_fix = 1,
9147 .input_mux = &alc882_capture_source,
9148 },
9149 [ALC882_ASUS_A7M] = {
9150 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009151 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9152 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009153 alc882_asus_a7m_verbs },
9154 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9155 .dac_nids = alc882_dac_nids,
9156 .dig_out_nid = ALC882_DIGOUT_NID,
9157 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9158 .channel_mode = alc880_threestack_modes,
9159 .need_dac_fix = 1,
9160 .input_mux = &alc882_capture_source,
9161 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009162 [ALC883_3ST_2ch_DIG] = {
9163 .mixers = { alc883_3ST_2ch_mixer },
9164 .init_verbs = { alc883_init_verbs },
9165 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9166 .dac_nids = alc883_dac_nids,
9167 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009168 .dig_in_nid = ALC883_DIGIN_NID,
9169 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9170 .channel_mode = alc883_3ST_2ch_modes,
9171 .input_mux = &alc883_capture_source,
9172 },
9173 [ALC883_3ST_6ch_DIG] = {
9174 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9175 .init_verbs = { alc883_init_verbs },
9176 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9177 .dac_nids = alc883_dac_nids,
9178 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009179 .dig_in_nid = ALC883_DIGIN_NID,
9180 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9181 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009182 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009183 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009184 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009185 [ALC883_3ST_6ch] = {
9186 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9187 .init_verbs = { alc883_init_verbs },
9188 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9189 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009190 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9191 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009192 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009193 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009194 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009195 [ALC883_3ST_6ch_INTEL] = {
9196 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9197 .init_verbs = { alc883_init_verbs },
9198 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9199 .dac_nids = alc883_dac_nids,
9200 .dig_out_nid = ALC883_DIGOUT_NID,
9201 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009202 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009203 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9204 .channel_mode = alc883_3ST_6ch_intel_modes,
9205 .need_dac_fix = 1,
9206 .input_mux = &alc883_3stack_6ch_intel,
9207 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009208 [ALC889A_INTEL] = {
9209 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009210 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9211 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009212 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9213 .dac_nids = alc883_dac_nids,
9214 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9215 .adc_nids = alc889_adc_nids,
9216 .dig_out_nid = ALC883_DIGOUT_NID,
9217 .dig_in_nid = ALC883_DIGIN_NID,
9218 .slave_dig_outs = alc883_slave_dig_outs,
9219 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9220 .channel_mode = alc889_8ch_intel_modes,
9221 .capsrc_nids = alc889_capsrc_nids,
9222 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009223 .setup = alc889_automute_setup,
9224 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009225 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009226 .need_dac_fix = 1,
9227 },
9228 [ALC889_INTEL] = {
9229 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9230 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009231 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009232 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9233 .dac_nids = alc883_dac_nids,
9234 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9235 .adc_nids = alc889_adc_nids,
9236 .dig_out_nid = ALC883_DIGOUT_NID,
9237 .dig_in_nid = ALC883_DIGIN_NID,
9238 .slave_dig_outs = alc883_slave_dig_outs,
9239 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9240 .channel_mode = alc889_8ch_intel_modes,
9241 .capsrc_nids = alc889_capsrc_nids,
9242 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009243 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009244 .init_hook = alc889_intel_init_hook,
9245 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009246 .need_dac_fix = 1,
9247 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009248 [ALC883_6ST_DIG] = {
9249 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9250 .init_verbs = { alc883_init_verbs },
9251 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9252 .dac_nids = alc883_dac_nids,
9253 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009254 .dig_in_nid = ALC883_DIGIN_NID,
9255 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9256 .channel_mode = alc883_sixstack_modes,
9257 .input_mux = &alc883_capture_source,
9258 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009259 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009260 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009261 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9262 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009263 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9264 .dac_nids = alc883_dac_nids,
9265 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009266 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9267 .channel_mode = alc883_3ST_6ch_modes,
9268 .need_dac_fix = 1,
9269 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009270 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009271 .setup = alc882_targa_setup,
9272 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009273 },
9274 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009275 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009276 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9277 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009278 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9279 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009280 .adc_nids = alc883_adc_nids_alt,
9281 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009282 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009283 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9284 .channel_mode = alc883_3ST_2ch_modes,
9285 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009286 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009287 .setup = alc882_targa_setup,
9288 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009289 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009290 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009291 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9292 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009293 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009294 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009295 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9296 .dac_nids = alc883_dac_nids,
9297 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9298 .adc_nids = alc883_adc_nids_rev,
9299 .capsrc_nids = alc883_capsrc_nids_rev,
9300 .dig_out_nid = ALC883_DIGOUT_NID,
9301 .dig_in_nid = ALC883_DIGIN_NID,
9302 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9303 .channel_mode = alc883_4ST_8ch_modes,
9304 .need_dac_fix = 1,
9305 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009306 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009307 .setup = alc882_targa_setup,
9308 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009309 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009310 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009311 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009312 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9313 * and the headphone jack. Turn this on and rely on the
9314 * standard mute methods whenever the user wants to turn
9315 * these outputs off.
9316 */
9317 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9318 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9319 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009320 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9321 .channel_mode = alc883_3ST_2ch_modes,
9322 .input_mux = &alc883_capture_source,
9323 },
Tobin Davis2880a862007-08-07 11:50:26 +02009324 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009325 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009326 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009327 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9328 .dac_nids = alc883_dac_nids,
9329 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009330 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9331 .channel_mode = alc883_3ST_2ch_modes,
9332 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009333 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009334 .setup = alc883_acer_aspire_setup,
9335 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009336 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009337 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009338 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009339 alc883_chmode_mixer },
9340 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9341 alc888_acer_aspire_4930g_verbs },
9342 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9343 .dac_nids = alc883_dac_nids,
9344 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9345 .adc_nids = alc883_adc_nids_rev,
9346 .capsrc_nids = alc883_capsrc_nids_rev,
9347 .dig_out_nid = ALC883_DIGOUT_NID,
9348 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9349 .channel_mode = alc883_3ST_6ch_modes,
9350 .need_dac_fix = 1,
9351 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009352 ARRAY_SIZE(alc888_2_capture_sources),
9353 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009354 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009355 .setup = alc888_acer_aspire_4930g_setup,
9356 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009357 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009358 [ALC888_ACER_ASPIRE_6530G] = {
9359 .mixers = { alc888_acer_aspire_6530_mixer },
9360 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9361 alc888_acer_aspire_6530g_verbs },
9362 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9363 .dac_nids = alc883_dac_nids,
9364 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9365 .adc_nids = alc883_adc_nids_rev,
9366 .capsrc_nids = alc883_capsrc_nids_rev,
9367 .dig_out_nid = ALC883_DIGOUT_NID,
9368 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9369 .channel_mode = alc883_3ST_2ch_modes,
9370 .num_mux_defs =
9371 ARRAY_SIZE(alc888_2_capture_sources),
9372 .input_mux = alc888_acer_aspire_6530_sources,
9373 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009374 .setup = alc888_acer_aspire_6530g_setup,
9375 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009376 },
Hector Martin3b315d72009-06-02 10:54:19 +02009377 [ALC888_ACER_ASPIRE_8930G] = {
9378 .mixers = { alc888_base_mixer,
9379 alc883_chmode_mixer },
9380 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009381 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009382 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9383 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009384 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9385 .adc_nids = alc889_adc_nids,
9386 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009387 .dig_out_nid = ALC883_DIGOUT_NID,
9388 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9389 .channel_mode = alc883_3ST_6ch_modes,
9390 .need_dac_fix = 1,
9391 .const_channel_count = 6,
9392 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009393 ARRAY_SIZE(alc889_capture_sources),
9394 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009395 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009396 .setup = alc889_acer_aspire_8930g_setup,
9397 .init_hook = alc_automute_amp,
Hector Martin3b315d72009-06-02 10:54:19 +02009398 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009399 [ALC888_ACER_ASPIRE_7730G] = {
9400 .mixers = { alc883_3ST_6ch_mixer,
9401 alc883_chmode_mixer },
9402 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9403 alc888_acer_aspire_7730G_verbs },
9404 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9405 .dac_nids = alc883_dac_nids,
9406 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9407 .adc_nids = alc883_adc_nids_rev,
9408 .capsrc_nids = alc883_capsrc_nids_rev,
9409 .dig_out_nid = ALC883_DIGOUT_NID,
9410 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9411 .channel_mode = alc883_3ST_6ch_modes,
9412 .need_dac_fix = 1,
9413 .const_channel_count = 6,
9414 .input_mux = &alc883_capture_source,
9415 .unsol_event = alc_automute_amp_unsol_event,
9416 .setup = alc888_acer_aspire_6530g_setup,
9417 .init_hook = alc_automute_amp,
9418 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009419 [ALC883_MEDION] = {
9420 .mixers = { alc883_fivestack_mixer,
9421 alc883_chmode_mixer },
9422 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009423 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009424 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9425 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009426 .adc_nids = alc883_adc_nids_alt,
9427 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009428 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9429 .channel_mode = alc883_sixstack_modes,
9430 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009431 },
Kailang Yang272a5272007-05-14 11:00:38 +02009432 [ALC883_MEDION_MD2] = {
9433 .mixers = { alc883_medion_md2_mixer},
9434 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9435 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9436 .dac_nids = alc883_dac_nids,
9437 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009438 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9439 .channel_mode = alc883_3ST_2ch_modes,
9440 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009441 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009442 .setup = alc883_medion_md2_setup,
9443 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009444 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009445 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009446 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009447 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9448 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9449 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009450 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9451 .channel_mode = alc883_3ST_2ch_modes,
9452 .input_mux = &alc883_capture_source,
9453 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309454 [ALC883_CLEVO_M540R] = {
9455 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9456 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9457 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9458 .dac_nids = alc883_dac_nids,
9459 .dig_out_nid = ALC883_DIGOUT_NID,
9460 .dig_in_nid = ALC883_DIGIN_NID,
9461 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9462 .channel_mode = alc883_3ST_6ch_clevo_modes,
9463 .need_dac_fix = 1,
9464 .input_mux = &alc883_capture_source,
9465 /* This machine has the hardware HP auto-muting, thus
9466 * we need no software mute via unsol event
9467 */
9468 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009469 [ALC883_CLEVO_M720] = {
9470 .mixers = { alc883_clevo_m720_mixer },
9471 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009472 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9473 .dac_nids = alc883_dac_nids,
9474 .dig_out_nid = ALC883_DIGOUT_NID,
9475 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9476 .channel_mode = alc883_3ST_2ch_modes,
9477 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009478 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009479 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009480 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009481 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009482 [ALC883_LENOVO_101E_2ch] = {
9483 .mixers = { alc883_lenovo_101e_2ch_mixer},
9484 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9485 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9486 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009487 .adc_nids = alc883_adc_nids_alt,
9488 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009489 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9490 .channel_mode = alc883_3ST_2ch_modes,
9491 .input_mux = &alc883_lenovo_101e_capture_source,
9492 .unsol_event = alc883_lenovo_101e_unsol_event,
9493 .init_hook = alc883_lenovo_101e_all_automute,
9494 },
Kailang Yang272a5272007-05-14 11:00:38 +02009495 [ALC883_LENOVO_NB0763] = {
9496 .mixers = { alc883_lenovo_nb0763_mixer },
9497 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9498 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9499 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009500 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9501 .channel_mode = alc883_3ST_2ch_modes,
9502 .need_dac_fix = 1,
9503 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009504 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009505 .setup = alc883_medion_md2_setup,
9506 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009507 },
9508 [ALC888_LENOVO_MS7195_DIG] = {
9509 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9510 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9511 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9512 .dac_nids = alc883_dac_nids,
9513 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009514 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9515 .channel_mode = alc883_3ST_6ch_modes,
9516 .need_dac_fix = 1,
9517 .input_mux = &alc883_capture_source,
9518 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9519 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009520 },
9521 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009522 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009523 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9524 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9525 .dac_nids = alc883_dac_nids,
9526 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009527 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9528 .channel_mode = alc883_3ST_2ch_modes,
9529 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009530 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009531 .setup = alc883_haier_w66_setup,
9532 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009533 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009534 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009535 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009536 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009537 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9538 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009539 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9540 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009541 .need_dac_fix = 1,
9542 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009543 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009544 .setup = alc888_3st_hp_setup,
9545 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009546 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009547 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009548 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009549 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9550 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9551 .dac_nids = alc883_dac_nids,
9552 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009553 .dig_in_nid = ALC883_DIGIN_NID,
9554 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9555 .channel_mode = alc883_sixstack_modes,
9556 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009557 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009558 .setup = alc888_6st_dell_setup,
9559 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009560 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009561 [ALC883_MITAC] = {
9562 .mixers = { alc883_mitac_mixer },
9563 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9564 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9565 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009566 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9567 .channel_mode = alc883_3ST_2ch_modes,
9568 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009569 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009570 .setup = alc883_mitac_setup,
9571 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009572 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009573 [ALC883_FUJITSU_PI2515] = {
9574 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9575 .init_verbs = { alc883_init_verbs,
9576 alc883_2ch_fujitsu_pi2515_verbs},
9577 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9578 .dac_nids = alc883_dac_nids,
9579 .dig_out_nid = ALC883_DIGOUT_NID,
9580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9581 .channel_mode = alc883_3ST_2ch_modes,
9582 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009583 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009584 .setup = alc883_2ch_fujitsu_pi2515_setup,
9585 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009586 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009587 [ALC888_FUJITSU_XA3530] = {
9588 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9589 .init_verbs = { alc883_init_verbs,
9590 alc888_fujitsu_xa3530_verbs },
9591 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9592 .dac_nids = alc883_dac_nids,
9593 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9594 .adc_nids = alc883_adc_nids_rev,
9595 .capsrc_nids = alc883_capsrc_nids_rev,
9596 .dig_out_nid = ALC883_DIGOUT_NID,
9597 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9598 .channel_mode = alc888_4ST_8ch_intel_modes,
9599 .num_mux_defs =
9600 ARRAY_SIZE(alc888_2_capture_sources),
9601 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009602 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009603 .setup = alc888_fujitsu_xa3530_setup,
9604 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009605 },
Kailang Yange2757d52008-08-26 13:17:46 +02009606 [ALC888_LENOVO_SKY] = {
9607 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9608 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9609 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9610 .dac_nids = alc883_dac_nids,
9611 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009612 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9613 .channel_mode = alc883_sixstack_modes,
9614 .need_dac_fix = 1,
9615 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009616 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009617 .setup = alc888_lenovo_sky_setup,
9618 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009619 },
9620 [ALC888_ASUS_M90V] = {
9621 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9622 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9623 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9624 .dac_nids = alc883_dac_nids,
9625 .dig_out_nid = ALC883_DIGOUT_NID,
9626 .dig_in_nid = ALC883_DIGIN_NID,
9627 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9628 .channel_mode = alc883_3ST_6ch_modes,
9629 .need_dac_fix = 1,
9630 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009631 .unsol_event = alc_sku_unsol_event,
9632 .setup = alc883_mode2_setup,
9633 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009634 },
9635 [ALC888_ASUS_EEE1601] = {
9636 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009637 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009638 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9639 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9640 .dac_nids = alc883_dac_nids,
9641 .dig_out_nid = ALC883_DIGOUT_NID,
9642 .dig_in_nid = ALC883_DIGIN_NID,
9643 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9644 .channel_mode = alc883_3ST_2ch_modes,
9645 .need_dac_fix = 1,
9646 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009647 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009648 .init_hook = alc883_eee1601_inithook,
9649 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009650 [ALC1200_ASUS_P5Q] = {
9651 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9652 .init_verbs = { alc883_init_verbs },
9653 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9654 .dac_nids = alc883_dac_nids,
9655 .dig_out_nid = ALC1200_DIGOUT_NID,
9656 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009657 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009658 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9659 .channel_mode = alc883_sixstack_modes,
9660 .input_mux = &alc883_capture_source,
9661 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009662 [ALC889A_MB31] = {
9663 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9664 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9665 alc880_gpio1_init_verbs },
9666 .adc_nids = alc883_adc_nids,
9667 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9668 .dac_nids = alc883_dac_nids,
9669 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9670 .channel_mode = alc889A_mb31_6ch_modes,
9671 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9672 .input_mux = &alc889A_mb31_capture_source,
9673 .dig_out_nid = ALC883_DIGOUT_NID,
9674 .unsol_event = alc889A_mb31_unsol_event,
9675 .init_hook = alc889A_mb31_automute,
9676 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009677 [ALC883_SONY_VAIO_TT] = {
9678 .mixers = { alc883_vaiott_mixer },
9679 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9680 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9681 .dac_nids = alc883_dac_nids,
9682 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9683 .channel_mode = alc883_3ST_2ch_modes,
9684 .input_mux = &alc883_capture_source,
9685 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009686 .setup = alc883_vaiott_setup,
9687 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009688 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009689};
9690
9691
9692/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009693 * Pin config fixes
9694 */
9695enum {
9696 PINFIX_ABIT_AW9D_MAX
9697};
9698
9699static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9700 { 0x15, 0x01080104 }, /* side */
9701 { 0x16, 0x01011012 }, /* rear */
9702 { 0x17, 0x01016011 }, /* clfe */
9703 { }
9704};
9705
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009706static const struct alc_fixup alc882_fixups[] = {
9707 [PINFIX_ABIT_AW9D_MAX] = {
9708 .pins = alc882_abit_aw9d_pinfix
9709 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009710};
9711
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009712static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009713 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9714 {}
9715};
9716
9717/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009718 * BIOS auto configuration
9719 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009720static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9721 const struct auto_pin_cfg *cfg)
9722{
9723 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9724}
9725
Takashi Iwai4953550a2009-06-30 15:28:30 +02009726static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009727 hda_nid_t nid, int pin_type,
9728 int dac_idx)
9729{
9730 /* set as output */
9731 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009732 int idx;
9733
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009734 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009735 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9736 idx = 4;
9737 else
9738 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009739 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9740
9741}
9742
Takashi Iwai4953550a2009-06-30 15:28:30 +02009743static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009744{
9745 struct alc_spec *spec = codec->spec;
9746 int i;
9747
9748 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009749 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009750 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009751 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009752 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009753 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009754 }
9755}
9756
Takashi Iwai4953550a2009-06-30 15:28:30 +02009757static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009758{
9759 struct alc_spec *spec = codec->spec;
9760 hda_nid_t pin;
9761
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009762 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009763 if (pin) /* connect to front */
9764 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009765 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009766 pin = spec->autocfg.speaker_pins[0];
9767 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009768 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009769}
9770
Takashi Iwai4953550a2009-06-30 15:28:30 +02009771static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009772{
9773 struct alc_spec *spec = codec->spec;
9774 int i;
9775
9776 for (i = 0; i < AUTO_PIN_LAST; i++) {
9777 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009778 if (!nid)
9779 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009780 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009781 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9782 snd_hda_codec_write(codec, nid, 0,
9783 AC_VERB_SET_AMP_GAIN_MUTE,
9784 AMP_OUT_MUTE);
9785 }
9786}
9787
9788static void alc882_auto_init_input_src(struct hda_codec *codec)
9789{
9790 struct alc_spec *spec = codec->spec;
9791 int c;
9792
9793 for (c = 0; c < spec->num_adc_nids; c++) {
9794 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9795 hda_nid_t nid = spec->capsrc_nids[c];
9796 unsigned int mux_idx;
9797 const struct hda_input_mux *imux;
9798 int conns, mute, idx, item;
9799
9800 conns = snd_hda_get_connections(codec, nid, conn_list,
9801 ARRAY_SIZE(conn_list));
9802 if (conns < 0)
9803 continue;
9804 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9805 imux = &spec->input_mux[mux_idx];
9806 for (idx = 0; idx < conns; idx++) {
9807 /* if the current connection is the selected one,
9808 * unmute it as default - otherwise mute it
9809 */
9810 mute = AMP_IN_MUTE(idx);
9811 for (item = 0; item < imux->num_items; item++) {
9812 if (imux->items[item].index == idx) {
9813 if (spec->cur_mux[c] == item)
9814 mute = AMP_IN_UNMUTE(idx);
9815 break;
9816 }
9817 }
9818 /* check if we have a selector or mixer
9819 * we could check for the widget type instead, but
9820 * just check for Amp-In presence (in case of mixer
9821 * without amp-in there is something wrong, this
9822 * function shouldn't be used or capsrc nid is wrong)
9823 */
9824 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009825 snd_hda_codec_write(codec, nid, 0,
9826 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009827 mute);
9828 else if (mute != AMP_IN_MUTE(idx))
9829 snd_hda_codec_write(codec, nid, 0,
9830 AC_VERB_SET_CONNECT_SEL,
9831 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009832 }
9833 }
9834}
9835
Takashi Iwai4953550a2009-06-30 15:28:30 +02009836/* add mic boosts if needed */
9837static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009838{
9839 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009840 int err;
9841 hda_nid_t nid;
9842
9843 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9844 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9845 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9846 "Mic Boost",
9847 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9848 if (err < 0)
9849 return err;
9850 }
9851 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9852 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9853 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9854 "Front Mic Boost",
9855 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9856 if (err < 0)
9857 return err;
9858 }
9859 return 0;
9860}
9861
9862/* almost identical with ALC880 parser... */
9863static int alc882_parse_auto_config(struct hda_codec *codec)
9864{
9865 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009866 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9867 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009868
Takashi Iwai05f5f472009-08-25 13:10:18 +02009869 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9870 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009871 if (err < 0)
9872 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009873 if (!spec->autocfg.line_outs)
9874 return 0; /* can't find valid BIOS pin config */
9875
9876 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9877 if (err < 0)
9878 return err;
9879 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9880 if (err < 0)
9881 return err;
9882 err = alc880_auto_create_extra_out(spec,
9883 spec->autocfg.speaker_pins[0],
9884 "Speaker");
9885 if (err < 0)
9886 return err;
9887 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9888 "Headphone");
9889 if (err < 0)
9890 return err;
9891 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9892 if (err < 0)
9893 return err;
9894
9895 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9896
9897 /* check multiple SPDIF-out (for recent codecs) */
9898 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9899 hda_nid_t dig_nid;
9900 err = snd_hda_get_connections(codec,
9901 spec->autocfg.dig_out_pins[i],
9902 &dig_nid, 1);
9903 if (err < 0)
9904 continue;
9905 if (!i)
9906 spec->multiout.dig_out_nid = dig_nid;
9907 else {
9908 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009909 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +02009910 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009911 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009912 }
9913 }
9914 if (spec->autocfg.dig_in_pin)
9915 spec->dig_in_nid = ALC880_DIGIN_NID;
9916
9917 if (spec->kctls.list)
9918 add_mixer(spec, spec->kctls.list);
9919
9920 add_verb(spec, alc883_auto_init_verbs);
9921 /* if ADC 0x07 is available, initialize it, too */
9922 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9923 add_verb(spec, alc882_adc1_init_verbs);
9924
9925 spec->num_mux_defs = 1;
9926 spec->input_mux = &spec->private_imux[0];
9927
9928 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +02009929
9930 err = alc_auto_add_mic_boost(codec);
9931 if (err < 0)
9932 return err;
9933
Takashi Iwai776e1842007-08-29 15:07:11 +02009934 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009935}
9936
9937/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009938static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009939{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009940 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009941 alc882_auto_init_multi_out(codec);
9942 alc882_auto_init_hp_out(codec);
9943 alc882_auto_init_analog_input(codec);
9944 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009945 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009946 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009947}
9948
Takashi Iwai4953550a2009-06-30 15:28:30 +02009949static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009950{
9951 struct alc_spec *spec;
9952 int err, board_config;
9953
9954 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9955 if (spec == NULL)
9956 return -ENOMEM;
9957
9958 codec->spec = spec;
9959
Takashi Iwai4953550a2009-06-30 15:28:30 +02009960 switch (codec->vendor_id) {
9961 case 0x10ec0882:
9962 case 0x10ec0885:
9963 break;
9964 default:
9965 /* ALC883 and variants */
9966 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9967 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009968 }
9969
Takashi Iwai4953550a2009-06-30 15:28:30 +02009970 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9971 alc882_models,
9972 alc882_cfg_tbl);
9973
9974 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9975 board_config = snd_hda_check_board_codec_sid_config(codec,
9976 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9977
9978 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009979 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009980 codec->chip_name);
9981 board_config = ALC882_AUTO;
9982 }
9983
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009984 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009985
9986 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009987 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009988 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009989 if (err < 0) {
9990 alc_free(codec);
9991 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009992 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009993 printk(KERN_INFO
9994 "hda_codec: Cannot set up configuration "
9995 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009996 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009997 }
9998 }
9999
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010000 err = snd_hda_attach_beep_device(codec, 0x1);
10001 if (err < 0) {
10002 alc_free(codec);
10003 return err;
10004 }
10005
Takashi Iwai4953550a2009-06-30 15:28:30 +020010006 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010007 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010008
Takashi Iwai4953550a2009-06-30 15:28:30 +020010009 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10010 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10011 /* FIXME: setup DAC5 */
10012 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10013 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10014
10015 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10016 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10017
10018 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010019 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010020
10021 if (!spec->adc_nids && spec->input_mux) {
10022 int i;
10023 spec->num_adc_nids = 0;
10024 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
10025 hda_nid_t cap;
10026 hda_nid_t nid = alc882_adc_nids[i];
10027 unsigned int wcap = get_wcaps(codec, nid);
10028 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010029 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010030 if (wcap != AC_WID_AUD_IN)
10031 continue;
10032 spec->private_adc_nids[spec->num_adc_nids] = nid;
10033 err = snd_hda_get_connections(codec, nid, &cap, 1);
10034 if (err < 0)
10035 continue;
10036 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10037 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010038 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010039 spec->adc_nids = spec->private_adc_nids;
10040 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010041 }
10042
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010043 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010044 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010045
Takashi Iwai2134ea42008-01-10 16:53:55 +010010046 spec->vmaster_nid = 0x0c;
10047
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010048 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010049 if (board_config == ALC882_AUTO)
10050 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010051#ifdef CONFIG_SND_HDA_POWER_SAVE
10052 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010053 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010054#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010010055 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010056
10057 return 0;
10058}
10059
Takashi Iwai4953550a2009-06-30 15:28:30 +020010060
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010061/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010062 * ALC262 support
10063 */
10064
10065#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10066#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10067
10068#define alc262_dac_nids alc260_dac_nids
10069#define alc262_adc_nids alc882_adc_nids
10070#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010071#define alc262_capsrc_nids alc882_capsrc_nids
10072#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010073
10074#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010075#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010076
Kailang Yang4e555fe2008-08-26 13:05:55 +020010077static hda_nid_t alc262_dmic_adc_nids[1] = {
10078 /* ADC0 */
10079 0x09
10080};
10081
10082static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10083
Kailang Yangdf694da2005-12-05 19:42:22 +010010084static struct snd_kcontrol_new alc262_base_mixer[] = {
10085 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10086 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10087 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10088 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10089 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10090 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10092 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010093 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010094 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10095 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010096 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010097 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10098 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10099 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10100 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010101 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010102};
10103
Takashi Iwaice875f02008-01-28 18:17:43 +010010104/* update HP, line and mono-out pins according to the master switch */
10105static void alc262_hp_master_update(struct hda_codec *codec)
10106{
10107 struct alc_spec *spec = codec->spec;
10108 int val = spec->master_sw;
10109
10110 /* HP & line-out */
10111 snd_hda_codec_write_cache(codec, 0x1b, 0,
10112 AC_VERB_SET_PIN_WIDGET_CONTROL,
10113 val ? PIN_HP : 0);
10114 snd_hda_codec_write_cache(codec, 0x15, 0,
10115 AC_VERB_SET_PIN_WIDGET_CONTROL,
10116 val ? PIN_HP : 0);
10117 /* mono (speaker) depending on the HP jack sense */
10118 val = val && !spec->jack_present;
10119 snd_hda_codec_write_cache(codec, 0x16, 0,
10120 AC_VERB_SET_PIN_WIDGET_CONTROL,
10121 val ? PIN_OUT : 0);
10122}
10123
10124static void alc262_hp_bpc_automute(struct hda_codec *codec)
10125{
10126 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010127
10128 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010129 alc262_hp_master_update(codec);
10130}
10131
10132static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10133{
10134 if ((res >> 26) != ALC880_HP_EVENT)
10135 return;
10136 alc262_hp_bpc_automute(codec);
10137}
10138
10139static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10140{
10141 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010142
10143 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010144 alc262_hp_master_update(codec);
10145}
10146
10147static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10148 unsigned int res)
10149{
10150 if ((res >> 26) != ALC880_HP_EVENT)
10151 return;
10152 alc262_hp_wildwest_automute(codec);
10153}
10154
Takashi Iwaib72519b2009-05-08 14:31:55 +020010155#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010156
10157static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10158 struct snd_ctl_elem_value *ucontrol)
10159{
10160 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10161 struct alc_spec *spec = codec->spec;
10162 int val = !!*ucontrol->value.integer.value;
10163
10164 if (val == spec->master_sw)
10165 return 0;
10166 spec->master_sw = val;
10167 alc262_hp_master_update(codec);
10168 return 1;
10169}
10170
Takashi Iwaib72519b2009-05-08 14:31:55 +020010171#define ALC262_HP_MASTER_SWITCH \
10172 { \
10173 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10174 .name = "Master Playback Switch", \
10175 .info = snd_ctl_boolean_mono_info, \
10176 .get = alc262_hp_master_sw_get, \
10177 .put = alc262_hp_master_sw_put, \
10178 }
10179
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010180static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010181 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010182 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10183 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10184 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010185 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10186 HDA_OUTPUT),
10187 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10188 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010189 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10190 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010191 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010192 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10193 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010194 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010195 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10196 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10197 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10198 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010199 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10200 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10201 { } /* end */
10202};
10203
Kailang Yangcd7509a2007-01-26 18:33:17 +010010204static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010205 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010206 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10207 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10208 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010210 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10211 HDA_OUTPUT),
10212 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10213 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010214 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10215 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010216 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010217 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10218 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10219 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10220 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010221 { } /* end */
10222};
10223
10224static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10225 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10226 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010227 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010228 { } /* end */
10229};
10230
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010231/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010232static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010233{
10234 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010235
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010236 spec->autocfg.hp_pins[0] = 0x15;
10237 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010238}
10239
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010240static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010241 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10242 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010243 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10244 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10245 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10246 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10247 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10248 { } /* end */
10249};
10250
10251static struct hda_verb alc262_hp_t5735_verbs[] = {
10252 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10253 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10254
10255 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10256 { }
10257};
10258
Kailang Yang8c427222008-01-10 13:03:59 +010010259static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010260 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10261 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010262 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10263 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010264 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10265 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10266 { } /* end */
10267};
10268
10269static struct hda_verb alc262_hp_rp5700_verbs[] = {
10270 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10271 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10273 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10274 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10275 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10276 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10278 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10280 {}
10281};
10282
10283static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10284 .num_items = 1,
10285 .items = {
10286 { "Line", 0x1 },
10287 },
10288};
10289
Takashi Iwai42171c12009-05-08 14:11:43 +020010290/* bind hp and internal speaker mute (with plug check) as master switch */
10291static void alc262_hippo_master_update(struct hda_codec *codec)
10292{
10293 struct alc_spec *spec = codec->spec;
10294 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10295 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10296 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10297 unsigned int mute;
10298
10299 /* HP */
10300 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10301 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10302 HDA_AMP_MUTE, mute);
10303 /* mute internal speaker per jack sense */
10304 if (spec->jack_present)
10305 mute = HDA_AMP_MUTE;
10306 if (line_nid)
10307 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10308 HDA_AMP_MUTE, mute);
10309 if (speaker_nid && speaker_nid != line_nid)
10310 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10311 HDA_AMP_MUTE, mute);
10312}
10313
10314#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10315
10316static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10317 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010318{
10319 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010320 struct alc_spec *spec = codec->spec;
10321 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010322
Takashi Iwai42171c12009-05-08 14:11:43 +020010323 if (val == spec->master_sw)
10324 return 0;
10325 spec->master_sw = val;
10326 alc262_hippo_master_update(codec);
10327 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010328}
Takashi Iwai5b319542007-07-26 11:49:22 +020010329
Takashi Iwai42171c12009-05-08 14:11:43 +020010330#define ALC262_HIPPO_MASTER_SWITCH \
10331 { \
10332 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10333 .name = "Master Playback Switch", \
10334 .info = snd_ctl_boolean_mono_info, \
10335 .get = alc262_hippo_master_sw_get, \
10336 .put = alc262_hippo_master_sw_put, \
10337 }
10338
10339static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10340 ALC262_HIPPO_MASTER_SWITCH,
10341 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10342 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10343 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10344 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10345 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10346 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10347 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10348 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10349 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10350 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10351 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10352 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10353 { } /* end */
10354};
10355
10356static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10357 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10358 ALC262_HIPPO_MASTER_SWITCH,
10359 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10360 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10361 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10362 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10363 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10364 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10365 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10366 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10367 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10368 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10369 { } /* end */
10370};
10371
10372/* mute/unmute internal speaker according to the hp jack and mute state */
10373static void alc262_hippo_automute(struct hda_codec *codec)
10374{
10375 struct alc_spec *spec = codec->spec;
10376 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010377
Wu Fengguang864f92b2009-11-18 12:38:02 +080010378 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010379 alc262_hippo_master_update(codec);
10380}
10381
10382static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10383{
10384 if ((res >> 26) != ALC880_HP_EVENT)
10385 return;
10386 alc262_hippo_automute(codec);
10387}
10388
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010389static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010390{
10391 struct alc_spec *spec = codec->spec;
10392
10393 spec->autocfg.hp_pins[0] = 0x15;
10394 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010395}
10396
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010397static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010398{
10399 struct alc_spec *spec = codec->spec;
10400
10401 spec->autocfg.hp_pins[0] = 0x1b;
10402 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010403}
10404
10405
Kailang Yang272a5272007-05-14 11:00:38 +020010406static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010407 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010408 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010409 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10410 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10411 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10412 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10413 { } /* end */
10414};
10415
Kailang Yang83c34212007-07-05 11:43:05 +020010416static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010417 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10418 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010419 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10420 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10421 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10422 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10423 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10424 { } /* end */
10425};
Kailang Yang272a5272007-05-14 11:00:38 +020010426
Tony Vroonba340e82009-02-02 19:01:30 +000010427static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10428 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10429 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10430 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10431 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10432 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10433 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10434 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10435 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10436 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10437 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10438 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10439 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10440 { } /* end */
10441};
10442
10443static struct hda_verb alc262_tyan_verbs[] = {
10444 /* Headphone automute */
10445 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10446 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10447 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10448
10449 /* P11 AUX_IN, white 4-pin connector */
10450 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10451 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10452 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10453 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10454
10455 {}
10456};
10457
10458/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010459static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010460{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010461 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010462
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010463 spec->autocfg.hp_pins[0] = 0x1b;
10464 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010465}
10466
Tony Vroonba340e82009-02-02 19:01:30 +000010467
Kailang Yangdf694da2005-12-05 19:42:22 +010010468#define alc262_capture_mixer alc882_capture_mixer
10469#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10470
10471/*
10472 * generic initialization of ADC, input mixers and output mixers
10473 */
10474static struct hda_verb alc262_init_verbs[] = {
10475 /*
10476 * Unmute ADC0-2 and set the default input to mic-in
10477 */
10478 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10480 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10481 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10482 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10483 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10484
Takashi Iwaicb53c622007-08-10 17:21:45 +020010485 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010486 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010487 * Note: PASD motherboards uses the Line In 2 as the input for
10488 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010489 */
10490 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010491 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10492 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10493 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10494 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10495 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010496
10497 /*
10498 * Set up output mixers (0x0c - 0x0e)
10499 */
10500 /* set vol=0 to output mixers */
10501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10503 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10504 /* set up input amps for analog loopback */
10505 /* Amp Indices: DAC = 0, mixer = 1 */
10506 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10507 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10508 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10509 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10510 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10511 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10512
10513 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10514 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10515 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10516 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10517 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10518 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10519
10520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10521 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10522 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10523 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10524 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010525
Kailang Yangdf694da2005-12-05 19:42:22 +010010526 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10527 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010528
Kailang Yangdf694da2005-12-05 19:42:22 +010010529 /* FIXME: use matrix-type input source selection */
10530 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10531 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10532 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10533 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10534 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10535 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10536 /* Input mixer2 */
10537 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10538 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10539 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10540 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10541 /* Input mixer3 */
10542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10543 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10544 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010545 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010546
10547 { }
10548};
10549
Kailang Yang4e555fe2008-08-26 13:05:55 +020010550static struct hda_verb alc262_eapd_verbs[] = {
10551 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10552 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10553 { }
10554};
10555
Kailang Yangccc656c2006-10-17 12:32:26 +020010556static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10557 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10558 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10560
10561 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10562 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10563 {}
10564};
10565
Kailang Yang272a5272007-05-14 11:00:38 +020010566static struct hda_verb alc262_sony_unsol_verbs[] = {
10567 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10568 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10569 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10570
10571 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10572 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010573 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010574};
10575
Kailang Yang4e555fe2008-08-26 13:05:55 +020010576static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10577 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10578 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10579 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10580 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10581 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010582 { } /* end */
10583};
10584
10585static struct hda_verb alc262_toshiba_s06_verbs[] = {
10586 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10587 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10588 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10589 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10590 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10591 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10592 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10593 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10594 {}
10595};
10596
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010597static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010598{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010599 struct alc_spec *spec = codec->spec;
10600
10601 spec->autocfg.hp_pins[0] = 0x15;
10602 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010603 spec->ext_mic.pin = 0x18;
10604 spec->ext_mic.mux_idx = 0;
10605 spec->int_mic.pin = 0x12;
10606 spec->int_mic.mux_idx = 9;
10607 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010608}
10609
Takashi Iwai834be882006-03-01 14:16:17 +010010610/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010611 * nec model
10612 * 0x15 = headphone
10613 * 0x16 = internal speaker
10614 * 0x18 = external mic
10615 */
10616
10617static struct snd_kcontrol_new alc262_nec_mixer[] = {
10618 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10619 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10620
10621 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10622 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10623 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10624
10625 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10626 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10627 { } /* end */
10628};
10629
10630static struct hda_verb alc262_nec_verbs[] = {
10631 /* Unmute Speaker */
10632 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10633
10634 /* Headphone */
10635 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10637
10638 /* External mic to headphone */
10639 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10640 /* External mic to speaker */
10641 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10642 {}
10643};
10644
10645/*
Takashi Iwai834be882006-03-01 14:16:17 +010010646 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010647 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10648 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010649 */
10650
10651#define ALC_HP_EVENT 0x37
10652
10653static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10654 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10655 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010656 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10657 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010658 {}
10659};
10660
Jiang zhe0e31daf2008-03-20 12:12:39 +010010661static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10662 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10663 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10664 {}
10665};
10666
Takashi Iwai834be882006-03-01 14:16:17 +010010667static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010668 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010669 .items = {
10670 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010671 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010672 { "CD", 0x4 },
10673 },
10674};
10675
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010676static struct hda_input_mux alc262_HP_capture_source = {
10677 .num_items = 5,
10678 .items = {
10679 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010680 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010681 { "Line", 0x2 },
10682 { "CD", 0x4 },
10683 { "AUX IN", 0x6 },
10684 },
10685};
10686
zhejiangaccbe492007-08-31 12:36:05 +020010687static struct hda_input_mux alc262_HP_D7000_capture_source = {
10688 .num_items = 4,
10689 .items = {
10690 { "Mic", 0x0 },
10691 { "Front Mic", 0x2 },
10692 { "Line", 0x1 },
10693 { "CD", 0x4 },
10694 },
10695};
10696
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010697/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010698static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10699{
10700 struct alc_spec *spec = codec->spec;
10701 unsigned int mute;
10702
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010703 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010704 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
10705 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010010706 spec->sense_updated = 1;
10707 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010708 /* unmute internal speaker only if both HPs are unplugged and
10709 * master switch is on
10710 */
10711 if (spec->jack_present)
10712 mute = HDA_AMP_MUTE;
10713 else
Takashi Iwai834be882006-03-01 14:16:17 +010010714 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010715 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10716 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010717}
10718
10719/* unsolicited event for HP jack sensing */
10720static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10721 unsigned int res)
10722{
10723 if ((res >> 26) != ALC_HP_EVENT)
10724 return;
10725 alc262_fujitsu_automute(codec, 1);
10726}
10727
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010728static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10729{
10730 alc262_fujitsu_automute(codec, 1);
10731}
10732
Takashi Iwai834be882006-03-01 14:16:17 +010010733/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010734static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10735 .ops = &snd_hda_bind_vol,
10736 .values = {
10737 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10738 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10739 0
10740 },
10741};
Takashi Iwai834be882006-03-01 14:16:17 +010010742
Jiang zhe0e31daf2008-03-20 12:12:39 +010010743/* mute/unmute internal speaker according to the hp jack and mute state */
10744static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10745{
10746 struct alc_spec *spec = codec->spec;
10747 unsigned int mute;
10748
10749 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010750 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010751 spec->sense_updated = 1;
10752 }
10753 if (spec->jack_present) {
10754 /* mute internal speaker */
10755 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10756 HDA_AMP_MUTE, HDA_AMP_MUTE);
10757 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10758 HDA_AMP_MUTE, HDA_AMP_MUTE);
10759 } else {
10760 /* unmute internal speaker if necessary */
10761 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10762 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10763 HDA_AMP_MUTE, mute);
10764 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10765 HDA_AMP_MUTE, mute);
10766 }
10767}
10768
10769/* unsolicited event for HP jack sensing */
10770static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10771 unsigned int res)
10772{
10773 if ((res >> 26) != ALC_HP_EVENT)
10774 return;
10775 alc262_lenovo_3000_automute(codec, 1);
10776}
10777
Takashi Iwai8de56b72009-07-24 16:51:47 +020010778static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10779 int dir, int idx, long *valp)
10780{
10781 int i, change = 0;
10782
10783 for (i = 0; i < 2; i++, valp++)
10784 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10785 HDA_AMP_MUTE,
10786 *valp ? 0 : HDA_AMP_MUTE);
10787 return change;
10788}
10789
Takashi Iwai834be882006-03-01 14:16:17 +010010790/* bind hp and internal speaker mute (with plug check) */
10791static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10792 struct snd_ctl_elem_value *ucontrol)
10793{
10794 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10795 long *valp = ucontrol->value.integer.value;
10796 int change;
10797
Takashi Iwai8de56b72009-07-24 16:51:47 +020010798 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10799 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010800 if (change)
10801 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010802 return change;
10803}
10804
10805static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010806 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010807 {
10808 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10809 .name = "Master Playback Switch",
10810 .info = snd_hda_mixer_amp_switch_info,
10811 .get = snd_hda_mixer_amp_switch_get,
10812 .put = alc262_fujitsu_master_sw_put,
10813 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10814 },
10815 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10816 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10817 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10819 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010820 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10821 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10822 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010823 { } /* end */
10824};
10825
Jiang zhe0e31daf2008-03-20 12:12:39 +010010826/* bind hp and internal speaker mute (with plug check) */
10827static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10828 struct snd_ctl_elem_value *ucontrol)
10829{
10830 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10831 long *valp = ucontrol->value.integer.value;
10832 int change;
10833
Takashi Iwai8de56b72009-07-24 16:51:47 +020010834 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010835 if (change)
10836 alc262_lenovo_3000_automute(codec, 0);
10837 return change;
10838}
10839
10840static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10841 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10842 {
10843 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10844 .name = "Master Playback Switch",
10845 .info = snd_hda_mixer_amp_switch_info,
10846 .get = snd_hda_mixer_amp_switch_get,
10847 .put = alc262_lenovo_3000_master_sw_put,
10848 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10849 },
10850 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10851 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10852 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10855 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10856 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10857 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10858 { } /* end */
10859};
10860
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010861static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10862 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010863 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10865 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10866 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10867 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10868 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10869 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10870 { } /* end */
10871};
10872
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010873/* additional init verbs for Benq laptops */
10874static struct hda_verb alc262_EAPD_verbs[] = {
10875 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10876 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10877 {}
10878};
10879
Kailang Yang83c34212007-07-05 11:43:05 +020010880static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10881 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10882 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10883
10884 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10885 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10886 {}
10887};
10888
Tobin Davisf651b502007-10-26 12:40:47 +020010889/* Samsung Q1 Ultra Vista model setup */
10890static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010891 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10892 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010893 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10894 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10895 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010896 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010897 { } /* end */
10898};
10899
10900static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010901 /* output mixer */
10902 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10903 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10905 /* speaker */
10906 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10907 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10909 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10910 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10914 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10915 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10916 /* internal mic */
10917 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10919 /* ADC, choose mic */
10920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10922 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10923 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10924 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10925 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10926 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10927 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10928 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10929 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010930 {}
10931};
10932
Tobin Davisf651b502007-10-26 12:40:47 +020010933/* mute/unmute internal speaker according to the hp jack and mute state */
10934static void alc262_ultra_automute(struct hda_codec *codec)
10935{
10936 struct alc_spec *spec = codec->spec;
10937 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010938
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010939 mute = 0;
10940 /* auto-mute only when HP is used as HP */
10941 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010942 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010943 if (spec->jack_present)
10944 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010945 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010946 /* mute/unmute internal speaker */
10947 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10948 HDA_AMP_MUTE, mute);
10949 /* mute/unmute HP */
10950 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10951 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010952}
10953
10954/* unsolicited event for HP jack sensing */
10955static void alc262_ultra_unsol_event(struct hda_codec *codec,
10956 unsigned int res)
10957{
10958 if ((res >> 26) != ALC880_HP_EVENT)
10959 return;
10960 alc262_ultra_automute(codec);
10961}
10962
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010963static struct hda_input_mux alc262_ultra_capture_source = {
10964 .num_items = 2,
10965 .items = {
10966 { "Mic", 0x1 },
10967 { "Headphone", 0x7 },
10968 },
10969};
10970
10971static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10972 struct snd_ctl_elem_value *ucontrol)
10973{
10974 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10975 struct alc_spec *spec = codec->spec;
10976 int ret;
10977
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010978 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010979 if (!ret)
10980 return 0;
10981 /* reprogram the HP pin as mic or HP according to the input source */
10982 snd_hda_codec_write_cache(codec, 0x15, 0,
10983 AC_VERB_SET_PIN_WIDGET_CONTROL,
10984 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10985 alc262_ultra_automute(codec); /* mute/unmute HP */
10986 return ret;
10987}
10988
10989static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10990 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10991 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10992 {
10993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10994 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010995 .info = alc_mux_enum_info,
10996 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010997 .put = alc262_ultra_mux_enum_put,
10998 },
10999 { } /* end */
11000};
11001
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011002/* We use two mixers depending on the output pin; 0x16 is a mono output
11003 * and thus it's bound with a different mixer.
11004 * This function returns which mixer amp should be used.
11005 */
11006static int alc262_check_volbit(hda_nid_t nid)
11007{
11008 if (!nid)
11009 return 0;
11010 else if (nid == 0x16)
11011 return 2;
11012 else
11013 return 1;
11014}
11015
11016static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11017 const char *pfx, int *vbits)
11018{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011019 unsigned long val;
11020 int vbit;
11021
11022 vbit = alc262_check_volbit(nid);
11023 if (!vbit)
11024 return 0;
11025 if (*vbits & vbit) /* a volume control for this mixer already there */
11026 return 0;
11027 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011028 if (vbit == 2)
11029 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11030 else
11031 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011032 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011033}
11034
11035static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11036 const char *pfx)
11037{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011038 unsigned long val;
11039
11040 if (!nid)
11041 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011042 if (nid == 0x16)
11043 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11044 else
11045 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011046 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011047}
11048
Kailang Yangdf694da2005-12-05 19:42:22 +010011049/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011050static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11051 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011052{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011053 const char *pfx;
11054 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011055 int err;
11056
11057 spec->multiout.num_dacs = 1; /* only use one dac */
11058 spec->multiout.dac_nids = spec->private_dac_nids;
11059 spec->multiout.dac_nids[0] = 2;
11060
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011061 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11062 pfx = "Master";
11063 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11064 pfx = "Speaker";
11065 else
11066 pfx = "Front";
11067 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11068 if (err < 0)
11069 return err;
11070 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11071 if (err < 0)
11072 return err;
11073 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11074 if (err < 0)
11075 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011076
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011077 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11078 alc262_check_volbit(cfg->speaker_pins[0]) |
11079 alc262_check_volbit(cfg->hp_pins[0]);
11080 if (vbits == 1 || vbits == 2)
11081 pfx = "Master"; /* only one mixer is used */
11082 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11083 pfx = "Speaker";
11084 else
11085 pfx = "Front";
11086 vbits = 0;
11087 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11088 if (err < 0)
11089 return err;
11090 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11091 &vbits);
11092 if (err < 0)
11093 return err;
11094 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11095 &vbits);
11096 if (err < 0)
11097 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011098 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011099}
11100
Takashi Iwai05f5f472009-08-25 13:10:18 +020011101#define alc262_auto_create_input_ctls \
11102 alc880_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011103
11104/*
11105 * generic initialization of ADC, input mixers and output mixers
11106 */
11107static struct hda_verb alc262_volume_init_verbs[] = {
11108 /*
11109 * Unmute ADC0-2 and set the default input to mic-in
11110 */
11111 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11112 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11113 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11115 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11117
Takashi Iwaicb53c622007-08-10 17:21:45 +020011118 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011119 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011120 * Note: PASD motherboards uses the Line In 2 as the input for
11121 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011122 */
11123 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011124 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11125 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011129
11130 /*
11131 * Set up output mixers (0x0c - 0x0f)
11132 */
11133 /* set vol=0 to output mixers */
11134 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11136 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011137
Kailang Yangdf694da2005-12-05 19:42:22 +010011138 /* set up input amps for analog loopback */
11139 /* Amp Indices: DAC = 0, mixer = 1 */
11140 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11142 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11143 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11144 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11145 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11146
11147 /* FIXME: use matrix-type input source selection */
11148 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11149 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11150 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11151 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11152 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11153 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11154 /* Input mixer2 */
11155 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11157 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11158 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11159 /* Input mixer3 */
11160 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11161 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11162 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11163 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11164
11165 { }
11166};
11167
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011168static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11169 /*
11170 * Unmute ADC0-2 and set the default input to mic-in
11171 */
11172 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11173 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11174 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11175 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11176 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11177 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11178
Takashi Iwaicb53c622007-08-10 17:21:45 +020011179 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011180 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011181 * Note: PASD motherboards uses the Line In 2 as the input for
11182 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011183 */
11184 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11186 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11187 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11188 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11189 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11190 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11191 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011192
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011193 /*
11194 * Set up output mixers (0x0c - 0x0e)
11195 */
11196 /* set vol=0 to output mixers */
11197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11198 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11199 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11200
11201 /* set up input amps for analog loopback */
11202 /* Amp Indices: DAC = 0, mixer = 1 */
11203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11205 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11206 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11207 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11208 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11209
Takashi Iwaice875f02008-01-28 18:17:43 +010011210 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11212 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11213
11214 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11215 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11216
11217 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11218 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11219
11220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11221 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11222 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11223 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11224 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11225
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011226 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011227 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11228 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011229 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011230 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11231 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11232
11233
11234 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011235 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11236 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011238 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11239 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11240 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011246 /* Input mixer2 */
11247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011248 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11249 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11250 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11251 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11252 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11253 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11254 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11255 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011256 /* Input mixer3 */
11257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011258 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11261 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011266
Takashi Iwaice875f02008-01-28 18:17:43 +010011267 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11268
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011269 { }
11270};
11271
Kailang Yangcd7509a2007-01-26 18:33:17 +010011272static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11273 /*
11274 * Unmute ADC0-2 and set the default input to mic-in
11275 */
11276 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11278 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11279 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11280 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11281 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11282
Takashi Iwaicb53c622007-08-10 17:21:45 +020011283 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011284 * mixer widget
11285 * Note: PASD motherboards uses the Line In 2 as the input for front
11286 * panel mic (mic 2)
11287 */
11288 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11296 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011297 /*
11298 * Set up output mixers (0x0c - 0x0e)
11299 */
11300 /* set vol=0 to output mixers */
11301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11302 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11303 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11304
11305 /* set up input amps for analog loopback */
11306 /* Amp Indices: DAC = 0, mixer = 1 */
11307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11311 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11312 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11313
11314
11315 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11316 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11317 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11318 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11319 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11320 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11321 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11322
11323 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11325
11326 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11327 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11328
11329 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11330 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11331 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11332 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11333 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11334 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11335
11336 /* FIXME: use matrix-type input source selection */
11337 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11338 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11339 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11340 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11344 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11346 /* Input mixer2 */
11347 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11352 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11353 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11354 /* Input mixer3 */
11355 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11357 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11358 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11359 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11360 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11362
Takashi Iwaice875f02008-01-28 18:17:43 +010011363 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11364
Kailang Yangcd7509a2007-01-26 18:33:17 +010011365 { }
11366};
11367
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011368static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11369
11370 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11371 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11372 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11373
11374 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11375 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11376 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11377 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11378
11379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11380 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11381 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11382 {}
11383};
11384
11385
Takashi Iwaicb53c622007-08-10 17:21:45 +020011386#ifdef CONFIG_SND_HDA_POWER_SAVE
11387#define alc262_loopbacks alc880_loopbacks
11388#endif
11389
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011390/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011391#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11392#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11393#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11394#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11395
11396/*
11397 * BIOS auto configuration
11398 */
11399static int alc262_parse_auto_config(struct hda_codec *codec)
11400{
11401 struct alc_spec *spec = codec->spec;
11402 int err;
11403 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11404
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011405 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11406 alc262_ignore);
11407 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011408 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011409 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011410 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011411 spec->multiout.max_channels = 2;
11412 spec->no_analog = 1;
11413 goto dig_only;
11414 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011415 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011416 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011417 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11418 if (err < 0)
11419 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011420 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011421 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011422 return err;
11423
11424 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11425
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011426 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011427 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011428 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011429 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011430 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011431 if (spec->autocfg.dig_in_pin)
11432 spec->dig_in_nid = ALC262_DIGIN_NID;
11433
Takashi Iwai603c4012008-07-30 15:01:44 +020011434 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011435 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011436
Takashi Iwaid88897e2008-10-31 15:01:37 +010011437 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011438 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011439 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011440
Takashi Iwai776e1842007-08-29 15:07:11 +020011441 err = alc_auto_add_mic_boost(codec);
11442 if (err < 0)
11443 return err;
11444
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011445 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11446
Kailang Yangdf694da2005-12-05 19:42:22 +010011447 return 1;
11448}
11449
11450#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11451#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11452#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011453#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011454
11455
11456/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011457static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011458{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011459 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011460 alc262_auto_init_multi_out(codec);
11461 alc262_auto_init_hp_out(codec);
11462 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011463 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011464 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011465 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011466}
11467
11468/*
11469 * configuration and preset
11470 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011471static const char *alc262_models[ALC262_MODEL_LAST] = {
11472 [ALC262_BASIC] = "basic",
11473 [ALC262_HIPPO] = "hippo",
11474 [ALC262_HIPPO_1] = "hippo_1",
11475 [ALC262_FUJITSU] = "fujitsu",
11476 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011477 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011478 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011479 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011480 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011481 [ALC262_BENQ_T31] = "benq-t31",
11482 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011483 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011484 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011485 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011486 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011487 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011488 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011489 [ALC262_AUTO] = "auto",
11490};
11491
11492static struct snd_pci_quirk alc262_cfg_tbl[] = {
11493 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011494 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011495 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11496 ALC262_HP_BPC),
11497 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11498 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011499 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11500 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011501 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011502 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011503 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011504 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011505 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011506 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011507 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011508 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011509 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11510 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11511 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011512 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11513 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011514 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011515 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011516 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011517 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011518 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011519 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011520 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011521 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011522#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011523 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11524 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011525#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011526 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011527 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011528 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011529 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011530 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011531 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011532 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11533 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011534 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011535 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011536 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011537 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011538 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011539 {}
11540};
11541
11542static struct alc_config_preset alc262_presets[] = {
11543 [ALC262_BASIC] = {
11544 .mixers = { alc262_base_mixer },
11545 .init_verbs = { alc262_init_verbs },
11546 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11547 .dac_nids = alc262_dac_nids,
11548 .hp_nid = 0x03,
11549 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11550 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011551 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011552 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011553 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011554 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011555 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011556 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11557 .dac_nids = alc262_dac_nids,
11558 .hp_nid = 0x03,
11559 .dig_out_nid = ALC262_DIGOUT_NID,
11560 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11561 .channel_mode = alc262_modes,
11562 .input_mux = &alc262_capture_source,
11563 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011564 .setup = alc262_hippo_setup,
11565 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011566 },
11567 [ALC262_HIPPO_1] = {
11568 .mixers = { alc262_hippo1_mixer },
11569 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11570 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11571 .dac_nids = alc262_dac_nids,
11572 .hp_nid = 0x02,
11573 .dig_out_nid = ALC262_DIGOUT_NID,
11574 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11575 .channel_mode = alc262_modes,
11576 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011577 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011578 .setup = alc262_hippo1_setup,
11579 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011580 },
Takashi Iwai834be882006-03-01 14:16:17 +010011581 [ALC262_FUJITSU] = {
11582 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011583 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11584 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011585 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11586 .dac_nids = alc262_dac_nids,
11587 .hp_nid = 0x03,
11588 .dig_out_nid = ALC262_DIGOUT_NID,
11589 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11590 .channel_mode = alc262_modes,
11591 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011592 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011593 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011594 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011595 [ALC262_HP_BPC] = {
11596 .mixers = { alc262_HP_BPC_mixer },
11597 .init_verbs = { alc262_HP_BPC_init_verbs },
11598 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11599 .dac_nids = alc262_dac_nids,
11600 .hp_nid = 0x03,
11601 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11602 .channel_mode = alc262_modes,
11603 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011604 .unsol_event = alc262_hp_bpc_unsol_event,
11605 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011606 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011607 [ALC262_HP_BPC_D7000_WF] = {
11608 .mixers = { alc262_HP_BPC_WildWest_mixer },
11609 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11610 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11611 .dac_nids = alc262_dac_nids,
11612 .hp_nid = 0x03,
11613 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11614 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011615 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011616 .unsol_event = alc262_hp_wildwest_unsol_event,
11617 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011618 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011619 [ALC262_HP_BPC_D7000_WL] = {
11620 .mixers = { alc262_HP_BPC_WildWest_mixer,
11621 alc262_HP_BPC_WildWest_option_mixer },
11622 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11623 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11624 .dac_nids = alc262_dac_nids,
11625 .hp_nid = 0x03,
11626 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11627 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011628 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011629 .unsol_event = alc262_hp_wildwest_unsol_event,
11630 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011631 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011632 [ALC262_HP_TC_T5735] = {
11633 .mixers = { alc262_hp_t5735_mixer },
11634 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11635 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11636 .dac_nids = alc262_dac_nids,
11637 .hp_nid = 0x03,
11638 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11639 .channel_mode = alc262_modes,
11640 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011641 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011642 .setup = alc262_hp_t5735_setup,
11643 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011644 },
11645 [ALC262_HP_RP5700] = {
11646 .mixers = { alc262_hp_rp5700_mixer },
11647 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11648 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11649 .dac_nids = alc262_dac_nids,
11650 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11651 .channel_mode = alc262_modes,
11652 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011653 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011654 [ALC262_BENQ_ED8] = {
11655 .mixers = { alc262_base_mixer },
11656 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11657 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11658 .dac_nids = alc262_dac_nids,
11659 .hp_nid = 0x03,
11660 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11661 .channel_mode = alc262_modes,
11662 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011663 },
Kailang Yang272a5272007-05-14 11:00:38 +020011664 [ALC262_SONY_ASSAMD] = {
11665 .mixers = { alc262_sony_mixer },
11666 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11667 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11668 .dac_nids = alc262_dac_nids,
11669 .hp_nid = 0x02,
11670 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11671 .channel_mode = alc262_modes,
11672 .input_mux = &alc262_capture_source,
11673 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011674 .setup = alc262_hippo_setup,
11675 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011676 },
11677 [ALC262_BENQ_T31] = {
11678 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011679 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11680 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011681 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11682 .dac_nids = alc262_dac_nids,
11683 .hp_nid = 0x03,
11684 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11685 .channel_mode = alc262_modes,
11686 .input_mux = &alc262_capture_source,
11687 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011688 .setup = alc262_hippo_setup,
11689 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011690 },
Tobin Davisf651b502007-10-26 12:40:47 +020011691 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011692 .mixers = { alc262_ultra_mixer },
11693 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011694 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011695 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11696 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011697 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11698 .channel_mode = alc262_modes,
11699 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011700 .adc_nids = alc262_adc_nids, /* ADC0 */
11701 .capsrc_nids = alc262_capsrc_nids,
11702 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011703 .unsol_event = alc262_ultra_unsol_event,
11704 .init_hook = alc262_ultra_automute,
11705 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011706 [ALC262_LENOVO_3000] = {
11707 .mixers = { alc262_lenovo_3000_mixer },
11708 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11709 alc262_lenovo_3000_unsol_verbs },
11710 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11711 .dac_nids = alc262_dac_nids,
11712 .hp_nid = 0x03,
11713 .dig_out_nid = ALC262_DIGOUT_NID,
11714 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11715 .channel_mode = alc262_modes,
11716 .input_mux = &alc262_fujitsu_capture_source,
11717 .unsol_event = alc262_lenovo_3000_unsol_event,
11718 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011719 [ALC262_NEC] = {
11720 .mixers = { alc262_nec_mixer },
11721 .init_verbs = { alc262_nec_verbs },
11722 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11723 .dac_nids = alc262_dac_nids,
11724 .hp_nid = 0x03,
11725 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11726 .channel_mode = alc262_modes,
11727 .input_mux = &alc262_capture_source,
11728 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011729 [ALC262_TOSHIBA_S06] = {
11730 .mixers = { alc262_toshiba_s06_mixer },
11731 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11732 alc262_eapd_verbs },
11733 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11734 .capsrc_nids = alc262_dmic_capsrc_nids,
11735 .dac_nids = alc262_dac_nids,
11736 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011737 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011738 .dig_out_nid = ALC262_DIGOUT_NID,
11739 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11740 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011741 .unsol_event = alc_sku_unsol_event,
11742 .setup = alc262_toshiba_s06_setup,
11743 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011744 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011745 [ALC262_TOSHIBA_RX1] = {
11746 .mixers = { alc262_toshiba_rx1_mixer },
11747 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11748 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11749 .dac_nids = alc262_dac_nids,
11750 .hp_nid = 0x03,
11751 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11752 .channel_mode = alc262_modes,
11753 .input_mux = &alc262_capture_source,
11754 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011755 .setup = alc262_hippo_setup,
11756 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011757 },
Tony Vroonba340e82009-02-02 19:01:30 +000011758 [ALC262_TYAN] = {
11759 .mixers = { alc262_tyan_mixer },
11760 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11761 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11762 .dac_nids = alc262_dac_nids,
11763 .hp_nid = 0x02,
11764 .dig_out_nid = ALC262_DIGOUT_NID,
11765 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11766 .channel_mode = alc262_modes,
11767 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011768 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011769 .setup = alc262_tyan_setup,
11770 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011771 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011772};
11773
11774static int patch_alc262(struct hda_codec *codec)
11775{
11776 struct alc_spec *spec;
11777 int board_config;
11778 int err;
11779
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011780 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011781 if (spec == NULL)
11782 return -ENOMEM;
11783
11784 codec->spec = spec;
11785#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011786 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11787 * under-run
11788 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011789 {
11790 int tmp;
11791 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11792 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11793 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11794 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11795 }
11796#endif
11797
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011798 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11799
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011800 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11801 alc262_models,
11802 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011803
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011804 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011805 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11806 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011807 board_config = ALC262_AUTO;
11808 }
11809
11810 if (board_config == ALC262_AUTO) {
11811 /* automatic parse from the BIOS config */
11812 err = alc262_parse_auto_config(codec);
11813 if (err < 0) {
11814 alc_free(codec);
11815 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011816 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011817 printk(KERN_INFO
11818 "hda_codec: Cannot set up configuration "
11819 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011820 board_config = ALC262_BASIC;
11821 }
11822 }
11823
Takashi Iwai07eba612009-02-19 08:06:35 +010011824 if (!spec->no_analog) {
11825 err = snd_hda_attach_beep_device(codec, 0x1);
11826 if (err < 0) {
11827 alc_free(codec);
11828 return err;
11829 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011830 }
11831
Kailang Yangdf694da2005-12-05 19:42:22 +010011832 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011833 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011834
Kailang Yangdf694da2005-12-05 19:42:22 +010011835 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11836 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011837
Kailang Yangdf694da2005-12-05 19:42:22 +010011838 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11839 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11840
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011841 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011842 int i;
11843 /* check whether the digital-mic has to be supported */
11844 for (i = 0; i < spec->input_mux->num_items; i++) {
11845 if (spec->input_mux->items[i].index >= 9)
11846 break;
11847 }
11848 if (i < spec->input_mux->num_items) {
11849 /* use only ADC0 */
11850 spec->adc_nids = alc262_dmic_adc_nids;
11851 spec->num_adc_nids = 1;
11852 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011853 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011854 /* all analog inputs */
11855 /* check whether NID 0x07 is valid */
11856 unsigned int wcap = get_wcaps(codec, 0x07);
11857
11858 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011859 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011860 if (wcap != AC_WID_AUD_IN) {
11861 spec->adc_nids = alc262_adc_nids_alt;
11862 spec->num_adc_nids =
11863 ARRAY_SIZE(alc262_adc_nids_alt);
11864 spec->capsrc_nids = alc262_capsrc_nids_alt;
11865 } else {
11866 spec->adc_nids = alc262_adc_nids;
11867 spec->num_adc_nids =
11868 ARRAY_SIZE(alc262_adc_nids);
11869 spec->capsrc_nids = alc262_capsrc_nids;
11870 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011871 }
11872 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011873 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011874 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011875 if (!spec->no_analog)
11876 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011877
Takashi Iwai2134ea42008-01-10 16:53:55 +010011878 spec->vmaster_nid = 0x0c;
11879
Kailang Yangdf694da2005-12-05 19:42:22 +010011880 codec->patch_ops = alc_patch_ops;
11881 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011882 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011883#ifdef CONFIG_SND_HDA_POWER_SAVE
11884 if (!spec->loopback.amplist)
11885 spec->loopback.amplist = alc262_loopbacks;
11886#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011887 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011888
Kailang Yangdf694da2005-12-05 19:42:22 +010011889 return 0;
11890}
11891
Kailang Yangdf694da2005-12-05 19:42:22 +010011892/*
Kailang Yanga361d842007-06-05 12:30:55 +020011893 * ALC268 channel source setting (2 channel)
11894 */
11895#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11896#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011897
Kailang Yanga361d842007-06-05 12:30:55 +020011898static hda_nid_t alc268_dac_nids[2] = {
11899 /* front, hp */
11900 0x02, 0x03
11901};
11902
11903static hda_nid_t alc268_adc_nids[2] = {
11904 /* ADC0-1 */
11905 0x08, 0x07
11906};
11907
11908static hda_nid_t alc268_adc_nids_alt[1] = {
11909 /* ADC0 */
11910 0x08
11911};
11912
Takashi Iwaie1406342008-02-11 18:32:32 +010011913static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11914
Kailang Yanga361d842007-06-05 12:30:55 +020011915static struct snd_kcontrol_new alc268_base_mixer[] = {
11916 /* output mixer control */
11917 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11918 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11919 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011921 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11922 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11923 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011924 { }
11925};
11926
Takashi Iwai42171c12009-05-08 14:11:43 +020011927static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11928 /* output mixer control */
11929 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11930 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11931 ALC262_HIPPO_MASTER_SWITCH,
11932 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11933 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11934 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11935 { }
11936};
11937
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011938/* bind Beep switches of both NID 0x0f and 0x10 */
11939static struct hda_bind_ctls alc268_bind_beep_sw = {
11940 .ops = &snd_hda_bind_sw,
11941 .values = {
11942 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11943 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11944 0
11945 },
11946};
11947
11948static struct snd_kcontrol_new alc268_beep_mixer[] = {
11949 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11950 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11951 { }
11952};
11953
Kailang Yangd1a991a2007-08-15 16:21:59 +020011954static struct hda_verb alc268_eapd_verbs[] = {
11955 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11956 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11957 { }
11958};
11959
Takashi Iwaid2738092007-08-16 14:59:45 +020011960/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011961static struct hda_verb alc268_toshiba_verbs[] = {
11962 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11963 { } /* end */
11964};
11965
11966/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011967/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011968static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11969 .ops = &snd_hda_bind_vol,
11970 .values = {
11971 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11972 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11973 0
11974 },
11975};
11976
Takashi Iwai889c4392007-08-23 18:56:52 +020011977/* mute/unmute internal speaker according to the hp jack and mute state */
11978static void alc268_acer_automute(struct hda_codec *codec, int force)
11979{
11980 struct alc_spec *spec = codec->spec;
11981 unsigned int mute;
11982
11983 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011984 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020011985 spec->sense_updated = 1;
11986 }
11987 if (spec->jack_present)
11988 mute = HDA_AMP_MUTE; /* mute internal speaker */
11989 else /* unmute internal speaker if necessary */
11990 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11991 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11992 HDA_AMP_MUTE, mute);
11993}
11994
11995
11996/* bind hp and internal speaker mute (with plug check) */
11997static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11998 struct snd_ctl_elem_value *ucontrol)
11999{
12000 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12001 long *valp = ucontrol->value.integer.value;
12002 int change;
12003
Takashi Iwai8de56b72009-07-24 16:51:47 +020012004 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012005 if (change)
12006 alc268_acer_automute(codec, 0);
12007 return change;
12008}
Takashi Iwaid2738092007-08-16 14:59:45 +020012009
Kailang Yang8ef355d2008-08-26 13:10:22 +020012010static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12011 /* output mixer control */
12012 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12013 {
12014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12015 .name = "Master Playback Switch",
12016 .info = snd_hda_mixer_amp_switch_info,
12017 .get = snd_hda_mixer_amp_switch_get,
12018 .put = alc268_acer_master_sw_put,
12019 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12020 },
12021 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12022 { }
12023};
12024
Takashi Iwaid2738092007-08-16 14:59:45 +020012025static struct snd_kcontrol_new alc268_acer_mixer[] = {
12026 /* output mixer control */
12027 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12028 {
12029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12030 .name = "Master Playback Switch",
12031 .info = snd_hda_mixer_amp_switch_info,
12032 .get = snd_hda_mixer_amp_switch_get,
12033 .put = alc268_acer_master_sw_put,
12034 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12035 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012036 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12037 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12038 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012039 { }
12040};
12041
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012042static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12043 /* output mixer control */
12044 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12045 {
12046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12047 .name = "Master Playback Switch",
12048 .info = snd_hda_mixer_amp_switch_info,
12049 .get = snd_hda_mixer_amp_switch_get,
12050 .put = alc268_acer_master_sw_put,
12051 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12052 },
12053 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12054 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12055 { }
12056};
12057
Kailang Yang8ef355d2008-08-26 13:10:22 +020012058static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12059 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12060 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12061 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12062 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12063 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12064 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12065 { }
12066};
12067
Takashi Iwaid2738092007-08-16 14:59:45 +020012068static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012069 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12070 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012071 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12072 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012073 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12074 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012075 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12076 { }
12077};
12078
12079/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012080#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012081#define alc268_toshiba_setup alc262_hippo_setup
12082#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012083
12084static void alc268_acer_unsol_event(struct hda_codec *codec,
12085 unsigned int res)
12086{
Takashi Iwai889c4392007-08-23 18:56:52 +020012087 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012088 return;
12089 alc268_acer_automute(codec, 1);
12090}
12091
Takashi Iwai889c4392007-08-23 18:56:52 +020012092static void alc268_acer_init_hook(struct hda_codec *codec)
12093{
12094 alc268_acer_automute(codec, 1);
12095}
12096
Kailang Yang8ef355d2008-08-26 13:10:22 +020012097/* toggle speaker-output according to the hp-jack state */
12098static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12099{
12100 unsigned int present;
12101 unsigned char bits;
12102
Wu Fengguang864f92b2009-11-18 12:38:02 +080012103 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012104 bits = present ? AMP_IN_MUTE(0) : 0;
12105 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12106 AMP_IN_MUTE(0), bits);
12107 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12108 AMP_IN_MUTE(0), bits);
12109}
12110
Kailang Yang8ef355d2008-08-26 13:10:22 +020012111static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12112 unsigned int res)
12113{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012114 switch (res >> 26) {
12115 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012116 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012117 break;
12118 case ALC880_MIC_EVENT:
12119 alc_mic_automute(codec);
12120 break;
12121 }
12122}
12123
12124static void alc268_acer_lc_setup(struct hda_codec *codec)
12125{
12126 struct alc_spec *spec = codec->spec;
12127 spec->ext_mic.pin = 0x18;
12128 spec->ext_mic.mux_idx = 0;
12129 spec->int_mic.pin = 0x12;
12130 spec->int_mic.mux_idx = 6;
12131 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012132}
12133
12134static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12135{
12136 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012137 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012138}
12139
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012140static struct snd_kcontrol_new alc268_dell_mixer[] = {
12141 /* output mixer control */
12142 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12143 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12144 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12145 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12146 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12147 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12148 { }
12149};
12150
12151static struct hda_verb alc268_dell_verbs[] = {
12152 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12153 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12154 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012155 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012156 { }
12157};
12158
12159/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012160static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012161{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012162 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012163
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012164 spec->autocfg.hp_pins[0] = 0x15;
12165 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012166 spec->ext_mic.pin = 0x18;
12167 spec->ext_mic.mux_idx = 0;
12168 spec->int_mic.pin = 0x19;
12169 spec->int_mic.mux_idx = 1;
12170 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012171}
12172
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012173static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12174 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12175 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12176 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12177 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12178 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12179 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12180 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12181 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12182 { }
12183};
12184
12185static struct hda_verb alc267_quanta_il1_verbs[] = {
12186 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12187 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12188 { }
12189};
12190
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012191static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012192{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012193 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012194 spec->autocfg.hp_pins[0] = 0x15;
12195 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012196 spec->ext_mic.pin = 0x18;
12197 spec->ext_mic.mux_idx = 0;
12198 spec->int_mic.pin = 0x19;
12199 spec->int_mic.mux_idx = 1;
12200 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012201}
12202
Kailang Yanga361d842007-06-05 12:30:55 +020012203/*
12204 * generic initialization of ADC, input mixers and output mixers
12205 */
12206static struct hda_verb alc268_base_init_verbs[] = {
12207 /* Unmute DAC0-1 and set vol = 0 */
12208 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012209 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012210
12211 /*
12212 * Set up output mixers (0x0c - 0x0e)
12213 */
12214 /* set vol=0 to output mixers */
12215 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012216 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12217
12218 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12219 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12220
12221 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12223 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12224 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12225 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12226 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12227 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12228 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12229
12230 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12231 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12232 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12233 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012234 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012235
12236 /* set PCBEEP vol = 0, mute connections */
12237 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12238 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12239 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012240
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012241 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012242
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012243 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12244 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12245 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012247
Kailang Yanga361d842007-06-05 12:30:55 +020012248 { }
12249};
12250
12251/*
12252 * generic initialization of ADC, input mixers and output mixers
12253 */
12254static struct hda_verb alc268_volume_init_verbs[] = {
12255 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012256 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12257 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012258
12259 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12260 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12261 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12262 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12263 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12264
Kailang Yanga361d842007-06-05 12:30:55 +020012265 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012266 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12267 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12268
12269 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012271
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012272 /* set PCBEEP vol = 0, mute connections */
12273 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12274 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12275 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012276
12277 { }
12278};
12279
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012280static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12281 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12282 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12283 { } /* end */
12284};
12285
Kailang Yanga361d842007-06-05 12:30:55 +020012286static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12287 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12288 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012289 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012290 { } /* end */
12291};
12292
12293static struct snd_kcontrol_new alc268_capture_mixer[] = {
12294 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12295 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12296 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12297 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012298 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012299 { } /* end */
12300};
12301
12302static struct hda_input_mux alc268_capture_source = {
12303 .num_items = 4,
12304 .items = {
12305 { "Mic", 0x0 },
12306 { "Front Mic", 0x1 },
12307 { "Line", 0x2 },
12308 { "CD", 0x3 },
12309 },
12310};
12311
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012312static struct hda_input_mux alc268_acer_capture_source = {
12313 .num_items = 3,
12314 .items = {
12315 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012316 { "Internal Mic", 0x1 },
12317 { "Line", 0x2 },
12318 },
12319};
12320
12321static struct hda_input_mux alc268_acer_dmic_capture_source = {
12322 .num_items = 3,
12323 .items = {
12324 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012325 { "Internal Mic", 0x6 },
12326 { "Line", 0x2 },
12327 },
12328};
12329
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012330#ifdef CONFIG_SND_DEBUG
12331static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012332 /* Volume widgets */
12333 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12334 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12335 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12336 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12337 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12338 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12339 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12340 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12341 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12342 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12343 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12344 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12345 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012346 /* The below appears problematic on some hardwares */
12347 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012348 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12349 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12350 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12351 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12352
12353 /* Modes for retasking pin widgets */
12354 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12355 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12356 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12357 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12358
12359 /* Controls for GPIO pins, assuming they are configured as outputs */
12360 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12361 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12362 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12363 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12364
12365 /* Switches to allow the digital SPDIF output pin to be enabled.
12366 * The ALC268 does not have an SPDIF input.
12367 */
12368 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12369
12370 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12371 * this output to turn on an external amplifier.
12372 */
12373 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12374 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12375
12376 { } /* end */
12377};
12378#endif
12379
Kailang Yanga361d842007-06-05 12:30:55 +020012380/* create input playback/capture controls for the given pin */
12381static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12382 const char *ctlname, int idx)
12383{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012384 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012385 int err;
12386
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012387 switch (nid) {
12388 case 0x14:
12389 case 0x16:
12390 dac = 0x02;
12391 break;
12392 case 0x15:
12393 dac = 0x03;
12394 break;
12395 default:
12396 return 0;
12397 }
12398 if (spec->multiout.dac_nids[0] != dac &&
12399 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012400 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012401 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012402 HDA_OUTPUT));
12403 if (err < 0)
12404 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012405 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12406 }
12407
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012408 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012409 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012410 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012411 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012412 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012413 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012414 if (err < 0)
12415 return err;
12416 return 0;
12417}
12418
12419/* add playback controls from the parsed DAC table */
12420static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12421 const struct auto_pin_cfg *cfg)
12422{
12423 hda_nid_t nid;
12424 int err;
12425
Kailang Yanga361d842007-06-05 12:30:55 +020012426 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012427
12428 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012429 if (nid) {
12430 const char *name;
12431 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12432 name = "Speaker";
12433 else
12434 name = "Front";
12435 err = alc268_new_analog_output(spec, nid, name, 0);
12436 if (err < 0)
12437 return err;
12438 }
Kailang Yanga361d842007-06-05 12:30:55 +020012439
12440 nid = cfg->speaker_pins[0];
12441 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012442 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012443 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12444 if (err < 0)
12445 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012446 } else {
12447 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12448 if (err < 0)
12449 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012450 }
12451 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012452 if (nid) {
12453 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12454 if (err < 0)
12455 return err;
12456 }
Kailang Yanga361d842007-06-05 12:30:55 +020012457
12458 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12459 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012460 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012461 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012462 if (err < 0)
12463 return err;
12464 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012465 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012466}
12467
12468/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012469static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012470 const struct auto_pin_cfg *cfg)
12471{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012472 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012473}
12474
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012475static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12476 hda_nid_t nid, int pin_type)
12477{
12478 int idx;
12479
12480 alc_set_pin_output(codec, nid, pin_type);
12481 if (nid == 0x14 || nid == 0x16)
12482 idx = 0;
12483 else
12484 idx = 1;
12485 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12486}
12487
12488static void alc268_auto_init_multi_out(struct hda_codec *codec)
12489{
12490 struct alc_spec *spec = codec->spec;
12491 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12492 if (nid) {
12493 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12494 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12495 }
12496}
12497
12498static void alc268_auto_init_hp_out(struct hda_codec *codec)
12499{
12500 struct alc_spec *spec = codec->spec;
12501 hda_nid_t pin;
12502
12503 pin = spec->autocfg.hp_pins[0];
12504 if (pin)
12505 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12506 pin = spec->autocfg.speaker_pins[0];
12507 if (pin)
12508 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12509}
12510
Kailang Yanga361d842007-06-05 12:30:55 +020012511static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12512{
12513 struct alc_spec *spec = codec->spec;
12514 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12515 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12516 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12517 unsigned int dac_vol1, dac_vol2;
12518
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012519 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012520 snd_hda_codec_write(codec, speaker_nid, 0,
12521 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012522 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012523 snd_hda_codec_write(codec, 0x0f, 0,
12524 AC_VERB_SET_AMP_GAIN_MUTE,
12525 AMP_IN_UNMUTE(1));
12526 snd_hda_codec_write(codec, 0x10, 0,
12527 AC_VERB_SET_AMP_GAIN_MUTE,
12528 AMP_IN_UNMUTE(1));
12529 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012530 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012531 snd_hda_codec_write(codec, 0x0f, 0,
12532 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12533 snd_hda_codec_write(codec, 0x10, 0,
12534 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12535 }
12536
12537 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012538 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012539 dac_vol2 = AMP_OUT_ZERO;
12540 else if (line_nid == 0x15)
12541 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012542 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012543 dac_vol2 = AMP_OUT_ZERO;
12544 else if (hp_nid == 0x15)
12545 dac_vol1 = AMP_OUT_ZERO;
12546 if (line_nid != 0x16 || hp_nid != 0x16 ||
12547 spec->autocfg.line_out_pins[1] != 0x16 ||
12548 spec->autocfg.line_out_pins[2] != 0x16)
12549 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12550
12551 snd_hda_codec_write(codec, 0x02, 0,
12552 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12553 snd_hda_codec_write(codec, 0x03, 0,
12554 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12555}
12556
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012557/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012558#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12559#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012560#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012561#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12562
12563/*
12564 * BIOS auto configuration
12565 */
12566static int alc268_parse_auto_config(struct hda_codec *codec)
12567{
12568 struct alc_spec *spec = codec->spec;
12569 int err;
12570 static hda_nid_t alc268_ignore[] = { 0 };
12571
12572 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12573 alc268_ignore);
12574 if (err < 0)
12575 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012576 if (!spec->autocfg.line_outs) {
12577 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12578 spec->multiout.max_channels = 2;
12579 spec->no_analog = 1;
12580 goto dig_only;
12581 }
Kailang Yanga361d842007-06-05 12:30:55 +020012582 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012583 }
Kailang Yanga361d842007-06-05 12:30:55 +020012584 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12585 if (err < 0)
12586 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012587 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012588 if (err < 0)
12589 return err;
12590
12591 spec->multiout.max_channels = 2;
12592
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012593 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012594 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012595 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012596 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012597 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12598 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012599 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012600 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012601
Takashi Iwai892981f2009-03-02 08:04:35 +010012602 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012603 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012604
Takashi Iwaid88897e2008-10-31 15:01:37 +010012605 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012606 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012607 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012608
Takashi Iwai776e1842007-08-29 15:07:11 +020012609 err = alc_auto_add_mic_boost(codec);
12610 if (err < 0)
12611 return err;
12612
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012613 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12614
Kailang Yanga361d842007-06-05 12:30:55 +020012615 return 1;
12616}
12617
Kailang Yanga361d842007-06-05 12:30:55 +020012618#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12619
12620/* init callback for auto-configuration model -- overriding the default init */
12621static void alc268_auto_init(struct hda_codec *codec)
12622{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012623 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012624 alc268_auto_init_multi_out(codec);
12625 alc268_auto_init_hp_out(codec);
12626 alc268_auto_init_mono_speaker_out(codec);
12627 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012628 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012629 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012630}
12631
12632/*
12633 * configuration and preset
12634 */
12635static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012636 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012637 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012638 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012639 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012640 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012641 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012642 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012643 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012644#ifdef CONFIG_SND_DEBUG
12645 [ALC268_TEST] = "test",
12646#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012647 [ALC268_AUTO] = "auto",
12648};
12649
12650static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012651 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012652 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012653 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012654 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012655 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012656 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12657 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012658 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050012659 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
12660 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012661 /* almost compatible with toshiba but with optional digital outs;
12662 * auto-probing seems working fine
12663 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012664 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012665 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012666 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012667 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012668 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012669 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012670 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012671 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012672 {}
12673};
12674
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012675/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12676static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12677 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12678 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12679 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12680 ALC268_TOSHIBA),
12681 {}
12682};
12683
Kailang Yanga361d842007-06-05 12:30:55 +020012684static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012685 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012686 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12687 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012688 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12689 alc267_quanta_il1_verbs },
12690 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12691 .dac_nids = alc268_dac_nids,
12692 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12693 .adc_nids = alc268_adc_nids_alt,
12694 .hp_nid = 0x03,
12695 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12696 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012697 .unsol_event = alc_sku_unsol_event,
12698 .setup = alc267_quanta_il1_setup,
12699 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012700 },
Kailang Yanga361d842007-06-05 12:30:55 +020012701 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012702 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12703 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012704 .init_verbs = { alc268_base_init_verbs },
12705 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12706 .dac_nids = alc268_dac_nids,
12707 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12708 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012709 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012710 .hp_nid = 0x03,
12711 .dig_out_nid = ALC268_DIGOUT_NID,
12712 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12713 .channel_mode = alc268_modes,
12714 .input_mux = &alc268_capture_source,
12715 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012716 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012717 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012718 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012719 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12720 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012721 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12722 .dac_nids = alc268_dac_nids,
12723 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12724 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012725 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012726 .hp_nid = 0x03,
12727 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12728 .channel_mode = alc268_modes,
12729 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012730 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012731 .setup = alc268_toshiba_setup,
12732 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012733 },
12734 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020012735 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012736 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012737 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12738 alc268_acer_verbs },
12739 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12740 .dac_nids = alc268_dac_nids,
12741 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12742 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012743 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012744 .hp_nid = 0x02,
12745 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12746 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012747 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012748 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012749 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012750 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012751 [ALC268_ACER_DMIC] = {
12752 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12753 alc268_beep_mixer },
12754 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12755 alc268_acer_verbs },
12756 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12757 .dac_nids = alc268_dac_nids,
12758 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12759 .adc_nids = alc268_adc_nids_alt,
12760 .capsrc_nids = alc268_capsrc_nids,
12761 .hp_nid = 0x02,
12762 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12763 .channel_mode = alc268_modes,
12764 .input_mux = &alc268_acer_dmic_capture_source,
12765 .unsol_event = alc268_acer_unsol_event,
12766 .init_hook = alc268_acer_init_hook,
12767 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012768 [ALC268_ACER_ASPIRE_ONE] = {
12769 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012770 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012771 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012772 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12773 alc268_acer_aspire_one_verbs },
12774 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12775 .dac_nids = alc268_dac_nids,
12776 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12777 .adc_nids = alc268_adc_nids_alt,
12778 .capsrc_nids = alc268_capsrc_nids,
12779 .hp_nid = 0x03,
12780 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12781 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012782 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012783 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012784 .init_hook = alc268_acer_lc_init_hook,
12785 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012786 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012787 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12788 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012789 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12790 alc268_dell_verbs },
12791 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12792 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012793 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12794 .adc_nids = alc268_adc_nids_alt,
12795 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012796 .hp_nid = 0x02,
12797 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12798 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012799 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012800 .setup = alc268_dell_setup,
12801 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012802 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012803 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012804 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12805 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012806 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12807 alc268_toshiba_verbs },
12808 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12809 .dac_nids = alc268_dac_nids,
12810 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12811 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012812 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012813 .hp_nid = 0x03,
12814 .dig_out_nid = ALC268_DIGOUT_NID,
12815 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12816 .channel_mode = alc268_modes,
12817 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012818 .setup = alc268_toshiba_setup,
12819 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012820 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012821#ifdef CONFIG_SND_DEBUG
12822 [ALC268_TEST] = {
12823 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12824 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12825 alc268_volume_init_verbs },
12826 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12827 .dac_nids = alc268_dac_nids,
12828 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12829 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012830 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012831 .hp_nid = 0x03,
12832 .dig_out_nid = ALC268_DIGOUT_NID,
12833 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12834 .channel_mode = alc268_modes,
12835 .input_mux = &alc268_capture_source,
12836 },
12837#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012838};
12839
12840static int patch_alc268(struct hda_codec *codec)
12841{
12842 struct alc_spec *spec;
12843 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012844 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012845
12846 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12847 if (spec == NULL)
12848 return -ENOMEM;
12849
12850 codec->spec = spec;
12851
12852 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12853 alc268_models,
12854 alc268_cfg_tbl);
12855
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012856 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12857 board_config = snd_hda_check_board_codec_sid_config(codec,
12858 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12859
Kailang Yanga361d842007-06-05 12:30:55 +020012860 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012861 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12862 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012863 board_config = ALC268_AUTO;
12864 }
12865
12866 if (board_config == ALC268_AUTO) {
12867 /* automatic parse from the BIOS config */
12868 err = alc268_parse_auto_config(codec);
12869 if (err < 0) {
12870 alc_free(codec);
12871 return err;
12872 } else if (!err) {
12873 printk(KERN_INFO
12874 "hda_codec: Cannot set up configuration "
12875 "from BIOS. Using base mode...\n");
12876 board_config = ALC268_3ST;
12877 }
12878 }
12879
12880 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012881 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012882
Kailang Yanga361d842007-06-05 12:30:55 +020012883 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12884 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012885 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012886
Kailang Yanga361d842007-06-05 12:30:55 +020012887 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12888
Takashi Iwai22971e32009-02-10 11:56:44 +010012889 has_beep = 0;
12890 for (i = 0; i < spec->num_mixers; i++) {
12891 if (spec->mixers[i] == alc268_beep_mixer) {
12892 has_beep = 1;
12893 break;
12894 }
12895 }
12896
12897 if (has_beep) {
12898 err = snd_hda_attach_beep_device(codec, 0x1);
12899 if (err < 0) {
12900 alc_free(codec);
12901 return err;
12902 }
12903 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12904 /* override the amp caps for beep generator */
12905 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012906 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12907 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12908 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12909 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012910 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012911
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012912 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012913 /* check whether NID 0x07 is valid */
12914 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012915 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012916
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012917 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012918 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012919 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012920 if (spec->auto_mic ||
12921 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012922 spec->adc_nids = alc268_adc_nids_alt;
12923 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012924 if (spec->auto_mic)
12925 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012926 if (spec->auto_mic || spec->input_mux->num_items == 1)
12927 add_mixer(spec, alc268_capture_nosrc_mixer);
12928 else
12929 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012930 } else {
12931 spec->adc_nids = alc268_adc_nids;
12932 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012933 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012934 }
Takashi Iwai85860c02008-02-19 15:00:15 +010012935 /* set default input source */
12936 for (i = 0; i < spec->num_adc_nids; i++)
12937 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12938 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012939 i < spec->num_mux_defs ?
12940 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012941 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012942 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012943
12944 spec->vmaster_nid = 0x02;
12945
Kailang Yanga361d842007-06-05 12:30:55 +020012946 codec->patch_ops = alc_patch_ops;
12947 if (board_config == ALC268_AUTO)
12948 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012949
Takashi Iwaidaead532008-11-28 12:55:36 +010012950 codec->proc_widget_hook = print_realtek_coef;
12951
Kailang Yanga361d842007-06-05 12:30:55 +020012952 return 0;
12953}
12954
12955/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012956 * ALC269 channel source setting (2 channel)
12957 */
12958#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12959
12960#define alc269_dac_nids alc260_dac_nids
12961
12962static hda_nid_t alc269_adc_nids[1] = {
12963 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012964 0x08,
12965};
12966
Takashi Iwaie01bf502008-08-21 16:25:07 +020012967static hda_nid_t alc269_capsrc_nids[1] = {
12968 0x23,
12969};
12970
12971/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12972 * not a mux!
12973 */
12974
Kailang Yangf6a92242007-12-13 16:52:54 +010012975#define alc269_modes alc260_modes
12976#define alc269_capture_source alc880_lg_lw_capture_source
12977
12978static struct snd_kcontrol_new alc269_base_mixer[] = {
12979 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12980 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12981 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12982 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12984 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12985 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12986 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12987 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12988 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12989 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12990 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12991 { } /* end */
12992};
12993
Kailang Yang60db6b52008-08-26 13:13:00 +020012994static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12995 /* output mixer control */
12996 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12997 {
12998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12999 .name = "Master Playback Switch",
13000 .info = snd_hda_mixer_amp_switch_info,
13001 .get = snd_hda_mixer_amp_switch_get,
13002 .put = alc268_acer_master_sw_put,
13003 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13004 },
13005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13006 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13007 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13008 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13009 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13010 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013011 { }
13012};
13013
Tony Vroon64154832008-11-06 15:08:49 +000013014static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13015 /* output mixer control */
13016 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13017 {
13018 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13019 .name = "Master Playback Switch",
13020 .info = snd_hda_mixer_amp_switch_info,
13021 .get = snd_hda_mixer_amp_switch_get,
13022 .put = alc268_acer_master_sw_put,
13023 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13024 },
13025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13027 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13028 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13029 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13030 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13031 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13032 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13033 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013034 { }
13035};
13036
Kailang Yangf53281e2008-07-18 12:36:43 +020013037static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013038 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013039 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013040 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013041 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013042 { } /* end */
13043};
13044
Kailang Yangf6a92242007-12-13 16:52:54 +010013045/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020013046static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
13047 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13048 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013049 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13050 { } /* end */
13051};
13052
13053/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020013054#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013055
Kailang Yang60db6b52008-08-26 13:13:00 +020013056static struct hda_verb alc269_quanta_fl1_verbs[] = {
13057 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13058 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13059 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13060 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13061 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13062 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13063 { }
13064};
13065
Tony Vroon64154832008-11-06 15:08:49 +000013066static struct hda_verb alc269_lifebook_verbs[] = {
13067 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13068 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13069 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13070 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13071 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13072 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13073 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13074 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13075 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13076 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13077 { }
13078};
13079
Kailang Yang60db6b52008-08-26 13:13:00 +020013080/* toggle speaker-output according to the hp-jack state */
13081static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13082{
13083 unsigned int present;
13084 unsigned char bits;
13085
Wu Fengguang864f92b2009-11-18 12:38:02 +080013086 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013087 bits = present ? AMP_IN_MUTE(0) : 0;
13088 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13089 AMP_IN_MUTE(0), bits);
13090 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13091 AMP_IN_MUTE(0), bits);
13092
13093 snd_hda_codec_write(codec, 0x20, 0,
13094 AC_VERB_SET_COEF_INDEX, 0x0c);
13095 snd_hda_codec_write(codec, 0x20, 0,
13096 AC_VERB_SET_PROC_COEF, 0x680);
13097
13098 snd_hda_codec_write(codec, 0x20, 0,
13099 AC_VERB_SET_COEF_INDEX, 0x0c);
13100 snd_hda_codec_write(codec, 0x20, 0,
13101 AC_VERB_SET_PROC_COEF, 0x480);
13102}
13103
Tony Vroon64154832008-11-06 15:08:49 +000013104/* toggle speaker-output according to the hp-jacks state */
13105static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13106{
13107 unsigned int present;
13108 unsigned char bits;
13109
13110 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013111 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013112
13113 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013114 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013115
13116 bits = present ? AMP_IN_MUTE(0) : 0;
13117 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13118 AMP_IN_MUTE(0), bits);
13119 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13120 AMP_IN_MUTE(0), bits);
13121
13122 snd_hda_codec_write(codec, 0x20, 0,
13123 AC_VERB_SET_COEF_INDEX, 0x0c);
13124 snd_hda_codec_write(codec, 0x20, 0,
13125 AC_VERB_SET_PROC_COEF, 0x680);
13126
13127 snd_hda_codec_write(codec, 0x20, 0,
13128 AC_VERB_SET_COEF_INDEX, 0x0c);
13129 snd_hda_codec_write(codec, 0x20, 0,
13130 AC_VERB_SET_PROC_COEF, 0x480);
13131}
13132
Tony Vroon64154832008-11-06 15:08:49 +000013133static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13134{
13135 unsigned int present_laptop;
13136 unsigned int present_dock;
13137
Wu Fengguang864f92b2009-11-18 12:38:02 +080013138 present_laptop = snd_hda_jack_detect(codec, 0x18);
13139 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013140
13141 /* Laptop mic port overrides dock mic port, design decision */
13142 if (present_dock)
13143 snd_hda_codec_write(codec, 0x23, 0,
13144 AC_VERB_SET_CONNECT_SEL, 0x3);
13145 if (present_laptop)
13146 snd_hda_codec_write(codec, 0x23, 0,
13147 AC_VERB_SET_CONNECT_SEL, 0x0);
13148 if (!present_dock && !present_laptop)
13149 snd_hda_codec_write(codec, 0x23, 0,
13150 AC_VERB_SET_CONNECT_SEL, 0x1);
13151}
13152
Kailang Yang60db6b52008-08-26 13:13:00 +020013153static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13154 unsigned int res)
13155{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013156 switch (res >> 26) {
13157 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013158 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013159 break;
13160 case ALC880_MIC_EVENT:
13161 alc_mic_automute(codec);
13162 break;
13163 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013164}
13165
Tony Vroon64154832008-11-06 15:08:49 +000013166static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13167 unsigned int res)
13168{
13169 if ((res >> 26) == ALC880_HP_EVENT)
13170 alc269_lifebook_speaker_automute(codec);
13171 if ((res >> 26) == ALC880_MIC_EVENT)
13172 alc269_lifebook_mic_autoswitch(codec);
13173}
13174
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013175static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13176{
13177 struct alc_spec *spec = codec->spec;
13178 spec->ext_mic.pin = 0x18;
13179 spec->ext_mic.mux_idx = 0;
13180 spec->int_mic.pin = 0x19;
13181 spec->int_mic.mux_idx = 1;
13182 spec->auto_mic = 1;
13183}
13184
Kailang Yang60db6b52008-08-26 13:13:00 +020013185static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13186{
13187 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013188 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013189}
13190
Tony Vroon64154832008-11-06 15:08:49 +000013191static void alc269_lifebook_init_hook(struct hda_codec *codec)
13192{
13193 alc269_lifebook_speaker_automute(codec);
13194 alc269_lifebook_mic_autoswitch(codec);
13195}
13196
Kailang Yang60db6b52008-08-26 13:13:00 +020013197static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13198 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13199 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13200 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13201 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13202 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13203 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13204 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13205 {}
13206};
13207
13208static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13209 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13210 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13211 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13212 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13213 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13214 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13215 {}
13216};
13217
13218/* toggle speaker-output according to the hp-jack state */
13219static void alc269_speaker_automute(struct hda_codec *codec)
13220{
13221 unsigned int present;
13222 unsigned char bits;
13223
Wu Fengguang864f92b2009-11-18 12:38:02 +080013224 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013225 bits = present ? AMP_IN_MUTE(0) : 0;
13226 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13227 AMP_IN_MUTE(0), bits);
13228 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13229 AMP_IN_MUTE(0), bits);
13230}
13231
Kailang Yang60db6b52008-08-26 13:13:00 +020013232/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013233static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013234 unsigned int res)
13235{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013236 switch (res >> 26) {
13237 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013238 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013239 break;
13240 case ALC880_MIC_EVENT:
13241 alc_mic_automute(codec);
13242 break;
13243 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013244}
13245
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013246static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13247{
13248 struct alc_spec *spec = codec->spec;
13249 spec->ext_mic.pin = 0x18;
13250 spec->ext_mic.mux_idx = 0;
13251 spec->int_mic.pin = 0x12;
13252 spec->int_mic.mux_idx = 5;
13253 spec->auto_mic = 1;
13254}
13255
13256static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13257{
13258 struct alc_spec *spec = codec->spec;
13259 spec->ext_mic.pin = 0x18;
13260 spec->ext_mic.mux_idx = 0;
13261 spec->int_mic.pin = 0x19;
13262 spec->int_mic.mux_idx = 1;
13263 spec->auto_mic = 1;
13264}
13265
13266static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013267{
13268 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013269 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013270}
13271
Kailang Yangf6a92242007-12-13 16:52:54 +010013272/*
13273 * generic initialization of ADC, input mixers and output mixers
13274 */
13275static struct hda_verb alc269_init_verbs[] = {
13276 /*
13277 * Unmute ADC0 and set the default input to mic-in
13278 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013280
13281 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13282 * analog-loopback mixer widget
13283 * Note: PASD motherboards uses the Line In 2 as the input for
13284 * front panel mic (mic 2)
13285 */
13286 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13292
13293 /*
13294 * Set up output mixers (0x0c - 0x0e)
13295 */
13296 /* set vol=0 to output mixers */
13297 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13298 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13299
13300 /* set up input amps for analog loopback */
13301 /* Amp Indices: DAC = 0, mixer = 1 */
13302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13304 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13305 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13306 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13307 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13308
13309 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13310 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13311 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13312 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13313 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13314 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13315 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13316
13317 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13318 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13319 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13320 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13321 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13322 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13323 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13324
13325 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13326 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13327
13328 /* FIXME: use matrix-type input source selection */
13329 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13330 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13335
13336 /* set EAPD */
13337 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13338 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13339 { }
13340};
13341
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013342#define alc269_auto_create_multi_out_ctls \
13343 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013344#define alc269_auto_create_input_ctls \
13345 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013346
13347#ifdef CONFIG_SND_HDA_POWER_SAVE
13348#define alc269_loopbacks alc880_loopbacks
13349#endif
13350
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013351/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013352#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13353#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13354#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13355#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13356
Takashi Iwaif03d3112009-03-05 14:18:16 +010013357static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13358 .substreams = 1,
13359 .channels_min = 2,
13360 .channels_max = 8,
13361 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13362 /* NID is set in alc_build_pcms */
13363 .ops = {
13364 .open = alc880_playback_pcm_open,
13365 .prepare = alc880_playback_pcm_prepare,
13366 .cleanup = alc880_playback_pcm_cleanup
13367 },
13368};
13369
13370static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13371 .substreams = 1,
13372 .channels_min = 2,
13373 .channels_max = 2,
13374 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13375 /* NID is set in alc_build_pcms */
13376};
13377
Kailang Yangf6a92242007-12-13 16:52:54 +010013378/*
13379 * BIOS auto configuration
13380 */
13381static int alc269_parse_auto_config(struct hda_codec *codec)
13382{
13383 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013384 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013385 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13386
13387 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13388 alc269_ignore);
13389 if (err < 0)
13390 return err;
13391
13392 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13393 if (err < 0)
13394 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013395 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013396 if (err < 0)
13397 return err;
13398
13399 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13400
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013401 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013402 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13403
Takashi Iwai603c4012008-07-30 15:01:44 +020013404 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013405 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013406
Takashi Iwaid88897e2008-10-31 15:01:37 +010013407 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013408 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013409 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013410 /* set default input source */
13411 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13412 0, AC_VERB_SET_CONNECT_SEL,
13413 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013414
13415 err = alc_auto_add_mic_boost(codec);
13416 if (err < 0)
13417 return err;
13418
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013419 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013420 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013421
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013422 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13423
Kailang Yangf6a92242007-12-13 16:52:54 +010013424 return 1;
13425}
13426
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013427#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13428#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013429#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13430
13431
13432/* init callback for auto-configuration model -- overriding the default init */
13433static void alc269_auto_init(struct hda_codec *codec)
13434{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013435 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013436 alc269_auto_init_multi_out(codec);
13437 alc269_auto_init_hp_out(codec);
13438 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013439 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013440 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013441}
13442
13443/*
13444 * configuration and preset
13445 */
13446static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013447 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013448 [ALC269_QUANTA_FL1] = "quanta",
13449 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013450 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013451 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013452 [ALC269_LIFEBOOK] = "lifebook",
13453 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013454};
13455
13456static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013457 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013458 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13459 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013460 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13461 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13462 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13463 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13464 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13465 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013466 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13467 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013468 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13469 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013470 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013471 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013472 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013473 {}
13474};
13475
13476static struct alc_config_preset alc269_presets[] = {
13477 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013478 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013479 .init_verbs = { alc269_init_verbs },
13480 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13481 .dac_nids = alc269_dac_nids,
13482 .hp_nid = 0x03,
13483 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13484 .channel_mode = alc269_modes,
13485 .input_mux = &alc269_capture_source,
13486 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013487 [ALC269_QUANTA_FL1] = {
13488 .mixers = { alc269_quanta_fl1_mixer },
13489 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13490 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13491 .dac_nids = alc269_dac_nids,
13492 .hp_nid = 0x03,
13493 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13494 .channel_mode = alc269_modes,
13495 .input_mux = &alc269_capture_source,
13496 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013497 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013498 .init_hook = alc269_quanta_fl1_init_hook,
13499 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013500 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013501 .mixers = { alc269_eeepc_mixer },
13502 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013503 .init_verbs = { alc269_init_verbs,
13504 alc269_eeepc_amic_init_verbs },
13505 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13506 .dac_nids = alc269_dac_nids,
13507 .hp_nid = 0x03,
13508 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13509 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013510 .unsol_event = alc269_eeepc_unsol_event,
13511 .setup = alc269_eeepc_amic_setup,
13512 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013513 },
13514 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013515 .mixers = { alc269_eeepc_mixer },
13516 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013517 .init_verbs = { alc269_init_verbs,
13518 alc269_eeepc_dmic_init_verbs },
13519 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13520 .dac_nids = alc269_dac_nids,
13521 .hp_nid = 0x03,
13522 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13523 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013524 .unsol_event = alc269_eeepc_unsol_event,
13525 .setup = alc269_eeepc_dmic_setup,
13526 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013527 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013528 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013529 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013530 .cap_mixer = alc269_epc_capture_mixer,
13531 .init_verbs = { alc269_init_verbs,
13532 alc269_eeepc_dmic_init_verbs },
13533 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13534 .dac_nids = alc269_dac_nids,
13535 .hp_nid = 0x03,
13536 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13537 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013538 .unsol_event = alc269_eeepc_unsol_event,
13539 .setup = alc269_eeepc_dmic_setup,
13540 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013541 },
Tony Vroon64154832008-11-06 15:08:49 +000013542 [ALC269_LIFEBOOK] = {
13543 .mixers = { alc269_lifebook_mixer },
13544 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13545 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13546 .dac_nids = alc269_dac_nids,
13547 .hp_nid = 0x03,
13548 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13549 .channel_mode = alc269_modes,
13550 .input_mux = &alc269_capture_source,
13551 .unsol_event = alc269_lifebook_unsol_event,
13552 .init_hook = alc269_lifebook_init_hook,
13553 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013554};
13555
13556static int patch_alc269(struct hda_codec *codec)
13557{
13558 struct alc_spec *spec;
13559 int board_config;
13560 int err;
13561
13562 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13563 if (spec == NULL)
13564 return -ENOMEM;
13565
13566 codec->spec = spec;
13567
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013568 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13569
Kailang Yang274693f2009-12-03 10:07:50 +010013570 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
13571 kfree(codec->chip_name);
13572 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013573 if (!codec->chip_name) {
13574 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010013575 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013576 }
Kailang Yang274693f2009-12-03 10:07:50 +010013577 }
13578
Kailang Yangf6a92242007-12-13 16:52:54 +010013579 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13580 alc269_models,
13581 alc269_cfg_tbl);
13582
13583 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013584 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13585 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013586 board_config = ALC269_AUTO;
13587 }
13588
13589 if (board_config == ALC269_AUTO) {
13590 /* automatic parse from the BIOS config */
13591 err = alc269_parse_auto_config(codec);
13592 if (err < 0) {
13593 alc_free(codec);
13594 return err;
13595 } else if (!err) {
13596 printk(KERN_INFO
13597 "hda_codec: Cannot set up configuration "
13598 "from BIOS. Using base mode...\n");
13599 board_config = ALC269_BASIC;
13600 }
13601 }
13602
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013603 err = snd_hda_attach_beep_device(codec, 0x1);
13604 if (err < 0) {
13605 alc_free(codec);
13606 return err;
13607 }
13608
Kailang Yangf6a92242007-12-13 16:52:54 +010013609 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013610 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013611
Takashi Iwaif03d3112009-03-05 14:18:16 +010013612 if (codec->subsystem_id == 0x17aa3bf8) {
13613 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13614 * fix the sample rate of analog I/O to 44.1kHz
13615 */
13616 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13617 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13618 } else {
13619 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13620 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13621 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013622 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13623 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13624
13625 spec->adc_nids = alc269_adc_nids;
13626 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013627 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013628 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013629 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013630 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013631
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013632 spec->vmaster_nid = 0x02;
13633
Kailang Yangf6a92242007-12-13 16:52:54 +010013634 codec->patch_ops = alc_patch_ops;
13635 if (board_config == ALC269_AUTO)
13636 spec->init_hook = alc269_auto_init;
13637#ifdef CONFIG_SND_HDA_POWER_SAVE
13638 if (!spec->loopback.amplist)
13639 spec->loopback.amplist = alc269_loopbacks;
13640#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013641 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013642
13643 return 0;
13644}
13645
13646/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013647 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13648 */
13649
13650/*
13651 * set the path ways for 2 channel output
13652 * need to set the codec line out and mic 1 pin widgets to inputs
13653 */
13654static struct hda_verb alc861_threestack_ch2_init[] = {
13655 /* set pin widget 1Ah (line in) for input */
13656 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013657 /* set pin widget 18h (mic1/2) for input, for mic also enable
13658 * the vref
13659 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013660 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13661
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013662 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13663#if 0
13664 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13665 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13666#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013667 { } /* end */
13668};
13669/*
13670 * 6ch mode
13671 * need to set the codec line out and mic 1 pin widgets to outputs
13672 */
13673static struct hda_verb alc861_threestack_ch6_init[] = {
13674 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13675 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13676 /* set pin widget 18h (mic1) for output (CLFE)*/
13677 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13678
13679 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013680 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013681
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013682 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13683#if 0
13684 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13685 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13686#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013687 { } /* end */
13688};
13689
13690static struct hda_channel_mode alc861_threestack_modes[2] = {
13691 { 2, alc861_threestack_ch2_init },
13692 { 6, alc861_threestack_ch6_init },
13693};
Takashi Iwai22309c32006-08-09 16:57:28 +020013694/* Set mic1 as input and unmute the mixer */
13695static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13696 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13697 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13698 { } /* end */
13699};
13700/* Set mic1 as output and mute mixer */
13701static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13702 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13703 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13704 { } /* end */
13705};
13706
13707static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13708 { 2, alc861_uniwill_m31_ch2_init },
13709 { 4, alc861_uniwill_m31_ch4_init },
13710};
Kailang Yangdf694da2005-12-05 19:42:22 +010013711
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013712/* Set mic1 and line-in as input and unmute the mixer */
13713static struct hda_verb alc861_asus_ch2_init[] = {
13714 /* set pin widget 1Ah (line in) for input */
13715 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013716 /* set pin widget 18h (mic1/2) for input, for mic also enable
13717 * the vref
13718 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013719 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13720
13721 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13722#if 0
13723 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13724 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13725#endif
13726 { } /* end */
13727};
13728/* Set mic1 nad line-in as output and mute mixer */
13729static struct hda_verb alc861_asus_ch6_init[] = {
13730 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13731 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13732 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13733 /* set pin widget 18h (mic1) for output (CLFE)*/
13734 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13735 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13736 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13737 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13738
13739 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13740#if 0
13741 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13742 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13743#endif
13744 { } /* end */
13745};
13746
13747static struct hda_channel_mode alc861_asus_modes[2] = {
13748 { 2, alc861_asus_ch2_init },
13749 { 6, alc861_asus_ch6_init },
13750};
13751
Kailang Yangdf694da2005-12-05 19:42:22 +010013752/* patch-ALC861 */
13753
13754static struct snd_kcontrol_new alc861_base_mixer[] = {
13755 /* output mixer control */
13756 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13757 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13758 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13759 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13760 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13761
13762 /*Input mixer control */
13763 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13764 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13765 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13766 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13767 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13768 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13769 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13770 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13771 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13772 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013773
Kailang Yangdf694da2005-12-05 19:42:22 +010013774 { } /* end */
13775};
13776
13777static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13778 /* output mixer control */
13779 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13780 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13781 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13782 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13783 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13784
13785 /* Input mixer control */
13786 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13787 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13788 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13789 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13790 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13791 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13793 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13794 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013796
Kailang Yangdf694da2005-12-05 19:42:22 +010013797 {
13798 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13799 .name = "Channel Mode",
13800 .info = alc_ch_mode_info,
13801 .get = alc_ch_mode_get,
13802 .put = alc_ch_mode_put,
13803 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13804 },
13805 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013806};
13807
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013808static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013809 /* output mixer control */
13810 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13812 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013813
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013814 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013815};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013816
Takashi Iwai22309c32006-08-09 16:57:28 +020013817static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13818 /* output mixer control */
13819 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13820 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13821 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13822 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13823 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13824
13825 /* Input mixer control */
13826 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13827 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13828 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13829 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13830 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13831 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13833 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13834 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13835 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013836
Takashi Iwai22309c32006-08-09 16:57:28 +020013837 {
13838 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13839 .name = "Channel Mode",
13840 .info = alc_ch_mode_info,
13841 .get = alc_ch_mode_get,
13842 .put = alc_ch_mode_put,
13843 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13844 },
13845 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013846};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013847
13848static struct snd_kcontrol_new alc861_asus_mixer[] = {
13849 /* output mixer control */
13850 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13851 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13852 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13853 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13854 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13855
13856 /* Input mixer control */
13857 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13858 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13859 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13860 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13861 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13862 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13864 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13865 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013866 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13867
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013868 {
13869 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13870 .name = "Channel Mode",
13871 .info = alc_ch_mode_info,
13872 .get = alc_ch_mode_get,
13873 .put = alc_ch_mode_put,
13874 .private_value = ARRAY_SIZE(alc861_asus_modes),
13875 },
13876 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013877};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013878
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013879/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013880static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013881 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13882 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013883 { }
13884};
13885
Kailang Yangdf694da2005-12-05 19:42:22 +010013886/*
13887 * generic initialization of ADC, input mixers and output mixers
13888 */
13889static struct hda_verb alc861_base_init_verbs[] = {
13890 /*
13891 * Unmute ADC0 and set the default input to mic-in
13892 */
13893 /* port-A for surround (rear panel) */
13894 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13895 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13896 /* port-B for mic-in (rear panel) with vref */
13897 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13898 /* port-C for line-in (rear panel) */
13899 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13900 /* port-D for Front */
13901 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13902 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13903 /* port-E for HP out (front panel) */
13904 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13905 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013906 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013907 /* port-F for mic-in (front panel) with vref */
13908 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13909 /* port-G for CLFE (rear panel) */
13910 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13911 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13912 /* port-H for side (rear panel) */
13913 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13914 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13915 /* CD-in */
13916 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13917 /* route front mic to ADC1*/
13918 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13919 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013920
Kailang Yangdf694da2005-12-05 19:42:22 +010013921 /* Unmute DAC0~3 & spdif out*/
13922 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13923 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13924 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13925 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13926 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013927
Kailang Yangdf694da2005-12-05 19:42:22 +010013928 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13929 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13930 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13931 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13932 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013933
Kailang Yangdf694da2005-12-05 19:42:22 +010013934 /* Unmute Stereo Mixer 15 */
13935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13936 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13937 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013938 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013939
13940 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13941 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13942 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13943 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13944 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13945 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13946 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13947 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013948 /* hp used DAC 3 (Front) */
13949 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013950 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13951
13952 { }
13953};
13954
13955static struct hda_verb alc861_threestack_init_verbs[] = {
13956 /*
13957 * Unmute ADC0 and set the default input to mic-in
13958 */
13959 /* port-A for surround (rear panel) */
13960 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13961 /* port-B for mic-in (rear panel) with vref */
13962 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13963 /* port-C for line-in (rear panel) */
13964 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13965 /* port-D for Front */
13966 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13967 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13968 /* port-E for HP out (front panel) */
13969 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13970 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013971 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013972 /* port-F for mic-in (front panel) with vref */
13973 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13974 /* port-G for CLFE (rear panel) */
13975 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13976 /* port-H for side (rear panel) */
13977 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13978 /* CD-in */
13979 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13980 /* route front mic to ADC1*/
13981 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13982 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13983 /* Unmute DAC0~3 & spdif out*/
13984 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13985 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13986 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13987 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13988 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013989
Kailang Yangdf694da2005-12-05 19:42:22 +010013990 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13991 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13992 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13993 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13994 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013995
Kailang Yangdf694da2005-12-05 19:42:22 +010013996 /* Unmute Stereo Mixer 15 */
13997 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13998 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13999 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014000 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014001
14002 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14003 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14004 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14005 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14006 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14007 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14008 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14009 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014010 /* hp used DAC 3 (Front) */
14011 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014012 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14013 { }
14014};
Takashi Iwai22309c32006-08-09 16:57:28 +020014015
14016static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14017 /*
14018 * Unmute ADC0 and set the default input to mic-in
14019 */
14020 /* port-A for surround (rear panel) */
14021 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14022 /* port-B for mic-in (rear panel) with vref */
14023 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14024 /* port-C for line-in (rear panel) */
14025 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14026 /* port-D for Front */
14027 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14028 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14029 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014030 /* this has to be set to VREF80 */
14031 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014032 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014033 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014034 /* port-F for mic-in (front panel) with vref */
14035 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14036 /* port-G for CLFE (rear panel) */
14037 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14038 /* port-H for side (rear panel) */
14039 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14040 /* CD-in */
14041 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14042 /* route front mic to ADC1*/
14043 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14044 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14045 /* Unmute DAC0~3 & spdif out*/
14046 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14047 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14048 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14049 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014051
Takashi Iwai22309c32006-08-09 16:57:28 +020014052 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14053 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14054 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14055 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14056 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014057
Takashi Iwai22309c32006-08-09 16:57:28 +020014058 /* Unmute Stereo Mixer 15 */
14059 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14060 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14061 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014063
14064 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14065 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14066 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14067 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14068 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14069 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14070 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014072 /* hp used DAC 3 (Front) */
14073 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014074 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14075 { }
14076};
14077
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014078static struct hda_verb alc861_asus_init_verbs[] = {
14079 /*
14080 * Unmute ADC0 and set the default input to mic-in
14081 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014082 /* port-A for surround (rear panel)
14083 * according to codec#0 this is the HP jack
14084 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014085 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14086 /* route front PCM to HP */
14087 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14088 /* port-B for mic-in (rear panel) with vref */
14089 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14090 /* port-C for line-in (rear panel) */
14091 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14092 /* port-D for Front */
14093 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14094 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14095 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014096 /* this has to be set to VREF80 */
14097 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014098 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014099 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014100 /* port-F for mic-in (front panel) with vref */
14101 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14102 /* port-G for CLFE (rear panel) */
14103 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14104 /* port-H for side (rear panel) */
14105 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14106 /* CD-in */
14107 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14108 /* route front mic to ADC1*/
14109 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14110 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14111 /* Unmute DAC0~3 & spdif out*/
14112 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14113 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14114 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14115 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14117 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14118 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14119 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14120 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14121 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014122
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014123 /* Unmute Stereo Mixer 15 */
14124 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014128
14129 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14130 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14131 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14132 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14134 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14135 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14136 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014137 /* hp used DAC 3 (Front) */
14138 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014139 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14140 { }
14141};
14142
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014143/* additional init verbs for ASUS laptops */
14144static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14145 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14146 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14147 { }
14148};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014149
Kailang Yangdf694da2005-12-05 19:42:22 +010014150/*
14151 * generic initialization of ADC, input mixers and output mixers
14152 */
14153static struct hda_verb alc861_auto_init_verbs[] = {
14154 /*
14155 * Unmute ADC0 and set the default input to mic-in
14156 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014157 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014158 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014159
Kailang Yangdf694da2005-12-05 19:42:22 +010014160 /* Unmute DAC0~3 & spdif out*/
14161 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14162 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14163 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14164 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14165 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014166
Kailang Yangdf694da2005-12-05 19:42:22 +010014167 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14168 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14169 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14170 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14171 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014172
Kailang Yangdf694da2005-12-05 19:42:22 +010014173 /* Unmute Stereo Mixer 15 */
14174 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14176 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14178
Takashi Iwai1c209302009-07-22 15:17:45 +020014179 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14180 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14181 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14182 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14183 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14184 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14185 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14186 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014187
14188 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14189 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014190 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14191 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014192 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14193 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14195 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014196
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014197 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014198
14199 { }
14200};
14201
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014202static struct hda_verb alc861_toshiba_init_verbs[] = {
14203 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014204
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014205 { }
14206};
14207
14208/* toggle speaker-output according to the hp-jack state */
14209static void alc861_toshiba_automute(struct hda_codec *codec)
14210{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014211 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014212
Takashi Iwai47fd8302007-08-10 17:11:07 +020014213 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14214 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14215 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14216 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014217}
14218
14219static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14220 unsigned int res)
14221{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014222 if ((res >> 26) == ALC880_HP_EVENT)
14223 alc861_toshiba_automute(codec);
14224}
14225
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014226/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014227#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14228#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14229#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14230#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14231
14232
14233#define ALC861_DIGOUT_NID 0x07
14234
14235static struct hda_channel_mode alc861_8ch_modes[1] = {
14236 { 8, NULL }
14237};
14238
14239static hda_nid_t alc861_dac_nids[4] = {
14240 /* front, surround, clfe, side */
14241 0x03, 0x06, 0x05, 0x04
14242};
14243
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014244static hda_nid_t alc660_dac_nids[3] = {
14245 /* front, clfe, surround */
14246 0x03, 0x05, 0x06
14247};
14248
Kailang Yangdf694da2005-12-05 19:42:22 +010014249static hda_nid_t alc861_adc_nids[1] = {
14250 /* ADC0-2 */
14251 0x08,
14252};
14253
14254static struct hda_input_mux alc861_capture_source = {
14255 .num_items = 5,
14256 .items = {
14257 { "Mic", 0x0 },
14258 { "Front Mic", 0x3 },
14259 { "Line", 0x1 },
14260 { "CD", 0x4 },
14261 { "Mixer", 0x5 },
14262 },
14263};
14264
Takashi Iwai1c209302009-07-22 15:17:45 +020014265static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14266{
14267 struct alc_spec *spec = codec->spec;
14268 hda_nid_t mix, srcs[5];
14269 int i, j, num;
14270
14271 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14272 return 0;
14273 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14274 if (num < 0)
14275 return 0;
14276 for (i = 0; i < num; i++) {
14277 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014278 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014279 if (type != AC_WID_AUD_OUT)
14280 continue;
14281 for (j = 0; j < spec->multiout.num_dacs; j++)
14282 if (spec->multiout.dac_nids[j] == srcs[i])
14283 break;
14284 if (j >= spec->multiout.num_dacs)
14285 return srcs[i];
14286 }
14287 return 0;
14288}
14289
Kailang Yangdf694da2005-12-05 19:42:22 +010014290/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014291static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014292 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014293{
Takashi Iwai1c209302009-07-22 15:17:45 +020014294 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014295 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014296 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014297
14298 spec->multiout.dac_nids = spec->private_dac_nids;
14299 for (i = 0; i < cfg->line_outs; i++) {
14300 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014301 dac = alc861_look_for_dac(codec, nid);
14302 if (!dac)
14303 continue;
14304 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014305 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014306 return 0;
14307}
14308
Takashi Iwai1c209302009-07-22 15:17:45 +020014309static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14310 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014311{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014312 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014313 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14314}
14315
14316/* add playback controls from the parsed DAC table */
14317static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14318 const struct auto_pin_cfg *cfg)
14319{
14320 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014321 static const char *chname[4] = {
14322 "Front", "Surround", NULL /*CLFE*/, "Side"
14323 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014324 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014325 int i, err;
14326
14327 if (cfg->line_outs == 1) {
14328 const char *pfx = NULL;
14329 if (!cfg->hp_outs)
14330 pfx = "Master";
14331 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14332 pfx = "Speaker";
14333 if (pfx) {
14334 nid = spec->multiout.dac_nids[0];
14335 return alc861_create_out_sw(codec, pfx, nid, 3);
14336 }
14337 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014338
14339 for (i = 0; i < cfg->line_outs; i++) {
14340 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014341 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014342 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014343 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014344 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014345 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014346 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014347 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014348 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014349 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014350 return err;
14351 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014352 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014353 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014354 return err;
14355 }
14356 }
14357 return 0;
14358}
14359
Takashi Iwai1c209302009-07-22 15:17:45 +020014360static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014361{
Takashi Iwai1c209302009-07-22 15:17:45 +020014362 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014363 int err;
14364 hda_nid_t nid;
14365
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014366 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014367 return 0;
14368
14369 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014370 nid = alc861_look_for_dac(codec, pin);
14371 if (nid) {
14372 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14373 if (err < 0)
14374 return err;
14375 spec->multiout.hp_nid = nid;
14376 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014377 }
14378 return 0;
14379}
14380
14381/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014382static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014383 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014384{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014385 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014386}
14387
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014388static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14389 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014390 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014391{
Takashi Iwai1c209302009-07-22 15:17:45 +020014392 hda_nid_t mix, srcs[5];
14393 int i, num;
14394
Jacek Luczak564c5be2008-05-03 18:41:23 +020014395 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14396 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014397 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014398 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014399 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14400 return;
14401 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14402 if (num < 0)
14403 return;
14404 for (i = 0; i < num; i++) {
14405 unsigned int mute;
14406 if (srcs[i] == dac || srcs[i] == 0x15)
14407 mute = AMP_IN_UNMUTE(i);
14408 else
14409 mute = AMP_IN_MUTE(i);
14410 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14411 mute);
14412 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014413}
14414
14415static void alc861_auto_init_multi_out(struct hda_codec *codec)
14416{
14417 struct alc_spec *spec = codec->spec;
14418 int i;
14419
14420 for (i = 0; i < spec->autocfg.line_outs; i++) {
14421 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014422 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014423 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014424 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014425 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014426 }
14427}
14428
14429static void alc861_auto_init_hp_out(struct hda_codec *codec)
14430{
14431 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014432
Takashi Iwai15870f02009-10-05 08:25:13 +020014433 if (spec->autocfg.hp_outs)
14434 alc861_auto_set_output_and_unmute(codec,
14435 spec->autocfg.hp_pins[0],
14436 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014437 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014438 if (spec->autocfg.speaker_outs)
14439 alc861_auto_set_output_and_unmute(codec,
14440 spec->autocfg.speaker_pins[0],
14441 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014442 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014443}
14444
14445static void alc861_auto_init_analog_input(struct hda_codec *codec)
14446{
14447 struct alc_spec *spec = codec->spec;
14448 int i;
14449
14450 for (i = 0; i < AUTO_PIN_LAST; i++) {
14451 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014452 if (nid >= 0x0c && nid <= 0x11)
14453 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014454 }
14455}
14456
14457/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014458/* return 1 if successful, 0 if the proper config is not found,
14459 * or a negative error code
14460 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014461static int alc861_parse_auto_config(struct hda_codec *codec)
14462{
14463 struct alc_spec *spec = codec->spec;
14464 int err;
14465 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14466
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014467 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14468 alc861_ignore);
14469 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014470 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014471 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014472 return 0; /* can't find valid BIOS pin config */
14473
Takashi Iwai1c209302009-07-22 15:17:45 +020014474 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014475 if (err < 0)
14476 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014477 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014478 if (err < 0)
14479 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014480 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014481 if (err < 0)
14482 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014483 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014484 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014485 return err;
14486
14487 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14488
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014489 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014490 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14491
Takashi Iwai603c4012008-07-30 15:01:44 +020014492 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014493 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014494
Takashi Iwaid88897e2008-10-31 15:01:37 +010014495 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014496
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014497 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014498 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014499
14500 spec->adc_nids = alc861_adc_nids;
14501 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014502 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014503
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014504 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14505
Kailang Yangdf694da2005-12-05 19:42:22 +010014506 return 1;
14507}
14508
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014509/* additional initialization for auto-configuration model */
14510static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014511{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014512 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014513 alc861_auto_init_multi_out(codec);
14514 alc861_auto_init_hp_out(codec);
14515 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014516 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014517 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014518}
14519
Takashi Iwaicb53c622007-08-10 17:21:45 +020014520#ifdef CONFIG_SND_HDA_POWER_SAVE
14521static struct hda_amp_list alc861_loopbacks[] = {
14522 { 0x15, HDA_INPUT, 0 },
14523 { 0x15, HDA_INPUT, 1 },
14524 { 0x15, HDA_INPUT, 2 },
14525 { 0x15, HDA_INPUT, 3 },
14526 { } /* end */
14527};
14528#endif
14529
Kailang Yangdf694da2005-12-05 19:42:22 +010014530
14531/*
14532 * configuration and preset
14533 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014534static const char *alc861_models[ALC861_MODEL_LAST] = {
14535 [ALC861_3ST] = "3stack",
14536 [ALC660_3ST] = "3stack-660",
14537 [ALC861_3ST_DIG] = "3stack-dig",
14538 [ALC861_6ST_DIG] = "6stack-dig",
14539 [ALC861_UNIWILL_M31] = "uniwill-m31",
14540 [ALC861_TOSHIBA] = "toshiba",
14541 [ALC861_ASUS] = "asus",
14542 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14543 [ALC861_AUTO] = "auto",
14544};
14545
14546static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014547 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014548 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14549 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14550 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014551 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014552 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014553 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014554 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14555 * Any other models that need this preset?
14556 */
14557 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014558 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14559 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014560 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14561 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14562 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14563 /* FIXME: the below seems conflict */
14564 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14565 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14566 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014567 {}
14568};
14569
14570static struct alc_config_preset alc861_presets[] = {
14571 [ALC861_3ST] = {
14572 .mixers = { alc861_3ST_mixer },
14573 .init_verbs = { alc861_threestack_init_verbs },
14574 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14575 .dac_nids = alc861_dac_nids,
14576 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14577 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014578 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014579 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14580 .adc_nids = alc861_adc_nids,
14581 .input_mux = &alc861_capture_source,
14582 },
14583 [ALC861_3ST_DIG] = {
14584 .mixers = { alc861_base_mixer },
14585 .init_verbs = { alc861_threestack_init_verbs },
14586 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14587 .dac_nids = alc861_dac_nids,
14588 .dig_out_nid = ALC861_DIGOUT_NID,
14589 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14590 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014591 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014592 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14593 .adc_nids = alc861_adc_nids,
14594 .input_mux = &alc861_capture_source,
14595 },
14596 [ALC861_6ST_DIG] = {
14597 .mixers = { alc861_base_mixer },
14598 .init_verbs = { alc861_base_init_verbs },
14599 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14600 .dac_nids = alc861_dac_nids,
14601 .dig_out_nid = ALC861_DIGOUT_NID,
14602 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14603 .channel_mode = alc861_8ch_modes,
14604 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14605 .adc_nids = alc861_adc_nids,
14606 .input_mux = &alc861_capture_source,
14607 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014608 [ALC660_3ST] = {
14609 .mixers = { alc861_3ST_mixer },
14610 .init_verbs = { alc861_threestack_init_verbs },
14611 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14612 .dac_nids = alc660_dac_nids,
14613 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14614 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014615 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014616 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14617 .adc_nids = alc861_adc_nids,
14618 .input_mux = &alc861_capture_source,
14619 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014620 [ALC861_UNIWILL_M31] = {
14621 .mixers = { alc861_uniwill_m31_mixer },
14622 .init_verbs = { alc861_uniwill_m31_init_verbs },
14623 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14624 .dac_nids = alc861_dac_nids,
14625 .dig_out_nid = ALC861_DIGOUT_NID,
14626 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14627 .channel_mode = alc861_uniwill_m31_modes,
14628 .need_dac_fix = 1,
14629 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14630 .adc_nids = alc861_adc_nids,
14631 .input_mux = &alc861_capture_source,
14632 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014633 [ALC861_TOSHIBA] = {
14634 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014635 .init_verbs = { alc861_base_init_verbs,
14636 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014637 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14638 .dac_nids = alc861_dac_nids,
14639 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14640 .channel_mode = alc883_3ST_2ch_modes,
14641 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14642 .adc_nids = alc861_adc_nids,
14643 .input_mux = &alc861_capture_source,
14644 .unsol_event = alc861_toshiba_unsol_event,
14645 .init_hook = alc861_toshiba_automute,
14646 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014647 [ALC861_ASUS] = {
14648 .mixers = { alc861_asus_mixer },
14649 .init_verbs = { alc861_asus_init_verbs },
14650 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14651 .dac_nids = alc861_dac_nids,
14652 .dig_out_nid = ALC861_DIGOUT_NID,
14653 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14654 .channel_mode = alc861_asus_modes,
14655 .need_dac_fix = 1,
14656 .hp_nid = 0x06,
14657 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14658 .adc_nids = alc861_adc_nids,
14659 .input_mux = &alc861_capture_source,
14660 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014661 [ALC861_ASUS_LAPTOP] = {
14662 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14663 .init_verbs = { alc861_asus_init_verbs,
14664 alc861_asus_laptop_init_verbs },
14665 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14666 .dac_nids = alc861_dac_nids,
14667 .dig_out_nid = ALC861_DIGOUT_NID,
14668 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14669 .channel_mode = alc883_3ST_2ch_modes,
14670 .need_dac_fix = 1,
14671 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14672 .adc_nids = alc861_adc_nids,
14673 .input_mux = &alc861_capture_source,
14674 },
14675};
Kailang Yangdf694da2005-12-05 19:42:22 +010014676
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014677/* Pin config fixes */
14678enum {
14679 PINFIX_FSC_AMILO_PI1505,
14680};
14681
14682static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
14683 { 0x0b, 0x0221101f }, /* HP */
14684 { 0x0f, 0x90170310 }, /* speaker */
14685 { }
14686};
14687
14688static const struct alc_fixup alc861_fixups[] = {
14689 [PINFIX_FSC_AMILO_PI1505] = {
14690 .pins = alc861_fsc_amilo_pi1505_pinfix
14691 },
14692};
14693
14694static struct snd_pci_quirk alc861_fixup_tbl[] = {
14695 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
14696 {}
14697};
Kailang Yangdf694da2005-12-05 19:42:22 +010014698
14699static int patch_alc861(struct hda_codec *codec)
14700{
14701 struct alc_spec *spec;
14702 int board_config;
14703 int err;
14704
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014705 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014706 if (spec == NULL)
14707 return -ENOMEM;
14708
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014709 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014710
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014711 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14712 alc861_models,
14713 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014714
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014715 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014716 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14717 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014718 board_config = ALC861_AUTO;
14719 }
14720
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014721 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
14722
Kailang Yangdf694da2005-12-05 19:42:22 +010014723 if (board_config == ALC861_AUTO) {
14724 /* automatic parse from the BIOS config */
14725 err = alc861_parse_auto_config(codec);
14726 if (err < 0) {
14727 alc_free(codec);
14728 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014729 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014730 printk(KERN_INFO
14731 "hda_codec: Cannot set up configuration "
14732 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014733 board_config = ALC861_3ST_DIG;
14734 }
14735 }
14736
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014737 err = snd_hda_attach_beep_device(codec, 0x23);
14738 if (err < 0) {
14739 alc_free(codec);
14740 return err;
14741 }
14742
Kailang Yangdf694da2005-12-05 19:42:22 +010014743 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014744 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014745
Kailang Yangdf694da2005-12-05 19:42:22 +010014746 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14747 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14748
Kailang Yangdf694da2005-12-05 19:42:22 +010014749 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14750 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14751
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014752 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14753
Takashi Iwai2134ea42008-01-10 16:53:55 +010014754 spec->vmaster_nid = 0x03;
14755
Kailang Yangdf694da2005-12-05 19:42:22 +010014756 codec->patch_ops = alc_patch_ops;
14757 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014758 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014759#ifdef CONFIG_SND_HDA_POWER_SAVE
14760 if (!spec->loopback.amplist)
14761 spec->loopback.amplist = alc861_loopbacks;
14762#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014763 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014764
Kailang Yangdf694da2005-12-05 19:42:22 +010014765 return 0;
14766}
14767
14768/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014769 * ALC861-VD support
14770 *
14771 * Based on ALC882
14772 *
14773 * In addition, an independent DAC
14774 */
14775#define ALC861VD_DIGOUT_NID 0x06
14776
14777static hda_nid_t alc861vd_dac_nids[4] = {
14778 /* front, surr, clfe, side surr */
14779 0x02, 0x03, 0x04, 0x05
14780};
14781
14782/* dac_nids for ALC660vd are in a different order - according to
14783 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014784 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014785 * of ALC660vd codecs, but for now there is only 3stack mixer
14786 * - and it is the same as in 861vd.
14787 * adc_nids in ALC660vd are (is) the same as in 861vd
14788 */
14789static hda_nid_t alc660vd_dac_nids[3] = {
14790 /* front, rear, clfe, rear_surr */
14791 0x02, 0x04, 0x03
14792};
14793
14794static hda_nid_t alc861vd_adc_nids[1] = {
14795 /* ADC0 */
14796 0x09,
14797};
14798
Takashi Iwaie1406342008-02-11 18:32:32 +010014799static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14800
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014801/* input MUX */
14802/* FIXME: should be a matrix-type input source selection */
14803static struct hda_input_mux alc861vd_capture_source = {
14804 .num_items = 4,
14805 .items = {
14806 { "Mic", 0x0 },
14807 { "Front Mic", 0x1 },
14808 { "Line", 0x2 },
14809 { "CD", 0x4 },
14810 },
14811};
14812
Kailang Yang272a5272007-05-14 11:00:38 +020014813static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014814 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014815 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014816 { "Ext Mic", 0x0 },
14817 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014818 },
14819};
14820
Kailang Yangd1a991a2007-08-15 16:21:59 +020014821static struct hda_input_mux alc861vd_hp_capture_source = {
14822 .num_items = 2,
14823 .items = {
14824 { "Front Mic", 0x0 },
14825 { "ATAPI Mic", 0x1 },
14826 },
14827};
14828
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014829/*
14830 * 2ch mode
14831 */
14832static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14833 { 2, NULL }
14834};
14835
14836/*
14837 * 6ch mode
14838 */
14839static struct hda_verb alc861vd_6stack_ch6_init[] = {
14840 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14841 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14842 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14843 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14844 { } /* end */
14845};
14846
14847/*
14848 * 8ch mode
14849 */
14850static struct hda_verb alc861vd_6stack_ch8_init[] = {
14851 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14852 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14853 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14854 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14855 { } /* end */
14856};
14857
14858static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14859 { 6, alc861vd_6stack_ch6_init },
14860 { 8, alc861vd_6stack_ch8_init },
14861};
14862
14863static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14864 {
14865 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14866 .name = "Channel Mode",
14867 .info = alc_ch_mode_info,
14868 .get = alc_ch_mode_get,
14869 .put = alc_ch_mode_put,
14870 },
14871 { } /* end */
14872};
14873
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014874/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14875 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14876 */
14877static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14878 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14879 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14880
14881 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14882 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14883
14884 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14885 HDA_OUTPUT),
14886 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14887 HDA_OUTPUT),
14888 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14889 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14890
14891 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14892 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14893
14894 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14895
14896 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14899
14900 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14901 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14902 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14903
14904 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14905 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14906
14907 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14908 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14909
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014910 { } /* end */
14911};
14912
14913static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14914 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14915 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14916
14917 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14918
14919 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14922
14923 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14924 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14925 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14926
14927 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14928 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14929
14930 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14931 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14932
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014933 { } /* end */
14934};
14935
Kailang Yangbdd148a2007-05-08 15:19:08 +020014936static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14937 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14938 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14939 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14940
14941 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14942
14943 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14944 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14945 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14946
14947 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14948 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14949 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14950
14951 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14952 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14953
14954 { } /* end */
14955};
14956
Tobin Davisb419f342008-03-07 11:57:51 +010014957/* Pin assignment: Speaker=0x14, HP = 0x15,
14958 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014959 */
14960static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014961 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14962 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014963 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14964 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014965 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14966 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14967 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14968 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14969 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14970 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014971 { } /* end */
14972};
14973
Kailang Yangd1a991a2007-08-15 16:21:59 +020014974/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14975 * Front Mic=0x18, ATAPI Mic = 0x19,
14976 */
14977static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14978 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14979 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14980 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14981 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14982 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14983 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14984 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14985 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014986
Kailang Yangd1a991a2007-08-15 16:21:59 +020014987 { } /* end */
14988};
14989
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014990/*
14991 * generic initialization of ADC, input mixers and output mixers
14992 */
14993static struct hda_verb alc861vd_volume_init_verbs[] = {
14994 /*
14995 * Unmute ADC0 and set the default input to mic-in
14996 */
14997 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14998 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14999
15000 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15001 * the analog-loopback mixer widget
15002 */
15003 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15005 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015009
15010 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15012 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015014 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015015
15016 /*
15017 * Set up output mixers (0x02 - 0x05)
15018 */
15019 /* set vol=0 to output mixers */
15020 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15021 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15022 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15023 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15024
15025 /* set up input amps for analog loopback */
15026 /* Amp Indices: DAC = 0, mixer = 1 */
15027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15028 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15029 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15030 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15031 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15032 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15033 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15034 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15035
15036 { }
15037};
15038
15039/*
15040 * 3-stack pin configuration:
15041 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15042 */
15043static struct hda_verb alc861vd_3stack_init_verbs[] = {
15044 /*
15045 * Set pin mode and muting
15046 */
15047 /* set front pin widgets 0x14 for output */
15048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15050 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15051
15052 /* Mic (rear) pin: input vref at 80% */
15053 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15054 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15055 /* Front Mic pin: input vref at 80% */
15056 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15057 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15058 /* Line In pin: input */
15059 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15060 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15061 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15062 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15063 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15064 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15065 /* CD pin widget for input */
15066 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15067
15068 { }
15069};
15070
15071/*
15072 * 6-stack pin configuration:
15073 */
15074static struct hda_verb alc861vd_6stack_init_verbs[] = {
15075 /*
15076 * Set pin mode and muting
15077 */
15078 /* set front pin widgets 0x14 for output */
15079 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15080 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15081 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15082
15083 /* Rear Pin: output 1 (0x0d) */
15084 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15085 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15086 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15087 /* CLFE Pin: output 2 (0x0e) */
15088 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15089 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15090 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15091 /* Side Pin: output 3 (0x0f) */
15092 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15093 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15094 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15095
15096 /* Mic (rear) pin: input vref at 80% */
15097 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15098 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15099 /* Front Mic pin: input vref at 80% */
15100 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15101 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15102 /* Line In pin: input */
15103 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15104 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15105 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15106 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15107 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15108 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15109 /* CD pin widget for input */
15110 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15111
15112 { }
15113};
15114
Kailang Yangbdd148a2007-05-08 15:19:08 +020015115static struct hda_verb alc861vd_eapd_verbs[] = {
15116 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15117 { }
15118};
15119
Kailang Yangf9423e72008-05-27 12:32:25 +020015120static struct hda_verb alc660vd_eapd_verbs[] = {
15121 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15122 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15123 { }
15124};
15125
Kailang Yangbdd148a2007-05-08 15:19:08 +020015126static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15127 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15130 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015131 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015132 {}
15133};
15134
Kailang Yangbdd148a2007-05-08 15:19:08 +020015135static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15136{
15137 unsigned int present;
15138 unsigned char bits;
15139
Wu Fengguang864f92b2009-11-18 12:38:02 +080015140 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015141 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015142
Takashi Iwai47fd8302007-08-10 17:11:07 +020015143 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15144 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015145}
15146
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015147static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015148{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015149 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015150 spec->autocfg.hp_pins[0] = 0x1b;
15151 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015152}
15153
15154static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15155{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015156 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015157 alc861vd_lenovo_mic_automute(codec);
15158}
15159
15160static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15161 unsigned int res)
15162{
15163 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015164 case ALC880_MIC_EVENT:
15165 alc861vd_lenovo_mic_automute(codec);
15166 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015167 default:
15168 alc_automute_amp_unsol_event(codec, res);
15169 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015170 }
15171}
15172
Kailang Yang272a5272007-05-14 11:00:38 +020015173static struct hda_verb alc861vd_dallas_verbs[] = {
15174 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15175 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15176 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15177 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15178
15179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15181 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15182 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15183 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15184 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15185 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15186 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015187
Kailang Yang272a5272007-05-14 11:00:38 +020015188 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15189 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15190 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15192 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15193 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15194 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15195 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15196
15197 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15198 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15199 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15200 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15201 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15202 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15203 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15204 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15205
15206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15209 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15210
15211 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015212 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015213 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15214
15215 { } /* end */
15216};
15217
15218/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015219static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015220{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015221 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015222
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015223 spec->autocfg.hp_pins[0] = 0x15;
15224 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015225}
15226
Takashi Iwaicb53c622007-08-10 17:21:45 +020015227#ifdef CONFIG_SND_HDA_POWER_SAVE
15228#define alc861vd_loopbacks alc880_loopbacks
15229#endif
15230
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015231/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015232#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15233#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15234#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15235#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15236
15237/*
15238 * configuration and preset
15239 */
15240static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15241 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015242 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015243 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015244 [ALC861VD_3ST] = "3stack",
15245 [ALC861VD_3ST_DIG] = "3stack-digout",
15246 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015247 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015248 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015249 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015250 [ALC861VD_AUTO] = "auto",
15251};
15252
15253static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015254 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15255 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015256 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015257 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015258 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015259 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015260 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015261 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015262 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015263 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015264 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015265 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015266 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015267 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015268 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015269 {}
15270};
15271
15272static struct alc_config_preset alc861vd_presets[] = {
15273 [ALC660VD_3ST] = {
15274 .mixers = { alc861vd_3st_mixer },
15275 .init_verbs = { alc861vd_volume_init_verbs,
15276 alc861vd_3stack_init_verbs },
15277 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15278 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015279 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15280 .channel_mode = alc861vd_3stack_2ch_modes,
15281 .input_mux = &alc861vd_capture_source,
15282 },
Mike Crash6963f842007-06-25 12:12:51 +020015283 [ALC660VD_3ST_DIG] = {
15284 .mixers = { alc861vd_3st_mixer },
15285 .init_verbs = { alc861vd_volume_init_verbs,
15286 alc861vd_3stack_init_verbs },
15287 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15288 .dac_nids = alc660vd_dac_nids,
15289 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015290 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15291 .channel_mode = alc861vd_3stack_2ch_modes,
15292 .input_mux = &alc861vd_capture_source,
15293 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015294 [ALC861VD_3ST] = {
15295 .mixers = { alc861vd_3st_mixer },
15296 .init_verbs = { alc861vd_volume_init_verbs,
15297 alc861vd_3stack_init_verbs },
15298 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15299 .dac_nids = alc861vd_dac_nids,
15300 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15301 .channel_mode = alc861vd_3stack_2ch_modes,
15302 .input_mux = &alc861vd_capture_source,
15303 },
15304 [ALC861VD_3ST_DIG] = {
15305 .mixers = { alc861vd_3st_mixer },
15306 .init_verbs = { alc861vd_volume_init_verbs,
15307 alc861vd_3stack_init_verbs },
15308 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15309 .dac_nids = alc861vd_dac_nids,
15310 .dig_out_nid = ALC861VD_DIGOUT_NID,
15311 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15312 .channel_mode = alc861vd_3stack_2ch_modes,
15313 .input_mux = &alc861vd_capture_source,
15314 },
15315 [ALC861VD_6ST_DIG] = {
15316 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15317 .init_verbs = { alc861vd_volume_init_verbs,
15318 alc861vd_6stack_init_verbs },
15319 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15320 .dac_nids = alc861vd_dac_nids,
15321 .dig_out_nid = ALC861VD_DIGOUT_NID,
15322 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15323 .channel_mode = alc861vd_6stack_modes,
15324 .input_mux = &alc861vd_capture_source,
15325 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015326 [ALC861VD_LENOVO] = {
15327 .mixers = { alc861vd_lenovo_mixer },
15328 .init_verbs = { alc861vd_volume_init_verbs,
15329 alc861vd_3stack_init_verbs,
15330 alc861vd_eapd_verbs,
15331 alc861vd_lenovo_unsol_verbs },
15332 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15333 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015334 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15335 .channel_mode = alc861vd_3stack_2ch_modes,
15336 .input_mux = &alc861vd_capture_source,
15337 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015338 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015339 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015340 },
Kailang Yang272a5272007-05-14 11:00:38 +020015341 [ALC861VD_DALLAS] = {
15342 .mixers = { alc861vd_dallas_mixer },
15343 .init_verbs = { alc861vd_dallas_verbs },
15344 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15345 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015346 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15347 .channel_mode = alc861vd_3stack_2ch_modes,
15348 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015349 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015350 .setup = alc861vd_dallas_setup,
15351 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015352 },
15353 [ALC861VD_HP] = {
15354 .mixers = { alc861vd_hp_mixer },
15355 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15356 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15357 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015358 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015359 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15360 .channel_mode = alc861vd_3stack_2ch_modes,
15361 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015362 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015363 .setup = alc861vd_dallas_setup,
15364 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015365 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015366 [ALC660VD_ASUS_V1S] = {
15367 .mixers = { alc861vd_lenovo_mixer },
15368 .init_verbs = { alc861vd_volume_init_verbs,
15369 alc861vd_3stack_init_verbs,
15370 alc861vd_eapd_verbs,
15371 alc861vd_lenovo_unsol_verbs },
15372 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15373 .dac_nids = alc660vd_dac_nids,
15374 .dig_out_nid = ALC861VD_DIGOUT_NID,
15375 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15376 .channel_mode = alc861vd_3stack_2ch_modes,
15377 .input_mux = &alc861vd_capture_source,
15378 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015379 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015380 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015381 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015382};
15383
15384/*
15385 * BIOS auto configuration
15386 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015387static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15388 const struct auto_pin_cfg *cfg)
15389{
15390 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15391}
15392
15393
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015394static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15395 hda_nid_t nid, int pin_type, int dac_idx)
15396{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015397 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015398}
15399
15400static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15401{
15402 struct alc_spec *spec = codec->spec;
15403 int i;
15404
15405 for (i = 0; i <= HDA_SIDE; i++) {
15406 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015407 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015408 if (nid)
15409 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015410 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015411 }
15412}
15413
15414
15415static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15416{
15417 struct alc_spec *spec = codec->spec;
15418 hda_nid_t pin;
15419
15420 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015421 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015422 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015423 pin = spec->autocfg.speaker_pins[0];
15424 if (pin)
15425 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015426}
15427
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015428#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15429
15430static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15431{
15432 struct alc_spec *spec = codec->spec;
15433 int i;
15434
15435 for (i = 0; i < AUTO_PIN_LAST; i++) {
15436 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015437 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015438 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015439 if (nid != ALC861VD_PIN_CD_NID &&
15440 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015441 snd_hda_codec_write(codec, nid, 0,
15442 AC_VERB_SET_AMP_GAIN_MUTE,
15443 AMP_OUT_MUTE);
15444 }
15445 }
15446}
15447
Takashi Iwaif511b012008-08-15 16:46:42 +020015448#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15449
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015450#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15451#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15452
15453/* add playback controls from the parsed DAC table */
15454/* Based on ALC880 version. But ALC861VD has separate,
15455 * different NIDs for mute/unmute switch and volume control */
15456static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15457 const struct auto_pin_cfg *cfg)
15458{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015459 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15460 hda_nid_t nid_v, nid_s;
15461 int i, err;
15462
15463 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015464 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015465 continue;
15466 nid_v = alc861vd_idx_to_mixer_vol(
15467 alc880_dac_to_idx(
15468 spec->multiout.dac_nids[i]));
15469 nid_s = alc861vd_idx_to_mixer_switch(
15470 alc880_dac_to_idx(
15471 spec->multiout.dac_nids[i]));
15472
15473 if (i == 2) {
15474 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015475 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15476 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015477 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15478 HDA_OUTPUT));
15479 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015480 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015481 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15482 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015483 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15484 HDA_OUTPUT));
15485 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015486 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015487 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15488 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015489 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15490 HDA_INPUT));
15491 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015492 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015493 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15494 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015495 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15496 HDA_INPUT));
15497 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015498 return err;
15499 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015500 const char *pfx;
15501 if (cfg->line_outs == 1 &&
15502 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15503 if (!cfg->hp_pins)
15504 pfx = "Speaker";
15505 else
15506 pfx = "PCM";
15507 } else
15508 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015509 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015510 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15511 HDA_OUTPUT));
15512 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015513 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015514 if (cfg->line_outs == 1 &&
15515 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15516 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015517 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015518 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015519 HDA_INPUT));
15520 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015521 return err;
15522 }
15523 }
15524 return 0;
15525}
15526
15527/* add playback controls for speaker and HP outputs */
15528/* Based on ALC880 version. But ALC861VD has separate,
15529 * different NIDs for mute/unmute switch and volume control */
15530static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15531 hda_nid_t pin, const char *pfx)
15532{
15533 hda_nid_t nid_v, nid_s;
15534 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015535
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015536 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015537 return 0;
15538
15539 if (alc880_is_fixed_pin(pin)) {
15540 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15541 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015542 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015543 spec->multiout.hp_nid = nid_v;
15544 else
15545 spec->multiout.extra_out_nid[0] = nid_v;
15546 /* control HP volume/switch on the output mixer amp */
15547 nid_v = alc861vd_idx_to_mixer_vol(
15548 alc880_fixed_pin_idx(pin));
15549 nid_s = alc861vd_idx_to_mixer_switch(
15550 alc880_fixed_pin_idx(pin));
15551
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015552 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015553 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15554 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015555 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015556 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015557 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15558 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015559 return err;
15560 } else if (alc880_is_multi_pin(pin)) {
15561 /* set manual connection */
15562 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015563 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015564 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15565 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015566 return err;
15567 }
15568 return 0;
15569}
15570
15571/* parse the BIOS configuration and set up the alc_spec
15572 * return 1 if successful, 0 if the proper config is not found,
15573 * or a negative error code
15574 * Based on ALC880 version - had to change it to override
15575 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15576static int alc861vd_parse_auto_config(struct hda_codec *codec)
15577{
15578 struct alc_spec *spec = codec->spec;
15579 int err;
15580 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15581
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015582 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15583 alc861vd_ignore);
15584 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015585 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015586 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015587 return 0; /* can't find valid BIOS pin config */
15588
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015589 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15590 if (err < 0)
15591 return err;
15592 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15593 if (err < 0)
15594 return err;
15595 err = alc861vd_auto_create_extra_out(spec,
15596 spec->autocfg.speaker_pins[0],
15597 "Speaker");
15598 if (err < 0)
15599 return err;
15600 err = alc861vd_auto_create_extra_out(spec,
15601 spec->autocfg.hp_pins[0],
15602 "Headphone");
15603 if (err < 0)
15604 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015605 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015606 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015607 return err;
15608
15609 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15610
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015611 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015612 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15613
Takashi Iwai603c4012008-07-30 15:01:44 +020015614 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015615 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015616
Takashi Iwaid88897e2008-10-31 15:01:37 +010015617 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015618
15619 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015620 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015621
Takashi Iwai776e1842007-08-29 15:07:11 +020015622 err = alc_auto_add_mic_boost(codec);
15623 if (err < 0)
15624 return err;
15625
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015626 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15627
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015628 return 1;
15629}
15630
15631/* additional initialization for auto-configuration model */
15632static void alc861vd_auto_init(struct hda_codec *codec)
15633{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015634 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015635 alc861vd_auto_init_multi_out(codec);
15636 alc861vd_auto_init_hp_out(codec);
15637 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015638 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015639 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015640 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015641}
15642
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015643enum {
15644 ALC660VD_FIX_ASUS_GPIO1
15645};
15646
15647/* reset GPIO1 */
15648static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15649 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15650 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15651 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15652 { }
15653};
15654
15655static const struct alc_fixup alc861vd_fixups[] = {
15656 [ALC660VD_FIX_ASUS_GPIO1] = {
15657 .verbs = alc660vd_fix_asus_gpio1_verbs,
15658 },
15659};
15660
15661static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15662 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15663 {}
15664};
15665
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015666static int patch_alc861vd(struct hda_codec *codec)
15667{
15668 struct alc_spec *spec;
15669 int err, board_config;
15670
15671 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15672 if (spec == NULL)
15673 return -ENOMEM;
15674
15675 codec->spec = spec;
15676
15677 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15678 alc861vd_models,
15679 alc861vd_cfg_tbl);
15680
15681 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015682 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15683 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015684 board_config = ALC861VD_AUTO;
15685 }
15686
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015687 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15688
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015689 if (board_config == ALC861VD_AUTO) {
15690 /* automatic parse from the BIOS config */
15691 err = alc861vd_parse_auto_config(codec);
15692 if (err < 0) {
15693 alc_free(codec);
15694 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015695 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015696 printk(KERN_INFO
15697 "hda_codec: Cannot set up configuration "
15698 "from BIOS. Using base mode...\n");
15699 board_config = ALC861VD_3ST;
15700 }
15701 }
15702
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015703 err = snd_hda_attach_beep_device(codec, 0x23);
15704 if (err < 0) {
15705 alc_free(codec);
15706 return err;
15707 }
15708
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015709 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015710 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015711
Kailang Yang2f893282008-05-27 12:14:47 +020015712 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015713 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015714 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015715 }
15716
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015717 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15718 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15719
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015720 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15721 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15722
Takashi Iwaidd704692009-08-11 08:45:11 +020015723 if (!spec->adc_nids) {
15724 spec->adc_nids = alc861vd_adc_nids;
15725 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15726 }
15727 if (!spec->capsrc_nids)
15728 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015729
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015730 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015731 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015732
Takashi Iwai2134ea42008-01-10 16:53:55 +010015733 spec->vmaster_nid = 0x02;
15734
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015735 codec->patch_ops = alc_patch_ops;
15736
15737 if (board_config == ALC861VD_AUTO)
15738 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015739#ifdef CONFIG_SND_HDA_POWER_SAVE
15740 if (!spec->loopback.amplist)
15741 spec->loopback.amplist = alc861vd_loopbacks;
15742#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015743 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015744
15745 return 0;
15746}
15747
15748/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015749 * ALC662 support
15750 *
15751 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15752 * configuration. Each pin widget can choose any input DACs and a mixer.
15753 * Each ADC is connected from a mixer of all inputs. This makes possible
15754 * 6-channel independent captures.
15755 *
15756 * In addition, an independent DAC for the multi-playback (not used in this
15757 * driver yet).
15758 */
15759#define ALC662_DIGOUT_NID 0x06
15760#define ALC662_DIGIN_NID 0x0a
15761
15762static hda_nid_t alc662_dac_nids[4] = {
15763 /* front, rear, clfe, rear_surr */
15764 0x02, 0x03, 0x04
15765};
15766
Kailang Yang622e84c2009-04-21 07:39:04 +020015767static hda_nid_t alc272_dac_nids[2] = {
15768 0x02, 0x03
15769};
15770
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015771static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015772 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015773 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015774};
Takashi Iwaie1406342008-02-11 18:32:32 +010015775
Kailang Yang622e84c2009-04-21 07:39:04 +020015776static hda_nid_t alc272_adc_nids[1] = {
15777 /* ADC1-2 */
15778 0x08,
15779};
15780
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015781static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015782static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15783
Takashi Iwaie1406342008-02-11 18:32:32 +010015784
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015785/* input MUX */
15786/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015787static struct hda_input_mux alc662_capture_source = {
15788 .num_items = 4,
15789 .items = {
15790 { "Mic", 0x0 },
15791 { "Front Mic", 0x1 },
15792 { "Line", 0x2 },
15793 { "CD", 0x4 },
15794 },
15795};
15796
15797static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15798 .num_items = 2,
15799 .items = {
15800 { "Mic", 0x1 },
15801 { "Line", 0x2 },
15802 },
15803};
Kailang Yang291702f2007-10-16 14:28:03 +020015804
Kailang Yang6dda9f42008-05-27 12:05:31 +020015805static struct hda_input_mux alc663_capture_source = {
15806 .num_items = 3,
15807 .items = {
15808 { "Mic", 0x0 },
15809 { "Front Mic", 0x1 },
15810 { "Line", 0x2 },
15811 },
15812};
15813
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015814#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015815static struct hda_input_mux alc272_nc10_capture_source = {
15816 .num_items = 16,
15817 .items = {
15818 { "Autoselect Mic", 0x0 },
15819 { "Internal Mic", 0x1 },
15820 { "In-0x02", 0x2 },
15821 { "In-0x03", 0x3 },
15822 { "In-0x04", 0x4 },
15823 { "In-0x05", 0x5 },
15824 { "In-0x06", 0x6 },
15825 { "In-0x07", 0x7 },
15826 { "In-0x08", 0x8 },
15827 { "In-0x09", 0x9 },
15828 { "In-0x0a", 0x0a },
15829 { "In-0x0b", 0x0b },
15830 { "In-0x0c", 0x0c },
15831 { "In-0x0d", 0x0d },
15832 { "In-0x0e", 0x0e },
15833 { "In-0x0f", 0x0f },
15834 },
15835};
15836#endif
15837
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015838/*
15839 * 2ch mode
15840 */
15841static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15842 { 2, NULL }
15843};
15844
15845/*
15846 * 2ch mode
15847 */
15848static struct hda_verb alc662_3ST_ch2_init[] = {
15849 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15850 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15851 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15852 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15853 { } /* end */
15854};
15855
15856/*
15857 * 6ch mode
15858 */
15859static struct hda_verb alc662_3ST_ch6_init[] = {
15860 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15861 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15862 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15865 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15866 { } /* end */
15867};
15868
15869static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15870 { 2, alc662_3ST_ch2_init },
15871 { 6, alc662_3ST_ch6_init },
15872};
15873
15874/*
15875 * 2ch mode
15876 */
15877static struct hda_verb alc662_sixstack_ch6_init[] = {
15878 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15879 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15880 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15881 { } /* end */
15882};
15883
15884/*
15885 * 6ch mode
15886 */
15887static struct hda_verb alc662_sixstack_ch8_init[] = {
15888 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15889 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15890 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15891 { } /* end */
15892};
15893
15894static struct hda_channel_mode alc662_5stack_modes[2] = {
15895 { 2, alc662_sixstack_ch6_init },
15896 { 6, alc662_sixstack_ch8_init },
15897};
15898
15899/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15900 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15901 */
15902
15903static struct snd_kcontrol_new alc662_base_mixer[] = {
15904 /* output mixer control */
15905 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015906 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015907 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015908 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015909 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15910 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015911 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15912 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015913 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15914
15915 /*Input mixer control */
15916 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15917 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15918 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15919 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15920 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15921 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15922 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15923 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015924 { } /* end */
15925};
15926
15927static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15928 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015929 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15937 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15938 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015939 { } /* end */
15940};
15941
15942static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15943 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015944 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015946 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015949 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15950 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015951 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15952 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15953 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15954 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15955 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15958 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015960 { } /* end */
15961};
15962
15963static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15964 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15965 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015966 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15967 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15969 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15970 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15972 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015973 { } /* end */
15974};
15975
Kailang Yang291702f2007-10-16 14:28:03 +020015976static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015977 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15978 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015979
15980 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15981 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15982 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15983
15984 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15985 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15986 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15987 { } /* end */
15988};
15989
Kailang Yang8c427222008-01-10 13:03:59 +010015990static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015991 ALC262_HIPPO_MASTER_SWITCH,
15992 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015993 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015994 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15995 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015996 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15997 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15998 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15999 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16000 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16001 { } /* end */
16002};
16003
Kailang Yangf1d4e282008-08-26 14:03:29 +020016004static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16005 .ops = &snd_hda_bind_vol,
16006 .values = {
16007 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16008 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16009 0
16010 },
16011};
16012
16013static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16014 .ops = &snd_hda_bind_sw,
16015 .values = {
16016 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16017 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16018 0
16019 },
16020};
16021
Kailang Yang6dda9f42008-05-27 12:05:31 +020016022static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016023 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16024 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16027 { } /* end */
16028};
16029
16030static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16031 .ops = &snd_hda_bind_sw,
16032 .values = {
16033 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16034 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16035 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16036 0
16037 },
16038};
16039
16040static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16041 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16042 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16045 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16046 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16047
16048 { } /* end */
16049};
16050
16051static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16052 .ops = &snd_hda_bind_sw,
16053 .values = {
16054 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16055 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16056 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16057 0
16058 },
16059};
16060
16061static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16062 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16063 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16064 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16065 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16066 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16067 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16068 { } /* end */
16069};
16070
16071static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016072 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16073 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016074 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16076 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16077 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16078 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16079 { } /* end */
16080};
16081
16082static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16083 .ops = &snd_hda_bind_vol,
16084 .values = {
16085 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16086 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16087 0
16088 },
16089};
16090
16091static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16092 .ops = &snd_hda_bind_sw,
16093 .values = {
16094 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16095 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16096 0
16097 },
16098};
16099
16100static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16101 HDA_BIND_VOL("Master Playback Volume",
16102 &alc663_asus_two_bind_master_vol),
16103 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16104 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16106 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16107 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016108 { } /* end */
16109};
16110
16111static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16112 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16113 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16114 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16117 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016118 { } /* end */
16119};
16120
16121static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16122 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16123 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16124 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16125 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16126 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16127
16128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16129 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16130 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16131 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16132 { } /* end */
16133};
16134
16135static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16136 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16137 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16139
16140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16142 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16143 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16144 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16145 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16146 { } /* end */
16147};
16148
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016149static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16150 {
16151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16152 .name = "Channel Mode",
16153 .info = alc_ch_mode_info,
16154 .get = alc_ch_mode_get,
16155 .put = alc_ch_mode_put,
16156 },
16157 { } /* end */
16158};
16159
16160static struct hda_verb alc662_init_verbs[] = {
16161 /* ADC: mute amp left and right */
16162 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16163 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16164 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16165
Takashi Iwaicb53c622007-08-10 17:21:45 +020016166 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16167 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16168 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016171
Kailang Yangb60dd392007-09-20 12:50:29 +020016172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16174 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16175 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16176 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16177 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016178
16179 /* Front Pin: output 0 (0x0c) */
16180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16181 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16182
16183 /* Rear Pin: output 1 (0x0d) */
16184 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16185 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16186
16187 /* CLFE Pin: output 2 (0x0e) */
16188 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16189 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16190
16191 /* Mic (rear) pin: input vref at 80% */
16192 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16193 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16194 /* Front Mic pin: input vref at 80% */
16195 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16196 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16197 /* Line In pin: input */
16198 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16200 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16201 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16202 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16203 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16204 /* CD pin widget for input */
16205 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16206
16207 /* FIXME: use matrix-type input source selection */
16208 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16209 /* Input mixer */
16210 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016212
16213 /* always trun on EAPD */
16214 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16215 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16216
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016217 { }
16218};
16219
16220static struct hda_verb alc662_sue_init_verbs[] = {
16221 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16222 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016223 {}
16224};
16225
16226static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16227 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16228 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16229 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016230};
16231
Kailang Yang8c427222008-01-10 13:03:59 +010016232/* Set Unsolicited Event*/
16233static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16234 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16235 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16236 {}
16237};
16238
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016239/*
16240 * generic initialization of ADC, input mixers and output mixers
16241 */
16242static struct hda_verb alc662_auto_init_verbs[] = {
16243 /*
16244 * Unmute ADC and set the default input to mic-in
16245 */
16246 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16247 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16248
16249 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16250 * mixer widget
16251 * Note: PASD motherboards uses the Line In 2 as the input for front
16252 * panel mic (mic 2)
16253 */
16254 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016255 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16256 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16257 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16258 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016260
16261 /*
16262 * Set up output mixers (0x0c - 0x0f)
16263 */
16264 /* set vol=0 to output mixers */
16265 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16266 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16267 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16268
16269 /* set up input amps for analog loopback */
16270 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016271 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16272 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16273 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16274 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16275 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16276 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016277
16278
16279 /* FIXME: use matrix-type input source selection */
16280 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16281 /* Input mixer */
16282 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016284 { }
16285};
16286
Takashi Iwai24fb9172008-09-02 14:48:20 +020016287/* additional verbs for ALC663 */
16288static struct hda_verb alc663_auto_init_verbs[] = {
16289 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16290 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16291 { }
16292};
16293
Kailang Yang6dda9f42008-05-27 12:05:31 +020016294static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16296 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016297 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16298 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016299 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016302 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16303 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16304 {}
16305};
16306
Kailang Yangf1d4e282008-08-26 14:03:29 +020016307static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16308 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16309 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16310 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16313 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16314 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16315 {}
16316};
16317
16318static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16319 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16320 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16321 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16322 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16325 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16326 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16327 {}
16328};
16329
16330static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16331 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16332 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16333 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16334 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16335 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16336 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16337 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16338 {}
16339};
16340
16341static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16342 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16343 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16344 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16345 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16346 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16347 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16348 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16349 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16350 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16351 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16352 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16353 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16354 {}
16355};
16356
16357static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16358 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16359 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16360 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16361 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16362 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16363 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16364 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16365 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16366 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16367 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16368 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16369 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16370 {}
16371};
16372
Kailang Yang6dda9f42008-05-27 12:05:31 +020016373static struct hda_verb alc663_g71v_init_verbs[] = {
16374 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16375 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16376 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16377
16378 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16379 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16380 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16381
16382 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16383 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16384 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16385 {}
16386};
16387
16388static struct hda_verb alc663_g50v_init_verbs[] = {
16389 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16390 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16391 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16392
16393 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16394 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16395 {}
16396};
16397
Kailang Yangf1d4e282008-08-26 14:03:29 +020016398static struct hda_verb alc662_ecs_init_verbs[] = {
16399 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16401 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16402 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16403 {}
16404};
16405
Kailang Yang622e84c2009-04-21 07:39:04 +020016406static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16407 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16408 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16409 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16410 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16411 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16412 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16413 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16415 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16416 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16417 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16418 {}
16419};
16420
16421static struct hda_verb alc272_dell_init_verbs[] = {
16422 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16423 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16424 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16425 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16426 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16427 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16428 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16429 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16430 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16431 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16432 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16433 {}
16434};
16435
Kailang Yangf1d4e282008-08-26 14:03:29 +020016436static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16437 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16438 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16439 { } /* end */
16440};
16441
Kailang Yang622e84c2009-04-21 07:39:04 +020016442static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16443 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16444 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16445 { } /* end */
16446};
16447
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016448static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16449{
16450 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016451 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016452
Wu Fengguang864f92b2009-11-18 12:38:02 +080016453 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016454 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016455
Takashi Iwai47fd8302007-08-10 17:11:07 +020016456 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16457 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016458}
16459
16460static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16461{
16462 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016463 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016464
Wu Fengguang864f92b2009-11-18 12:38:02 +080016465 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016466 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016467
Takashi Iwai47fd8302007-08-10 17:11:07 +020016468 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16469 HDA_AMP_MUTE, bits);
16470 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16471 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016472}
16473
16474static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16475 unsigned int res)
16476{
16477 if ((res >> 26) == ALC880_HP_EVENT)
16478 alc662_lenovo_101e_all_automute(codec);
16479 if ((res >> 26) == ALC880_FRONT_EVENT)
16480 alc662_lenovo_101e_ispeaker_automute(codec);
16481}
16482
Kailang Yang291702f2007-10-16 14:28:03 +020016483/* unsolicited event for HP jack sensing */
16484static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16485 unsigned int res)
16486{
Kailang Yang291702f2007-10-16 14:28:03 +020016487 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016488 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016489 else
16490 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016491}
16492
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016493static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016494{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016495 struct alc_spec *spec = codec->spec;
16496
16497 alc262_hippo1_setup(codec);
16498 spec->ext_mic.pin = 0x18;
16499 spec->ext_mic.mux_idx = 0;
16500 spec->int_mic.pin = 0x19;
16501 spec->int_mic.mux_idx = 1;
16502 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016503}
16504
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016505static void alc662_eeepc_inithook(struct hda_codec *codec)
16506{
16507 alc262_hippo_automute(codec);
16508 alc_mic_automute(codec);
16509}
16510
16511static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016512{
Takashi Iwai42171c12009-05-08 14:11:43 +020016513 struct alc_spec *spec = codec->spec;
16514
16515 spec->autocfg.hp_pins[0] = 0x14;
16516 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016517}
16518
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016519#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16520
Kailang Yang6dda9f42008-05-27 12:05:31 +020016521static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16522{
16523 unsigned int present;
16524 unsigned char bits;
16525
Wu Fengguang864f92b2009-11-18 12:38:02 +080016526 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016527 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016528 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16529 AMP_IN_MUTE(0), bits);
16530 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16531 AMP_IN_MUTE(0), bits);
16532}
16533
16534static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16535{
16536 unsigned int present;
16537 unsigned char bits;
16538
Wu Fengguang864f92b2009-11-18 12:38:02 +080016539 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016540 bits = present ? HDA_AMP_MUTE : 0;
16541 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16542 AMP_IN_MUTE(0), bits);
16543 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16544 AMP_IN_MUTE(0), bits);
16545 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16546 AMP_IN_MUTE(0), bits);
16547 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16548 AMP_IN_MUTE(0), bits);
16549}
16550
16551static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16552{
16553 unsigned int present;
16554 unsigned char bits;
16555
Wu Fengguang864f92b2009-11-18 12:38:02 +080016556 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016557 bits = present ? HDA_AMP_MUTE : 0;
16558 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16559 AMP_IN_MUTE(0), bits);
16560 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16561 AMP_IN_MUTE(0), bits);
16562 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16563 AMP_IN_MUTE(0), bits);
16564 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16565 AMP_IN_MUTE(0), bits);
16566}
16567
16568static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16569{
16570 unsigned int present;
16571 unsigned char bits;
16572
Wu Fengguang864f92b2009-11-18 12:38:02 +080016573 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016574 bits = present ? 0 : PIN_OUT;
16575 snd_hda_codec_write(codec, 0x14, 0,
16576 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16577}
16578
16579static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16580{
16581 unsigned int present1, present2;
16582
Wu Fengguang864f92b2009-11-18 12:38:02 +080016583 present1 = snd_hda_jack_detect(codec, 0x21);
16584 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016585
16586 if (present1 || present2) {
16587 snd_hda_codec_write_cache(codec, 0x14, 0,
16588 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16589 } else {
16590 snd_hda_codec_write_cache(codec, 0x14, 0,
16591 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16592 }
16593}
16594
16595static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16596{
16597 unsigned int present1, present2;
16598
Wu Fengguang864f92b2009-11-18 12:38:02 +080016599 present1 = snd_hda_jack_detect(codec, 0x1b);
16600 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016601
16602 if (present1 || present2) {
16603 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16604 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16605 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16606 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16607 } else {
16608 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16609 AMP_IN_MUTE(0), 0);
16610 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16611 AMP_IN_MUTE(0), 0);
16612 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016613}
16614
Kailang Yang6dda9f42008-05-27 12:05:31 +020016615static void alc663_m51va_unsol_event(struct hda_codec *codec,
16616 unsigned int res)
16617{
16618 switch (res >> 26) {
16619 case ALC880_HP_EVENT:
16620 alc663_m51va_speaker_automute(codec);
16621 break;
16622 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016623 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016624 break;
16625 }
16626}
16627
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016628static void alc663_m51va_setup(struct hda_codec *codec)
16629{
16630 struct alc_spec *spec = codec->spec;
16631 spec->ext_mic.pin = 0x18;
16632 spec->ext_mic.mux_idx = 0;
16633 spec->int_mic.pin = 0x12;
16634 spec->int_mic.mux_idx = 1;
16635 spec->auto_mic = 1;
16636}
16637
Kailang Yang6dda9f42008-05-27 12:05:31 +020016638static void alc663_m51va_inithook(struct hda_codec *codec)
16639{
16640 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016641 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016642}
16643
Kailang Yangf1d4e282008-08-26 14:03:29 +020016644/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016645#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16646#define alc663_mode1_setup alc663_m51va_setup
16647#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016648
Kailang Yangf1d4e282008-08-26 14:03:29 +020016649/* ***************** Mode2 ******************************/
16650static void alc662_mode2_unsol_event(struct hda_codec *codec,
16651 unsigned int res)
16652{
16653 switch (res >> 26) {
16654 case ALC880_HP_EVENT:
16655 alc662_f5z_speaker_automute(codec);
16656 break;
16657 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016658 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016659 break;
16660 }
16661}
16662
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016663#define alc662_mode2_setup alc663_m51va_setup
16664
Kailang Yangf1d4e282008-08-26 14:03:29 +020016665static void alc662_mode2_inithook(struct hda_codec *codec)
16666{
16667 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016668 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016669}
16670/* ***************** Mode3 ******************************/
16671static void alc663_mode3_unsol_event(struct hda_codec *codec,
16672 unsigned int res)
16673{
16674 switch (res >> 26) {
16675 case ALC880_HP_EVENT:
16676 alc663_two_hp_m1_speaker_automute(codec);
16677 break;
16678 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016679 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016680 break;
16681 }
16682}
16683
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016684#define alc663_mode3_setup alc663_m51va_setup
16685
Kailang Yangf1d4e282008-08-26 14:03:29 +020016686static void alc663_mode3_inithook(struct hda_codec *codec)
16687{
16688 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016689 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016690}
16691/* ***************** Mode4 ******************************/
16692static void alc663_mode4_unsol_event(struct hda_codec *codec,
16693 unsigned int res)
16694{
16695 switch (res >> 26) {
16696 case ALC880_HP_EVENT:
16697 alc663_21jd_two_speaker_automute(codec);
16698 break;
16699 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016700 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016701 break;
16702 }
16703}
16704
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016705#define alc663_mode4_setup alc663_m51va_setup
16706
Kailang Yangf1d4e282008-08-26 14:03:29 +020016707static void alc663_mode4_inithook(struct hda_codec *codec)
16708{
16709 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016710 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016711}
16712/* ***************** Mode5 ******************************/
16713static void alc663_mode5_unsol_event(struct hda_codec *codec,
16714 unsigned int res)
16715{
16716 switch (res >> 26) {
16717 case ALC880_HP_EVENT:
16718 alc663_15jd_two_speaker_automute(codec);
16719 break;
16720 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016721 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016722 break;
16723 }
16724}
16725
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016726#define alc663_mode5_setup alc663_m51va_setup
16727
Kailang Yangf1d4e282008-08-26 14:03:29 +020016728static void alc663_mode5_inithook(struct hda_codec *codec)
16729{
16730 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016731 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016732}
16733/* ***************** Mode6 ******************************/
16734static void alc663_mode6_unsol_event(struct hda_codec *codec,
16735 unsigned int res)
16736{
16737 switch (res >> 26) {
16738 case ALC880_HP_EVENT:
16739 alc663_two_hp_m2_speaker_automute(codec);
16740 break;
16741 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016742 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016743 break;
16744 }
16745}
16746
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016747#define alc663_mode6_setup alc663_m51va_setup
16748
Kailang Yangf1d4e282008-08-26 14:03:29 +020016749static void alc663_mode6_inithook(struct hda_codec *codec)
16750{
16751 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016752 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016753}
16754
Kailang Yang6dda9f42008-05-27 12:05:31 +020016755static void alc663_g71v_hp_automute(struct hda_codec *codec)
16756{
16757 unsigned int present;
16758 unsigned char bits;
16759
Wu Fengguang864f92b2009-11-18 12:38:02 +080016760 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016761 bits = present ? HDA_AMP_MUTE : 0;
16762 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16763 HDA_AMP_MUTE, bits);
16764 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16765 HDA_AMP_MUTE, bits);
16766}
16767
16768static void alc663_g71v_front_automute(struct hda_codec *codec)
16769{
16770 unsigned int present;
16771 unsigned char bits;
16772
Wu Fengguang864f92b2009-11-18 12:38:02 +080016773 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016774 bits = present ? HDA_AMP_MUTE : 0;
16775 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16776 HDA_AMP_MUTE, bits);
16777}
16778
16779static void alc663_g71v_unsol_event(struct hda_codec *codec,
16780 unsigned int res)
16781{
16782 switch (res >> 26) {
16783 case ALC880_HP_EVENT:
16784 alc663_g71v_hp_automute(codec);
16785 break;
16786 case ALC880_FRONT_EVENT:
16787 alc663_g71v_front_automute(codec);
16788 break;
16789 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016790 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016791 break;
16792 }
16793}
16794
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016795#define alc663_g71v_setup alc663_m51va_setup
16796
Kailang Yang6dda9f42008-05-27 12:05:31 +020016797static void alc663_g71v_inithook(struct hda_codec *codec)
16798{
16799 alc663_g71v_front_automute(codec);
16800 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016801 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016802}
16803
16804static void alc663_g50v_unsol_event(struct hda_codec *codec,
16805 unsigned int res)
16806{
16807 switch (res >> 26) {
16808 case ALC880_HP_EVENT:
16809 alc663_m51va_speaker_automute(codec);
16810 break;
16811 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016812 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016813 break;
16814 }
16815}
16816
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016817#define alc663_g50v_setup alc663_m51va_setup
16818
Kailang Yang6dda9f42008-05-27 12:05:31 +020016819static void alc663_g50v_inithook(struct hda_codec *codec)
16820{
16821 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016822 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016823}
16824
Kailang Yangf1d4e282008-08-26 14:03:29 +020016825static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16826 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016827 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016828
16829 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16830 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16831 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16832
16833 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16834 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16835 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16836 { } /* end */
16837};
16838
Chris Pockelé9541ba12009-05-12 08:08:53 +020016839static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16840 /* Master Playback automatically created from Speaker and Headphone */
16841 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16842 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16843 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16845
16846 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16847 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16848 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16849
16850 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16851 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16852 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16853 { } /* end */
16854};
16855
Takashi Iwaicb53c622007-08-10 17:21:45 +020016856#ifdef CONFIG_SND_HDA_POWER_SAVE
16857#define alc662_loopbacks alc880_loopbacks
16858#endif
16859
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016860
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016861/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016862#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16863#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16864#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16865#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16866
16867/*
16868 * configuration and preset
16869 */
16870static const char *alc662_models[ALC662_MODEL_LAST] = {
16871 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16872 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16873 [ALC662_3ST_6ch] = "3stack-6ch",
16874 [ALC662_5ST_DIG] = "6stack-dig",
16875 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016876 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016877 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016878 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016879 [ALC663_ASUS_M51VA] = "m51va",
16880 [ALC663_ASUS_G71V] = "g71v",
16881 [ALC663_ASUS_H13] = "h13",
16882 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016883 [ALC663_ASUS_MODE1] = "asus-mode1",
16884 [ALC662_ASUS_MODE2] = "asus-mode2",
16885 [ALC663_ASUS_MODE3] = "asus-mode3",
16886 [ALC663_ASUS_MODE4] = "asus-mode4",
16887 [ALC663_ASUS_MODE5] = "asus-mode5",
16888 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016889 [ALC272_DELL] = "dell",
16890 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016891 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016892 [ALC662_AUTO] = "auto",
16893};
16894
16895static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016896 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016897 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16898 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016899 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16900 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16901 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16902 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16903 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16904 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16905 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16906 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16907 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16908 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16909 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16910 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016911 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16912 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16913 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016914 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16915 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16916 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16917 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016918 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016919 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16920 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016921 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016922 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16923 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16924 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016925 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16926 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16927 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016928 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16929 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16930 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016931 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016932 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16933 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016934 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016935 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016936 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016937 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16938 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16939 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016940 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016941 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16942 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016943 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016944 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016945 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016946 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016947 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16948 ALC662_3ST_6ch_DIG),
Manoj Iyer3db6c032009-09-22 18:33:29 -050016949 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB200", ALC663_ASUS_MODE4),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016950 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016951 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16952 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016953 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016954 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016955 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016956 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016957 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016958 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16959 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016960 {}
16961};
16962
16963static struct alc_config_preset alc662_presets[] = {
16964 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016965 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016966 .init_verbs = { alc662_init_verbs },
16967 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16968 .dac_nids = alc662_dac_nids,
16969 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016970 .dig_in_nid = ALC662_DIGIN_NID,
16971 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16972 .channel_mode = alc662_3ST_2ch_modes,
16973 .input_mux = &alc662_capture_source,
16974 },
16975 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016976 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016977 .init_verbs = { alc662_init_verbs },
16978 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16979 .dac_nids = alc662_dac_nids,
16980 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016981 .dig_in_nid = ALC662_DIGIN_NID,
16982 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16983 .channel_mode = alc662_3ST_6ch_modes,
16984 .need_dac_fix = 1,
16985 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016986 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016987 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016988 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016989 .init_verbs = { alc662_init_verbs },
16990 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16991 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016992 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16993 .channel_mode = alc662_3ST_6ch_modes,
16994 .need_dac_fix = 1,
16995 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016996 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016997 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016998 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016999 .init_verbs = { alc662_init_verbs },
17000 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17001 .dac_nids = alc662_dac_nids,
17002 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017003 .dig_in_nid = ALC662_DIGIN_NID,
17004 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17005 .channel_mode = alc662_5stack_modes,
17006 .input_mux = &alc662_capture_source,
17007 },
17008 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017009 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017010 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17011 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17012 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017013 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17014 .channel_mode = alc662_3ST_2ch_modes,
17015 .input_mux = &alc662_lenovo_101e_capture_source,
17016 .unsol_event = alc662_lenovo_101e_unsol_event,
17017 .init_hook = alc662_lenovo_101e_all_automute,
17018 },
Kailang Yang291702f2007-10-16 14:28:03 +020017019 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017020 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017021 .init_verbs = { alc662_init_verbs,
17022 alc662_eeepc_sue_init_verbs },
17023 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17024 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017025 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17026 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017027 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017028 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017029 .init_hook = alc662_eeepc_inithook,
17030 },
Kailang Yang8c427222008-01-10 13:03:59 +010017031 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017032 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017033 alc662_chmode_mixer },
17034 .init_verbs = { alc662_init_verbs,
17035 alc662_eeepc_ep20_sue_init_verbs },
17036 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17037 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017038 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17039 .channel_mode = alc662_3ST_6ch_modes,
17040 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017041 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017042 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017043 .init_hook = alc662_eeepc_ep20_inithook,
17044 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017045 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017046 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017047 .init_verbs = { alc662_init_verbs,
17048 alc662_ecs_init_verbs },
17049 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17050 .dac_nids = alc662_dac_nids,
17051 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17052 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017053 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017054 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017055 .init_hook = alc662_eeepc_inithook,
17056 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017057 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017058 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017059 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17060 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17061 .dac_nids = alc662_dac_nids,
17062 .dig_out_nid = ALC662_DIGOUT_NID,
17063 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17064 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017065 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017066 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017067 .init_hook = alc663_m51va_inithook,
17068 },
17069 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017070 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017071 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17072 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17073 .dac_nids = alc662_dac_nids,
17074 .dig_out_nid = ALC662_DIGOUT_NID,
17075 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17076 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017077 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017078 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017079 .init_hook = alc663_g71v_inithook,
17080 },
17081 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017082 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017083 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17084 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17085 .dac_nids = alc662_dac_nids,
17086 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17087 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017088 .unsol_event = alc663_m51va_unsol_event,
17089 .init_hook = alc663_m51va_inithook,
17090 },
17091 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017092 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017093 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17094 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17095 .dac_nids = alc662_dac_nids,
17096 .dig_out_nid = ALC662_DIGOUT_NID,
17097 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17098 .channel_mode = alc662_3ST_6ch_modes,
17099 .input_mux = &alc663_capture_source,
17100 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017101 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017102 .init_hook = alc663_g50v_inithook,
17103 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017104 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017105 .mixers = { alc663_m51va_mixer },
17106 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017107 .init_verbs = { alc662_init_verbs,
17108 alc663_21jd_amic_init_verbs },
17109 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17110 .hp_nid = 0x03,
17111 .dac_nids = alc662_dac_nids,
17112 .dig_out_nid = ALC662_DIGOUT_NID,
17113 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17114 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017115 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017116 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017117 .init_hook = alc663_mode1_inithook,
17118 },
17119 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017120 .mixers = { alc662_1bjd_mixer },
17121 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017122 .init_verbs = { alc662_init_verbs,
17123 alc662_1bjd_amic_init_verbs },
17124 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17125 .dac_nids = alc662_dac_nids,
17126 .dig_out_nid = ALC662_DIGOUT_NID,
17127 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17128 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017129 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017130 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017131 .init_hook = alc662_mode2_inithook,
17132 },
17133 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017134 .mixers = { alc663_two_hp_m1_mixer },
17135 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017136 .init_verbs = { alc662_init_verbs,
17137 alc663_two_hp_amic_m1_init_verbs },
17138 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17139 .hp_nid = 0x03,
17140 .dac_nids = alc662_dac_nids,
17141 .dig_out_nid = ALC662_DIGOUT_NID,
17142 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17143 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017144 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017145 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017146 .init_hook = alc663_mode3_inithook,
17147 },
17148 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017149 .mixers = { alc663_asus_21jd_clfe_mixer },
17150 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017151 .init_verbs = { alc662_init_verbs,
17152 alc663_21jd_amic_init_verbs},
17153 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17154 .hp_nid = 0x03,
17155 .dac_nids = alc662_dac_nids,
17156 .dig_out_nid = ALC662_DIGOUT_NID,
17157 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17158 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017159 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017160 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017161 .init_hook = alc663_mode4_inithook,
17162 },
17163 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017164 .mixers = { alc663_asus_15jd_clfe_mixer },
17165 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017166 .init_verbs = { alc662_init_verbs,
17167 alc663_15jd_amic_init_verbs },
17168 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17169 .hp_nid = 0x03,
17170 .dac_nids = alc662_dac_nids,
17171 .dig_out_nid = ALC662_DIGOUT_NID,
17172 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17173 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017174 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017175 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017176 .init_hook = alc663_mode5_inithook,
17177 },
17178 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017179 .mixers = { alc663_two_hp_m2_mixer },
17180 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017181 .init_verbs = { alc662_init_verbs,
17182 alc663_two_hp_amic_m2_init_verbs },
17183 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17184 .hp_nid = 0x03,
17185 .dac_nids = alc662_dac_nids,
17186 .dig_out_nid = ALC662_DIGOUT_NID,
17187 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17188 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017189 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017190 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017191 .init_hook = alc663_mode6_inithook,
17192 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017193 [ALC272_DELL] = {
17194 .mixers = { alc663_m51va_mixer },
17195 .cap_mixer = alc272_auto_capture_mixer,
17196 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17197 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17198 .dac_nids = alc662_dac_nids,
17199 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17200 .adc_nids = alc272_adc_nids,
17201 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17202 .capsrc_nids = alc272_capsrc_nids,
17203 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017204 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017205 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017206 .init_hook = alc663_m51va_inithook,
17207 },
17208 [ALC272_DELL_ZM1] = {
17209 .mixers = { alc663_m51va_mixer },
17210 .cap_mixer = alc662_auto_capture_mixer,
17211 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17212 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17213 .dac_nids = alc662_dac_nids,
17214 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17215 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017216 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017217 .capsrc_nids = alc662_capsrc_nids,
17218 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017219 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017220 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017221 .init_hook = alc663_m51va_inithook,
17222 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017223 [ALC272_SAMSUNG_NC10] = {
17224 .mixers = { alc272_nc10_mixer },
17225 .init_verbs = { alc662_init_verbs,
17226 alc663_21jd_amic_init_verbs },
17227 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17228 .dac_nids = alc272_dac_nids,
17229 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17230 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017231 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017232 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017233 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017234 .init_hook = alc663_mode4_inithook,
17235 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017236};
17237
17238
17239/*
17240 * BIOS auto configuration
17241 */
17242
Takashi Iwai7085ec12009-10-02 09:03:58 +020017243/* convert from MIX nid to DAC */
17244static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17245{
17246 if (nid == 0x0f)
17247 return 0x02;
17248 else if (nid >= 0x0c && nid <= 0x0e)
17249 return nid - 0x0c + 0x02;
17250 else
17251 return 0;
17252}
17253
17254/* get MIX nid connected to the given pin targeted to DAC */
17255static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17256 hda_nid_t dac)
17257{
17258 hda_nid_t mix[4];
17259 int i, num;
17260
17261 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17262 for (i = 0; i < num; i++) {
17263 if (alc662_mix_to_dac(mix[i]) == dac)
17264 return mix[i];
17265 }
17266 return 0;
17267}
17268
17269/* look for an empty DAC slot */
17270static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17271{
17272 struct alc_spec *spec = codec->spec;
17273 hda_nid_t srcs[5];
17274 int i, j, num;
17275
17276 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17277 if (num < 0)
17278 return 0;
17279 for (i = 0; i < num; i++) {
17280 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17281 if (!nid)
17282 continue;
17283 for (j = 0; j < spec->multiout.num_dacs; j++)
17284 if (spec->multiout.dac_nids[j] == nid)
17285 break;
17286 if (j >= spec->multiout.num_dacs)
17287 return nid;
17288 }
17289 return 0;
17290}
17291
17292/* fill in the dac_nids table from the parsed pin configuration */
17293static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17294 const struct auto_pin_cfg *cfg)
17295{
17296 struct alc_spec *spec = codec->spec;
17297 int i;
17298 hda_nid_t dac;
17299
17300 spec->multiout.dac_nids = spec->private_dac_nids;
17301 for (i = 0; i < cfg->line_outs; i++) {
17302 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17303 if (!dac)
17304 continue;
17305 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17306 }
17307 return 0;
17308}
17309
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017310static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017311 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017312{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017313 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017314 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17315}
17316
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017317static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017318 hda_nid_t nid, unsigned int chs)
17319{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017320 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017321 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17322}
17323
17324#define alc662_add_stereo_vol(spec, pfx, nid) \
17325 alc662_add_vol_ctl(spec, pfx, nid, 3)
17326#define alc662_add_stereo_sw(spec, pfx, nid) \
17327 alc662_add_sw_ctl(spec, pfx, nid, 3)
17328
17329/* add playback controls from the parsed DAC table */
17330static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17331 const struct auto_pin_cfg *cfg)
17332{
17333 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017334 static const char *chname[4] = {
17335 "Front", "Surround", NULL /*CLFE*/, "Side"
17336 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020017337 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017338 int i, err;
17339
17340 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017341 nid = spec->multiout.dac_nids[i];
17342 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017343 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017344 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17345 if (!mix)
17346 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017347 if (i == 2) {
17348 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017349 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017350 if (err < 0)
17351 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017352 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017353 if (err < 0)
17354 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017355 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017356 if (err < 0)
17357 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017358 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017359 if (err < 0)
17360 return err;
17361 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017362 const char *pfx;
17363 if (cfg->line_outs == 1 &&
17364 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017365 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017366 pfx = "Speaker";
17367 else
17368 pfx = "PCM";
17369 } else
17370 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017371 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017372 if (err < 0)
17373 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017374 if (cfg->line_outs == 1 &&
17375 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17376 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020017377 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017378 if (err < 0)
17379 return err;
17380 }
17381 }
17382 return 0;
17383}
17384
17385/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017386/* return DAC nid if any new DAC is assigned */
17387static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017388 const char *pfx)
17389{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017390 struct alc_spec *spec = codec->spec;
17391 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017392 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017393
17394 if (!pin)
17395 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017396 nid = alc662_look_for_dac(codec, pin);
17397 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017398 /* the corresponding DAC is already occupied */
17399 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17400 return 0; /* no way */
17401 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017402 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017403 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17404 }
17405
17406 mix = alc662_dac_to_mix(codec, pin, nid);
17407 if (!mix)
17408 return 0;
17409 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17410 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020017411 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017412 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17413 if (err < 0)
17414 return err;
17415 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017416}
17417
17418/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017419#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020017420 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017421
17422static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17423 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017424 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017425{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017426 int i, num;
17427 hda_nid_t srcs[4];
17428
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017429 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017430 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017431 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17432 if (num <= 1)
17433 return;
17434 for (i = 0; i < num; i++) {
17435 if (alc662_mix_to_dac(srcs[i]) != dac)
17436 continue;
17437 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17438 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017439 }
17440}
17441
17442static void alc662_auto_init_multi_out(struct hda_codec *codec)
17443{
17444 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017445 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017446 int i;
17447
17448 for (i = 0; i <= HDA_SIDE; i++) {
17449 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17450 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017451 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017452 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017453 }
17454}
17455
17456static void alc662_auto_init_hp_out(struct hda_codec *codec)
17457{
17458 struct alc_spec *spec = codec->spec;
17459 hda_nid_t pin;
17460
17461 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017462 if (pin)
17463 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17464 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017465 pin = spec->autocfg.speaker_pins[0];
17466 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020017467 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17468 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017469}
17470
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017471#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17472
17473static void alc662_auto_init_analog_input(struct hda_codec *codec)
17474{
17475 struct alc_spec *spec = codec->spec;
17476 int i;
17477
17478 for (i = 0; i < AUTO_PIN_LAST; i++) {
17479 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017480 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017481 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017482 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017483 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017484 snd_hda_codec_write(codec, nid, 0,
17485 AC_VERB_SET_AMP_GAIN_MUTE,
17486 AMP_OUT_MUTE);
17487 }
17488 }
17489}
17490
Takashi Iwaif511b012008-08-15 16:46:42 +020017491#define alc662_auto_init_input_src alc882_auto_init_input_src
17492
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017493static int alc662_parse_auto_config(struct hda_codec *codec)
17494{
17495 struct alc_spec *spec = codec->spec;
17496 int err;
17497 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17498
17499 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17500 alc662_ignore);
17501 if (err < 0)
17502 return err;
17503 if (!spec->autocfg.line_outs)
17504 return 0; /* can't find valid BIOS pin config */
17505
Takashi Iwai7085ec12009-10-02 09:03:58 +020017506 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017507 if (err < 0)
17508 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017509 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017510 if (err < 0)
17511 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017512 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017513 spec->autocfg.speaker_pins[0],
17514 "Speaker");
17515 if (err < 0)
17516 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017517 if (err)
17518 spec->multiout.extra_out_nid[0] = err;
17519 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017520 "Headphone");
17521 if (err < 0)
17522 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017523 if (err)
17524 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017525 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017526 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017527 return err;
17528
17529 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17530
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017531 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017532 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17533
Takashi Iwai603c4012008-07-30 15:01:44 +020017534 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017535 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017536
17537 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017538 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017539
Takashi Iwaid88897e2008-10-31 15:01:37 +010017540 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017541 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017542 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017543
17544 err = alc_auto_add_mic_boost(codec);
17545 if (err < 0)
17546 return err;
17547
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017548 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17549
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017550 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017551}
17552
17553/* additional initialization for auto-configuration model */
17554static void alc662_auto_init(struct hda_codec *codec)
17555{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017556 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017557 alc662_auto_init_multi_out(codec);
17558 alc662_auto_init_hp_out(codec);
17559 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017560 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017561 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017562 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017563}
17564
17565static int patch_alc662(struct hda_codec *codec)
17566{
17567 struct alc_spec *spec;
17568 int err, board_config;
17569
17570 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17571 if (!spec)
17572 return -ENOMEM;
17573
17574 codec->spec = spec;
17575
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017576 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17577
Kailang Yang274693f2009-12-03 10:07:50 +010017578 if (alc_read_coef_idx(codec, 0)==0x8020){
17579 kfree(codec->chip_name);
17580 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017581 if (!codec->chip_name) {
17582 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017583 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017584 }
Kailang Yang274693f2009-12-03 10:07:50 +010017585 }
17586
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017587 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17588 alc662_models,
17589 alc662_cfg_tbl);
17590 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017591 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17592 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017593 board_config = ALC662_AUTO;
17594 }
17595
17596 if (board_config == ALC662_AUTO) {
17597 /* automatic parse from the BIOS config */
17598 err = alc662_parse_auto_config(codec);
17599 if (err < 0) {
17600 alc_free(codec);
17601 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017602 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017603 printk(KERN_INFO
17604 "hda_codec: Cannot set up configuration "
17605 "from BIOS. Using base mode...\n");
17606 board_config = ALC662_3ST_2ch_DIG;
17607 }
17608 }
17609
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017610 err = snd_hda_attach_beep_device(codec, 0x1);
17611 if (err < 0) {
17612 alc_free(codec);
17613 return err;
17614 }
17615
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017616 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017617 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017618
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017619 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17620 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17621
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017622 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17623 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17624
Takashi Iwaidd704692009-08-11 08:45:11 +020017625 if (!spec->adc_nids) {
17626 spec->adc_nids = alc662_adc_nids;
17627 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17628 }
17629 if (!spec->capsrc_nids)
17630 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017631
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017632 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017633 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017634 if (codec->vendor_id == 0x10ec0662)
17635 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17636 else
17637 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017638
Takashi Iwai2134ea42008-01-10 16:53:55 +010017639 spec->vmaster_nid = 0x02;
17640
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017641 codec->patch_ops = alc_patch_ops;
17642 if (board_config == ALC662_AUTO)
17643 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017644#ifdef CONFIG_SND_HDA_POWER_SAVE
17645 if (!spec->loopback.amplist)
17646 spec->loopback.amplist = alc662_loopbacks;
17647#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017648 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017649
17650 return 0;
17651}
17652
Kailang Yang274693f2009-12-03 10:07:50 +010017653static int patch_alc888(struct hda_codec *codec)
17654{
17655 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
17656 kfree(codec->chip_name);
17657 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017658 if (!codec->chip_name) {
17659 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017660 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017661 }
17662 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017663 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017664 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017665}
17666
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017667/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017668 * patch entries
17669 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017670static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017671 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017672 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017673 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017674 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017675 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017676 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017677 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017678 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017679 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17680 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17681 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017682 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017683 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017684 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17685 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017686 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017687 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017688 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017689 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017690 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017691 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017692 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017693 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017694 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017695 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017696 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017697 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010017698 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017699 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010017700 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017701 {} /* terminator */
17702};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017703
17704MODULE_ALIAS("snd-hda-codec-id:10ec*");
17705
17706MODULE_LICENSE("GPL");
17707MODULE_DESCRIPTION("Realtek HD-audio codec");
17708
17709static struct hda_codec_preset_list realtek_list = {
17710 .preset = snd_hda_preset_realtek,
17711 .owner = THIS_MODULE,
17712};
17713
17714static int __init patch_realtek_init(void)
17715{
17716 return snd_hda_add_codec_preset(&realtek_list);
17717}
17718
17719static void __exit patch_realtek_exit(void)
17720{
17721 snd_hda_delete_codec_preset(&realtek_list);
17722}
17723
17724module_init(patch_realtek_init)
17725module_exit(patch_realtek_exit)