blob: 105fb23398e1b523991a05c32d075c52e224006f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang 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,
Kailang Yang272a5272007-05-14 11:00:38 +0200211 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100212 ALC882_MODEL_LAST,
213};
214
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200215/* ALC883 models */
216enum {
217 ALC883_3ST_2ch_DIG,
218 ALC883_3ST_6ch_DIG,
219 ALC883_3ST_6ch,
220 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200221 ALC883_TARGA_DIG,
222 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200223 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200224 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200225 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800226 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100227 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200228 ALC888_ACER_ASPIRE_8930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200229 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200230 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100231 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200232 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200233 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200234 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200235 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200236 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200237 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100238 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100239 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100240 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100241 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800242 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200243 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200244 ALC888_ASUS_M90V,
245 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200246 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100247 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200248 ALC883_SONY_VAIO_TT,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200249 ALC883_AUTO,
250 ALC883_MODEL_LAST,
251};
252
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200253/* styles of capture selection */
254enum {
255 CAPT_MUX = 0, /* only mux based */
256 CAPT_MIX, /* only mixer based */
257 CAPT_1MUX_MIX, /* first mux and other mixers */
258};
259
Kailang Yangdf694da2005-12-05 19:42:22 +0100260/* for GPIO Poll */
261#define GPIO_MASK 0x03
262
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200263/* extra amp-initialization sequence types */
264enum {
265 ALC_INIT_NONE,
266 ALC_INIT_DEFAULT,
267 ALC_INIT_GPIO1,
268 ALC_INIT_GPIO2,
269 ALC_INIT_GPIO3,
270};
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
Kailang Yangdf694da2005-12-05 19:42:22 +0100279 const struct hda_verb *init_verbs[5]; /* 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 Iwai812a2cc2009-05-16 10:00:49 +0200285 char stream_name_analog[16]; /* 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 Iwai812a2cc2009-05-16 10:00:49 +0200291 char stream_name_digital[16]; /* 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 */
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200309 int capture_style; /* capture style (CAPT_*) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310
311 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200312 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 const struct hda_input_mux *input_mux;
314 unsigned int cur_mux[3];
315
316 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100317 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200319 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200320 int const_channel_count;
321 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100324 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200325
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200326 /* dynamic controls, init_verbs and input_mux */
327 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200328 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200329 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200330 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100331
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100332 /* hooks */
333 void (*init_hook)(struct hda_codec *codec);
334 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
335
Takashi Iwai834be882006-03-01 14:16:17 +0100336 /* for pin sensing */
337 unsigned int sense_updated: 1;
338 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100339 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200340
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100341 /* other flags */
342 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200343 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100344
Takashi Iwai2134ea42008-01-10 16:53:55 +0100345 /* for virtual master */
346 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200347#ifdef CONFIG_SND_HDA_POWER_SAVE
348 struct hda_loopback_check loopback;
349#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200350
351 /* for PLL fix */
352 hda_nid_t pll_nid;
353 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100354};
355
356/*
357 * configuration template - to be copied to the spec instance
358 */
359struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200360 struct snd_kcontrol_new *mixers[5]; /* should be identical size
361 * with spec
362 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100363 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100364 const struct hda_verb *init_verbs[5];
365 unsigned int num_dacs;
366 hda_nid_t *dac_nids;
367 hda_nid_t dig_out_nid; /* optional */
368 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800369 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100370 unsigned int num_adc_nids;
371 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100372 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100373 hda_nid_t dig_in_nid;
374 unsigned int num_channel_mode;
375 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200376 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200377 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200378 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100379 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100380 void (*unsol_event)(struct hda_codec *, unsigned int);
381 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200382#ifdef CONFIG_SND_HDA_POWER_SAVE
383 struct hda_amp_list *loopbacks;
384#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385};
386
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
388/*
389 * input MUX handling
390 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200391static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
392 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393{
394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
395 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200396 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
397 if (mux_idx >= spec->num_mux_defs)
398 mux_idx = 0;
399 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400}
401
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200402static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
403 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404{
405 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
406 struct alc_spec *spec = codec->spec;
407 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
408
409 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
410 return 0;
411}
412
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200413static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
414 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415{
416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
417 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100418 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100420 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100421 hda_nid_t nid = spec->capsrc_nids ?
422 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423
Takashi Iwaicd896c32008-11-18 12:36:33 +0100424 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
425 imux = &spec->input_mux[mux_idx];
426
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200427 if (spec->capture_style &&
428 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100429 /* Matrix-mixer style (e.g. ALC882) */
430 unsigned int *cur_val = &spec->cur_mux[adc_idx];
431 unsigned int i, idx;
432
433 idx = ucontrol->value.enumerated.item[0];
434 if (idx >= imux->num_items)
435 idx = imux->num_items - 1;
436 if (*cur_val == idx)
437 return 0;
438 for (i = 0; i < imux->num_items; i++) {
439 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
440 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
441 imux->items[i].index,
442 HDA_AMP_MUTE, v);
443 }
444 *cur_val = idx;
445 return 1;
446 } else {
447 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100448 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100449 &spec->cur_mux[adc_idx]);
450 }
451}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200452
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453/*
454 * channel mode setting
455 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200456static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
457 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458{
459 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
460 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100461 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
462 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463}
464
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200465static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
466 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467{
468 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
469 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100470 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200471 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200472 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473}
474
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200475static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
476 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477{
478 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
479 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200480 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
481 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200482 &spec->ext_channel_count);
483 if (err >= 0 && !spec->const_channel_count) {
484 spec->multiout.max_channels = spec->ext_channel_count;
485 if (spec->need_dac_fix)
486 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
487 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200488 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489}
490
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100492 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200493 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100494 * being part of a format specifier. Maximum allowed length of a value is
495 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100496 *
497 * Note: some retasking pin complexes seem to ignore requests for input
498 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
499 * are requested. Therefore order this list so that this behaviour will not
500 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200501 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
502 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200503 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100504static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100505 "Mic 50pc bias", "Mic 80pc bias",
506 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100507};
508static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100509 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510};
511/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200512 * in the pin being assumed to be exclusively an input or an output pin. In
513 * addition, "input" pins may or may not process the mic bias option
514 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
515 * accept requests for bias as of chip versions up to March 2006) and/or
516 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100517 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200518#define ALC_PIN_DIR_IN 0x00
519#define ALC_PIN_DIR_OUT 0x01
520#define ALC_PIN_DIR_INOUT 0x02
521#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
522#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100523
Kailang Yangea1fb292008-08-26 12:58:38 +0200524/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100525 * For each direction the minimum and maximum values are given.
526 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200527static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100528 { 0, 2 }, /* ALC_PIN_DIR_IN */
529 { 3, 4 }, /* ALC_PIN_DIR_OUT */
530 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200531 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
532 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533};
534#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
535#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
536#define alc_pin_mode_n_items(_dir) \
537 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
538
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200539static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
540 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200541{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100542 unsigned int item_num = uinfo->value.enumerated.item;
543 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
544
545 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200546 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100547 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
548
549 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
550 item_num = alc_pin_mode_min(dir);
551 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200552 return 0;
553}
554
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200555static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
556 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200557{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100558 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100561 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200562 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200563 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
564 AC_VERB_GET_PIN_WIDGET_CONTROL,
565 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200566
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567 /* Find enumerated value for current pinctl setting */
568 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200569 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200571 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100572 return 0;
573}
574
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200575static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
576 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577{
578 signed int change;
579 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
580 hda_nid_t nid = kcontrol->private_value & 0xffff;
581 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
582 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
584 AC_VERB_GET_PIN_WIDGET_CONTROL,
585 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100586
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200587 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100588 val = alc_pin_mode_min(dir);
589
590 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100591 if (change) {
592 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200593 snd_hda_codec_write_cache(codec, nid, 0,
594 AC_VERB_SET_PIN_WIDGET_CONTROL,
595 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100596
Kailang Yangea1fb292008-08-26 12:58:38 +0200597 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100598 * for the requested pin mode. Enum values of 2 or less are
599 * input modes.
600 *
601 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200602 * reduces noise slightly (particularly on input) so we'll
603 * do it. However, having both input and output buffers
604 * enabled simultaneously doesn't seem to be problematic if
605 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100606 */
607 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200608 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
609 HDA_AMP_MUTE, HDA_AMP_MUTE);
610 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
611 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100612 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200613 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
614 HDA_AMP_MUTE, HDA_AMP_MUTE);
615 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
616 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100617 }
618 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200619 return change;
620}
621
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100622#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200623 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100624 .info = alc_pin_mode_info, \
625 .get = alc_pin_mode_get, \
626 .put = alc_pin_mode_put, \
627 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100628
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100629/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
630 * together using a mask with more than one bit set. This control is
631 * currently used only by the ALC260 test model. At this stage they are not
632 * needed for any "production" models.
633 */
634#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200635#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200636
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200637static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
638 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100639{
640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
641 hda_nid_t nid = kcontrol->private_value & 0xffff;
642 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
643 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200644 unsigned int val = snd_hda_codec_read(codec, nid, 0,
645 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100646
647 *valp = (val & mask) != 0;
648 return 0;
649}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200650static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
651 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100652{
653 signed int change;
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 hda_nid_t nid = kcontrol->private_value & 0xffff;
656 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
657 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200658 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
659 AC_VERB_GET_GPIO_DATA,
660 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100661
662 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200663 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
664 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100665 gpio_data &= ~mask;
666 else
667 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200668 snd_hda_codec_write_cache(codec, nid, 0,
669 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100670
671 return change;
672}
673#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
674 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
675 .info = alc_gpio_data_info, \
676 .get = alc_gpio_data_get, \
677 .put = alc_gpio_data_put, \
678 .private_value = nid | (mask<<16) }
679#endif /* CONFIG_SND_DEBUG */
680
Jonathan Woithe92621f12006-02-28 11:47:47 +0100681/* A switch control to allow the enabling of the digital IO pins on the
682 * ALC260. This is incredibly simplistic; the intention of this control is
683 * to provide something in the test model allowing digital outputs to be
684 * identified if present. If models are found which can utilise these
685 * outputs a more complete mixer control can be devised for those models if
686 * necessary.
687 */
688#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200689#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200690
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200691static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
692 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100693{
694 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
695 hda_nid_t nid = kcontrol->private_value & 0xffff;
696 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
697 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200698 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100699 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100700
701 *valp = (val & mask) != 0;
702 return 0;
703}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200704static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
705 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100706{
707 signed int change;
708 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
709 hda_nid_t nid = kcontrol->private_value & 0xffff;
710 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
711 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200712 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100713 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200714 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100715
716 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200717 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100718 if (val==0)
719 ctrl_data &= ~mask;
720 else
721 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200722 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
723 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100724
725 return change;
726}
727#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
728 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
729 .info = alc_spdif_ctrl_info, \
730 .get = alc_spdif_ctrl_get, \
731 .put = alc_spdif_ctrl_put, \
732 .private_value = nid | (mask<<16) }
733#endif /* CONFIG_SND_DEBUG */
734
Jonathan Woithef8225f62008-01-08 12:16:54 +0100735/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
736 * Again, this is only used in the ALC26x test models to help identify when
737 * the EAPD line must be asserted for features to work.
738 */
739#ifdef CONFIG_SND_DEBUG
740#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
741
742static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
743 struct snd_ctl_elem_value *ucontrol)
744{
745 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
746 hda_nid_t nid = kcontrol->private_value & 0xffff;
747 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
748 long *valp = ucontrol->value.integer.value;
749 unsigned int val = snd_hda_codec_read(codec, nid, 0,
750 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
751
752 *valp = (val & mask) != 0;
753 return 0;
754}
755
756static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
757 struct snd_ctl_elem_value *ucontrol)
758{
759 int change;
760 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
761 hda_nid_t nid = kcontrol->private_value & 0xffff;
762 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
763 long val = *ucontrol->value.integer.value;
764 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
765 AC_VERB_GET_EAPD_BTLENABLE,
766 0x00);
767
768 /* Set/unset the masked control bit(s) as needed */
769 change = (!val ? 0 : mask) != (ctrl_data & mask);
770 if (!val)
771 ctrl_data &= ~mask;
772 else
773 ctrl_data |= mask;
774 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
775 ctrl_data);
776
777 return change;
778}
779
780#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
781 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
782 .info = alc_eapd_ctrl_info, \
783 .get = alc_eapd_ctrl_get, \
784 .put = alc_eapd_ctrl_put, \
785 .private_value = nid | (mask<<16) }
786#endif /* CONFIG_SND_DEBUG */
787
Kailang Yangdf694da2005-12-05 19:42:22 +0100788/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100789 * set up the input pin config (depending on the given auto-pin type)
790 */
791static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
792 int auto_pin_type)
793{
794 unsigned int val = PIN_IN;
795
796 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
797 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100798 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100799 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
800 if (pincap & AC_PINCAP_VREF_80)
801 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200802 else if (pincap & AC_PINCAP_VREF_50)
803 val = PIN_VREF50;
804 else if (pincap & AC_PINCAP_VREF_100)
805 val = PIN_VREF100;
806 else if (pincap & AC_PINCAP_VREF_GRD)
807 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100808 }
809 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
810}
811
812/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100813 */
814static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
815{
816 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
817 return;
818 spec->mixers[spec->num_mixers++] = mix;
819}
820
821static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
822{
823 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
824 return;
825 spec->init_verbs[spec->num_init_verbs++] = verb;
826}
827
Takashi Iwaidaead532008-11-28 12:55:36 +0100828#ifdef CONFIG_PROC_FS
829/*
830 * hook for proc
831 */
832static void print_realtek_coef(struct snd_info_buffer *buffer,
833 struct hda_codec *codec, hda_nid_t nid)
834{
835 int coeff;
836
837 if (nid != 0x20)
838 return;
839 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
840 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
841 coeff = snd_hda_codec_read(codec, nid, 0,
842 AC_VERB_GET_COEF_INDEX, 0);
843 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
844}
845#else
846#define print_realtek_coef NULL
847#endif
848
Takashi Iwaid88897e2008-10-31 15:01:37 +0100849/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100850 * set up from the preset table
851 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200852static void setup_preset(struct alc_spec *spec,
853 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100854{
855 int i;
856
857 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100858 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100859 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200860 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
861 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100862 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200863
Kailang Yangdf694da2005-12-05 19:42:22 +0100864 spec->channel_mode = preset->channel_mode;
865 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200866 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200867 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100868
Hector Martin3b315d72009-06-02 10:54:19 +0200869 if (preset->const_channel_count)
870 spec->multiout.max_channels = preset->const_channel_count;
871 else
872 spec->multiout.max_channels = spec->channel_mode[0].channels;
873 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100874
875 spec->multiout.num_dacs = preset->num_dacs;
876 spec->multiout.dac_nids = preset->dac_nids;
877 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800878 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100879 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200880
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200881 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200882 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200883 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100884 spec->input_mux = preset->input_mux;
885
886 spec->num_adc_nids = preset->num_adc_nids;
887 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100888 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100889 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100890
891 spec->unsol_event = preset->unsol_event;
892 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200893#ifdef CONFIG_SND_HDA_POWER_SAVE
894 spec->loopback.amplist = preset->loopbacks;
895#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100896}
897
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200898/* Enable GPIO mask and set output */
899static struct hda_verb alc_gpio1_init_verbs[] = {
900 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
901 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
902 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
903 { }
904};
905
906static struct hda_verb alc_gpio2_init_verbs[] = {
907 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
908 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
909 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
910 { }
911};
912
Kailang Yangbdd148a2007-05-08 15:19:08 +0200913static struct hda_verb alc_gpio3_init_verbs[] = {
914 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
915 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
916 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
917 { }
918};
919
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200920/*
921 * Fix hardware PLL issue
922 * On some codecs, the analog PLL gating control must be off while
923 * the default value is 1.
924 */
925static void alc_fix_pll(struct hda_codec *codec)
926{
927 struct alc_spec *spec = codec->spec;
928 unsigned int val;
929
930 if (!spec->pll_nid)
931 return;
932 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
933 spec->pll_coef_idx);
934 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
935 AC_VERB_GET_PROC_COEF, 0);
936 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
937 spec->pll_coef_idx);
938 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
939 val & ~(1 << spec->pll_coef_bit));
940}
941
942static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
943 unsigned int coef_idx, unsigned int coef_bit)
944{
945 struct alc_spec *spec = codec->spec;
946 spec->pll_nid = nid;
947 spec->pll_coef_idx = coef_idx;
948 spec->pll_coef_bit = coef_bit;
949 alc_fix_pll(codec);
950}
951
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200952static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200953{
954 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200955 unsigned int present;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200956 unsigned int nid = spec->autocfg.hp_pins[0];
957 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200958
959 /* need to execute and sync at first */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200960 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
961 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200962 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200963 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
964 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
965 nid = spec->autocfg.speaker_pins[i];
966 if (!nid)
967 break;
968 snd_hda_codec_write(codec, nid, 0,
969 AC_VERB_SET_PIN_WIDGET_CONTROL,
970 spec->jack_present ? 0 : PIN_OUT);
971 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200972}
973
Sasha Alexandrdef319f2009-06-16 16:00:15 -0400974#if 0 /* it's broken in some cases -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200975static void alc_mic_automute(struct hda_codec *codec)
976{
977 struct alc_spec *spec = codec->spec;
978 unsigned int present;
979 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
980 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
981 unsigned int mix_nid = spec->capsrc_nids[0];
982 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
983
984 capsrc_idx_mic = mic_nid - 0x18;
985 capsrc_idx_fmic = fmic_nid - 0x18;
986 present = snd_hda_codec_read(codec, mic_nid, 0,
987 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
988 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
989 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
990 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
991 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
992 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
993 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
994}
Takashi Iwai4605b712008-10-31 14:18:24 +0100995#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100996#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100997#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200998
Kailang Yangc9b58002007-10-16 14:30:01 +0200999/* unsolicited event for HP jack sensing */
1000static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1001{
1002 if (codec->vendor_id == 0x10ec0880)
1003 res >>= 28;
1004 else
1005 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001006 switch (res) {
1007 case ALC880_HP_EVENT:
1008 alc_automute_pin(codec);
1009 break;
1010 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001011 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001012 break;
1013 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001014}
1015
1016static void alc_inithook(struct hda_codec *codec)
1017{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001018 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001019 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001020}
1021
Kailang Yangf9423e72008-05-27 12:32:25 +02001022/* additional initialization for ALC888 variants */
1023static void alc888_coef_init(struct hda_codec *codec)
1024{
1025 unsigned int tmp;
1026
1027 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1028 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1029 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001030 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001031 /* alc888S-VC */
1032 snd_hda_codec_read(codec, 0x20, 0,
1033 AC_VERB_SET_PROC_COEF, 0x830);
1034 else
1035 /* alc888-VB */
1036 snd_hda_codec_read(codec, 0x20, 0,
1037 AC_VERB_SET_PROC_COEF, 0x3030);
1038}
1039
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001040static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001041{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001042 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001043
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001044 switch (type) {
1045 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001046 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1047 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001048 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001049 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1050 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001051 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001052 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1053 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001054 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001055 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001056 case 0x10ec0260:
1057 snd_hda_codec_write(codec, 0x0f, 0,
1058 AC_VERB_SET_EAPD_BTLENABLE, 2);
1059 snd_hda_codec_write(codec, 0x10, 0,
1060 AC_VERB_SET_EAPD_BTLENABLE, 2);
1061 break;
1062 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001063 case 0x10ec0267:
1064 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001065 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001066 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001067 case 0x10ec0660:
1068 case 0x10ec0662:
1069 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001070 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001071 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001072 snd_hda_codec_write(codec, 0x14, 0,
1073 AC_VERB_SET_EAPD_BTLENABLE, 2);
1074 snd_hda_codec_write(codec, 0x15, 0,
1075 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001076 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001077 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001078 switch (codec->vendor_id) {
1079 case 0x10ec0260:
1080 snd_hda_codec_write(codec, 0x1a, 0,
1081 AC_VERB_SET_COEF_INDEX, 7);
1082 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1083 AC_VERB_GET_PROC_COEF, 0);
1084 snd_hda_codec_write(codec, 0x1a, 0,
1085 AC_VERB_SET_COEF_INDEX, 7);
1086 snd_hda_codec_write(codec, 0x1a, 0,
1087 AC_VERB_SET_PROC_COEF,
1088 tmp | 0x2010);
1089 break;
1090 case 0x10ec0262:
1091 case 0x10ec0880:
1092 case 0x10ec0882:
1093 case 0x10ec0883:
1094 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001095 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001096 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001097 snd_hda_codec_write(codec, 0x20, 0,
1098 AC_VERB_SET_COEF_INDEX, 7);
1099 tmp = snd_hda_codec_read(codec, 0x20, 0,
1100 AC_VERB_GET_PROC_COEF, 0);
1101 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001102 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001103 snd_hda_codec_write(codec, 0x20, 0,
1104 AC_VERB_SET_PROC_COEF,
1105 tmp | 0x2010);
1106 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001107 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001108 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001109 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001110 case 0x10ec0267:
1111 case 0x10ec0268:
1112 snd_hda_codec_write(codec, 0x20, 0,
1113 AC_VERB_SET_COEF_INDEX, 7);
1114 tmp = snd_hda_codec_read(codec, 0x20, 0,
1115 AC_VERB_GET_PROC_COEF, 0);
1116 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001117 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001118 snd_hda_codec_write(codec, 0x20, 0,
1119 AC_VERB_SET_PROC_COEF,
1120 tmp | 0x3000);
1121 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001122 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001123 break;
1124 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001125}
Kailang Yangea1fb292008-08-26 12:58:38 +02001126
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001127static void alc_init_auto_hp(struct hda_codec *codec)
1128{
1129 struct alc_spec *spec = codec->spec;
1130
1131 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001133
Kailang Yangc9b58002007-10-16 14:30:01 +02001134 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001135 if (spec->autocfg.line_out_pins[0] &&
1136 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001137 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001138 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001139 else
1140 return;
1141 }
1142
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001143 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1144 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001145 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1146 AC_VERB_SET_UNSOLICITED_ENABLE,
1147 AC_USRSP_EN | ALC880_HP_EVENT);
1148 spec->unsol_event = alc_sku_unsol_event;
1149}
1150
1151/* check subsystem ID and set up device-specific initialization;
1152 * return 1 if initialized, 0 if invalid SSID
1153 */
1154/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1155 * 31 ~ 16 : Manufacture ID
1156 * 15 ~ 8 : SKU ID
1157 * 7 ~ 0 : Assembly ID
1158 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1159 */
1160static int alc_subsystem_id(struct hda_codec *codec,
1161 hda_nid_t porta, hda_nid_t porte,
1162 hda_nid_t portd)
1163{
1164 unsigned int ass, tmp, i;
1165 unsigned nid;
1166 struct alc_spec *spec = codec->spec;
1167
1168 ass = codec->subsystem_id & 0xffff;
1169 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1170 goto do_sku;
1171
1172 /* invalid SSID, check the special NID pin defcfg instead */
1173 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001174 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001175 * 29~21 : reserve
1176 * 20 : PCBEEP input
1177 * 19~16 : Check sum (15:1)
1178 * 15~1 : Custom
1179 * 0 : override
1180 */
1181 nid = 0x1d;
1182 if (codec->vendor_id == 0x10ec0260)
1183 nid = 0x17;
1184 ass = snd_hda_codec_get_pincfg(codec, nid);
1185 snd_printd("realtek: No valid SSID, "
1186 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001187 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001188 if (!(ass & 1) && !(ass & 0x100000))
1189 return 0;
1190 if ((ass >> 30) != 1) /* no physical connection */
1191 return 0;
1192
1193 /* check sum */
1194 tmp = 0;
1195 for (i = 1; i < 16; i++) {
1196 if ((ass >> i) & 1)
1197 tmp++;
1198 }
1199 if (((ass >> 16) & 0xf) != tmp)
1200 return 0;
1201do_sku:
1202 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1203 ass & 0xffff, codec->vendor_id);
1204 /*
1205 * 0 : override
1206 * 1 : Swap Jack
1207 * 2 : 0 --> Desktop, 1 --> Laptop
1208 * 3~5 : External Amplifier control
1209 * 7~6 : Reserved
1210 */
1211 tmp = (ass & 0x38) >> 3; /* external Amp control */
1212 switch (tmp) {
1213 case 1:
1214 spec->init_amp = ALC_INIT_GPIO1;
1215 break;
1216 case 3:
1217 spec->init_amp = ALC_INIT_GPIO2;
1218 break;
1219 case 7:
1220 spec->init_amp = ALC_INIT_GPIO3;
1221 break;
1222 case 5:
1223 spec->init_amp = ALC_INIT_DEFAULT;
1224 break;
1225 }
1226
1227 /* is laptop or Desktop and enable the function "Mute internal speaker
1228 * when the external headphone out jack is plugged"
1229 */
1230 if (!(ass & 0x8000))
1231 return 1;
1232 /*
1233 * 10~8 : Jack location
1234 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1235 * 14~13: Resvered
1236 * 15 : 1 --> enable the function "Mute internal speaker
1237 * when the external headphone out jack is plugged"
1238 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001239 if (!spec->autocfg.hp_pins[0]) {
1240 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1241 if (tmp == 0)
1242 spec->autocfg.hp_pins[0] = porta;
1243 else if (tmp == 1)
1244 spec->autocfg.hp_pins[0] = porte;
1245 else if (tmp == 2)
1246 spec->autocfg.hp_pins[0] = portd;
1247 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001248 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001249 }
1250
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001251 alc_init_auto_hp(codec);
1252 return 1;
1253}
Kailang Yangea1fb292008-08-26 12:58:38 +02001254
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001255static void alc_ssid_check(struct hda_codec *codec,
1256 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1257{
1258 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1259 struct alc_spec *spec = codec->spec;
1260 snd_printd("realtek: "
1261 "Enable default setup for auto mode as fallback\n");
1262 spec->init_amp = ALC_INIT_DEFAULT;
1263 alc_init_auto_hp(codec);
1264 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001265}
1266
Takashi Iwai41e41f12005-06-08 14:48:49 +02001267/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001268 * Fix-up pin default configurations
1269 */
1270
1271struct alc_pincfg {
1272 hda_nid_t nid;
1273 u32 val;
1274};
1275
1276static void alc_fix_pincfg(struct hda_codec *codec,
1277 const struct snd_pci_quirk *quirk,
1278 const struct alc_pincfg **pinfix)
1279{
1280 const struct alc_pincfg *cfg;
1281
1282 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1283 if (!quirk)
1284 return;
1285
1286 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001287 for (; cfg->nid; cfg++)
1288 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001289}
1290
1291/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001292 * ALC888
1293 */
1294
1295/*
1296 * 2ch mode
1297 */
1298static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1299/* Mic-in jack as mic in */
1300 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1301 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1302/* Line-in jack as Line in */
1303 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1304 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1305/* Line-Out as Front */
1306 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1307 { } /* end */
1308};
1309
1310/*
1311 * 4ch mode
1312 */
1313static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1314/* Mic-in jack as mic in */
1315 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1316 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1317/* Line-in jack as Surround */
1318 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1319 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1320/* Line-Out as Front */
1321 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1322 { } /* end */
1323};
1324
1325/*
1326 * 6ch mode
1327 */
1328static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1329/* Mic-in jack as CLFE */
1330 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1331 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1332/* Line-in jack as Surround */
1333 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1334 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1335/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1336 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1337 { } /* end */
1338};
1339
1340/*
1341 * 8ch mode
1342 */
1343static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1344/* Mic-in jack as CLFE */
1345 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1346 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1347/* Line-in jack as Surround */
1348 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1349 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1350/* Line-Out as Side */
1351 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1352 { } /* end */
1353};
1354
1355static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1356 { 2, alc888_4ST_ch2_intel_init },
1357 { 4, alc888_4ST_ch4_intel_init },
1358 { 6, alc888_4ST_ch6_intel_init },
1359 { 8, alc888_4ST_ch8_intel_init },
1360};
1361
1362/*
1363 * ALC888 Fujitsu Siemens Amillo xa3530
1364 */
1365
1366static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1367/* Front Mic: set to PIN_IN (empty by default) */
1368 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1369/* Connect Internal HP to Front */
1370 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1371 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1372 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1373/* Connect Bass HP to Front */
1374 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1375 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1376 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1377/* Connect Line-Out side jack (SPDIF) to Side */
1378 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1379 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1380 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1381/* Connect Mic jack to CLFE */
1382 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1383 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1384 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1385/* Connect Line-in jack to Surround */
1386 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1387 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1388 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1389/* Connect HP out jack to Front */
1390 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1392 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1393/* Enable unsolicited event for HP jack and Line-out jack */
1394 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1395 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1396 {}
1397};
1398
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001399static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001400{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001401 struct alc_spec *spec = codec->spec;
1402 unsigned int val, mute;
1403 hda_nid_t nid;
1404 int i;
1405
1406 spec->jack_present = 0;
1407 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1408 nid = spec->autocfg.hp_pins[i];
1409 if (!nid)
1410 break;
1411 val = snd_hda_codec_read(codec, nid, 0,
1412 AC_VERB_GET_PIN_SENSE, 0);
1413 if (val & AC_PINSENSE_PRESENCE) {
1414 spec->jack_present = 1;
1415 break;
1416 }
1417 }
1418
1419 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001420 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001421 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1422 nid = spec->autocfg.speaker_pins[i];
1423 if (!nid)
1424 break;
1425 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1426 HDA_AMP_MUTE, mute);
1427 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001428}
1429
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001430static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1431 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001432{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001433 if (codec->vendor_id == 0x10ec0880)
1434 res >>= 28;
1435 else
1436 res >>= 26;
1437 if (res == ALC880_HP_EVENT)
1438 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001439}
1440
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001441static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1442{
1443 struct alc_spec *spec = codec->spec;
1444
1445 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1446 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1447 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1448 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1449 alc_automute_amp(codec);
1450}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001451
1452/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001453 * ALC888 Acer Aspire 4930G model
1454 */
1455
1456static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1457/* Front Mic: set to PIN_IN (empty by default) */
1458 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1459/* Unselect Front Mic by default in input mixer 3 */
1460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001461/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001462 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1463/* Connect Internal HP to front */
1464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1466 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1467/* Connect HP out to front */
1468 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1469 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1470 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1471 { }
1472};
1473
Hector Martin3b315d72009-06-02 10:54:19 +02001474/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001475 * ALC888 Acer Aspire 6530G model
1476 */
1477
1478static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1479/* Bias voltage on for external mic port */
1480 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1481/* Enable unsolicited event for HP jack */
1482 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1483/* Enable speaker output */
1484 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1485 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1486/* Enable headphone output */
1487 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1488 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1489 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1490 { }
1491};
1492
1493/*
Hector Martin018df412009-06-04 00:13:40 +02001494 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001495 */
1496
Hector Martin018df412009-06-04 00:13:40 +02001497static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001498/* Front Mic: set to PIN_IN (empty by default) */
1499 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1500/* Unselect Front Mic by default in input mixer 3 */
1501 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1502/* Enable unsolicited event for HP jack */
1503 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1504/* Connect Internal Front to Front */
1505 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1506 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1507 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1508/* Connect Internal Rear to Rear */
1509 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1510 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1511 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1512/* Connect Internal CLFE to CLFE */
1513 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1514 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1515 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1516/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001517 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001518 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1519 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1520/* Enable all DACs */
1521/* DAC DISABLE/MUTE 1? */
1522/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1523 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1524 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1525/* DAC DISABLE/MUTE 2? */
1526/* some bit here disables the other DACs. Init=0x4900 */
1527 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1528 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1529/* Enable amplifiers */
1530 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1531 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001532/* DMIC fix
1533 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1534 * which makes the stereo useless. However, either the mic or the ALC889
1535 * makes the signal become a difference/sum signal instead of standard
1536 * stereo, which is annoying. So instead we flip this bit which makes the
1537 * codec replicate the sum signal to both channels, turning it into a
1538 * normal mono mic.
1539 */
1540/* DMIC_CONTROL? Init value = 0x0001 */
1541 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1542 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001543 { }
1544};
1545
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001546static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001547 /* Front mic only available on one ADC */
1548 {
1549 .num_items = 4,
1550 .items = {
1551 { "Mic", 0x0 },
1552 { "Line", 0x2 },
1553 { "CD", 0x4 },
1554 { "Front Mic", 0xb },
1555 },
1556 },
1557 {
1558 .num_items = 3,
1559 .items = {
1560 { "Mic", 0x0 },
1561 { "Line", 0x2 },
1562 { "CD", 0x4 },
1563 },
1564 }
1565};
1566
Tony Vroond2fd4b02009-06-21 00:40:10 +01001567static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1568 /* Interal mic only available on one ADC */
1569 {
1570 .num_items = 3,
1571 .items = {
1572 { "Ext Mic", 0x0 },
1573 { "CD", 0x4 },
1574 { "Int Mic", 0xb },
1575 },
1576 },
1577 {
1578 .num_items = 2,
1579 .items = {
1580 { "Ext Mic", 0x0 },
1581 { "CD", 0x4 },
1582 },
1583 }
1584};
1585
Hector Martin018df412009-06-04 00:13:40 +02001586static struct hda_input_mux alc889_capture_sources[3] = {
1587 /* Digital mic only available on first "ADC" */
1588 {
1589 .num_items = 5,
1590 .items = {
1591 { "Mic", 0x0 },
1592 { "Line", 0x2 },
1593 { "CD", 0x4 },
1594 { "Front Mic", 0xb },
1595 { "Input Mix", 0xa },
1596 },
1597 },
1598 {
1599 .num_items = 4,
1600 .items = {
1601 { "Mic", 0x0 },
1602 { "Line", 0x2 },
1603 { "CD", 0x4 },
1604 { "Input Mix", 0xa },
1605 },
1606 },
1607 {
1608 .num_items = 4,
1609 .items = {
1610 { "Mic", 0x0 },
1611 { "Line", 0x2 },
1612 { "CD", 0x4 },
1613 { "Input Mix", 0xa },
1614 },
1615 }
1616};
1617
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001618static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001619 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1620 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1621 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1622 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1623 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1624 HDA_OUTPUT),
1625 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1626 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1627 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1628 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1629 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1630 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1631 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1632 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1633 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1635 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001637 { } /* end */
1638};
1639
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001640static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001641{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001642 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001643
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001644 spec->autocfg.hp_pins[0] = 0x15;
1645 spec->autocfg.speaker_pins[0] = 0x14;
1646 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001647}
1648
Hector Martin018df412009-06-04 00:13:40 +02001649static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001650{
1651 struct alc_spec *spec = codec->spec;
1652
1653 spec->autocfg.hp_pins[0] = 0x15;
1654 spec->autocfg.speaker_pins[0] = 0x14;
1655 spec->autocfg.speaker_pins[1] = 0x16;
1656 spec->autocfg.speaker_pins[2] = 0x1b;
1657 alc_automute_amp(codec);
1658}
1659
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001660/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001661 * ALC880 3-stack model
1662 *
1663 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001664 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1665 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666 */
1667
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001668static hda_nid_t alc880_dac_nids[4] = {
1669 /* front, rear, clfe, rear_surr */
1670 0x02, 0x05, 0x04, 0x03
1671};
1672
1673static hda_nid_t alc880_adc_nids[3] = {
1674 /* ADC0-2 */
1675 0x07, 0x08, 0x09,
1676};
1677
1678/* The datasheet says the node 0x07 is connected from inputs,
1679 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001680 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001681 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001682static hda_nid_t alc880_adc_nids_alt[2] = {
1683 /* ADC1-2 */
1684 0x08, 0x09,
1685};
1686
1687#define ALC880_DIGOUT_NID 0x06
1688#define ALC880_DIGIN_NID 0x0a
1689
1690static struct hda_input_mux alc880_capture_source = {
1691 .num_items = 4,
1692 .items = {
1693 { "Mic", 0x0 },
1694 { "Front Mic", 0x3 },
1695 { "Line", 0x2 },
1696 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001697 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001698};
1699
1700/* channel source setting (2/6 channel selection for 3-stack) */
1701/* 2ch mode */
1702static struct hda_verb alc880_threestack_ch2_init[] = {
1703 /* set line-in to input, mute it */
1704 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1705 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1706 /* set mic-in to input vref 80%, mute it */
1707 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1708 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001709 { } /* end */
1710};
1711
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001712/* 6ch mode */
1713static struct hda_verb alc880_threestack_ch6_init[] = {
1714 /* set line-in to output, unmute it */
1715 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1716 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1717 /* set mic-in to output, unmute it */
1718 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1719 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1720 { } /* end */
1721};
1722
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001723static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001724 { 2, alc880_threestack_ch2_init },
1725 { 6, alc880_threestack_ch6_init },
1726};
1727
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001728static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001729 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001730 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001731 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001732 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001733 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1734 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001735 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1736 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1738 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1739 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1740 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1742 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1743 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1744 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001746 {
1747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1748 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001749 .info = alc_ch_mode_info,
1750 .get = alc_ch_mode_get,
1751 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001752 },
1753 { } /* end */
1754};
1755
1756/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001757static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1758 struct snd_ctl_elem_info *uinfo)
1759{
1760 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1761 struct alc_spec *spec = codec->spec;
1762 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001763
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001764 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001765 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1766 HDA_INPUT);
1767 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001768 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001769 return err;
1770}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001771
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001772static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1773 unsigned int size, unsigned int __user *tlv)
1774{
1775 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1776 struct alc_spec *spec = codec->spec;
1777 int err;
1778
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001779 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001780 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1781 HDA_INPUT);
1782 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001783 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001784 return err;
1785}
1786
1787typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1788 struct snd_ctl_elem_value *ucontrol);
1789
1790static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1791 struct snd_ctl_elem_value *ucontrol,
1792 getput_call_t func)
1793{
1794 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1795 struct alc_spec *spec = codec->spec;
1796 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1797 int err;
1798
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001799 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001800 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1801 3, 0, HDA_INPUT);
1802 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001803 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001804 return err;
1805}
1806
1807static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1808 struct snd_ctl_elem_value *ucontrol)
1809{
1810 return alc_cap_getput_caller(kcontrol, ucontrol,
1811 snd_hda_mixer_amp_volume_get);
1812}
1813
1814static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1815 struct snd_ctl_elem_value *ucontrol)
1816{
1817 return alc_cap_getput_caller(kcontrol, ucontrol,
1818 snd_hda_mixer_amp_volume_put);
1819}
1820
1821/* capture mixer elements */
1822#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1823
1824static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1825 struct snd_ctl_elem_value *ucontrol)
1826{
1827 return alc_cap_getput_caller(kcontrol, ucontrol,
1828 snd_hda_mixer_amp_switch_get);
1829}
1830
1831static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1832 struct snd_ctl_elem_value *ucontrol)
1833{
1834 return alc_cap_getput_caller(kcontrol, ucontrol,
1835 snd_hda_mixer_amp_switch_put);
1836}
1837
Takashi Iwaia23b6882009-03-23 15:21:36 +01001838#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001839 { \
1840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1841 .name = "Capture Switch", \
1842 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1843 .count = num, \
1844 .info = alc_cap_sw_info, \
1845 .get = alc_cap_sw_get, \
1846 .put = alc_cap_sw_put, \
1847 }, \
1848 { \
1849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1850 .name = "Capture Volume", \
1851 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1852 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1853 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1854 .count = num, \
1855 .info = alc_cap_vol_info, \
1856 .get = alc_cap_vol_get, \
1857 .put = alc_cap_vol_put, \
1858 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001859 }
1860
1861#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001862 { \
1863 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1864 /* .name = "Capture Source", */ \
1865 .name = "Input Source", \
1866 .count = num, \
1867 .info = alc_mux_enum_info, \
1868 .get = alc_mux_enum_get, \
1869 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001870 }
1871
1872#define DEFINE_CAPMIX(num) \
1873static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1874 _DEFINE_CAPMIX(num), \
1875 _DEFINE_CAPSRC(num), \
1876 { } /* end */ \
1877}
1878
1879#define DEFINE_CAPMIX_NOSRC(num) \
1880static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1881 _DEFINE_CAPMIX(num), \
1882 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001883}
1884
1885/* up to three ADCs */
1886DEFINE_CAPMIX(1);
1887DEFINE_CAPMIX(2);
1888DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001889DEFINE_CAPMIX_NOSRC(1);
1890DEFINE_CAPMIX_NOSRC(2);
1891DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001892
1893/*
1894 * ALC880 5-stack model
1895 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001896 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1897 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001898 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1899 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1900 */
1901
1902/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001903static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001904 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001905 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906 { } /* end */
1907};
1908
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001909/* channel source setting (6/8 channel selection for 5-stack) */
1910/* 6ch mode */
1911static struct hda_verb alc880_fivestack_ch6_init[] = {
1912 /* set line-in to input, mute it */
1913 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1914 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001915 { } /* end */
1916};
1917
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001918/* 8ch mode */
1919static struct hda_verb alc880_fivestack_ch8_init[] = {
1920 /* set line-in to output, unmute it */
1921 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1922 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1923 { } /* end */
1924};
1925
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001926static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001927 { 6, alc880_fivestack_ch6_init },
1928 { 8, alc880_fivestack_ch8_init },
1929};
1930
1931
1932/*
1933 * ALC880 6-stack model
1934 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001935 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1936 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001937 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1938 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1939 */
1940
1941static hda_nid_t alc880_6st_dac_nids[4] = {
1942 /* front, rear, clfe, rear_surr */
1943 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001944};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001945
1946static struct hda_input_mux alc880_6stack_capture_source = {
1947 .num_items = 4,
1948 .items = {
1949 { "Mic", 0x0 },
1950 { "Front Mic", 0x1 },
1951 { "Line", 0x2 },
1952 { "CD", 0x4 },
1953 },
1954};
1955
1956/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001957static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001958 { 8, NULL },
1959};
1960
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001961static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001962 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001963 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001964 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001965 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001966 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1967 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001968 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1969 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001970 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001971 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1977 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1978 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1979 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001980 {
1981 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1982 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001983 .info = alc_ch_mode_info,
1984 .get = alc_ch_mode_get,
1985 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001986 },
1987 { } /* end */
1988};
1989
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001990
1991/*
1992 * ALC880 W810 model
1993 *
1994 * W810 has rear IO for:
1995 * Front (DAC 02)
1996 * Surround (DAC 03)
1997 * Center/LFE (DAC 04)
1998 * Digital out (06)
1999 *
2000 * The system also has a pair of internal speakers, and a headphone jack.
2001 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002002 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002003 * There is a variable resistor to control the speaker or headphone
2004 * volume. This is a hardware-only device without a software API.
2005 *
2006 * Plugging headphones in will disable the internal speakers. This is
2007 * implemented in hardware, not via the driver using jack sense. In
2008 * a similar fashion, plugging into the rear socket marked "front" will
2009 * disable both the speakers and headphones.
2010 *
2011 * For input, there's a microphone jack, and an "audio in" jack.
2012 * These may not do anything useful with this driver yet, because I
2013 * haven't setup any initialization verbs for these yet...
2014 */
2015
2016static hda_nid_t alc880_w810_dac_nids[3] = {
2017 /* front, rear/surround, clfe */
2018 0x02, 0x03, 0x04
2019};
2020
2021/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002022static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002023 { 6, NULL }
2024};
2025
2026/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002027static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002028 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002029 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002030 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002031 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002032 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2033 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002034 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2035 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002036 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2037 { } /* end */
2038};
2039
2040
2041/*
2042 * Z710V model
2043 *
2044 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002045 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2046 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002047 */
2048
2049static hda_nid_t alc880_z71v_dac_nids[1] = {
2050 0x02
2051};
2052#define ALC880_Z71V_HP_DAC 0x03
2053
2054/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002055static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002056 { 2, NULL }
2057};
2058
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002059static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002060 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002061 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002062 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002063 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002064 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2065 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2066 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2067 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2068 { } /* end */
2069};
2070
2071
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002072/*
2073 * ALC880 F1734 model
2074 *
2075 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2076 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2077 */
2078
2079static hda_nid_t alc880_f1734_dac_nids[1] = {
2080 0x03
2081};
2082#define ALC880_F1734_HP_DAC 0x02
2083
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002084static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002085 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002086 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002087 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2088 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002089 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2090 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2092 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002093 { } /* end */
2094};
2095
Takashi Iwai937b4162008-02-11 14:52:36 +01002096static struct hda_input_mux alc880_f1734_capture_source = {
2097 .num_items = 2,
2098 .items = {
2099 { "Mic", 0x1 },
2100 { "CD", 0x4 },
2101 },
2102};
2103
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002105/*
2106 * ALC880 ASUS model
2107 *
2108 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2109 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2110 * Mic = 0x18, Line = 0x1a
2111 */
2112
2113#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2114#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2115
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002116static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002117 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002118 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002119 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002120 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002121 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2122 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002123 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2124 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002125 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2126 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, 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 * ALC880 ASUS W1V model
2143 *
2144 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2145 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2146 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2147 */
2148
2149/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002150static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002151 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2152 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002153 { } /* end */
2154};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002155
Kailang Yangdf694da2005-12-05 19:42:22 +01002156/* TCL S700 */
2157static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2158 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2159 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2160 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2161 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2162 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2165 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2166 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002167 { } /* end */
2168};
2169
Kailang Yangccc656c2006-10-17 12:32:26 +02002170/* Uniwill */
2171static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002172 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2173 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2174 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2175 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002176 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2177 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2178 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2179 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2180 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2181 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2182 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2183 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2184 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2185 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2186 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2187 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002188 {
2189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2190 .name = "Channel Mode",
2191 .info = alc_ch_mode_info,
2192 .get = alc_ch_mode_get,
2193 .put = alc_ch_mode_put,
2194 },
2195 { } /* end */
2196};
2197
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002198static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2199 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2200 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2201 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2202 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2203 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2204 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2205 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2206 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2207 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2208 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2209 { } /* end */
2210};
2211
Kailang Yangccc656c2006-10-17 12:32:26 +02002212static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002213 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2214 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2215 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2216 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002217 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
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002223 * virtual master controls
2224 */
2225
2226/*
2227 * slave controls for virtual master
2228 */
2229static const char *alc_slave_vols[] = {
2230 "Front Playback Volume",
2231 "Surround Playback Volume",
2232 "Center Playback Volume",
2233 "LFE Playback Volume",
2234 "Side Playback Volume",
2235 "Headphone Playback Volume",
2236 "Speaker Playback Volume",
2237 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002238 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002239 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002240 NULL,
2241};
2242
2243static const char *alc_slave_sws[] = {
2244 "Front Playback Switch",
2245 "Surround Playback Switch",
2246 "Center Playback Switch",
2247 "LFE Playback Switch",
2248 "Side Playback Switch",
2249 "Headphone Playback Switch",
2250 "Speaker Playback Switch",
2251 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002252 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002253 NULL,
2254};
2255
2256/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002257 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002258 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002259
2260static void alc_free_kctls(struct hda_codec *codec);
2261
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002262/* additional beep mixers; the actual parameters are overwritten at build */
2263static struct snd_kcontrol_new alc_beep_mixer[] = {
2264 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2265 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2266 { } /* end */
2267};
2268
Linus Torvalds1da177e2005-04-16 15:20:36 -07002269static int alc_build_controls(struct hda_codec *codec)
2270{
2271 struct alc_spec *spec = codec->spec;
2272 int err;
2273 int i;
2274
2275 for (i = 0; i < spec->num_mixers; i++) {
2276 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2277 if (err < 0)
2278 return err;
2279 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002280 if (spec->cap_mixer) {
2281 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2282 if (err < 0)
2283 return err;
2284 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002285 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002286 err = snd_hda_create_spdif_out_ctls(codec,
2287 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002288 if (err < 0)
2289 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002290 if (!spec->no_analog) {
2291 err = snd_hda_create_spdif_share_sw(codec,
2292 &spec->multiout);
2293 if (err < 0)
2294 return err;
2295 spec->multiout.share_spdif = 1;
2296 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002297 }
2298 if (spec->dig_in_nid) {
2299 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2300 if (err < 0)
2301 return err;
2302 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002303
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002304 /* create beep controls if needed */
2305 if (spec->beep_amp) {
2306 struct snd_kcontrol_new *knew;
2307 for (knew = alc_beep_mixer; knew->name; knew++) {
2308 struct snd_kcontrol *kctl;
2309 kctl = snd_ctl_new1(knew, codec);
2310 if (!kctl)
2311 return -ENOMEM;
2312 kctl->private_value = spec->beep_amp;
2313 err = snd_hda_ctl_add(codec, kctl);
2314 if (err < 0)
2315 return err;
2316 }
2317 }
2318
Takashi Iwai2134ea42008-01-10 16:53:55 +01002319 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002320 if (!spec->no_analog &&
2321 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002322 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002323 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002324 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002325 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002326 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002327 if (err < 0)
2328 return err;
2329 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002330 if (!spec->no_analog &&
2331 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002332 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2333 NULL, alc_slave_sws);
2334 if (err < 0)
2335 return err;
2336 }
2337
Takashi Iwai603c4012008-07-30 15:01:44 +02002338 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339 return 0;
2340}
2341
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002342
Linus Torvalds1da177e2005-04-16 15:20:36 -07002343/*
2344 * initialize the codec volumes, etc
2345 */
2346
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002347/*
2348 * generic initialization of ADC, input mixers and output mixers
2349 */
2350static struct hda_verb alc880_volume_init_verbs[] = {
2351 /*
2352 * Unmute ADC0-2 and set the default input to mic-in
2353 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002354 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002355 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002356 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002357 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002358 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002359 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002361 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2362 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002363 * Note: PASD motherboards uses the Line In 2 as the input for front
2364 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002366 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2373 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002374
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002375 /*
2376 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002378 /* set vol=0 to output mixers */
2379 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2380 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2381 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2382 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2383 /* set up input amps for analog loopback */
2384 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002385 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2386 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002387 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2388 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002389 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2390 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002391 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2392 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393
2394 { }
2395};
2396
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002397/*
2398 * 3-stack pin configuration:
2399 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2400 */
2401static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2402 /*
2403 * preset connection lists of input pins
2404 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2405 */
2406 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2407 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2408 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2409
2410 /*
2411 * Set pin mode and muting
2412 */
2413 /* set front pin widgets 0x14 for output */
2414 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2415 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2416 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2417 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2418 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2419 /* Mic2 (as headphone out) for HP output */
2420 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2421 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2422 /* Line In pin widget for input */
2423 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2424 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2425 /* Line2 (as front mic) pin widget for input and vref at 80% */
2426 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2427 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2428 /* CD pin widget for input */
2429 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2430
2431 { }
2432};
2433
2434/*
2435 * 5-stack pin configuration:
2436 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2437 * line-in/side = 0x1a, f-mic = 0x1b
2438 */
2439static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2440 /*
2441 * preset connection lists of input pins
2442 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2443 */
2444 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2445 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2446
2447 /*
2448 * Set pin mode and muting
2449 */
2450 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002451 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2452 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2453 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2454 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002455 /* unmute pins for output (no gain on this amp) */
2456 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2457 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2458 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2459 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2460
Linus Torvalds1da177e2005-04-16 15:20:36 -07002461 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002462 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002463 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2464 /* Mic2 (as headphone out) for HP output */
2465 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002466 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002467 /* Line In pin widget for input */
2468 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2469 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2470 /* Line2 (as front mic) pin widget for input and vref at 80% */
2471 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2472 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2473 /* CD pin widget for input */
2474 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475
2476 { }
2477};
2478
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002479/*
2480 * W810 pin configuration:
2481 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2482 */
2483static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002484 /* hphone/speaker input selector: front DAC */
2485 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2486
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002487 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2488 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2490 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2491 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2492 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2493
2494 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002495 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497 { }
2498};
2499
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002500/*
2501 * Z71V pin configuration:
2502 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2503 */
2504static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002505 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002506 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002507 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002508 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002509
Takashi Iwai16ded522005-06-10 19:58:24 +02002510 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002511 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002512 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002513 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002514
2515 { }
2516};
2517
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002518/*
2519 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002520 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2521 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002522 */
2523static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2524 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2525
Takashi Iwai16ded522005-06-10 19:58:24 +02002526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002528 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002530 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002531 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002532 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002533 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2534
Takashi Iwai16ded522005-06-10 19:58:24 +02002535 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002536 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002537 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002538 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002539 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002540 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002541 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002542 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002543 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002544
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002545 { }
2546};
Takashi Iwai16ded522005-06-10 19:58:24 +02002547
Kailang Yangccc656c2006-10-17 12:32:26 +02002548/*
2549 * Uniwill pin configuration:
2550 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2551 * line = 0x1a
2552 */
2553static struct hda_verb alc880_uniwill_init_verbs[] = {
2554 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2555
2556 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2557 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2558 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2560 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2561 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2562 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2563 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2565 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2566 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2567 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2568 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2569 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2570
2571 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2572 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2573 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2574 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2575 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2577 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2578 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2579 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2580
2581 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2582 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2583
2584 { }
2585};
2586
2587/*
2588* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002589* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002590 */
2591static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2592 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2593
2594 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2595 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2596 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2597 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2598 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2599 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2600 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2602 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2603 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2604 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2605 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2606
2607 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2608 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2609 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2610 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2611 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2612 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2613
2614 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2615 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2616
2617 { }
2618};
2619
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002620static struct hda_verb alc880_beep_init_verbs[] = {
2621 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2622 { }
2623};
2624
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002625/* auto-toggle front mic */
2626static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2627{
2628 unsigned int present;
2629 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002630
2631 present = snd_hda_codec_read(codec, 0x18, 0,
2632 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002633 bits = present ? HDA_AMP_MUTE : 0;
2634 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002635}
2636
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002637static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002638{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002639 struct alc_spec *spec = codec->spec;
2640
2641 spec->autocfg.hp_pins[0] = 0x14;
2642 spec->autocfg.speaker_pins[0] = 0x15;
2643 spec->autocfg.speaker_pins[0] = 0x16;
2644 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002645 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002646}
2647
2648static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2649 unsigned int res)
2650{
2651 /* Looks like the unsol event is incompatible with the standard
2652 * definition. 4bit tag is placed at 28 bit!
2653 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002654 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002655 case ALC880_MIC_EVENT:
2656 alc880_uniwill_mic_automute(codec);
2657 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002658 default:
2659 alc_automute_amp_unsol_event(codec, res);
2660 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002661 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002662}
2663
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002664static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002665{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002666 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002667
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002668 spec->autocfg.hp_pins[0] = 0x14;
2669 spec->autocfg.speaker_pins[0] = 0x15;
2670 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002671}
2672
2673static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2674{
2675 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002676
Kailang Yangccc656c2006-10-17 12:32:26 +02002677 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002678 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2679 present &= HDA_AMP_VOLMASK;
2680 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2681 HDA_AMP_VOLMASK, present);
2682 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2683 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002684}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002685
Kailang Yangccc656c2006-10-17 12:32:26 +02002686static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2687 unsigned int res)
2688{
2689 /* Looks like the unsol event is incompatible with the standard
2690 * definition. 4bit tag is placed at 28 bit!
2691 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002692 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002693 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002694 else
2695 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002696}
2697
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002698/*
2699 * F1734 pin configuration:
2700 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2701 */
2702static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002703 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2705 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2706 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2707 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2708
2709 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2710 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2713
2714 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2715 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002716 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002717 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2718 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2719 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2720 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2721 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2722 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002723
Takashi Iwai937b4162008-02-11 14:52:36 +01002724 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2725 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2726
Takashi Iwai16ded522005-06-10 19:58:24 +02002727 { }
2728};
2729
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002730/*
2731 * ASUS pin configuration:
2732 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2733 */
2734static struct hda_verb alc880_pin_asus_init_verbs[] = {
2735 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2736 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2737 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2738 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2739
2740 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2741 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2742 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2743 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2744 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2746 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2747 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2748
2749 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2750 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2751 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2752 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2753 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2754 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2755 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2756 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2757 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002758
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002759 { }
2760};
2761
2762/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002763#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2764#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002765#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002766
Kailang Yangdf694da2005-12-05 19:42:22 +01002767/* Clevo m520g init */
2768static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2769 /* headphone output */
2770 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2771 /* line-out */
2772 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2773 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2774 /* Line-in */
2775 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2776 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2777 /* CD */
2778 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2779 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2780 /* Mic1 (rear panel) */
2781 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2782 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2783 /* Mic2 (front panel) */
2784 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2785 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2786 /* headphone */
2787 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2788 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2789 /* change to EAPD mode */
2790 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2791 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2792
2793 { }
2794};
2795
2796static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002797 /* change to EAPD mode */
2798 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2799 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2800
Kailang Yangdf694da2005-12-05 19:42:22 +01002801 /* Headphone output */
2802 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2803 /* Front output*/
2804 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2805 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2806
2807 /* Line In pin widget for input */
2808 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2809 /* CD pin widget for input */
2810 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2811 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2812 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2813
2814 /* change to EAPD mode */
2815 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2816 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2817
2818 { }
2819};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002820
2821/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002822 * LG m1 express dual
2823 *
2824 * Pin assignment:
2825 * Rear Line-In/Out (blue): 0x14
2826 * Build-in Mic-In: 0x15
2827 * Speaker-out: 0x17
2828 * HP-Out (green): 0x1b
2829 * Mic-In/Out (red): 0x19
2830 * SPDIF-Out: 0x1e
2831 */
2832
2833/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2834static hda_nid_t alc880_lg_dac_nids[3] = {
2835 0x05, 0x02, 0x03
2836};
2837
2838/* seems analog CD is not working */
2839static struct hda_input_mux alc880_lg_capture_source = {
2840 .num_items = 3,
2841 .items = {
2842 { "Mic", 0x1 },
2843 { "Line", 0x5 },
2844 { "Internal Mic", 0x6 },
2845 },
2846};
2847
2848/* 2,4,6 channel modes */
2849static struct hda_verb alc880_lg_ch2_init[] = {
2850 /* set line-in and mic-in to input */
2851 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2852 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2853 { }
2854};
2855
2856static struct hda_verb alc880_lg_ch4_init[] = {
2857 /* set line-in to out and mic-in to input */
2858 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2859 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2860 { }
2861};
2862
2863static struct hda_verb alc880_lg_ch6_init[] = {
2864 /* set line-in and mic-in to output */
2865 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2866 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2867 { }
2868};
2869
2870static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2871 { 2, alc880_lg_ch2_init },
2872 { 4, alc880_lg_ch4_init },
2873 { 6, alc880_lg_ch6_init },
2874};
2875
2876static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002877 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2878 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002879 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2880 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2881 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2882 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2883 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2884 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2885 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2886 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2887 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2888 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2889 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2890 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2891 {
2892 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2893 .name = "Channel Mode",
2894 .info = alc_ch_mode_info,
2895 .get = alc_ch_mode_get,
2896 .put = alc_ch_mode_put,
2897 },
2898 { } /* end */
2899};
2900
2901static struct hda_verb alc880_lg_init_verbs[] = {
2902 /* set capture source to mic-in */
2903 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2904 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2905 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2906 /* mute all amp mixer inputs */
2907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2909 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002910 /* line-in to input */
2911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2913 /* built-in mic */
2914 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2916 /* speaker-out */
2917 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2918 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2919 /* mic-in to input */
2920 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2921 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2922 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2923 /* HP-out */
2924 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2925 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2926 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2927 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002928 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002929 { }
2930};
2931
2932/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002933static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002934{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002935 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002936
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002937 spec->autocfg.hp_pins[0] = 0x1b;
2938 spec->autocfg.speaker_pins[0] = 0x17;
2939 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002940}
2941
2942/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002943 * LG LW20
2944 *
2945 * Pin assignment:
2946 * Speaker-out: 0x14
2947 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002948 * Built-in Mic-In: 0x19
2949 * Line-In: 0x1b
2950 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002951 * SPDIF-Out: 0x1e
2952 */
2953
Takashi Iwaid6815182006-03-23 16:06:23 +01002954static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002955 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002956 .items = {
2957 { "Mic", 0x0 },
2958 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002959 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002960 },
2961};
2962
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002963#define alc880_lg_lw_modes alc880_threestack_modes
2964
Takashi Iwaid6815182006-03-23 16:06:23 +01002965static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002966 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2967 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2968 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2969 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2970 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2971 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2972 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2973 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2977 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2978 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2979 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002980 {
2981 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2982 .name = "Channel Mode",
2983 .info = alc_ch_mode_info,
2984 .get = alc_ch_mode_get,
2985 .put = alc_ch_mode_put,
2986 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002987 { } /* end */
2988};
2989
2990static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002991 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2992 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2993 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2994
Takashi Iwaid6815182006-03-23 16:06:23 +01002995 /* set capture source to mic-in */
2996 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2997 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2998 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002999 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003000 /* speaker-out */
3001 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3002 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3003 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003004 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3005 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3006 /* mic-in to input */
3007 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3008 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3009 /* built-in mic */
3010 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3011 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3012 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003013 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003014 { }
3015};
3016
3017/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003018static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003019{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003020 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003021
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003022 spec->autocfg.hp_pins[0] = 0x1b;
3023 spec->autocfg.speaker_pins[0] = 0x14;
3024 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01003025}
3026
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003027static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3028 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3029 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3032 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3033 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3034 { } /* end */
3035};
3036
3037static struct hda_input_mux alc880_medion_rim_capture_source = {
3038 .num_items = 2,
3039 .items = {
3040 { "Mic", 0x0 },
3041 { "Internal Mic", 0x1 },
3042 },
3043};
3044
3045static struct hda_verb alc880_medion_rim_init_verbs[] = {
3046 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3047
3048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3050
3051 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3052 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3053 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3054 /* Mic2 (as headphone out) for HP output */
3055 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3056 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3057 /* Internal Speaker */
3058 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3059 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3060
3061 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3062 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3063
3064 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3065 { }
3066};
3067
3068/* toggle speaker-output according to the hp-jack state */
3069static void alc880_medion_rim_automute(struct hda_codec *codec)
3070{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003071 struct alc_spec *spec = codec->spec;
3072 alc_automute_amp(codec);
3073 /* toggle EAPD */
3074 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003075 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3076 else
3077 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3078}
3079
3080static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3081 unsigned int res)
3082{
3083 /* Looks like the unsol event is incompatible with the standard
3084 * definition. 4bit tag is placed at 28 bit!
3085 */
3086 if ((res >> 28) == ALC880_HP_EVENT)
3087 alc880_medion_rim_automute(codec);
3088}
3089
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003090static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3091{
3092 struct alc_spec *spec = codec->spec;
3093
3094 spec->autocfg.hp_pins[0] = 0x14;
3095 spec->autocfg.speaker_pins[0] = 0x1b;
3096 alc880_medion_rim_automute(codec);
3097}
3098
Takashi Iwaicb53c622007-08-10 17:21:45 +02003099#ifdef CONFIG_SND_HDA_POWER_SAVE
3100static struct hda_amp_list alc880_loopbacks[] = {
3101 { 0x0b, HDA_INPUT, 0 },
3102 { 0x0b, HDA_INPUT, 1 },
3103 { 0x0b, HDA_INPUT, 2 },
3104 { 0x0b, HDA_INPUT, 3 },
3105 { 0x0b, HDA_INPUT, 4 },
3106 { } /* end */
3107};
3108
3109static struct hda_amp_list alc880_lg_loopbacks[] = {
3110 { 0x0b, HDA_INPUT, 1 },
3111 { 0x0b, HDA_INPUT, 6 },
3112 { 0x0b, HDA_INPUT, 7 },
3113 { } /* end */
3114};
3115#endif
3116
Takashi Iwaid6815182006-03-23 16:06:23 +01003117/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003118 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003119 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003120
Linus Torvalds1da177e2005-04-16 15:20:36 -07003121static int alc_init(struct hda_codec *codec)
3122{
3123 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003124 unsigned int i;
3125
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003126 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003127 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003128
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003129 for (i = 0; i < spec->num_init_verbs; i++)
3130 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003131
3132 if (spec->init_hook)
3133 spec->init_hook(codec);
3134
Linus Torvalds1da177e2005-04-16 15:20:36 -07003135 return 0;
3136}
3137
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003138static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3139{
3140 struct alc_spec *spec = codec->spec;
3141
3142 if (spec->unsol_event)
3143 spec->unsol_event(codec, res);
3144}
3145
Takashi Iwaicb53c622007-08-10 17:21:45 +02003146#ifdef CONFIG_SND_HDA_POWER_SAVE
3147static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3148{
3149 struct alc_spec *spec = codec->spec;
3150 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3151}
3152#endif
3153
Linus Torvalds1da177e2005-04-16 15:20:36 -07003154/*
3155 * Analog playback callbacks
3156 */
3157static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3158 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003159 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003160{
3161 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003162 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3163 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003164}
3165
3166static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3167 struct hda_codec *codec,
3168 unsigned int stream_tag,
3169 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003170 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003171{
3172 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003173 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3174 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003175}
3176
3177static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3178 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003179 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003180{
3181 struct alc_spec *spec = codec->spec;
3182 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3183}
3184
3185/*
3186 * Digital out
3187 */
3188static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3189 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003190 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003191{
3192 struct alc_spec *spec = codec->spec;
3193 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3194}
3195
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003196static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3197 struct hda_codec *codec,
3198 unsigned int stream_tag,
3199 unsigned int format,
3200 struct snd_pcm_substream *substream)
3201{
3202 struct alc_spec *spec = codec->spec;
3203 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3204 stream_tag, format, substream);
3205}
3206
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003207static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3208 struct hda_codec *codec,
3209 struct snd_pcm_substream *substream)
3210{
3211 struct alc_spec *spec = codec->spec;
3212 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3213}
3214
Linus Torvalds1da177e2005-04-16 15:20:36 -07003215static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3216 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003217 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003218{
3219 struct alc_spec *spec = codec->spec;
3220 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3221}
3222
3223/*
3224 * Analog capture
3225 */
Takashi Iwai63300792008-01-24 15:31:36 +01003226static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003227 struct hda_codec *codec,
3228 unsigned int stream_tag,
3229 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003230 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003231{
3232 struct alc_spec *spec = codec->spec;
3233
Takashi Iwai63300792008-01-24 15:31:36 +01003234 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003235 stream_tag, 0, format);
3236 return 0;
3237}
3238
Takashi Iwai63300792008-01-24 15:31:36 +01003239static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003240 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003241 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003242{
3243 struct alc_spec *spec = codec->spec;
3244
Takashi Iwai888afa12008-03-18 09:57:50 +01003245 snd_hda_codec_cleanup_stream(codec,
3246 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003247 return 0;
3248}
3249
3250
3251/*
3252 */
3253static struct hda_pcm_stream alc880_pcm_analog_playback = {
3254 .substreams = 1,
3255 .channels_min = 2,
3256 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003258 .ops = {
3259 .open = alc880_playback_pcm_open,
3260 .prepare = alc880_playback_pcm_prepare,
3261 .cleanup = alc880_playback_pcm_cleanup
3262 },
3263};
3264
3265static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003266 .substreams = 1,
3267 .channels_min = 2,
3268 .channels_max = 2,
3269 /* NID is set in alc_build_pcms */
3270};
3271
3272static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3273 .substreams = 1,
3274 .channels_min = 2,
3275 .channels_max = 2,
3276 /* NID is set in alc_build_pcms */
3277};
3278
3279static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3280 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003281 .channels_min = 2,
3282 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003283 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003284 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003285 .prepare = alc880_alt_capture_pcm_prepare,
3286 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003287 },
3288};
3289
3290static struct hda_pcm_stream alc880_pcm_digital_playback = {
3291 .substreams = 1,
3292 .channels_min = 2,
3293 .channels_max = 2,
3294 /* NID is set in alc_build_pcms */
3295 .ops = {
3296 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003297 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003298 .prepare = alc880_dig_playback_pcm_prepare,
3299 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003300 },
3301};
3302
3303static struct hda_pcm_stream alc880_pcm_digital_capture = {
3304 .substreams = 1,
3305 .channels_min = 2,
3306 .channels_max = 2,
3307 /* NID is set in alc_build_pcms */
3308};
3309
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003310/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003311static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003312 .substreams = 0,
3313 .channels_min = 0,
3314 .channels_max = 0,
3315};
3316
Linus Torvalds1da177e2005-04-16 15:20:36 -07003317static int alc_build_pcms(struct hda_codec *codec)
3318{
3319 struct alc_spec *spec = codec->spec;
3320 struct hda_pcm *info = spec->pcm_rec;
3321 int i;
3322
3323 codec->num_pcms = 1;
3324 codec->pcm_info = info;
3325
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003326 if (spec->no_analog)
3327 goto skip_analog;
3328
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003329 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3330 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003331 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003332
Takashi Iwai4a471b72005-12-07 13:56:29 +01003333 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003334 if (snd_BUG_ON(!spec->multiout.dac_nids))
3335 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003336 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3337 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3338 }
3339 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003340 if (snd_BUG_ON(!spec->adc_nids))
3341 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003342 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3343 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3344 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003345
Takashi Iwai4a471b72005-12-07 13:56:29 +01003346 if (spec->channel_mode) {
3347 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3348 for (i = 0; i < spec->num_channel_mode; i++) {
3349 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3350 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3351 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003352 }
3353 }
3354
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003355 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003356 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003357 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003358 snprintf(spec->stream_name_digital,
3359 sizeof(spec->stream_name_digital),
3360 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003361 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003362 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003363 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003364 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003365 if (spec->dig_out_type)
3366 info->pcm_type = spec->dig_out_type;
3367 else
3368 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003369 if (spec->multiout.dig_out_nid &&
3370 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003371 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3372 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3373 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003374 if (spec->dig_in_nid &&
3375 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003376 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3377 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3378 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003379 /* FIXME: do we need this for all Realtek codec models? */
3380 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003381 }
3382
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003383 if (spec->no_analog)
3384 return 0;
3385
Takashi Iwaie08a0072006-09-07 17:52:14 +02003386 /* If the use of more than one ADC is requested for the current
3387 * model, configure a second analog capture-only PCM.
3388 */
3389 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003390 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3391 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003392 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003393 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003394 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003395 if (spec->alt_dac_nid) {
3396 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3397 *spec->stream_analog_alt_playback;
3398 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3399 spec->alt_dac_nid;
3400 } else {
3401 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3402 alc_pcm_null_stream;
3403 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3404 }
3405 if (spec->num_adc_nids > 1) {
3406 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3407 *spec->stream_analog_alt_capture;
3408 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3409 spec->adc_nids[1];
3410 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3411 spec->num_adc_nids - 1;
3412 } else {
3413 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3414 alc_pcm_null_stream;
3415 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003416 }
3417 }
3418
Linus Torvalds1da177e2005-04-16 15:20:36 -07003419 return 0;
3420}
3421
Takashi Iwai603c4012008-07-30 15:01:44 +02003422static void alc_free_kctls(struct hda_codec *codec)
3423{
3424 struct alc_spec *spec = codec->spec;
3425
3426 if (spec->kctls.list) {
3427 struct snd_kcontrol_new *kctl = spec->kctls.list;
3428 int i;
3429 for (i = 0; i < spec->kctls.used; i++)
3430 kfree(kctl[i].name);
3431 }
3432 snd_array_free(&spec->kctls);
3433}
3434
Linus Torvalds1da177e2005-04-16 15:20:36 -07003435static void alc_free(struct hda_codec *codec)
3436{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003437 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003438
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003439 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003440 return;
3441
Takashi Iwai603c4012008-07-30 15:01:44 +02003442 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003443 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003444 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003445}
3446
Takashi Iwaie044c392008-10-27 16:56:24 +01003447#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003448static int alc_resume(struct hda_codec *codec)
3449{
Takashi Iwaie044c392008-10-27 16:56:24 +01003450 codec->patch_ops.init(codec);
3451 snd_hda_codec_resume_amp(codec);
3452 snd_hda_codec_resume_cache(codec);
3453 return 0;
3454}
Takashi Iwaie044c392008-10-27 16:56:24 +01003455#endif
3456
Linus Torvalds1da177e2005-04-16 15:20:36 -07003457/*
3458 */
3459static struct hda_codec_ops alc_patch_ops = {
3460 .build_controls = alc_build_controls,
3461 .build_pcms = alc_build_pcms,
3462 .init = alc_init,
3463 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003464 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003465#ifdef SND_HDA_NEEDS_RESUME
3466 .resume = alc_resume,
3467#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003468#ifdef CONFIG_SND_HDA_POWER_SAVE
3469 .check_power_status = alc_check_power_status,
3470#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003471};
3472
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003473
3474/*
3475 * Test configuration for debugging
3476 *
3477 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3478 * enum controls.
3479 */
3480#ifdef CONFIG_SND_DEBUG
3481static hda_nid_t alc880_test_dac_nids[4] = {
3482 0x02, 0x03, 0x04, 0x05
3483};
3484
3485static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003486 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003487 .items = {
3488 { "In-1", 0x0 },
3489 { "In-2", 0x1 },
3490 { "In-3", 0x2 },
3491 { "In-4", 0x3 },
3492 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003493 { "Front", 0x5 },
3494 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003495 },
3496};
3497
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003498static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003499 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003500 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003501 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003502 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003503};
3504
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003505static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3506 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003507{
3508 static char *texts[] = {
3509 "N/A", "Line Out", "HP Out",
3510 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3511 };
3512 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3513 uinfo->count = 1;
3514 uinfo->value.enumerated.items = 8;
3515 if (uinfo->value.enumerated.item >= 8)
3516 uinfo->value.enumerated.item = 7;
3517 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3518 return 0;
3519}
3520
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003521static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3522 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003523{
3524 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3525 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3526 unsigned int pin_ctl, item = 0;
3527
3528 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3529 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3530 if (pin_ctl & AC_PINCTL_OUT_EN) {
3531 if (pin_ctl & AC_PINCTL_HP_EN)
3532 item = 2;
3533 else
3534 item = 1;
3535 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3536 switch (pin_ctl & AC_PINCTL_VREFEN) {
3537 case AC_PINCTL_VREF_HIZ: item = 3; break;
3538 case AC_PINCTL_VREF_50: item = 4; break;
3539 case AC_PINCTL_VREF_GRD: item = 5; break;
3540 case AC_PINCTL_VREF_80: item = 6; break;
3541 case AC_PINCTL_VREF_100: item = 7; break;
3542 }
3543 }
3544 ucontrol->value.enumerated.item[0] = item;
3545 return 0;
3546}
3547
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003548static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3549 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003550{
3551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3552 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3553 static unsigned int ctls[] = {
3554 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3555 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3556 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3557 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3558 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3559 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3560 };
3561 unsigned int old_ctl, new_ctl;
3562
3563 old_ctl = snd_hda_codec_read(codec, nid, 0,
3564 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3565 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3566 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003567 int val;
3568 snd_hda_codec_write_cache(codec, nid, 0,
3569 AC_VERB_SET_PIN_WIDGET_CONTROL,
3570 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003571 val = ucontrol->value.enumerated.item[0] >= 3 ?
3572 HDA_AMP_MUTE : 0;
3573 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3574 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003575 return 1;
3576 }
3577 return 0;
3578}
3579
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003580static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3581 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003582{
3583 static char *texts[] = {
3584 "Front", "Surround", "CLFE", "Side"
3585 };
3586 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3587 uinfo->count = 1;
3588 uinfo->value.enumerated.items = 4;
3589 if (uinfo->value.enumerated.item >= 4)
3590 uinfo->value.enumerated.item = 3;
3591 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3592 return 0;
3593}
3594
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003595static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3596 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003597{
3598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3599 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3600 unsigned int sel;
3601
3602 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3603 ucontrol->value.enumerated.item[0] = sel & 3;
3604 return 0;
3605}
3606
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003607static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3608 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003609{
3610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3611 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3612 unsigned int sel;
3613
3614 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3615 if (ucontrol->value.enumerated.item[0] != sel) {
3616 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003617 snd_hda_codec_write_cache(codec, nid, 0,
3618 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003619 return 1;
3620 }
3621 return 0;
3622}
3623
3624#define PIN_CTL_TEST(xname,nid) { \
3625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3626 .name = xname, \
3627 .info = alc_test_pin_ctl_info, \
3628 .get = alc_test_pin_ctl_get, \
3629 .put = alc_test_pin_ctl_put, \
3630 .private_value = nid \
3631 }
3632
3633#define PIN_SRC_TEST(xname,nid) { \
3634 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3635 .name = xname, \
3636 .info = alc_test_pin_src_info, \
3637 .get = alc_test_pin_src_get, \
3638 .put = alc_test_pin_src_put, \
3639 .private_value = nid \
3640 }
3641
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003642static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003643 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3644 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3645 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3646 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003647 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3648 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3649 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3650 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003651 PIN_CTL_TEST("Front Pin Mode", 0x14),
3652 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3653 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3654 PIN_CTL_TEST("Side Pin Mode", 0x17),
3655 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3656 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3657 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3658 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3659 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3660 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3661 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3662 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3663 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3664 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3665 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3666 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3667 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3668 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3669 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3670 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3671 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3672 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003673 {
3674 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3675 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003676 .info = alc_ch_mode_info,
3677 .get = alc_ch_mode_get,
3678 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003679 },
3680 { } /* end */
3681};
3682
3683static struct hda_verb alc880_test_init_verbs[] = {
3684 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003685 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3687 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3689 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3690 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3691 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3692 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003693 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003694 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3695 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3696 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3697 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003698 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003699 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3701 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3702 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003703 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3706 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3707 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003708 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003709 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3710 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003711 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3712 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3713 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003714 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003715 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3716 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3717 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3718 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003719 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003720 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003721 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003722 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003723 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003724 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003725 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003726 /* Analog input/passthru */
3727 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3729 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003732 { }
3733};
3734#endif
3735
Linus Torvalds1da177e2005-04-16 15:20:36 -07003736/*
3737 */
3738
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003739static const char *alc880_models[ALC880_MODEL_LAST] = {
3740 [ALC880_3ST] = "3stack",
3741 [ALC880_TCL_S700] = "tcl",
3742 [ALC880_3ST_DIG] = "3stack-digout",
3743 [ALC880_CLEVO] = "clevo",
3744 [ALC880_5ST] = "5stack",
3745 [ALC880_5ST_DIG] = "5stack-digout",
3746 [ALC880_W810] = "w810",
3747 [ALC880_Z71V] = "z71v",
3748 [ALC880_6ST] = "6stack",
3749 [ALC880_6ST_DIG] = "6stack-digout",
3750 [ALC880_ASUS] = "asus",
3751 [ALC880_ASUS_W1V] = "asus-w1v",
3752 [ALC880_ASUS_DIG] = "asus-dig",
3753 [ALC880_ASUS_DIG2] = "asus-dig2",
3754 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003755 [ALC880_UNIWILL_P53] = "uniwill-p53",
3756 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003757 [ALC880_F1734] = "F1734",
3758 [ALC880_LG] = "lg",
3759 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003760 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003761#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003762 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003763#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003764 [ALC880_AUTO] = "auto",
3765};
3766
3767static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003768 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003769 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3770 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3771 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3772 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3773 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3774 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3775 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3776 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003777 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3778 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003779 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3780 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3781 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3782 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3783 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3784 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3785 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3786 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3787 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3788 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003789 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003790 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3791 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3792 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003793 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003794 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003795 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3796 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003797 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3798 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003799 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3800 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3801 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3802 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003803 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3804 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003805 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003806 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003807 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003808 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003809 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3810 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003811 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003812 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003813 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003814 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003815 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003816 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003817 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003818 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003819 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003820 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3821 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003822 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003823 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3824 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3825 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3826 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003827 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3828 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003829 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003830 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003831 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3832 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003833 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3834 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3835 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003836 /* default Intel */
3837 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003838 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3839 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003840 {}
3841};
3842
Takashi Iwai16ded522005-06-10 19:58:24 +02003843/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003844 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003845 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003846static struct alc_config_preset alc880_presets[] = {
3847 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003848 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003849 .init_verbs = { alc880_volume_init_verbs,
3850 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003851 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003852 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003853 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3854 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003855 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003856 .input_mux = &alc880_capture_source,
3857 },
3858 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003859 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003860 .init_verbs = { alc880_volume_init_verbs,
3861 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003862 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003863 .dac_nids = alc880_dac_nids,
3864 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003865 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3866 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003867 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003868 .input_mux = &alc880_capture_source,
3869 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003870 [ALC880_TCL_S700] = {
3871 .mixers = { alc880_tcl_s700_mixer },
3872 .init_verbs = { alc880_volume_init_verbs,
3873 alc880_pin_tcl_S700_init_verbs,
3874 alc880_gpio2_init_verbs },
3875 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3876 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003877 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3878 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003879 .hp_nid = 0x03,
3880 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3881 .channel_mode = alc880_2_jack_modes,
3882 .input_mux = &alc880_capture_source,
3883 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003884 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003885 .mixers = { alc880_three_stack_mixer,
3886 alc880_five_stack_mixer},
3887 .init_verbs = { alc880_volume_init_verbs,
3888 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003889 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3890 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003891 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3892 .channel_mode = alc880_fivestack_modes,
3893 .input_mux = &alc880_capture_source,
3894 },
3895 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003896 .mixers = { alc880_three_stack_mixer,
3897 alc880_five_stack_mixer },
3898 .init_verbs = { alc880_volume_init_verbs,
3899 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003900 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3901 .dac_nids = alc880_dac_nids,
3902 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003903 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3904 .channel_mode = alc880_fivestack_modes,
3905 .input_mux = &alc880_capture_source,
3906 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003907 [ALC880_6ST] = {
3908 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003909 .init_verbs = { alc880_volume_init_verbs,
3910 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003911 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3912 .dac_nids = alc880_6st_dac_nids,
3913 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3914 .channel_mode = alc880_sixstack_modes,
3915 .input_mux = &alc880_6stack_capture_source,
3916 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003917 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003918 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003919 .init_verbs = { alc880_volume_init_verbs,
3920 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003921 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3922 .dac_nids = alc880_6st_dac_nids,
3923 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003924 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3925 .channel_mode = alc880_sixstack_modes,
3926 .input_mux = &alc880_6stack_capture_source,
3927 },
3928 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003929 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003930 .init_verbs = { alc880_volume_init_verbs,
3931 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003932 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003933 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3934 .dac_nids = alc880_w810_dac_nids,
3935 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003936 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3937 .channel_mode = alc880_w810_modes,
3938 .input_mux = &alc880_capture_source,
3939 },
3940 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003941 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003942 .init_verbs = { alc880_volume_init_verbs,
3943 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003944 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3945 .dac_nids = alc880_z71v_dac_nids,
3946 .dig_out_nid = ALC880_DIGOUT_NID,
3947 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003948 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3949 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003950 .input_mux = &alc880_capture_source,
3951 },
3952 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003953 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003954 .init_verbs = { alc880_volume_init_verbs,
3955 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003956 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3957 .dac_nids = alc880_f1734_dac_nids,
3958 .hp_nid = 0x02,
3959 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3960 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003961 .input_mux = &alc880_f1734_capture_source,
3962 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003963 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02003964 },
3965 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003966 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003967 .init_verbs = { alc880_volume_init_verbs,
3968 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003969 alc880_gpio1_init_verbs },
3970 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3971 .dac_nids = alc880_asus_dac_nids,
3972 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3973 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003974 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003975 .input_mux = &alc880_capture_source,
3976 },
3977 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003978 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003979 .init_verbs = { alc880_volume_init_verbs,
3980 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003981 alc880_gpio1_init_verbs },
3982 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3983 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003984 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003985 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3986 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003987 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003988 .input_mux = &alc880_capture_source,
3989 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003990 [ALC880_ASUS_DIG2] = {
3991 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003992 .init_verbs = { alc880_volume_init_verbs,
3993 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003994 alc880_gpio2_init_verbs }, /* use GPIO2 */
3995 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3996 .dac_nids = alc880_asus_dac_nids,
3997 .dig_out_nid = ALC880_DIGOUT_NID,
3998 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3999 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004000 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004001 .input_mux = &alc880_capture_source,
4002 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004003 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004004 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004005 .init_verbs = { alc880_volume_init_verbs,
4006 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004007 alc880_gpio1_init_verbs },
4008 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4009 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004010 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004011 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4012 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004013 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004014 .input_mux = &alc880_capture_source,
4015 },
4016 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004017 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004018 .init_verbs = { alc880_volume_init_verbs,
4019 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004020 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4021 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004022 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004023 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4024 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004025 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004026 .input_mux = &alc880_capture_source,
4027 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004028 [ALC880_UNIWILL] = {
4029 .mixers = { alc880_uniwill_mixer },
4030 .init_verbs = { alc880_volume_init_verbs,
4031 alc880_uniwill_init_verbs },
4032 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4033 .dac_nids = alc880_asus_dac_nids,
4034 .dig_out_nid = ALC880_DIGOUT_NID,
4035 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4036 .channel_mode = alc880_threestack_modes,
4037 .need_dac_fix = 1,
4038 .input_mux = &alc880_capture_source,
4039 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004040 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004041 },
4042 [ALC880_UNIWILL_P53] = {
4043 .mixers = { alc880_uniwill_p53_mixer },
4044 .init_verbs = { alc880_volume_init_verbs,
4045 alc880_uniwill_p53_init_verbs },
4046 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4047 .dac_nids = alc880_asus_dac_nids,
4048 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004049 .channel_mode = alc880_threestack_modes,
4050 .input_mux = &alc880_capture_source,
4051 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004052 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004053 },
4054 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004055 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004056 .init_verbs = { alc880_volume_init_verbs,
4057 alc880_uniwill_p53_init_verbs,
4058 alc880_beep_init_verbs },
4059 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4060 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004061 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004062 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4063 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004064 .input_mux = &alc880_capture_source,
4065 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004066 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004067 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004068 [ALC880_CLEVO] = {
4069 .mixers = { alc880_three_stack_mixer },
4070 .init_verbs = { alc880_volume_init_verbs,
4071 alc880_pin_clevo_init_verbs },
4072 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4073 .dac_nids = alc880_dac_nids,
4074 .hp_nid = 0x03,
4075 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4076 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004077 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004078 .input_mux = &alc880_capture_source,
4079 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004080 [ALC880_LG] = {
4081 .mixers = { alc880_lg_mixer },
4082 .init_verbs = { alc880_volume_init_verbs,
4083 alc880_lg_init_verbs },
4084 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4085 .dac_nids = alc880_lg_dac_nids,
4086 .dig_out_nid = ALC880_DIGOUT_NID,
4087 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4088 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004089 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004090 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004091 .unsol_event = alc_automute_amp_unsol_event,
4092 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004093#ifdef CONFIG_SND_HDA_POWER_SAVE
4094 .loopbacks = alc880_lg_loopbacks,
4095#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004096 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004097 [ALC880_LG_LW] = {
4098 .mixers = { alc880_lg_lw_mixer },
4099 .init_verbs = { alc880_volume_init_verbs,
4100 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004101 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004102 .dac_nids = alc880_dac_nids,
4103 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004104 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4105 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004106 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004107 .unsol_event = alc_automute_amp_unsol_event,
4108 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01004109 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004110 [ALC880_MEDION_RIM] = {
4111 .mixers = { alc880_medion_rim_mixer },
4112 .init_verbs = { alc880_volume_init_verbs,
4113 alc880_medion_rim_init_verbs,
4114 alc_gpio2_init_verbs },
4115 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4116 .dac_nids = alc880_dac_nids,
4117 .dig_out_nid = ALC880_DIGOUT_NID,
4118 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4119 .channel_mode = alc880_2_jack_modes,
4120 .input_mux = &alc880_medion_rim_capture_source,
4121 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004122 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004123 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004124#ifdef CONFIG_SND_DEBUG
4125 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004126 .mixers = { alc880_test_mixer },
4127 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004128 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4129 .dac_nids = alc880_test_dac_nids,
4130 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004131 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4132 .channel_mode = alc880_test_modes,
4133 .input_mux = &alc880_test_capture_source,
4134 },
4135#endif
4136};
4137
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004138/*
4139 * Automatic parse of I/O pins from the BIOS configuration
4140 */
4141
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004142enum {
4143 ALC_CTL_WIDGET_VOL,
4144 ALC_CTL_WIDGET_MUTE,
4145 ALC_CTL_BIND_MUTE,
4146};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004147static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004148 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4149 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004150 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004151};
4152
4153/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004154static int add_control(struct alc_spec *spec, int type, const char *name,
4155 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004156{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004157 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004158
Takashi Iwai603c4012008-07-30 15:01:44 +02004159 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4160 knew = snd_array_new(&spec->kctls);
4161 if (!knew)
4162 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004163 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004164 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004165 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004166 return -ENOMEM;
4167 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004168 return 0;
4169}
4170
4171#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4172#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4173#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4174#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4175#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4176#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4177#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4178#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4179#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4180#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4181#define ALC880_PIN_CD_NID 0x1c
4182
4183/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004184static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4185 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004186{
4187 hda_nid_t nid;
4188 int assigned[4];
4189 int i, j;
4190
4191 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004192 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004193
4194 /* check the pins hardwired to audio widget */
4195 for (i = 0; i < cfg->line_outs; i++) {
4196 nid = cfg->line_out_pins[i];
4197 if (alc880_is_fixed_pin(nid)) {
4198 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004199 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004200 assigned[idx] = 1;
4201 }
4202 }
4203 /* left pins can be connect to any audio widget */
4204 for (i = 0; i < cfg->line_outs; i++) {
4205 nid = cfg->line_out_pins[i];
4206 if (alc880_is_fixed_pin(nid))
4207 continue;
4208 /* search for an empty channel */
4209 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004210 if (!assigned[j]) {
4211 spec->multiout.dac_nids[i] =
4212 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004213 assigned[j] = 1;
4214 break;
4215 }
4216 }
4217 }
4218 spec->multiout.num_dacs = cfg->line_outs;
4219 return 0;
4220}
4221
4222/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004223static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4224 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004225{
4226 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004227 static const char *chname[4] = {
4228 "Front", "Surround", NULL /*CLFE*/, "Side"
4229 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004230 hda_nid_t nid;
4231 int i, err;
4232
4233 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004234 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004235 continue;
4236 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4237 if (i == 2) {
4238 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004239 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4240 "Center Playback Volume",
4241 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4242 HDA_OUTPUT));
4243 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004244 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004245 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4246 "LFE Playback Volume",
4247 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4248 HDA_OUTPUT));
4249 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004250 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004251 err = add_control(spec, ALC_CTL_BIND_MUTE,
4252 "Center Playback Switch",
4253 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4254 HDA_INPUT));
4255 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004256 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004257 err = add_control(spec, ALC_CTL_BIND_MUTE,
4258 "LFE Playback Switch",
4259 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4260 HDA_INPUT));
4261 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004262 return err;
4263 } else {
4264 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004265 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4266 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4267 HDA_OUTPUT));
4268 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004269 return err;
4270 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004271 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4272 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4273 HDA_INPUT));
4274 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004275 return err;
4276 }
4277 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004278 return 0;
4279}
4280
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004281/* add playback controls for speaker and HP outputs */
4282static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4283 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004284{
4285 hda_nid_t nid;
4286 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004287 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004288
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004289 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004290 return 0;
4291
4292 if (alc880_is_fixed_pin(pin)) {
4293 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004294 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004295 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004296 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004297 else
4298 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004299 /* control HP volume/switch on the output mixer amp */
4300 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004301 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004302 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4303 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4304 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004305 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004306 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004307 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4308 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4309 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004310 return err;
4311 } else if (alc880_is_multi_pin(pin)) {
4312 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004313 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004314 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004315 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4316 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4317 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004318 return err;
4319 }
4320 return 0;
4321}
4322
4323/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004324static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4325 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004326 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004327{
4328 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004329 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004330
4331 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004332 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4333 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4334 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004335 return err;
4336 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004337 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4338 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4339 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004340 return err;
4341 return 0;
4342}
4343
4344/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004345static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4346 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004347{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004348 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004349 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004350
4351 for (i = 0; i < AUTO_PIN_LAST; i++) {
4352 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004353 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004354 err = new_analog_input(spec, cfg->input_pins[i],
4355 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004356 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004357 if (err < 0)
4358 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004359 imux->items[imux->num_items].label =
4360 auto_pin_cfg_labels[i];
4361 imux->items[imux->num_items].index =
4362 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004363 imux->num_items++;
4364 }
4365 }
4366 return 0;
4367}
4368
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004369static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4370 unsigned int pin_type)
4371{
4372 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4373 pin_type);
4374 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004375 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4376 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004377}
4378
Kailang Yangdf694da2005-12-05 19:42:22 +01004379static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4380 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004381 int dac_idx)
4382{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004383 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004384 /* need the manual connection? */
4385 if (alc880_is_multi_pin(nid)) {
4386 struct alc_spec *spec = codec->spec;
4387 int idx = alc880_multi_pin_idx(nid);
4388 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4389 AC_VERB_SET_CONNECT_SEL,
4390 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4391 }
4392}
4393
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004394static int get_pin_type(int line_out_type)
4395{
4396 if (line_out_type == AUTO_PIN_HP_OUT)
4397 return PIN_HP;
4398 else
4399 return PIN_OUT;
4400}
4401
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004402static void alc880_auto_init_multi_out(struct hda_codec *codec)
4403{
4404 struct alc_spec *spec = codec->spec;
4405 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004406
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004407 for (i = 0; i < spec->autocfg.line_outs; i++) {
4408 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004409 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4410 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004411 }
4412}
4413
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004414static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004415{
4416 struct alc_spec *spec = codec->spec;
4417 hda_nid_t pin;
4418
Takashi Iwai82bc9552006-03-21 11:24:42 +01004419 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004420 if (pin) /* connect to front */
4421 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004422 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004423 if (pin) /* connect to front */
4424 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4425}
4426
4427static void alc880_auto_init_analog_input(struct hda_codec *codec)
4428{
4429 struct alc_spec *spec = codec->spec;
4430 int i;
4431
4432 for (i = 0; i < AUTO_PIN_LAST; i++) {
4433 hda_nid_t nid = spec->autocfg.input_pins[i];
4434 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004435 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004436 if (nid != ALC880_PIN_CD_NID &&
4437 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004438 snd_hda_codec_write(codec, nid, 0,
4439 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004440 AMP_OUT_MUTE);
4441 }
4442 }
4443}
4444
4445/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004446/* return 1 if successful, 0 if the proper config is not found,
4447 * or a negative error code
4448 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449static int alc880_parse_auto_config(struct hda_codec *codec)
4450{
4451 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004452 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004453 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004454
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004455 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4456 alc880_ignore);
4457 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004458 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004459 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004460 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004461
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004462 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4463 if (err < 0)
4464 return err;
4465 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4466 if (err < 0)
4467 return err;
4468 err = alc880_auto_create_extra_out(spec,
4469 spec->autocfg.speaker_pins[0],
4470 "Speaker");
4471 if (err < 0)
4472 return err;
4473 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4474 "Headphone");
4475 if (err < 0)
4476 return err;
4477 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4478 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004479 return err;
4480
4481 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4482
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004483 /* check multiple SPDIF-out (for recent codecs) */
4484 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4485 hda_nid_t dig_nid;
4486 err = snd_hda_get_connections(codec,
4487 spec->autocfg.dig_out_pins[i],
4488 &dig_nid, 1);
4489 if (err < 0)
4490 continue;
4491 if (!i)
4492 spec->multiout.dig_out_nid = dig_nid;
4493 else {
4494 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4495 spec->slave_dig_outs[i - 1] = dig_nid;
4496 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4497 break;
4498 }
4499 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004500 if (spec->autocfg.dig_in_pin)
4501 spec->dig_in_nid = ALC880_DIGIN_NID;
4502
Takashi Iwai603c4012008-07-30 15:01:44 +02004503 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004504 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004505
Takashi Iwaid88897e2008-10-31 15:01:37 +01004506 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004507
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004508 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004509 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004510
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004511 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4512
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004513 return 1;
4514}
4515
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004516/* additional initialization for auto-configuration model */
4517static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004518{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004519 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004520 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004521 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004522 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004523 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004524 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004525}
4526
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004527static void set_capture_mixer(struct alc_spec *spec)
4528{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004529 static struct snd_kcontrol_new *caps[2][3] = {
4530 { alc_capture_mixer_nosrc1,
4531 alc_capture_mixer_nosrc2,
4532 alc_capture_mixer_nosrc3 },
4533 { alc_capture_mixer1,
4534 alc_capture_mixer2,
4535 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004536 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004537 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4538 int mux;
4539 if (spec->input_mux && spec->input_mux->num_items > 1)
4540 mux = 1;
4541 else
4542 mux = 0;
4543 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4544 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004545}
4546
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004547#define set_beep_amp(spec, nid, idx, dir) \
4548 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4549
4550/*
4551 * OK, here we have finally the patch for ALC880
4552 */
4553
Linus Torvalds1da177e2005-04-16 15:20:36 -07004554static int patch_alc880(struct hda_codec *codec)
4555{
4556 struct alc_spec *spec;
4557 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004558 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004559
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004560 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004561 if (spec == NULL)
4562 return -ENOMEM;
4563
4564 codec->spec = spec;
4565
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004566 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4567 alc880_models,
4568 alc880_cfg_tbl);
4569 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02004570 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4571 "trying auto-probe from BIOS...\n", codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004572 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004573 }
4574
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004575 if (board_config == ALC880_AUTO) {
4576 /* automatic parse from the BIOS config */
4577 err = alc880_parse_auto_config(codec);
4578 if (err < 0) {
4579 alc_free(codec);
4580 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004581 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004582 printk(KERN_INFO
4583 "hda_codec: Cannot set up configuration "
4584 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004585 board_config = ALC880_3ST;
4586 }
4587 }
4588
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004589 err = snd_hda_attach_beep_device(codec, 0x1);
4590 if (err < 0) {
4591 alc_free(codec);
4592 return err;
4593 }
4594
Kailang Yangdf694da2005-12-05 19:42:22 +01004595 if (board_config != ALC880_AUTO)
4596 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004597
Linus Torvalds1da177e2005-04-16 15:20:36 -07004598 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4599 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004600 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004601
Linus Torvalds1da177e2005-04-16 15:20:36 -07004602 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4603 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4604
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004605 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004606 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004607 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004608 /* get type */
4609 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004610 if (wcap != AC_WID_AUD_IN) {
4611 spec->adc_nids = alc880_adc_nids_alt;
4612 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004613 } else {
4614 spec->adc_nids = alc880_adc_nids;
4615 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004616 }
4617 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004618 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004619 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004620
Takashi Iwai2134ea42008-01-10 16:53:55 +01004621 spec->vmaster_nid = 0x0c;
4622
Linus Torvalds1da177e2005-04-16 15:20:36 -07004623 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004624 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004625 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004626#ifdef CONFIG_SND_HDA_POWER_SAVE
4627 if (!spec->loopback.amplist)
4628 spec->loopback.amplist = alc880_loopbacks;
4629#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004630 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004631
4632 return 0;
4633}
4634
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004635
Linus Torvalds1da177e2005-04-16 15:20:36 -07004636/*
4637 * ALC260 support
4638 */
4639
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004640static hda_nid_t alc260_dac_nids[1] = {
4641 /* front */
4642 0x02,
4643};
4644
4645static hda_nid_t alc260_adc_nids[1] = {
4646 /* ADC0 */
4647 0x04,
4648};
4649
Kailang Yangdf694da2005-12-05 19:42:22 +01004650static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004651 /* ADC1 */
4652 0x05,
4653};
4654
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004655/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4656 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4657 */
4658static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004659 /* ADC0, ADC1 */
4660 0x04, 0x05
4661};
4662
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004663#define ALC260_DIGOUT_NID 0x03
4664#define ALC260_DIGIN_NID 0x06
4665
4666static struct hda_input_mux alc260_capture_source = {
4667 .num_items = 4,
4668 .items = {
4669 { "Mic", 0x0 },
4670 { "Front Mic", 0x1 },
4671 { "Line", 0x2 },
4672 { "CD", 0x4 },
4673 },
4674};
4675
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004676/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004677 * headphone jack and the internal CD lines since these are the only pins at
4678 * which audio can appear. For flexibility, also allow the option of
4679 * recording the mixer output on the second ADC (ADC0 doesn't have a
4680 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004681 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004682static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4683 {
4684 .num_items = 3,
4685 .items = {
4686 { "Mic/Line", 0x0 },
4687 { "CD", 0x4 },
4688 { "Headphone", 0x2 },
4689 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004690 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004691 {
4692 .num_items = 4,
4693 .items = {
4694 { "Mic/Line", 0x0 },
4695 { "CD", 0x4 },
4696 { "Headphone", 0x2 },
4697 { "Mixer", 0x5 },
4698 },
4699 },
4700
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004701};
4702
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004703/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4704 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004705 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004706static struct hda_input_mux alc260_acer_capture_sources[2] = {
4707 {
4708 .num_items = 4,
4709 .items = {
4710 { "Mic", 0x0 },
4711 { "Line", 0x2 },
4712 { "CD", 0x4 },
4713 { "Headphone", 0x5 },
4714 },
4715 },
4716 {
4717 .num_items = 5,
4718 .items = {
4719 { "Mic", 0x0 },
4720 { "Line", 0x2 },
4721 { "CD", 0x4 },
4722 { "Headphone", 0x6 },
4723 { "Mixer", 0x5 },
4724 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004725 },
4726};
Michael Schwingencc959482009-02-22 18:58:45 +01004727
4728/* Maxdata Favorit 100XS */
4729static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4730 {
4731 .num_items = 2,
4732 .items = {
4733 { "Line/Mic", 0x0 },
4734 { "CD", 0x4 },
4735 },
4736 },
4737 {
4738 .num_items = 3,
4739 .items = {
4740 { "Line/Mic", 0x0 },
4741 { "CD", 0x4 },
4742 { "Mixer", 0x5 },
4743 },
4744 },
4745};
4746
Linus Torvalds1da177e2005-04-16 15:20:36 -07004747/*
4748 * This is just place-holder, so there's something for alc_build_pcms to look
4749 * at when it calculates the maximum number of channels. ALC260 has no mixer
4750 * element which allows changing the channel mode, so the verb list is
4751 * never used.
4752 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004753static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004754 { 2, NULL },
4755};
4756
Kailang Yangdf694da2005-12-05 19:42:22 +01004757
4758/* Mixer combinations
4759 *
4760 * basic: base_output + input + pc_beep + capture
4761 * HP: base_output + input + capture_alt
4762 * HP_3013: hp_3013 + input + capture
4763 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004764 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004765 */
4766
4767static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004768 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004769 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004770 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4771 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4772 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4773 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4774 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004775};
Kailang Yangdf694da2005-12-05 19:42:22 +01004776
4777static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004778 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4779 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4780 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4781 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4782 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4783 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4784 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4785 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004786 { } /* end */
4787};
4788
Takashi Iwaibec15c32008-01-28 18:16:30 +01004789/* update HP, line and mono out pins according to the master switch */
4790static void alc260_hp_master_update(struct hda_codec *codec,
4791 hda_nid_t hp, hda_nid_t line,
4792 hda_nid_t mono)
4793{
4794 struct alc_spec *spec = codec->spec;
4795 unsigned int val = spec->master_sw ? PIN_HP : 0;
4796 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004797 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004798 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004799 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004800 val);
4801 /* mono (speaker) depending on the HP jack sense */
4802 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004803 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004804 val);
4805}
4806
4807static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4808 struct snd_ctl_elem_value *ucontrol)
4809{
4810 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4811 struct alc_spec *spec = codec->spec;
4812 *ucontrol->value.integer.value = spec->master_sw;
4813 return 0;
4814}
4815
4816static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4817 struct snd_ctl_elem_value *ucontrol)
4818{
4819 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4820 struct alc_spec *spec = codec->spec;
4821 int val = !!*ucontrol->value.integer.value;
4822 hda_nid_t hp, line, mono;
4823
4824 if (val == spec->master_sw)
4825 return 0;
4826 spec->master_sw = val;
4827 hp = (kcontrol->private_value >> 16) & 0xff;
4828 line = (kcontrol->private_value >> 8) & 0xff;
4829 mono = kcontrol->private_value & 0xff;
4830 alc260_hp_master_update(codec, hp, line, mono);
4831 return 1;
4832}
4833
4834static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4835 {
4836 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4837 .name = "Master Playback Switch",
4838 .info = snd_ctl_boolean_mono_info,
4839 .get = alc260_hp_master_sw_get,
4840 .put = alc260_hp_master_sw_put,
4841 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4842 },
4843 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4844 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4845 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4846 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4847 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4848 HDA_OUTPUT),
4849 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4850 { } /* end */
4851};
4852
4853static struct hda_verb alc260_hp_unsol_verbs[] = {
4854 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4855 {},
4856};
4857
4858static void alc260_hp_automute(struct hda_codec *codec)
4859{
4860 struct alc_spec *spec = codec->spec;
4861 unsigned int present;
4862
4863 present = snd_hda_codec_read(codec, 0x10, 0,
4864 AC_VERB_GET_PIN_SENSE, 0);
4865 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4866 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4867}
4868
4869static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4870{
4871 if ((res >> 26) == ALC880_HP_EVENT)
4872 alc260_hp_automute(codec);
4873}
4874
Kailang Yangdf694da2005-12-05 19:42:22 +01004875static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004876 {
4877 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4878 .name = "Master Playback Switch",
4879 .info = snd_ctl_boolean_mono_info,
4880 .get = alc260_hp_master_sw_get,
4881 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004882 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004883 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004884 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4885 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4886 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4887 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4888 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4889 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004890 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4891 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004892 { } /* end */
4893};
4894
Kailang Yang3f878302008-08-26 13:02:23 +02004895static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4896 .ops = &snd_hda_bind_vol,
4897 .values = {
4898 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4899 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4900 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4901 0
4902 },
4903};
4904
4905static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4906 .ops = &snd_hda_bind_sw,
4907 .values = {
4908 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4909 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4910 0
4911 },
4912};
4913
4914static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4915 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4916 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4917 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4918 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4919 { } /* end */
4920};
4921
Takashi Iwaibec15c32008-01-28 18:16:30 +01004922static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4923 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4924 {},
4925};
4926
4927static void alc260_hp_3013_automute(struct hda_codec *codec)
4928{
4929 struct alc_spec *spec = codec->spec;
4930 unsigned int present;
4931
4932 present = snd_hda_codec_read(codec, 0x15, 0,
4933 AC_VERB_GET_PIN_SENSE, 0);
4934 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004935 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004936}
4937
4938static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4939 unsigned int res)
4940{
4941 if ((res >> 26) == ALC880_HP_EVENT)
4942 alc260_hp_3013_automute(codec);
4943}
4944
Kailang Yang3f878302008-08-26 13:02:23 +02004945static void alc260_hp_3012_automute(struct hda_codec *codec)
4946{
4947 unsigned int present, bits;
4948
4949 present = snd_hda_codec_read(codec, 0x10, 0,
4950 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4951
4952 bits = present ? 0 : PIN_OUT;
4953 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4954 bits);
4955 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4956 bits);
4957 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4958 bits);
4959}
4960
4961static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4962 unsigned int res)
4963{
4964 if ((res >> 26) == ALC880_HP_EVENT)
4965 alc260_hp_3012_automute(codec);
4966}
4967
4968/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004969 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4970 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004971static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004972 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004973 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004974 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004975 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4976 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4977 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4978 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004979 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004980 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4981 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004982 { } /* end */
4983};
4984
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004985/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4986 * versions of the ALC260 don't act on requests to enable mic bias from NID
4987 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4988 * datasheet doesn't mention this restriction. At this stage it's not clear
4989 * whether this behaviour is intentional or is a hardware bug in chip
4990 * revisions available in early 2006. Therefore for now allow the
4991 * "Headphone Jack Mode" control to span all choices, but if it turns out
4992 * that the lack of mic bias for this NID is intentional we could change the
4993 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4994 *
4995 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4996 * don't appear to make the mic bias available from the "line" jack, even
4997 * though the NID used for this jack (0x14) can supply it. The theory is
4998 * that perhaps Acer have included blocking capacitors between the ALC260
4999 * and the output jack. If this turns out to be the case for all such
5000 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5001 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005002 *
5003 * The C20x Tablet series have a mono internal speaker which is controlled
5004 * via the chip's Mono sum widget and pin complex, so include the necessary
5005 * controls for such models. On models without a "mono speaker" the control
5006 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005007 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005008static struct snd_kcontrol_new alc260_acer_mixer[] = {
5009 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5010 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005011 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005012 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005013 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005014 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005015 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005016 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5017 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5019 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5020 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5021 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5022 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5023 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005024 { } /* end */
5025};
5026
Michael Schwingencc959482009-02-22 18:58:45 +01005027/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5028 */
5029static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5030 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5031 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5032 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5033 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5034 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5035 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5036 { } /* end */
5037};
5038
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005039/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5040 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5041 */
5042static struct snd_kcontrol_new alc260_will_mixer[] = {
5043 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5044 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5046 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5047 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5048 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5049 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5050 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5051 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5052 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005053 { } /* end */
5054};
5055
5056/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5057 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5058 */
5059static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5060 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5061 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5063 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5064 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5065 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5066 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5067 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5068 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5069 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5070 { } /* end */
5071};
5072
Kailang Yangdf694da2005-12-05 19:42:22 +01005073/*
5074 * initialization verbs
5075 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005076static struct hda_verb alc260_init_verbs[] = {
5077 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005078 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005079 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005080 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005081 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005082 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005083 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005084 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005085 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005086 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005087 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005088 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005089 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005090 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005091 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005092 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005093 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005094 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5095 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005096 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005097 /* set connection select to line in (default select for this ADC) */
5098 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005099 /* mute capture amp left and right */
5100 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5101 /* set connection select to line in (default select for this ADC) */
5102 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005103 /* set vol=0 Line-Out mixer amp left and right */
5104 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5105 /* unmute pin widget amp left and right (no gain on this amp) */
5106 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5107 /* set vol=0 HP mixer amp left and right */
5108 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5109 /* unmute pin widget amp left and right (no gain on this amp) */
5110 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5111 /* set vol=0 Mono mixer amp left and right */
5112 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5113 /* unmute pin widget amp left and right (no gain on this amp) */
5114 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5115 /* unmute LINE-2 out pin */
5116 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005117 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5118 * Line In 2 = 0x03
5119 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005120 /* mute analog inputs */
5121 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5122 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5123 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5124 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5125 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005126 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005127 /* mute Front out path */
5128 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5129 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5130 /* mute Headphone out path */
5131 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5132 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5133 /* mute Mono out path */
5134 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5135 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005136 { }
5137};
5138
Takashi Iwai474167d2006-05-17 17:17:43 +02005139#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005140static struct hda_verb alc260_hp_init_verbs[] = {
5141 /* Headphone and output */
5142 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5143 /* mono output */
5144 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5145 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5146 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5147 /* Mic2 (front panel) pin widget for input and vref at 80% */
5148 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5149 /* Line In pin widget for input */
5150 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5151 /* Line-2 pin widget for output */
5152 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5153 /* CD pin widget for input */
5154 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5155 /* unmute amp left and right */
5156 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5157 /* set connection select to line in (default select for this ADC) */
5158 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5159 /* unmute Line-Out mixer amp left and right (volume = 0) */
5160 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5161 /* mute pin widget amp left and right (no gain on this amp) */
5162 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5163 /* unmute HP mixer amp left and right (volume = 0) */
5164 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5165 /* mute pin widget amp left and right (no gain on this amp) */
5166 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005167 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5168 * Line In 2 = 0x03
5169 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005170 /* mute analog inputs */
5171 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5172 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5173 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5174 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5175 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005176 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5177 /* Unmute Front out path */
5178 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5179 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5180 /* Unmute Headphone out path */
5181 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5182 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5183 /* Unmute Mono out path */
5184 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5185 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5186 { }
5187};
Takashi Iwai474167d2006-05-17 17:17:43 +02005188#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005189
5190static struct hda_verb alc260_hp_3013_init_verbs[] = {
5191 /* Line out and output */
5192 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5193 /* mono output */
5194 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5195 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5196 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5197 /* Mic2 (front panel) pin widget for input and vref at 80% */
5198 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5199 /* Line In pin widget for input */
5200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5201 /* Headphone pin widget for output */
5202 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5203 /* CD pin widget for input */
5204 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5205 /* unmute amp left and right */
5206 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5207 /* set connection select to line in (default select for this ADC) */
5208 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5209 /* unmute Line-Out mixer amp left and right (volume = 0) */
5210 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5211 /* mute pin widget amp left and right (no gain on this amp) */
5212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5213 /* unmute HP mixer amp left and right (volume = 0) */
5214 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5215 /* mute pin widget amp left and right (no gain on this amp) */
5216 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005217 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5218 * Line In 2 = 0x03
5219 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005220 /* mute analog inputs */
5221 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5222 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5223 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5224 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005226 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5227 /* Unmute Front out path */
5228 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5229 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5230 /* Unmute Headphone out path */
5231 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5232 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5233 /* Unmute Mono out path */
5234 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5235 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5236 { }
5237};
5238
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005239/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005240 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5241 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005242 */
5243static struct hda_verb alc260_fujitsu_init_verbs[] = {
5244 /* Disable all GPIOs */
5245 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5246 /* Internal speaker is connected to headphone pin */
5247 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5248 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005250 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5251 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5252 /* Ensure all other unused pins are disabled and muted. */
5253 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5254 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005255 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005256 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005257 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005258 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5259 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5260 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005261
Jonathan Woithef7ace402006-02-28 11:46:14 +01005262 /* Disable digital (SPDIF) pins */
5263 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5264 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005265
Kailang Yangea1fb292008-08-26 12:58:38 +02005266 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005267 * when acting as an output.
5268 */
5269 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5270
5271 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005272 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5273 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5274 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5275 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5276 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5277 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5278 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5279 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5280 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005281
Jonathan Woithef7ace402006-02-28 11:46:14 +01005282 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5283 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5284 /* Unmute Line1 pin widget output buffer since it starts as an output.
5285 * If the pin mode is changed by the user the pin mode control will
5286 * take care of enabling the pin's input/output buffers as needed.
5287 * Therefore there's no need to enable the input buffer at this
5288 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005289 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005290 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005291 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005292 * mixer ctrl)
5293 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005294 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005295
Jonathan Woithef7ace402006-02-28 11:46:14 +01005296 /* Mute capture amp left and right */
5297 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005298 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005299 * in (on mic1 pin)
5300 */
5301 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005302
Jonathan Woithef7ace402006-02-28 11:46:14 +01005303 /* Do the same for the second ADC: mute capture input amp and
5304 * set ADC connection to line in (on mic1 pin)
5305 */
5306 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5307 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005308
Jonathan Woithef7ace402006-02-28 11:46:14 +01005309 /* Mute all inputs to mixer widget (even unconnected ones) */
5310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5314 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5315 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5316 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5317 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005318
5319 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005320};
5321
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005322/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5323 * similar laptops (adapted from Fujitsu init verbs).
5324 */
5325static struct hda_verb alc260_acer_init_verbs[] = {
5326 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5327 * the headphone jack. Turn this on and rely on the standard mute
5328 * methods whenever the user wants to turn these outputs off.
5329 */
5330 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5331 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5332 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5333 /* Internal speaker/Headphone jack is connected to Line-out pin */
5334 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5335 /* Internal microphone/Mic jack is connected to Mic1 pin */
5336 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5337 /* Line In jack is connected to Line1 pin */
5338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005339 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5340 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005341 /* Ensure all other unused pins are disabled and muted. */
5342 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5343 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005344 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5345 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5346 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5347 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5348 /* Disable digital (SPDIF) pins */
5349 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5350 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5351
Kailang Yangea1fb292008-08-26 12:58:38 +02005352 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005353 * bus when acting as outputs.
5354 */
5355 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5356 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5357
5358 /* Start with output sum widgets muted and their output gains at min */
5359 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5360 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5361 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5362 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5363 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5364 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5365 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5366 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5367 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5368
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005369 /* Unmute Line-out pin widget amp left and right
5370 * (no equiv mixer ctrl)
5371 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005372 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005373 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5374 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005375 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5376 * inputs. If the pin mode is changed by the user the pin mode control
5377 * will take care of enabling the pin's input/output buffers as needed.
5378 * Therefore there's no need to enable the input buffer at this
5379 * stage.
5380 */
5381 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5382 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5383
5384 /* Mute capture amp left and right */
5385 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5386 /* Set ADC connection select to match default mixer setting - mic
5387 * (on mic1 pin)
5388 */
5389 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5390
5391 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005392 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005393 */
5394 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005395 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005396
5397 /* Mute all inputs to mixer widget (even unconnected ones) */
5398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5405 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5406
5407 { }
5408};
5409
Michael Schwingencc959482009-02-22 18:58:45 +01005410/* Initialisation sequence for Maxdata Favorit 100XS
5411 * (adapted from Acer init verbs).
5412 */
5413static struct hda_verb alc260_favorit100_init_verbs[] = {
5414 /* GPIO 0 enables the output jack.
5415 * Turn this on and rely on the standard mute
5416 * methods whenever the user wants to turn these outputs off.
5417 */
5418 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5419 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5420 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5421 /* Line/Mic input jack is connected to Mic1 pin */
5422 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5423 /* Ensure all other unused pins are disabled and muted. */
5424 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5425 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5426 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5427 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5428 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5429 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5430 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5431 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5432 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5433 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5434 /* Disable digital (SPDIF) pins */
5435 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5436 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5437
5438 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5439 * bus when acting as outputs.
5440 */
5441 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5442 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5443
5444 /* Start with output sum widgets muted and their output gains at min */
5445 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5447 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5448 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5449 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5450 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5451 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5452 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5453 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5454
5455 /* Unmute Line-out pin widget amp left and right
5456 * (no equiv mixer ctrl)
5457 */
5458 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5459 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5460 * inputs. If the pin mode is changed by the user the pin mode control
5461 * will take care of enabling the pin's input/output buffers as needed.
5462 * Therefore there's no need to enable the input buffer at this
5463 * stage.
5464 */
5465 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5466
5467 /* Mute capture amp left and right */
5468 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5469 /* Set ADC connection select to match default mixer setting - mic
5470 * (on mic1 pin)
5471 */
5472 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5473
5474 /* Do similar with the second ADC: mute capture input amp and
5475 * set ADC connection to mic to match ALSA's default state.
5476 */
5477 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5478 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5479
5480 /* Mute all inputs to mixer widget (even unconnected ones) */
5481 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5482 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5483 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5484 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5485 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5489
5490 { }
5491};
5492
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005493static struct hda_verb alc260_will_verbs[] = {
5494 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5495 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5496 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5497 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5498 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5499 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5500 {}
5501};
5502
5503static struct hda_verb alc260_replacer_672v_verbs[] = {
5504 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5505 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5506 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5507
5508 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5509 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5510 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5511
5512 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5513 {}
5514};
5515
5516/* toggle speaker-output according to the hp-jack state */
5517static void alc260_replacer_672v_automute(struct hda_codec *codec)
5518{
5519 unsigned int present;
5520
5521 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5522 present = snd_hda_codec_read(codec, 0x0f, 0,
5523 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5524 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005525 snd_hda_codec_write_cache(codec, 0x01, 0,
5526 AC_VERB_SET_GPIO_DATA, 1);
5527 snd_hda_codec_write_cache(codec, 0x0f, 0,
5528 AC_VERB_SET_PIN_WIDGET_CONTROL,
5529 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005530 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005531 snd_hda_codec_write_cache(codec, 0x01, 0,
5532 AC_VERB_SET_GPIO_DATA, 0);
5533 snd_hda_codec_write_cache(codec, 0x0f, 0,
5534 AC_VERB_SET_PIN_WIDGET_CONTROL,
5535 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005536 }
5537}
5538
5539static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5540 unsigned int res)
5541{
5542 if ((res >> 26) == ALC880_HP_EVENT)
5543 alc260_replacer_672v_automute(codec);
5544}
5545
Kailang Yang3f878302008-08-26 13:02:23 +02005546static struct hda_verb alc260_hp_dc7600_verbs[] = {
5547 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5548 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5549 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5550 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5551 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5552 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5553 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5554 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5555 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5556 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5557 {}
5558};
5559
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005560/* Test configuration for debugging, modelled after the ALC880 test
5561 * configuration.
5562 */
5563#ifdef CONFIG_SND_DEBUG
5564static hda_nid_t alc260_test_dac_nids[1] = {
5565 0x02,
5566};
5567static hda_nid_t alc260_test_adc_nids[2] = {
5568 0x04, 0x05,
5569};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005570/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005571 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005572 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005573 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005574static struct hda_input_mux alc260_test_capture_sources[2] = {
5575 {
5576 .num_items = 7,
5577 .items = {
5578 { "MIC1 pin", 0x0 },
5579 { "MIC2 pin", 0x1 },
5580 { "LINE1 pin", 0x2 },
5581 { "LINE2 pin", 0x3 },
5582 { "CD pin", 0x4 },
5583 { "LINE-OUT pin", 0x5 },
5584 { "HP-OUT pin", 0x6 },
5585 },
5586 },
5587 {
5588 .num_items = 8,
5589 .items = {
5590 { "MIC1 pin", 0x0 },
5591 { "MIC2 pin", 0x1 },
5592 { "LINE1 pin", 0x2 },
5593 { "LINE2 pin", 0x3 },
5594 { "CD pin", 0x4 },
5595 { "Mixer", 0x5 },
5596 { "LINE-OUT pin", 0x6 },
5597 { "HP-OUT pin", 0x7 },
5598 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005599 },
5600};
5601static struct snd_kcontrol_new alc260_test_mixer[] = {
5602 /* Output driver widgets */
5603 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5604 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5605 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5606 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5607 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5608 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5609
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005610 /* Modes for retasking pin widgets
5611 * Note: the ALC260 doesn't seem to act on requests to enable mic
5612 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5613 * mention this restriction. At this stage it's not clear whether
5614 * this behaviour is intentional or is a hardware bug in chip
5615 * revisions available at least up until early 2006. Therefore for
5616 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5617 * choices, but if it turns out that the lack of mic bias for these
5618 * NIDs is intentional we could change their modes from
5619 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5620 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005621 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5622 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5623 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5624 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5625 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5626 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5627
5628 /* Loopback mixer controls */
5629 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5630 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5631 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5632 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5633 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5634 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5635 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5636 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5637 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5638 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005639 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5640 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5641 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5642 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005643
5644 /* Controls for GPIO pins, assuming they are configured as outputs */
5645 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5646 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5647 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5648 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5649
Jonathan Woithe92621f12006-02-28 11:47:47 +01005650 /* Switches to allow the digital IO pins to be enabled. The datasheet
5651 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005652 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005653 */
5654 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5655 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5656
Jonathan Woithef8225f62008-01-08 12:16:54 +01005657 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5658 * this output to turn on an external amplifier.
5659 */
5660 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5661 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5662
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005663 { } /* end */
5664};
5665static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005666 /* Enable all GPIOs as outputs with an initial value of 0 */
5667 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5668 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5669 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5670
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005671 /* Enable retasking pins as output, initially without power amp */
5672 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5673 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5674 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5675 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5676 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5677 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5678
Jonathan Woithe92621f12006-02-28 11:47:47 +01005679 /* Disable digital (SPDIF) pins initially, but users can enable
5680 * them via a mixer switch. In the case of SPDIF-out, this initverb
5681 * payload also sets the generation to 0, output to be in "consumer"
5682 * PCM format, copyright asserted, no pre-emphasis and no validity
5683 * control.
5684 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005685 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5686 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5687
Kailang Yangea1fb292008-08-26 12:58:38 +02005688 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005689 * OUT1 sum bus when acting as an output.
5690 */
5691 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5692 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5693 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5694 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5695
5696 /* Start with output sum widgets muted and their output gains at min */
5697 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5698 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5699 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5700 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5701 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5702 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5703 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5704 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5705 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5706
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005707 /* Unmute retasking pin widget output buffers since the default
5708 * state appears to be output. As the pin mode is changed by the
5709 * user the pin mode control will take care of enabling the pin's
5710 * input/output buffers as needed.
5711 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005712 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5713 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5714 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5715 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5716 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5717 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5718 /* Also unmute the mono-out pin widget */
5719 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5720
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005721 /* Mute capture amp left and right */
5722 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005723 /* Set ADC connection select to match default mixer setting (mic1
5724 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005725 */
5726 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5727
5728 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005729 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005730 */
5731 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5732 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5733
5734 /* Mute all inputs to mixer widget (even unconnected ones) */
5735 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5736 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5739 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5741 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5742 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5743
5744 { }
5745};
5746#endif
5747
Takashi Iwai63300792008-01-24 15:31:36 +01005748#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5749#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005750
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005751#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5752#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5753
Kailang Yangdf694da2005-12-05 19:42:22 +01005754/*
5755 * for BIOS auto-configuration
5756 */
5757
5758static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005759 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005760{
5761 hda_nid_t nid_vol;
5762 unsigned long vol_val, sw_val;
5763 char name[32];
5764 int err;
5765
5766 if (nid >= 0x0f && nid < 0x11) {
5767 nid_vol = nid - 0x7;
5768 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5769 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5770 } else if (nid == 0x11) {
5771 nid_vol = nid - 0x7;
5772 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5773 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5774 } else if (nid >= 0x12 && nid <= 0x15) {
5775 nid_vol = 0x08;
5776 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5777 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5778 } else
5779 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005780
Takashi Iwai863b4512008-10-21 17:01:47 +02005781 if (!(*vol_bits & (1 << nid_vol))) {
5782 /* first control for the volume widget */
5783 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5784 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5785 if (err < 0)
5786 return err;
5787 *vol_bits |= (1 << nid_vol);
5788 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005789 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005790 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5791 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005792 return err;
5793 return 1;
5794}
5795
5796/* add playback controls from the parsed DAC table */
5797static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5798 const struct auto_pin_cfg *cfg)
5799{
5800 hda_nid_t nid;
5801 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005802 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005803
5804 spec->multiout.num_dacs = 1;
5805 spec->multiout.dac_nids = spec->private_dac_nids;
5806 spec->multiout.dac_nids[0] = 0x02;
5807
5808 nid = cfg->line_out_pins[0];
5809 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005810 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005811 if (err < 0)
5812 return err;
5813 }
5814
Takashi Iwai82bc9552006-03-21 11:24:42 +01005815 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005816 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005817 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005818 if (err < 0)
5819 return err;
5820 }
5821
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005822 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005823 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005824 err = alc260_add_playback_controls(spec, nid, "Headphone",
5825 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005826 if (err < 0)
5827 return err;
5828 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005829 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005830}
5831
5832/* create playback/capture controls for input pins */
5833static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5834 const struct auto_pin_cfg *cfg)
5835{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005836 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005837 int i, err, idx;
5838
5839 for (i = 0; i < AUTO_PIN_LAST; i++) {
5840 if (cfg->input_pins[i] >= 0x12) {
5841 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005842 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005843 auto_pin_cfg_labels[i], idx,
5844 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005845 if (err < 0)
5846 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005847 imux->items[imux->num_items].label =
5848 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005849 imux->items[imux->num_items].index = idx;
5850 imux->num_items++;
5851 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005852 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005853 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005854 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005855 auto_pin_cfg_labels[i], idx,
5856 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005857 if (err < 0)
5858 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005859 imux->items[imux->num_items].label =
5860 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005861 imux->items[imux->num_items].index = idx;
5862 imux->num_items++;
5863 }
5864 }
5865 return 0;
5866}
5867
5868static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5869 hda_nid_t nid, int pin_type,
5870 int sel_idx)
5871{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005872 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005873 /* need the manual connection? */
5874 if (nid >= 0x12) {
5875 int idx = nid - 0x12;
5876 snd_hda_codec_write(codec, idx + 0x0b, 0,
5877 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005878 }
5879}
5880
5881static void alc260_auto_init_multi_out(struct hda_codec *codec)
5882{
5883 struct alc_spec *spec = codec->spec;
5884 hda_nid_t nid;
5885
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005886 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005887 if (nid) {
5888 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5889 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5890 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005891
Takashi Iwai82bc9552006-03-21 11:24:42 +01005892 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005893 if (nid)
5894 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5895
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005896 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005897 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005898 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005899}
Kailang Yangdf694da2005-12-05 19:42:22 +01005900
5901#define ALC260_PIN_CD_NID 0x16
5902static void alc260_auto_init_analog_input(struct hda_codec *codec)
5903{
5904 struct alc_spec *spec = codec->spec;
5905 int i;
5906
5907 for (i = 0; i < AUTO_PIN_LAST; i++) {
5908 hda_nid_t nid = spec->autocfg.input_pins[i];
5909 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005910 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005911 if (nid != ALC260_PIN_CD_NID &&
5912 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005913 snd_hda_codec_write(codec, nid, 0,
5914 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005915 AMP_OUT_MUTE);
5916 }
5917 }
5918}
5919
5920/*
5921 * generic initialization of ADC, input mixers and output mixers
5922 */
5923static struct hda_verb alc260_volume_init_verbs[] = {
5924 /*
5925 * Unmute ADC0-1 and set the default input to mic-in
5926 */
5927 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5928 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5929 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5930 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005931
Kailang Yangdf694da2005-12-05 19:42:22 +01005932 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5933 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005934 * Note: PASD motherboards uses the Line In 2 as the input for
5935 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005936 */
5937 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005938 /* mute analog inputs */
5939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005944
5945 /*
5946 * Set up output mixers (0x08 - 0x0a)
5947 */
5948 /* set vol=0 to output mixers */
5949 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5950 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5951 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5952 /* set up input amps for analog loopback */
5953 /* Amp Indices: DAC = 0, mixer = 1 */
5954 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5956 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5958 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5959 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005960
Kailang Yangdf694da2005-12-05 19:42:22 +01005961 { }
5962};
5963
5964static int alc260_parse_auto_config(struct hda_codec *codec)
5965{
5966 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005967 int err;
5968 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5969
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005970 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5971 alc260_ignore);
5972 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005973 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005974 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5975 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005976 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005977 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005978 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005979 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5980 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005981 return err;
5982
5983 spec->multiout.max_channels = 2;
5984
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005985 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005986 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005987 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005988 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005989
Takashi Iwaid88897e2008-10-31 15:01:37 +01005990 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005991
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005992 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005993 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005994
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005995 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5996
Kailang Yangdf694da2005-12-05 19:42:22 +01005997 return 1;
5998}
5999
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006000/* additional initialization for auto-configuration model */
6001static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006002{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006003 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006004 alc260_auto_init_multi_out(codec);
6005 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006006 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006007 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006008}
6009
Takashi Iwaicb53c622007-08-10 17:21:45 +02006010#ifdef CONFIG_SND_HDA_POWER_SAVE
6011static struct hda_amp_list alc260_loopbacks[] = {
6012 { 0x07, HDA_INPUT, 0 },
6013 { 0x07, HDA_INPUT, 1 },
6014 { 0x07, HDA_INPUT, 2 },
6015 { 0x07, HDA_INPUT, 3 },
6016 { 0x07, HDA_INPUT, 4 },
6017 { } /* end */
6018};
6019#endif
6020
Kailang Yangdf694da2005-12-05 19:42:22 +01006021/*
6022 * ALC260 configurations
6023 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006024static const char *alc260_models[ALC260_MODEL_LAST] = {
6025 [ALC260_BASIC] = "basic",
6026 [ALC260_HP] = "hp",
6027 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006028 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006029 [ALC260_FUJITSU_S702X] = "fujitsu",
6030 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006031 [ALC260_WILL] = "will",
6032 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006033 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006034#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006035 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006036#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006037 [ALC260_AUTO] = "auto",
6038};
6039
6040static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006041 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006042 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006043 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006044 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006045 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006046 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006047 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006048 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006049 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6050 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6051 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6052 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6053 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6054 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6055 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6056 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6057 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006058 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006059 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006060 {}
6061};
6062
Kailang Yangdf694da2005-12-05 19:42:22 +01006063static struct alc_config_preset alc260_presets[] = {
6064 [ALC260_BASIC] = {
6065 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006066 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006067 .init_verbs = { alc260_init_verbs },
6068 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6069 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006070 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006071 .adc_nids = alc260_adc_nids,
6072 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6073 .channel_mode = alc260_modes,
6074 .input_mux = &alc260_capture_source,
6075 },
6076 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006077 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006078 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006079 .init_verbs = { alc260_init_verbs,
6080 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006081 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6082 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006083 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6084 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006085 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6086 .channel_mode = alc260_modes,
6087 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006088 .unsol_event = alc260_hp_unsol_event,
6089 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006090 },
Kailang Yang3f878302008-08-26 13:02:23 +02006091 [ALC260_HP_DC7600] = {
6092 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006093 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006094 .init_verbs = { alc260_init_verbs,
6095 alc260_hp_dc7600_verbs },
6096 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6097 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006098 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6099 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006100 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6101 .channel_mode = alc260_modes,
6102 .input_mux = &alc260_capture_source,
6103 .unsol_event = alc260_hp_3012_unsol_event,
6104 .init_hook = alc260_hp_3012_automute,
6105 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006106 [ALC260_HP_3013] = {
6107 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006108 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006109 .init_verbs = { alc260_hp_3013_init_verbs,
6110 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006111 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6112 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006113 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6114 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006115 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6116 .channel_mode = alc260_modes,
6117 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006118 .unsol_event = alc260_hp_3013_unsol_event,
6119 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006120 },
6121 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006122 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006123 .init_verbs = { alc260_fujitsu_init_verbs },
6124 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6125 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006126 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6127 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006128 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6129 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006130 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6131 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006132 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006133 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006134 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006135 .init_verbs = { alc260_acer_init_verbs },
6136 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6137 .dac_nids = alc260_dac_nids,
6138 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6139 .adc_nids = alc260_dual_adc_nids,
6140 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6141 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006142 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6143 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006144 },
Michael Schwingencc959482009-02-22 18:58:45 +01006145 [ALC260_FAVORIT100] = {
6146 .mixers = { alc260_favorit100_mixer },
6147 .init_verbs = { alc260_favorit100_init_verbs },
6148 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6149 .dac_nids = alc260_dac_nids,
6150 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6151 .adc_nids = alc260_dual_adc_nids,
6152 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6153 .channel_mode = alc260_modes,
6154 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6155 .input_mux = alc260_favorit100_capture_sources,
6156 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006157 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006158 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006159 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6160 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6161 .dac_nids = alc260_dac_nids,
6162 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6163 .adc_nids = alc260_adc_nids,
6164 .dig_out_nid = ALC260_DIGOUT_NID,
6165 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6166 .channel_mode = alc260_modes,
6167 .input_mux = &alc260_capture_source,
6168 },
6169 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006170 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006171 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6172 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6173 .dac_nids = alc260_dac_nids,
6174 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6175 .adc_nids = alc260_adc_nids,
6176 .dig_out_nid = ALC260_DIGOUT_NID,
6177 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6178 .channel_mode = alc260_modes,
6179 .input_mux = &alc260_capture_source,
6180 .unsol_event = alc260_replacer_672v_unsol_event,
6181 .init_hook = alc260_replacer_672v_automute,
6182 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006183#ifdef CONFIG_SND_DEBUG
6184 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006185 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006186 .init_verbs = { alc260_test_init_verbs },
6187 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6188 .dac_nids = alc260_test_dac_nids,
6189 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6190 .adc_nids = alc260_test_adc_nids,
6191 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6192 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006193 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6194 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006195 },
6196#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006197};
6198
Linus Torvalds1da177e2005-04-16 15:20:36 -07006199static int patch_alc260(struct hda_codec *codec)
6200{
6201 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006202 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006203
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006204 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006205 if (spec == NULL)
6206 return -ENOMEM;
6207
6208 codec->spec = spec;
6209
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006210 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6211 alc260_models,
6212 alc260_cfg_tbl);
6213 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02006214 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6215 "trying auto-probe from BIOS...\n",
6216 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006217 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006218 }
6219
Kailang Yangdf694da2005-12-05 19:42:22 +01006220 if (board_config == ALC260_AUTO) {
6221 /* automatic parse from the BIOS config */
6222 err = alc260_parse_auto_config(codec);
6223 if (err < 0) {
6224 alc_free(codec);
6225 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006226 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006227 printk(KERN_INFO
6228 "hda_codec: Cannot set up configuration "
6229 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006230 board_config = ALC260_BASIC;
6231 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006232 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006233
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006234 err = snd_hda_attach_beep_device(codec, 0x1);
6235 if (err < 0) {
6236 alc_free(codec);
6237 return err;
6238 }
6239
Kailang Yangdf694da2005-12-05 19:42:22 +01006240 if (board_config != ALC260_AUTO)
6241 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006242
Linus Torvalds1da177e2005-04-16 15:20:36 -07006243 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6244 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6245
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006246 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6247 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6248
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006249 if (!spec->adc_nids && spec->input_mux) {
6250 /* check whether NID 0x04 is valid */
6251 unsigned int wcap = get_wcaps(codec, 0x04);
6252 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6253 /* get type */
6254 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6255 spec->adc_nids = alc260_adc_nids_alt;
6256 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6257 } else {
6258 spec->adc_nids = alc260_adc_nids;
6259 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6260 }
6261 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006262 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006263 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006264
Takashi Iwai2134ea42008-01-10 16:53:55 +01006265 spec->vmaster_nid = 0x08;
6266
Linus Torvalds1da177e2005-04-16 15:20:36 -07006267 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006268 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006269 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006270#ifdef CONFIG_SND_HDA_POWER_SAVE
6271 if (!spec->loopback.amplist)
6272 spec->loopback.amplist = alc260_loopbacks;
6273#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006274 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006275
6276 return 0;
6277}
6278
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006279
Linus Torvalds1da177e2005-04-16 15:20:36 -07006280/*
6281 * ALC882 support
6282 *
6283 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6284 * configuration. Each pin widget can choose any input DACs and a mixer.
6285 * Each ADC is connected from a mixer of all inputs. This makes possible
6286 * 6-channel independent captures.
6287 *
6288 * In addition, an independent DAC for the multi-playback (not used in this
6289 * driver yet).
6290 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006291#define ALC882_DIGOUT_NID 0x06
6292#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006293
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006294static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006295 { 8, NULL }
6296};
6297
6298static hda_nid_t alc882_dac_nids[4] = {
6299 /* front, rear, clfe, rear_surr */
6300 0x02, 0x03, 0x04, 0x05
6301};
6302
Kailang Yangdf694da2005-12-05 19:42:22 +01006303/* identical with ALC880 */
6304#define alc882_adc_nids alc880_adc_nids
6305#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006306
Takashi Iwaie1406342008-02-11 18:32:32 +01006307static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6308static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6309
Linus Torvalds1da177e2005-04-16 15:20:36 -07006310/* input MUX */
6311/* FIXME: should be a matrix-type input source selection */
6312
6313static struct hda_input_mux alc882_capture_source = {
6314 .num_items = 4,
6315 .items = {
6316 { "Mic", 0x0 },
6317 { "Front Mic", 0x1 },
6318 { "Line", 0x2 },
6319 { "CD", 0x4 },
6320 },
6321};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006322
6323static struct hda_input_mux mb5_capture_source = {
6324 .num_items = 3,
6325 .items = {
6326 { "Mic", 0x1 },
6327 { "Line", 0x2 },
6328 { "CD", 0x4 },
6329 },
6330};
6331
Kailang Yangdf694da2005-12-05 19:42:22 +01006332/*
Kailang Yang272a5272007-05-14 11:00:38 +02006333 * 2ch mode
6334 */
6335static struct hda_verb alc882_3ST_ch2_init[] = {
6336 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6337 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6338 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6339 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6340 { } /* end */
6341};
6342
6343/*
6344 * 6ch mode
6345 */
6346static struct hda_verb alc882_3ST_ch6_init[] = {
6347 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6348 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6349 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6350 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6351 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6352 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6353 { } /* end */
6354};
6355
6356static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6357 { 2, alc882_3ST_ch2_init },
6358 { 6, alc882_3ST_ch6_init },
6359};
6360
6361/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006362 * 6ch mode
6363 */
6364static struct hda_verb alc882_sixstack_ch6_init[] = {
6365 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6366 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6367 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6368 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6369 { } /* end */
6370};
6371
6372/*
6373 * 8ch mode
6374 */
6375static struct hda_verb alc882_sixstack_ch8_init[] = {
6376 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6377 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6378 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6379 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6380 { } /* end */
6381};
6382
6383static struct hda_channel_mode alc882_sixstack_modes[2] = {
6384 { 6, alc882_sixstack_ch6_init },
6385 { 8, alc882_sixstack_ch8_init },
6386};
6387
Takashi Iwai87350ad2007-08-16 18:19:38 +02006388/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006389 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006390 */
6391
6392/*
6393 * 2ch mode
6394 */
6395static struct hda_verb alc885_mbp_ch2_init[] = {
6396 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6397 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6398 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6399 { } /* end */
6400};
6401
6402/*
6403 * 6ch mode
6404 */
6405static struct hda_verb alc885_mbp_ch6_init[] = {
6406 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6407 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6408 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6409 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6410 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6411 { } /* end */
6412};
6413
6414static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6415 { 2, alc885_mbp_ch2_init },
6416 { 6, alc885_mbp_ch6_init },
6417};
6418
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006419/*
6420 * 2ch
6421 * Speakers/Woofer/HP = Front
6422 * LineIn = Input
6423 */
6424static struct hda_verb alc885_mb5_ch2_init[] = {
6425 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6427 { } /* end */
6428};
6429
6430/*
6431 * 6ch mode
6432 * Speakers/HP = Front
6433 * Woofer = LFE
6434 * LineIn = Surround
6435 */
6436static struct hda_verb alc885_mb5_ch6_init[] = {
6437 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6438 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6439 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6440 { } /* end */
6441};
6442
6443static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6444 { 2, alc885_mb5_ch2_init },
6445 { 6, alc885_mb5_ch6_init },
6446};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006447
Linus Torvalds1da177e2005-04-16 15:20:36 -07006448/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6449 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6450 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01006451static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006452 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006453 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006454 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006455 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006456 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6457 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006458 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6459 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006460 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006461 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6463 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6464 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6465 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6466 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006468 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006469 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6470 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006471 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006472 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006473 { } /* end */
6474};
6475
Takashi Iwai87350ad2007-08-16 18:19:38 +02006476static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006477 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6478 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6479 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6480 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6481 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6482 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6484 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006485 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006486 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6487 { } /* end */
6488};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006489
6490static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006491 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6492 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6493 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6494 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6495 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6496 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6497 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6498 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006499 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6500 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6502 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6503 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6504 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6505 { } /* end */
6506};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006507
Kailang Yangbdd148a2007-05-08 15:19:08 +02006508static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6509 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6510 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6511 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6512 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6513 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6514 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6515 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6516 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6517 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006518 { } /* end */
6519};
6520
Kailang Yang272a5272007-05-14 11:00:38 +02006521static struct snd_kcontrol_new alc882_targa_mixer[] = {
6522 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6523 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6524 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6525 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6526 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6527 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6528 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6529 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6530 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02006531 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006532 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6533 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02006534 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006535 { } /* end */
6536};
6537
6538/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6539 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6540 */
6541static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6542 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6543 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6545 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6546 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6547 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6548 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6549 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6550 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6551 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6552 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6553 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02006554 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006555 { } /* end */
6556};
6557
Takashi Iwai914759b2007-09-06 14:52:04 +02006558static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6559 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6560 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6561 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6562 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6563 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6564 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6565 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6567 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6568 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006569 { } /* end */
6570};
6571
Kailang Yangdf694da2005-12-05 19:42:22 +01006572static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6573 {
6574 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6575 .name = "Channel Mode",
6576 .info = alc_ch_mode_info,
6577 .get = alc_ch_mode_get,
6578 .put = alc_ch_mode_put,
6579 },
6580 { } /* end */
6581};
6582
Linus Torvalds1da177e2005-04-16 15:20:36 -07006583static struct hda_verb alc882_init_verbs[] = {
6584 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6586 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006588 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006589 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6591 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006592 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6594 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6595 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006596 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006597 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6598 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6599 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006600
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006601 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006602 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006603 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006604 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006605 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006606 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006607 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006608 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006609 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006610 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006611 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006612 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006613 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006614 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006615 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006616 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006617 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006618 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006619 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6620 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006621 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006622 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6623 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006624 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006625 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6626 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6627 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6628 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6629 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006630 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006631 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006632
6633 /* FIXME: use matrix-type input source selection */
6634 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6635 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006636 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6637 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6638 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6639 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006640 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006641 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6642 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6643 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6644 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006645 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006646 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6647 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6648 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6649 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6650 /* ADC1: mute amp left and right */
6651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006652 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006653 /* ADC2: mute amp left and right */
6654 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006655 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006656 /* ADC3: mute amp left and right */
6657 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006658 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006659
6660 { }
6661};
6662
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006663static struct hda_verb alc882_eapd_verbs[] = {
6664 /* change to EAPD mode */
6665 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006666 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006667 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006668};
6669
Tobin Davis9102cd12006-12-15 10:02:12 +01006670/* Mac Pro test */
6671static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6672 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6673 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6674 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6675 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6676 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006677 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006678 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6679 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006680 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006681 { } /* end */
6682};
6683
6684static struct hda_verb alc882_macpro_init_verbs[] = {
6685 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6688 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6689 /* Front Pin: output 0 (0x0c) */
6690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6692 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6693 /* Front Mic pin: input vref at 80% */
6694 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6695 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6696 /* Speaker: output */
6697 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6698 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6699 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6700 /* Headphone output (output 0 - 0x0c) */
6701 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6702 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6703 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6704
6705 /* FIXME: use matrix-type input source selection */
6706 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6707 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6708 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6709 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6710 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6711 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6712 /* Input mixer2 */
6713 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6714 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6715 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6716 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6717 /* Input mixer3 */
6718 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6719 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6720 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6721 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6722 /* ADC1: mute amp left and right */
6723 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6724 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6725 /* ADC2: mute amp left and right */
6726 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6727 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6728 /* ADC3: mute amp left and right */
6729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6730 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6731
6732 { }
6733};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006734
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006735/* Macbook 5,1 */
6736static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006737 /* DACs */
6738 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6739 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6740 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6741 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006742 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006746 /* Surround mixer */
6747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6748 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6749 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6750 /* LFE mixer */
6751 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6752 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6753 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6754 /* HP mixer */
6755 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6756 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6757 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6758 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006759 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6760 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006761 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6762 /* LFE Pin (0x0e) */
6763 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6764 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6765 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
6766 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006767 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6768 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006769 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006770 /* Front Mic pin: input vref at 80% */
6771 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6772 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6773 /* Line In pin */
6774 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6776
6777 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6778 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6779 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6780 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6781 { }
6782};
6783
Takashi Iwai87350ad2007-08-16 18:19:38 +02006784/* Macbook Pro rev3 */
6785static struct hda_verb alc885_mbp3_init_verbs[] = {
6786 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6788 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6789 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6790 /* Rear mixer */
6791 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6792 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6793 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6794 /* Front Pin: output 0 (0x0c) */
6795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6796 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6797 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6798 /* HP Pin: output 0 (0x0d) */
6799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6801 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6802 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6803 /* Mic (rear) pin: input vref at 80% */
6804 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6805 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6806 /* Front Mic pin: input vref at 80% */
6807 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6808 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6809 /* Line In pin: use output 1 when in LineOut mode */
6810 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6812 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6813
6814 /* FIXME: use matrix-type input source selection */
6815 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6816 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6817 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6818 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6819 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6820 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6821 /* Input mixer2 */
6822 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6823 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6824 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6825 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6826 /* Input mixer3 */
6827 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6828 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6829 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6830 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6831 /* ADC1: mute amp left and right */
6832 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6833 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6834 /* ADC2: mute amp left and right */
6835 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6836 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6837 /* ADC3: mute amp left and right */
6838 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6839 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6840
6841 { }
6842};
6843
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006844/* iMac 24 mixer. */
6845static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6846 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6847 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6848 { } /* end */
6849};
6850
6851/* iMac 24 init verbs. */
6852static struct hda_verb alc885_imac24_init_verbs[] = {
6853 /* Internal speakers: output 0 (0x0c) */
6854 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6855 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6856 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6857 /* Internal speakers: output 0 (0x0c) */
6858 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6859 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6860 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6861 /* Headphone: output 0 (0x0c) */
6862 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6863 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6864 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6865 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6866 /* Front Mic: input vref at 80% */
6867 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6868 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6869 { }
6870};
6871
6872/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006873static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006874{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006875 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006876
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006877 spec->autocfg.hp_pins[0] = 0x14;
6878 spec->autocfg.speaker_pins[0] = 0x18;
6879 spec->autocfg.speaker_pins[1] = 0x1a;
6880 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006881}
6882
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006883static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006884{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006885 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006886
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006887 spec->autocfg.hp_pins[0] = 0x15;
6888 spec->autocfg.speaker_pins[0] = 0x14;
6889 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006890}
6891
6892
Kailang Yang272a5272007-05-14 11:00:38 +02006893static struct hda_verb alc882_targa_verbs[] = {
6894 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6895 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6896
6897 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6898 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006899
Kailang Yang272a5272007-05-14 11:00:38 +02006900 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6901 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6902 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6903
6904 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6905 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6906 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6907 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6908 { } /* end */
6909};
6910
6911/* toggle speaker-output according to the hp-jack state */
6912static void alc882_targa_automute(struct hda_codec *codec)
6913{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006914 struct alc_spec *spec = codec->spec;
6915 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006916 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006917 spec->jack_present ? 1 : 3);
6918}
6919
6920static void alc882_targa_init_hook(struct hda_codec *codec)
6921{
6922 struct alc_spec *spec = codec->spec;
6923
6924 spec->autocfg.hp_pins[0] = 0x14;
6925 spec->autocfg.speaker_pins[0] = 0x1b;
6926 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006927}
6928
6929static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6930{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006931 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006932 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006933}
6934
6935static struct hda_verb alc882_asus_a7j_verbs[] = {
6936 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6937 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6938
6939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6940 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6941 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006942
Kailang Yang272a5272007-05-14 11:00:38 +02006943 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6944 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6945 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6946
6947 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6948 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6949 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6950 { } /* end */
6951};
6952
Takashi Iwai914759b2007-09-06 14:52:04 +02006953static struct hda_verb alc882_asus_a7m_verbs[] = {
6954 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6956
6957 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6958 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6959 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006960
Takashi Iwai914759b2007-09-06 14:52:04 +02006961 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6962 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6963 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6964
6965 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6966 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6967 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6968 { } /* end */
6969};
6970
Tobin Davis9102cd12006-12-15 10:02:12 +01006971static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6972{
6973 unsigned int gpiostate, gpiomask, gpiodir;
6974
6975 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6976 AC_VERB_GET_GPIO_DATA, 0);
6977
6978 if (!muted)
6979 gpiostate |= (1 << pin);
6980 else
6981 gpiostate &= ~(1 << pin);
6982
6983 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6984 AC_VERB_GET_GPIO_MASK, 0);
6985 gpiomask |= (1 << pin);
6986
6987 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6988 AC_VERB_GET_GPIO_DIRECTION, 0);
6989 gpiodir |= (1 << pin);
6990
6991
6992 snd_hda_codec_write(codec, codec->afg, 0,
6993 AC_VERB_SET_GPIO_MASK, gpiomask);
6994 snd_hda_codec_write(codec, codec->afg, 0,
6995 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6996
6997 msleep(1);
6998
6999 snd_hda_codec_write(codec, codec->afg, 0,
7000 AC_VERB_SET_GPIO_DATA, gpiostate);
7001}
7002
Takashi Iwai7debbe52007-08-16 15:01:03 +02007003/* set up GPIO at initialization */
7004static void alc885_macpro_init_hook(struct hda_codec *codec)
7005{
7006 alc882_gpio_mute(codec, 0, 0);
7007 alc882_gpio_mute(codec, 1, 0);
7008}
7009
7010/* set up GPIO and update auto-muting at initialization */
7011static void alc885_imac24_init_hook(struct hda_codec *codec)
7012{
7013 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007014 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007015}
7016
Kailang Yangdf694da2005-12-05 19:42:22 +01007017/*
7018 * generic initialization of ADC, input mixers and output mixers
7019 */
7020static struct hda_verb alc882_auto_init_verbs[] = {
7021 /*
7022 * Unmute ADC0-2 and set the default input to mic-in
7023 */
7024 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7026 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7027 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7028 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7029 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7030
Takashi Iwaicb53c622007-08-10 17:21:45 +02007031 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007032 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007033 * Note: PASD motherboards uses the Line In 2 as the input for
7034 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007035 */
7036 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007042
7043 /*
7044 * Set up output mixers (0x0c - 0x0f)
7045 */
7046 /* set vol=0 to output mixers */
7047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7049 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7050 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7051 /* set up input amps for analog loopback */
7052 /* Amp Indices: DAC = 0, mixer = 1 */
7053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7058 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7059 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7060 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7061 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7062 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7063
7064 /* FIXME: use matrix-type input source selection */
7065 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7066 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7067 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7068 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7069 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7070 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7071 /* Input mixer2 */
7072 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7073 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7074 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7075 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7076 /* Input mixer3 */
7077 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7078 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7081
7082 { }
7083};
7084
Takashi Iwaicb53c622007-08-10 17:21:45 +02007085#ifdef CONFIG_SND_HDA_POWER_SAVE
7086#define alc882_loopbacks alc880_loopbacks
7087#endif
7088
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007089/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007090#define alc882_pcm_analog_playback alc880_pcm_analog_playback
7091#define alc882_pcm_analog_capture alc880_pcm_analog_capture
7092#define alc882_pcm_digital_playback alc880_pcm_digital_playback
7093#define alc882_pcm_digital_capture alc880_pcm_digital_capture
7094
7095/*
7096 * configuration and preset
7097 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007098static const char *alc882_models[ALC882_MODEL_LAST] = {
7099 [ALC882_3ST_DIG] = "3stack-dig",
7100 [ALC882_6ST_DIG] = "6stack-dig",
7101 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02007102 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02007103 [ALC882_TARGA] = "targa",
7104 [ALC882_ASUS_A7J] = "asus-a7j",
7105 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01007106 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007107 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02007108 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007109 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007110 [ALC882_AUTO] = "auto",
7111};
7112
7113static struct snd_pci_quirk alc882_cfg_tbl[] = {
7114 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02007115 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02007116 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02007117 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007118 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02007119 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01007120 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007121 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01007122 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007123 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
7124 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
7125 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01007126 {}
7127};
7128
7129static struct alc_config_preset alc882_presets[] = {
7130 [ALC882_3ST_DIG] = {
7131 .mixers = { alc882_base_mixer },
7132 .init_verbs = { alc882_init_verbs },
7133 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7134 .dac_nids = alc882_dac_nids,
7135 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007136 .dig_in_nid = ALC882_DIGIN_NID,
7137 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7138 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007139 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007140 .input_mux = &alc882_capture_source,
7141 },
7142 [ALC882_6ST_DIG] = {
7143 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7144 .init_verbs = { alc882_init_verbs },
7145 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7146 .dac_nids = alc882_dac_nids,
7147 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007148 .dig_in_nid = ALC882_DIGIN_NID,
7149 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7150 .channel_mode = alc882_sixstack_modes,
7151 .input_mux = &alc882_capture_source,
7152 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007153 [ALC882_ARIMA] = {
7154 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7155 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
7156 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7157 .dac_nids = alc882_dac_nids,
7158 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7159 .channel_mode = alc882_sixstack_modes,
7160 .input_mux = &alc882_capture_source,
7161 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02007162 [ALC882_W2JC] = {
7163 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
7164 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7165 alc880_gpio1_init_verbs },
7166 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7167 .dac_nids = alc882_dac_nids,
7168 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7169 .channel_mode = alc880_threestack_modes,
7170 .need_dac_fix = 1,
7171 .input_mux = &alc882_capture_source,
7172 .dig_out_nid = ALC882_DIGOUT_NID,
7173 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007174 [ALC885_MBP3] = {
7175 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
7176 .init_verbs = { alc885_mbp3_init_verbs,
7177 alc880_gpio1_init_verbs },
7178 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7179 .dac_nids = alc882_dac_nids,
7180 .channel_mode = alc885_mbp_6ch_modes,
7181 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
7182 .input_mux = &alc882_capture_source,
7183 .dig_out_nid = ALC882_DIGOUT_NID,
7184 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007185 .unsol_event = alc_automute_amp_unsol_event,
7186 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02007187 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007188 [ALC885_MB5] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007189 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007190 .init_verbs = { alc885_mb5_init_verbs,
7191 alc880_gpio1_init_verbs },
7192 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7193 .dac_nids = alc882_dac_nids,
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007194 .channel_mode = alc885_mb5_6ch_modes,
7195 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007196 .input_mux = &mb5_capture_source,
7197 .dig_out_nid = ALC882_DIGOUT_NID,
7198 .dig_in_nid = ALC882_DIGIN_NID,
7199 },
Tobin Davis9102cd12006-12-15 10:02:12 +01007200 [ALC885_MACPRO] = {
7201 .mixers = { alc882_macpro_mixer },
7202 .init_verbs = { alc882_macpro_init_verbs },
7203 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7204 .dac_nids = alc882_dac_nids,
7205 .dig_out_nid = ALC882_DIGOUT_NID,
7206 .dig_in_nid = ALC882_DIGIN_NID,
7207 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7208 .channel_mode = alc882_ch_modes,
7209 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007210 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007211 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007212 [ALC885_IMAC24] = {
7213 .mixers = { alc885_imac24_mixer },
7214 .init_verbs = { alc885_imac24_init_verbs },
7215 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7216 .dac_nids = alc882_dac_nids,
7217 .dig_out_nid = ALC882_DIGOUT_NID,
7218 .dig_in_nid = ALC882_DIGIN_NID,
7219 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7220 .channel_mode = alc882_ch_modes,
7221 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007222 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007223 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007224 },
Kailang Yang272a5272007-05-14 11:00:38 +02007225 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007226 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007227 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7228 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7229 .dac_nids = alc882_dac_nids,
7230 .dig_out_nid = ALC882_DIGOUT_NID,
7231 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7232 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007233 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007234 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7235 .channel_mode = alc882_3ST_6ch_modes,
7236 .need_dac_fix = 1,
7237 .input_mux = &alc882_capture_source,
7238 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007239 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007240 },
7241 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007242 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007243 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7244 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7245 .dac_nids = alc882_dac_nids,
7246 .dig_out_nid = ALC882_DIGOUT_NID,
7247 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7248 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007249 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007250 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7251 .channel_mode = alc882_3ST_6ch_modes,
7252 .need_dac_fix = 1,
7253 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007254 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007255 [ALC882_ASUS_A7M] = {
7256 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7257 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7258 alc880_gpio1_init_verbs,
7259 alc882_asus_a7m_verbs },
7260 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7261 .dac_nids = alc882_dac_nids,
7262 .dig_out_nid = ALC882_DIGOUT_NID,
7263 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7264 .channel_mode = alc880_threestack_modes,
7265 .need_dac_fix = 1,
7266 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007267 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007268};
7269
7270
7271/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007272 * Pin config fixes
7273 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007274enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007275 PINFIX_ABIT_AW9D_MAX
7276};
7277
7278static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7279 { 0x15, 0x01080104 }, /* side */
7280 { 0x16, 0x01011012 }, /* rear */
7281 { 0x17, 0x01016011 }, /* clfe */
7282 { }
7283};
7284
7285static const struct alc_pincfg *alc882_pin_fixes[] = {
7286 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7287};
7288
7289static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7290 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7291 {}
7292};
7293
7294/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007295 * BIOS auto configuration
7296 */
7297static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7298 hda_nid_t nid, int pin_type,
7299 int dac_idx)
7300{
7301 /* set as output */
7302 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007303 int idx;
7304
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007305 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007306 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7307 idx = 4;
7308 else
7309 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007310 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7311
7312}
7313
7314static void alc882_auto_init_multi_out(struct hda_codec *codec)
7315{
7316 struct alc_spec *spec = codec->spec;
7317 int i;
7318
7319 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007320 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007321 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007322 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007323 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007324 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007325 }
7326}
7327
7328static void alc882_auto_init_hp_out(struct hda_codec *codec)
7329{
7330 struct alc_spec *spec = codec->spec;
7331 hda_nid_t pin;
7332
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007333 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007334 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007335 /* use dac 0 */
7336 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007337 pin = spec->autocfg.speaker_pins[0];
7338 if (pin)
7339 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007340}
7341
7342#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7343#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7344
7345static void alc882_auto_init_analog_input(struct hda_codec *codec)
7346{
7347 struct alc_spec *spec = codec->spec;
7348 int i;
7349
7350 for (i = 0; i < AUTO_PIN_LAST; i++) {
7351 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007352 if (!nid)
7353 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007354 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007355 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7356 snd_hda_codec_write(codec, nid, 0,
7357 AC_VERB_SET_AMP_GAIN_MUTE,
7358 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007359 }
7360}
7361
Takashi Iwaif511b012008-08-15 16:46:42 +02007362static void alc882_auto_init_input_src(struct hda_codec *codec)
7363{
7364 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007365 int c;
7366
7367 for (c = 0; c < spec->num_adc_nids; c++) {
7368 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7369 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007370 unsigned int mux_idx;
7371 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007372 int conns, mute, idx, item;
7373
7374 conns = snd_hda_get_connections(codec, nid, conn_list,
7375 ARRAY_SIZE(conn_list));
7376 if (conns < 0)
7377 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007378 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7379 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007380 for (idx = 0; idx < conns; idx++) {
7381 /* if the current connection is the selected one,
7382 * unmute it as default - otherwise mute it
7383 */
7384 mute = AMP_IN_MUTE(idx);
7385 for (item = 0; item < imux->num_items; item++) {
7386 if (imux->items[item].index == idx) {
7387 if (spec->cur_mux[c] == item)
7388 mute = AMP_IN_UNMUTE(idx);
7389 break;
7390 }
7391 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007392 /* check if we have a selector or mixer
7393 * we could check for the widget type instead, but
7394 * just check for Amp-In presence (in case of mixer
7395 * without amp-in there is something wrong, this
7396 * function shouldn't be used or capsrc nid is wrong)
7397 */
7398 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7399 snd_hda_codec_write(codec, nid, 0,
7400 AC_VERB_SET_AMP_GAIN_MUTE,
7401 mute);
7402 else if (mute != AMP_IN_MUTE(idx))
7403 snd_hda_codec_write(codec, nid, 0,
7404 AC_VERB_SET_CONNECT_SEL,
7405 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007406 }
7407 }
7408}
7409
Takashi Iwai776e1842007-08-29 15:07:11 +02007410/* add mic boosts if needed */
7411static int alc_auto_add_mic_boost(struct hda_codec *codec)
7412{
7413 struct alc_spec *spec = codec->spec;
7414 int err;
7415 hda_nid_t nid;
7416
7417 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007418 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007419 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7420 "Mic Boost",
7421 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7422 if (err < 0)
7423 return err;
7424 }
7425 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007426 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007427 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7428 "Front Mic Boost",
7429 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7430 if (err < 0)
7431 return err;
7432 }
7433 return 0;
7434}
7435
Kailang Yangdf694da2005-12-05 19:42:22 +01007436/* almost identical with ALC880 parser... */
7437static int alc882_parse_auto_config(struct hda_codec *codec)
7438{
7439 struct alc_spec *spec = codec->spec;
7440 int err = alc880_parse_auto_config(codec);
7441
7442 if (err < 0)
7443 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007444 else if (!err)
7445 return 0; /* no config found */
7446
7447 err = alc_auto_add_mic_boost(codec);
7448 if (err < 0)
7449 return err;
7450
7451 /* hack - override the init verbs */
7452 spec->init_verbs[0] = alc882_auto_init_verbs;
7453
7454 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007455}
7456
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007457/* additional initialization for auto-configuration model */
7458static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007459{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007460 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007461 alc882_auto_init_multi_out(codec);
7462 alc882_auto_init_hp_out(codec);
7463 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007464 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007465 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007466 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007467}
7468
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007469static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7470
Linus Torvalds1da177e2005-04-16 15:20:36 -07007471static int patch_alc882(struct hda_codec *codec)
7472{
7473 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007474 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007475
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007476 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007477 if (spec == NULL)
7478 return -ENOMEM;
7479
Linus Torvalds1da177e2005-04-16 15:20:36 -07007480 codec->spec = spec;
7481
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007482 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7483 alc882_models,
7484 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007485
Kailang Yangdf694da2005-12-05 19:42:22 +01007486 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007487 /* Pick up systems that don't supply PCI SSID */
7488 switch (codec->subsystem_id) {
7489 case 0x106b0c00: /* Mac Pro */
7490 board_config = ALC885_MACPRO;
7491 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007492 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007493 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007494 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007495 board_config = ALC885_IMAC24;
7496 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007497 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007498 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007499 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007500 case 0x106b2c00: /* Macbook Pro rev3 */
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007501 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
Luke Yelavich2a884642009-01-28 15:58:38 +11007502 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007503 board_config = ALC885_MBP3;
7504 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007505 case 0x106b3f00: /* Macbook 5,1 */
Takashi Iwai7442f9d2009-05-14 18:20:33 +02007506 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7507 * seems not working, so apparently
7508 * no perfect solution yet
7509 */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007510 board_config = ALC885_MB5;
7511 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007512 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007513 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007514 if (codec->revision_id == 0x100101 ||
7515 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007516 alc_free(codec);
7517 return patch_alc883(codec);
7518 }
Takashi Iwai6c627f32009-05-18 12:33:36 +02007519 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7520 "trying auto-probe from BIOS...\n",
7521 codec->chip_name);
Tobin Davis081d17c2007-02-15 17:46:18 +01007522 board_config = ALC882_AUTO;
7523 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007524 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007525
Takashi Iwaif95474e2007-07-10 00:47:43 +02007526 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7527
Kailang Yangdf694da2005-12-05 19:42:22 +01007528 if (board_config == ALC882_AUTO) {
7529 /* automatic parse from the BIOS config */
7530 err = alc882_parse_auto_config(codec);
7531 if (err < 0) {
7532 alc_free(codec);
7533 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007534 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007535 printk(KERN_INFO
7536 "hda_codec: Cannot set up configuration "
7537 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007538 board_config = ALC882_3ST_DIG;
7539 }
7540 }
7541
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007542 err = snd_hda_attach_beep_device(codec, 0x1);
7543 if (err < 0) {
7544 alc_free(codec);
7545 return err;
7546 }
7547
Kailang Yangdf694da2005-12-05 19:42:22 +01007548 if (board_config != ALC882_AUTO)
7549 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007550
Kailang Yangdf694da2005-12-05 19:42:22 +01007551 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7552 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007553 /* FIXME: setup DAC5 */
7554 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7555 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007556
Kailang Yangdf694da2005-12-05 19:42:22 +01007557 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7558 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007559
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007560 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007561 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007562 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007563 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007564 /* get type */
7565 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007566 if (wcap != AC_WID_AUD_IN) {
7567 spec->adc_nids = alc882_adc_nids_alt;
7568 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007569 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007570 } else {
7571 spec->adc_nids = alc882_adc_nids;
7572 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007573 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007574 }
7575 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007576 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007577 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007578
Takashi Iwai2134ea42008-01-10 16:53:55 +01007579 spec->vmaster_nid = 0x0c;
7580
Linus Torvalds1da177e2005-04-16 15:20:36 -07007581 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007582 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007583 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007584#ifdef CONFIG_SND_HDA_POWER_SAVE
7585 if (!spec->loopback.amplist)
7586 spec->loopback.amplist = alc882_loopbacks;
7587#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007588 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007589
7590 return 0;
7591}
7592
7593/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007594 * ALC883 support
7595 *
7596 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7597 * configuration. Each pin widget can choose any input DACs and a mixer.
7598 * Each ADC is connected from a mixer of all inputs. This makes possible
7599 * 6-channel independent captures.
7600 *
7601 * In addition, an independent DAC for the multi-playback (not used in this
7602 * driver yet).
7603 */
7604#define ALC883_DIGOUT_NID 0x06
7605#define ALC883_DIGIN_NID 0x0a
7606
Wu Fengguang3ab90932008-11-17 09:51:09 +01007607#define ALC1200_DIGOUT_NID 0x10
7608
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007609static hda_nid_t alc883_dac_nids[4] = {
7610 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007611 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007612};
7613
7614static hda_nid_t alc883_adc_nids[2] = {
7615 /* ADC1-2 */
7616 0x08, 0x09,
7617};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007618
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007619static hda_nid_t alc883_adc_nids_alt[1] = {
7620 /* ADC1 */
7621 0x08,
7622};
7623
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007624static hda_nid_t alc883_adc_nids_rev[2] = {
7625 /* ADC2-1 */
7626 0x09, 0x08
7627};
7628
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007629#define alc889_adc_nids alc880_adc_nids
7630
Takashi Iwaie1406342008-02-11 18:32:32 +01007631static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7632
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007633static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7634
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007635#define alc889_capsrc_nids alc882_capsrc_nids
7636
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007637/* input MUX */
7638/* FIXME: should be a matrix-type input source selection */
7639
7640static struct hda_input_mux alc883_capture_source = {
7641 .num_items = 4,
7642 .items = {
7643 { "Mic", 0x0 },
7644 { "Front Mic", 0x1 },
7645 { "Line", 0x2 },
7646 { "CD", 0x4 },
7647 },
7648};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007649
Jiang zhe17bba1b2008-06-04 12:11:07 +02007650static struct hda_input_mux alc883_3stack_6ch_intel = {
7651 .num_items = 4,
7652 .items = {
7653 { "Mic", 0x1 },
7654 { "Front Mic", 0x0 },
7655 { "Line", 0x2 },
7656 { "CD", 0x4 },
7657 },
7658};
7659
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007660static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7661 .num_items = 2,
7662 .items = {
7663 { "Mic", 0x1 },
7664 { "Line", 0x2 },
7665 },
7666};
7667
Kailang Yang272a5272007-05-14 11:00:38 +02007668static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7669 .num_items = 4,
7670 .items = {
7671 { "Mic", 0x0 },
7672 { "iMic", 0x1 },
7673 { "Line", 0x2 },
7674 { "CD", 0x4 },
7675 },
7676};
7677
Jiang zhefb97dc62008-03-06 11:07:11 +01007678static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7679 .num_items = 2,
7680 .items = {
7681 { "Mic", 0x0 },
7682 { "Int Mic", 0x1 },
7683 },
7684};
7685
Kailang Yange2757d52008-08-26 13:17:46 +02007686static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7687 .num_items = 3,
7688 .items = {
7689 { "Mic", 0x0 },
7690 { "Front Mic", 0x1 },
7691 { "Line", 0x4 },
7692 },
7693};
7694
7695static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7696 .num_items = 2,
7697 .items = {
7698 { "Mic", 0x0 },
7699 { "Line", 0x2 },
7700 },
7701};
7702
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007703static struct hda_input_mux alc889A_mb31_capture_source = {
7704 .num_items = 2,
7705 .items = {
7706 { "Mic", 0x0 },
7707 /* Front Mic (0x01) unused */
7708 { "Line", 0x2 },
7709 /* Line 2 (0x03) unused */
7710 /* CD (0x04) unsused? */
7711 },
7712};
7713
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007714/*
7715 * 2ch mode
7716 */
7717static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7718 { 2, NULL }
7719};
7720
7721/*
7722 * 2ch mode
7723 */
7724static struct hda_verb alc883_3ST_ch2_init[] = {
7725 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7726 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7727 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7728 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7729 { } /* end */
7730};
7731
7732/*
Tobin Davisb2011312007-09-17 12:45:11 +02007733 * 4ch mode
7734 */
7735static struct hda_verb alc883_3ST_ch4_init[] = {
7736 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7737 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7738 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7739 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7740 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7741 { } /* end */
7742};
7743
7744/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007745 * 6ch mode
7746 */
7747static struct hda_verb alc883_3ST_ch6_init[] = {
7748 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7749 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7750 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7751 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7752 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7753 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7754 { } /* end */
7755};
7756
Tobin Davisb2011312007-09-17 12:45:11 +02007757static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007758 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007759 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007760 { 6, alc883_3ST_ch6_init },
7761};
7762
David Heidelberger64a8be72009-06-08 16:15:18 +02007763
7764/*
7765 * 2ch mode
7766 */
7767static struct hda_verb alc883_4ST_ch2_init[] = {
Takashi Iwaif03ecf52009-06-08 16:38:17 +02007768 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
David Heidelberger64a8be72009-06-08 16:15:18 +02007769 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7770 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7771 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7772 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7773 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7774 { } /* end */
7775};
7776
7777/*
7778 * 4ch mode
7779 */
7780static struct hda_verb alc883_4ST_ch4_init[] = {
7781 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7782 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7783 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7784 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7785 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7786 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7787 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7788 { } /* end */
7789};
7790
7791/*
7792 * 6ch mode
7793 */
7794static struct hda_verb alc883_4ST_ch6_init[] = {
7795 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7796 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7797 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7798 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7799 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7800 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7801 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7802 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7803 { } /* end */
7804};
7805
7806/*
7807 * 8ch mode
7808 */
7809static struct hda_verb alc883_4ST_ch8_init[] = {
7810 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7811 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7812 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7813 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7814 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7815 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7816 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7817 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7818 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7819 { } /* end */
7820};
7821
7822static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7823 { 2, alc883_4ST_ch2_init },
7824 { 4, alc883_4ST_ch4_init },
7825 { 6, alc883_4ST_ch6_init },
7826 { 8, alc883_4ST_ch8_init },
7827};
7828
7829
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007830/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007831 * 2ch mode
7832 */
7833static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7834 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7835 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7836 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7837 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7838 { } /* end */
7839};
7840
7841/*
7842 * 4ch mode
7843 */
7844static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7845 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7846 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7847 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7848 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7849 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7850 { } /* end */
7851};
7852
7853/*
7854 * 6ch mode
7855 */
7856static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7857 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7858 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7859 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7860 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7861 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7862 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7863 { } /* end */
7864};
7865
7866static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7867 { 2, alc883_3ST_ch2_intel_init },
7868 { 4, alc883_3ST_ch4_intel_init },
7869 { 6, alc883_3ST_ch6_intel_init },
7870};
7871
7872/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007873 * 6ch mode
7874 */
7875static struct hda_verb alc883_sixstack_ch6_init[] = {
7876 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7877 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7878 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7879 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7880 { } /* end */
7881};
7882
7883/*
7884 * 8ch mode
7885 */
7886static struct hda_verb alc883_sixstack_ch8_init[] = {
7887 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7888 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7889 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7890 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7891 { } /* end */
7892};
7893
7894static struct hda_channel_mode alc883_sixstack_modes[2] = {
7895 { 6, alc883_sixstack_ch6_init },
7896 { 8, alc883_sixstack_ch8_init },
7897};
7898
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007899/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7900static struct hda_verb alc889A_mb31_ch2_init[] = {
7901 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7902 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7903 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7904 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7905 { } /* end */
7906};
7907
7908/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7909static struct hda_verb alc889A_mb31_ch4_init[] = {
7910 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7911 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7912 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7913 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7914 { } /* end */
7915};
7916
7917/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7918static struct hda_verb alc889A_mb31_ch5_init[] = {
7919 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7920 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7921 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7922 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7923 { } /* end */
7924};
7925
7926/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7927static struct hda_verb alc889A_mb31_ch6_init[] = {
7928 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7929 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7930 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7931 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7932 { } /* end */
7933};
7934
7935static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7936 { 2, alc889A_mb31_ch2_init },
7937 { 4, alc889A_mb31_ch4_init },
7938 { 5, alc889A_mb31_ch5_init },
7939 { 6, alc889A_mb31_ch6_init },
7940};
7941
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007942static struct hda_verb alc883_medion_eapd_verbs[] = {
7943 /* eanable EAPD on medion laptop */
7944 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7945 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7946 { }
7947};
7948
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007949/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7950 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7951 */
7952
7953static struct snd_kcontrol_new alc883_base_mixer[] = {
7954 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7955 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7956 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7957 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7958 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7959 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7960 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7961 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7962 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7963 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7965 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7966 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007970 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007971 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7972 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007973 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007974 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007975 { } /* end */
7976};
7977
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007978static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7979 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7980 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7981 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7982 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7983 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7984 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7985 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7987 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7988 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7989 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7991 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007992 { } /* end */
7993};
7994
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007995static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007996 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7997 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7998 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7999 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8001 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8003 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8004 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8005 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008006 { } /* end */
8007};
8008
Jiang zhefb97dc62008-03-06 11:07:11 +01008009static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8010 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8011 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8012 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8013 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8014 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8015 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8016 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8017 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8018 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8019 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008020 { } /* end */
8021};
8022
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008023static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8024 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8025 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8027 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8028 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8029 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8030 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008032 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008033 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8034 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008035 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008036 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008037 { } /* end */
8038};
8039
8040static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8041 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8043 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8044 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8045 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8046 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8047 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8048 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8049 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
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),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008056 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8057 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008058 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008059 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008060 { } /* end */
8061};
8062
Jiang zhe17bba1b2008-06-04 12:11:07 +02008063static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8064 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8065 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8066 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8067 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8068 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8069 HDA_OUTPUT),
8070 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8071 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8072 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8073 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8074 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8075 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8076 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8077 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8078 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8079 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8080 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8081 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8082 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8083 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008084 { } /* end */
8085};
8086
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008087static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008088 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008089 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008090 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008091 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008092 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8093 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008094 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8095 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008096 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8097 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8098 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8099 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8100 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008102 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008103 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8104 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008105 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008106 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008107 { } /* end */
8108};
8109
Sasha Alexandrc2592492009-06-16 14:52:54 -04008110static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008111 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", 0x1b, 0x0, HDA_OUTPUT),
8114 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8115 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8116 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8117 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8118 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8119 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8120 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8121 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8122 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8123 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008125 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008127 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008128};
Kailang Yangccc656c2006-10-17 12:32:26 +02008129
Sasha Alexandrc2592492009-06-16 14:52:54 -04008130static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008131 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8132 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8133 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8134 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8135 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008137 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008139 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8140 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8141 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008142 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008143};
Kailang Yangccc656c2006-10-17 12:32:26 +02008144
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008145static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8146 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8147 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008148 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8149 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008150 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8151 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8152 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8153 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008154 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008155};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008156
Kailang Yang272a5272007-05-14 11:00:38 +02008157static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8158 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8159 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8160 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8161 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8162 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8165 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8166 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008167 { } /* end */
8168};
8169
8170static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8171 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8173 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8174 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8175 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8178 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8179 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008180 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008181};
Kailang Yang272a5272007-05-14 11:00:38 +02008182
Tobin Davis2880a862007-08-07 11:50:26 +02008183static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008184 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8185 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008186 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008187 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8188 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008189 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8190 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008192 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008193};
Tobin Davis2880a862007-08-07 11:50:26 +02008194
Tony Vroond2fd4b02009-06-21 00:40:10 +01008195static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8196 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8197 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8198 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8199 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
8200 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8201 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8203 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8205 { } /* end */
8206};
8207
Kailang Yange2757d52008-08-26 13:17:46 +02008208static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8209 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8210 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8211 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8212 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8213 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8214 0x0d, 1, 0x0, HDA_OUTPUT),
8215 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8216 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8217 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8218 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8219 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008220 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8221 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8222 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8223 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8225 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8227 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8228 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8229 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008230 { } /* end */
8231};
8232
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008233static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8234 /* Output mixers */
8235 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8236 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8237 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8238 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8239 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8240 HDA_OUTPUT),
8241 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8242 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8243 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8244 /* Output switches */
8245 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8246 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8247 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8248 /* Boost mixers */
8249 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8250 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8251 /* Input mixers */
8252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8253 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8254 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8255 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8256 { } /* end */
8257};
8258
Guido Günther3e1647c2009-06-05 00:47:26 +02008259static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8260 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8261 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8262 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8263 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8264 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8265 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8266 { } /* end */
8267};
8268
Kailang Yange2757d52008-08-26 13:17:46 +02008269static struct hda_bind_ctls alc883_bind_cap_vol = {
8270 .ops = &snd_hda_bind_vol,
8271 .values = {
8272 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8273 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8274 0
8275 },
8276};
8277
8278static struct hda_bind_ctls alc883_bind_cap_switch = {
8279 .ops = &snd_hda_bind_sw,
8280 .values = {
8281 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8282 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8283 0
8284 },
8285};
8286
8287static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8288 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8289 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8290 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8291 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8292 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8293 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8294 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008296 { } /* end */
8297};
8298
8299static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008300 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8301 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8302 {
8303 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8304 /* .name = "Capture Source", */
8305 .name = "Input Source",
8306 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008307 .info = alc_mux_enum_info,
8308 .get = alc_mux_enum_get,
8309 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008310 },
8311 { } /* end */
8312};
8313
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008314static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8315 {
8316 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8317 .name = "Channel Mode",
8318 .info = alc_ch_mode_info,
8319 .get = alc_ch_mode_get,
8320 .put = alc_ch_mode_put,
8321 },
8322 { } /* end */
8323};
8324
8325static struct hda_verb alc883_init_verbs[] = {
8326 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02008327 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008328 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8329 /* ADC2: mute amp left and right */
8330 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8331 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8332 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8336 /* Rear mixer */
8337 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8338 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8339 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8340 /* CLFE mixer */
8341 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8342 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8343 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8344 /* Side mixer */
8345 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8346 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8347 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8348
Takashi Iwaicb53c622007-08-10 17:21:45 +02008349 /* mute analog input loopbacks */
8350 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8351 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8352 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8353 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8354 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008355
8356 /* Front Pin: output 0 (0x0c) */
8357 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8358 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8359 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8360 /* Rear Pin: output 1 (0x0d) */
8361 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8363 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8364 /* CLFE Pin: output 2 (0x0e) */
8365 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8366 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8367 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8368 /* Side Pin: output 3 (0x0f) */
8369 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8370 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8371 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8372 /* Mic (rear) pin: input vref at 80% */
8373 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8374 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8375 /* Front Mic pin: input vref at 80% */
8376 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8377 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8378 /* Line In pin: input */
8379 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8380 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8381 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8382 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8383 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8384 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8385 /* CD pin widget for input */
8386 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8387
8388 /* FIXME: use matrix-type input source selection */
8389 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8390 /* Input mixer2 */
8391 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008392 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008395 /* Input mixer3 */
8396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008397 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8398 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008400 { }
8401};
8402
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008403/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008404static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008405{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008406 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008407
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008408 spec->autocfg.hp_pins[0] = 0x15;
8409 spec->autocfg.speaker_pins[0] = 0x14;
8410 spec->autocfg.speaker_pins[1] = 0x17;
8411 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008412}
8413
8414/* auto-toggle front mic */
8415/*
8416static void alc883_mitac_mic_automute(struct hda_codec *codec)
8417{
8418 unsigned int present;
8419 unsigned char bits;
8420
8421 present = snd_hda_codec_read(codec, 0x18, 0,
8422 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8423 bits = present ? HDA_AMP_MUTE : 0;
8424 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8425}
8426*/
8427
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008428static struct hda_verb alc883_mitac_verbs[] = {
8429 /* HP */
8430 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8431 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8432 /* Subwoofer */
8433 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8434 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8435
8436 /* enable unsolicited event */
8437 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8438 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8439
8440 { } /* end */
8441};
8442
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008443static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008444 /* HP */
8445 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8446 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8447 /* Int speaker */
8448 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8449 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8450
8451 /* enable unsolicited event */
8452 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008453 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008454
8455 { } /* end */
8456};
8457
Jiang zhefb97dc62008-03-06 11:07:11 +01008458static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8459 /* HP */
8460 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8462 /* Subwoofer */
8463 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8465
8466 /* enable unsolicited event */
8467 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8468
8469 { } /* end */
8470};
8471
Sasha Alexandrc2592492009-06-16 14:52:54 -04008472static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8474 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8475
8476 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8477 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008478
David Heidelberger64a8be72009-06-08 16:15:18 +02008479/* Connect Line-Out side jack (SPDIF) to Side */
8480 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8481 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8482 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8483/* Connect Mic jack to CLFE */
8484 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8485 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8486 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8487/* Connect Line-in jack to Surround */
8488 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8489 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8490 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8491/* Connect HP out jack to Front */
8492 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8493 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8494 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008495
8496 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008497
8498 { } /* end */
8499};
8500
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008501static struct hda_verb alc883_lenovo_101e_verbs[] = {
8502 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8503 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8504 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8505 { } /* end */
8506};
8507
Kailang Yang272a5272007-05-14 11:00:38 +02008508static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8509 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8510 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8511 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8512 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8513 { } /* end */
8514};
8515
8516static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8519 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8520 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8521 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8522 { } /* end */
8523};
8524
Kailang Yang189609a2007-08-20 11:31:23 +02008525static struct hda_verb alc883_haier_w66_verbs[] = {
8526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8527 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8528
8529 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8530
8531 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8532 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8533 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8535 { } /* end */
8536};
8537
Kailang Yange2757d52008-08-26 13:17:46 +02008538static struct hda_verb alc888_lenovo_sky_verbs[] = {
8539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8542 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8543 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8544 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8545 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8546 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8547 { } /* end */
8548};
8549
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008550static struct hda_verb alc888_6st_dell_verbs[] = {
8551 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8552 { }
8553};
8554
Guido Günther3e1647c2009-06-05 00:47:26 +02008555static struct hda_verb alc883_vaiott_verbs[] = {
8556 /* HP */
8557 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8558 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8559
8560 /* enable unsolicited event */
8561 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8562
8563 { } /* end */
8564};
8565
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008566static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008567{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008568 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008569
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008570 spec->autocfg.hp_pins[0] = 0x1b;
8571 spec->autocfg.speaker_pins[0] = 0x14;
8572 spec->autocfg.speaker_pins[1] = 0x16;
8573 spec->autocfg.speaker_pins[2] = 0x18;
8574 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008575}
8576
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008577static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008578 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008579 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8580 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008581 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008582 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008583};
8584
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008585/*
8586 * 2ch mode
8587 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008588static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008589 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8590 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8591 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8592 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008593 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008594};
8595
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008596/*
8597 * 4ch mode
8598 */
8599static struct hda_verb alc888_3st_hp_4ch_init[] = {
8600 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8601 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8602 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8603 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8604 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8605 { } /* end */
8606};
8607
8608/*
8609 * 6ch mode
8610 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008611static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008612 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8613 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008614 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008615 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8616 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008617 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8618 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008619};
8620
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008621static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008622 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008623 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008624 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008625};
8626
Kailang Yang272a5272007-05-14 11:00:38 +02008627/* toggle front-jack and RCA according to the hp-jack state */
8628static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8629{
8630 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008631
Kailang Yang272a5272007-05-14 11:00:38 +02008632 present = snd_hda_codec_read(codec, 0x1b, 0,
8633 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008634 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8635 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8636 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8637 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008638}
8639
8640/* toggle RCA according to the front-jack state */
8641static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8642{
8643 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008644
Kailang Yang272a5272007-05-14 11:00:38 +02008645 present = snd_hda_codec_read(codec, 0x14, 0,
8646 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008647 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8648 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008649}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008650
Kailang Yang272a5272007-05-14 11:00:38 +02008651static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8652 unsigned int res)
8653{
8654 if ((res >> 26) == ALC880_HP_EVENT)
8655 alc888_lenovo_ms7195_front_automute(codec);
8656 if ((res >> 26) == ALC880_FRONT_EVENT)
8657 alc888_lenovo_ms7195_rca_automute(codec);
8658}
8659
8660static struct hda_verb alc883_medion_md2_verbs[] = {
8661 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8662 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8663
8664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8665
8666 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8667 { } /* end */
8668};
8669
8670/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008671static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008672{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008673 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008674
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008675 spec->autocfg.hp_pins[0] = 0x14;
8676 spec->autocfg.speaker_pins[0] = 0x15;
8677 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008678}
8679
Kailang Yangccc656c2006-10-17 12:32:26 +02008680/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008681#define alc883_targa_init_hook alc882_targa_init_hook
8682#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008683
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008684static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8685{
8686 unsigned int present;
8687
8688 present = snd_hda_codec_read(codec, 0x18, 0,
8689 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8690 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8691 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8692}
8693
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008694static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008695{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008696 struct alc_spec *spec = codec->spec;
8697
8698 spec->autocfg.hp_pins[0] = 0x15;
8699 spec->autocfg.speaker_pins[0] = 0x14;
8700 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008701 alc883_clevo_m720_mic_automute(codec);
8702}
8703
8704static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008705 unsigned int res)
8706{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008707 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008708 case ALC880_MIC_EVENT:
8709 alc883_clevo_m720_mic_automute(codec);
8710 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008711 default:
8712 alc_automute_amp_unsol_event(codec, res);
8713 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008714 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008715}
8716
Jiang zhefb97dc62008-03-06 11:07:11 +01008717/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008718static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008719{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008720 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008721
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008722 spec->autocfg.hp_pins[0] = 0x14;
8723 spec->autocfg.speaker_pins[0] = 0x15;
8724 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008725}
8726
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008727static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008728{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008729 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008730
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008731 spec->autocfg.hp_pins[0] = 0x1b;
8732 spec->autocfg.speaker_pins[0] = 0x14;
8733 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008734}
8735
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008736static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8737{
8738 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008739 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008740
David Heidelberger64a8be72009-06-08 16:15:18 +02008741 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8742 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008743 bits = present ? HDA_AMP_MUTE : 0;
8744 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8745 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008746}
8747
8748static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8749{
8750 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008751 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008752
8753 present = snd_hda_codec_read(codec, 0x1b, 0,
8754 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008755 bits = present ? HDA_AMP_MUTE : 0;
8756 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8757 HDA_AMP_MUTE, bits);
8758 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8759 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008760}
8761
8762static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8763 unsigned int res)
8764{
8765 if ((res >> 26) == ALC880_HP_EVENT)
8766 alc883_lenovo_101e_all_automute(codec);
8767 if ((res >> 26) == ALC880_FRONT_EVENT)
8768 alc883_lenovo_101e_ispeaker_automute(codec);
8769}
8770
Takashi Iwai676a9b52007-08-16 15:23:35 +02008771/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008772static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008773{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008774 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008775
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008776 spec->autocfg.hp_pins[0] = 0x14;
8777 spec->autocfg.speaker_pins[0] = 0x15;
8778 spec->autocfg.speaker_pins[1] = 0x16;
8779 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008780}
8781
Kailang Yangd1a991a2007-08-15 16:21:59 +02008782static struct hda_verb alc883_acer_eapd_verbs[] = {
8783 /* HP Pin: output 0 (0x0c) */
8784 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8785 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8786 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8787 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8789 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008790 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008791 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8792 /* eanable EAPD on medion laptop */
8793 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8794 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008795 /* enable unsolicited event */
8796 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008797 { }
8798};
8799
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008800static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008801{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008802 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008803
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008804 spec->autocfg.hp_pins[0] = 0x1b;
8805 spec->autocfg.speaker_pins[0] = 0x14;
8806 spec->autocfg.speaker_pins[1] = 0x15;
8807 spec->autocfg.speaker_pins[2] = 0x16;
8808 spec->autocfg.speaker_pins[3] = 0x17;
8809 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008810}
8811
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008812static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008813{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008814 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008815
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008816 spec->autocfg.hp_pins[0] = 0x1b;
8817 spec->autocfg.speaker_pins[0] = 0x14;
8818 spec->autocfg.speaker_pins[1] = 0x15;
8819 spec->autocfg.speaker_pins[2] = 0x16;
8820 spec->autocfg.speaker_pins[3] = 0x17;
8821 spec->autocfg.speaker_pins[4] = 0x1a;
8822 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008823}
8824
Guido Günther3e1647c2009-06-05 00:47:26 +02008825static void alc883_vaiott_init_hook(struct hda_codec *codec)
8826{
8827 struct alc_spec *spec = codec->spec;
8828
8829 spec->autocfg.hp_pins[0] = 0x15;
8830 spec->autocfg.speaker_pins[0] = 0x14;
8831 spec->autocfg.speaker_pins[1] = 0x17;
8832 alc_automute_amp(codec);
8833}
8834
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008835/*
8836 * generic initialization of ADC, input mixers and output mixers
8837 */
8838static struct hda_verb alc883_auto_init_verbs[] = {
8839 /*
8840 * Unmute ADC0-2 and set the default input to mic-in
8841 */
8842 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8843 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8844 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8845 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8846
Takashi Iwaicb53c622007-08-10 17:21:45 +02008847 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008848 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008849 * Note: PASD motherboards uses the Line In 2 as the input for
8850 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008851 */
8852 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008858
8859 /*
8860 * Set up output mixers (0x0c - 0x0f)
8861 */
8862 /* set vol=0 to output mixers */
8863 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8864 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8865 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8866 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8867 /* set up input amps for analog loopback */
8868 /* Amp Indices: DAC = 0, mixer = 1 */
8869 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8870 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8871 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8872 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8873 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8874 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8875 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8876 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8877 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8878 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8879
8880 /* FIXME: use matrix-type input source selection */
8881 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8882 /* Input mixer1 */
8883 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8884 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8885 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008886 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008887 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8888 /* Input mixer2 */
8889 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8890 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8891 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008892 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008893 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008894
8895 { }
8896};
8897
Kailang Yange2757d52008-08-26 13:17:46 +02008898static struct hda_verb alc888_asus_m90v_verbs[] = {
8899 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8900 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8901 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8902 /* enable unsolicited event */
8903 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8904 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8905 { } /* end */
8906};
8907
8908static void alc883_nb_mic_automute(struct hda_codec *codec)
8909{
8910 unsigned int present;
8911
8912 present = snd_hda_codec_read(codec, 0x18, 0,
8913 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8914 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8915 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8916 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8917 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8918}
8919
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008920static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008921{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008922 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008923
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008924 spec->autocfg.hp_pins[0] = 0x1b;
8925 spec->autocfg.speaker_pins[0] = 0x14;
8926 spec->autocfg.speaker_pins[1] = 0x15;
8927 spec->autocfg.speaker_pins[2] = 0x16;
8928 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008929}
8930
8931static void alc883_mode2_unsol_event(struct hda_codec *codec,
8932 unsigned int res)
8933{
8934 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008935 case ALC880_MIC_EVENT:
8936 alc883_nb_mic_automute(codec);
8937 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008938 default:
8939 alc_sku_unsol_event(codec, res);
8940 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008941 }
8942}
8943
8944static void alc883_mode2_inithook(struct hda_codec *codec)
8945{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008946 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008947 alc883_nb_mic_automute(codec);
8948}
8949
8950static struct hda_verb alc888_asus_eee1601_verbs[] = {
8951 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8952 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8954 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8955 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8956 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8957 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8958 /* enable unsolicited event */
8959 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8960 { } /* end */
8961};
8962
Kailang Yange2757d52008-08-26 13:17:46 +02008963static void alc883_eee1601_inithook(struct hda_codec *codec)
8964{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008965 struct alc_spec *spec = codec->spec;
8966
8967 spec->autocfg.hp_pins[0] = 0x14;
8968 spec->autocfg.speaker_pins[0] = 0x1b;
8969 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008970}
8971
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008972static struct hda_verb alc889A_mb31_verbs[] = {
8973 /* Init rear pin (used as headphone output) */
8974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8975 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8976 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8977 /* Init line pin (used as output in 4ch and 6ch mode) */
8978 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8979 /* Init line 2 pin (used as headphone out by default) */
8980 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8981 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8982 { } /* end */
8983};
8984
8985/* Mute speakers according to the headphone jack state */
8986static void alc889A_mb31_automute(struct hda_codec *codec)
8987{
8988 unsigned int present;
8989
8990 /* Mute only in 2ch or 4ch mode */
8991 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8992 == 0x00) {
8993 present = snd_hda_codec_read(codec, 0x15, 0,
8994 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8995 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8996 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8997 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8998 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8999 }
9000}
9001
9002static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9003{
9004 if ((res >> 26) == ALC880_HP_EVENT)
9005 alc889A_mb31_automute(codec);
9006}
9007
Takashi Iwaicb53c622007-08-10 17:21:45 +02009008#ifdef CONFIG_SND_HDA_POWER_SAVE
9009#define alc883_loopbacks alc880_loopbacks
9010#endif
9011
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009012/* pcm configuration: identical with ALC880 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009013#define alc883_pcm_analog_playback alc880_pcm_analog_playback
9014#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01009015#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009016#define alc883_pcm_digital_playback alc880_pcm_digital_playback
9017#define alc883_pcm_digital_capture alc880_pcm_digital_capture
9018
9019/*
9020 * configuration and preset
9021 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009022static const char *alc883_models[ALC883_MODEL_LAST] = {
9023 [ALC883_3ST_2ch_DIG] = "3stack-dig",
9024 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9025 [ALC883_3ST_6ch] = "3stack-6ch",
9026 [ALC883_6ST_DIG] = "6stack-dig",
9027 [ALC883_TARGA_DIG] = "targa-dig",
9028 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009029 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009030 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009031 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009032 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009033 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009034 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009035 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009036 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009037 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009038 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009039 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9040 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009041 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009042 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009043 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009044 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009045 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009046 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009047 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009048 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009049 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009050 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009051 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009052 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009053 [ALC883_AUTO] = "auto",
9054};
9055
9056static struct snd_pci_quirk alc883_cfg_tbl[] = {
9057 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009058 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009059 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009060 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009061 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9062 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009063 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009064 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9065 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009066 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
9067 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009068 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9069 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009070 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9071 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01009072 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01009073 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009074 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
9075 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009076 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009077 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009078 /* default Acer -- disabled as it causes more problems.
9079 * model=auto should work fine now
9080 */
9081 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009082 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02009083 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009084 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9085 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009086 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009087 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009088 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009089 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009090 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009091 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009092 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009093 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02009094 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009095 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009096 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009097 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9098 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009099 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009100 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02009101 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009102 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9103 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9104 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02009105 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009106 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009107 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009108 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9109 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9110 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9111 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9112 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9113 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
9114 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9115 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9116 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009117 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009118 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9119 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009120 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009121 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009122 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009123 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009124 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009125 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009126 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009127 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009128 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9129 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009130 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009131 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009132 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009133 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009134 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009135 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009136 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009137 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009138 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009139 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9140 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009141 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009142 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009143 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009144 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009145 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009146 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9147 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009148 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08009149 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009150 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Guido Günther3e1647c2009-06-05 00:47:26 +02009151 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009152 {}
9153};
9154
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009155static hda_nid_t alc883_slave_dig_outs[] = {
9156 ALC1200_DIGOUT_NID, 0,
9157};
9158
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009159static hda_nid_t alc1200_slave_dig_outs[] = {
9160 ALC883_DIGOUT_NID, 0,
9161};
9162
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009163static struct alc_config_preset alc883_presets[] = {
9164 [ALC883_3ST_2ch_DIG] = {
9165 .mixers = { alc883_3ST_2ch_mixer },
9166 .init_verbs = { alc883_init_verbs },
9167 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9168 .dac_nids = alc883_dac_nids,
9169 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009170 .dig_in_nid = ALC883_DIGIN_NID,
9171 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9172 .channel_mode = alc883_3ST_2ch_modes,
9173 .input_mux = &alc883_capture_source,
9174 },
9175 [ALC883_3ST_6ch_DIG] = {
9176 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9177 .init_verbs = { alc883_init_verbs },
9178 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9179 .dac_nids = alc883_dac_nids,
9180 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009181 .dig_in_nid = ALC883_DIGIN_NID,
9182 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9183 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009184 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009185 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009186 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009187 [ALC883_3ST_6ch] = {
9188 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9189 .init_verbs = { alc883_init_verbs },
9190 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9191 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009192 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9193 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009194 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009195 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009196 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009197 [ALC883_3ST_6ch_INTEL] = {
9198 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9199 .init_verbs = { alc883_init_verbs },
9200 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9201 .dac_nids = alc883_dac_nids,
9202 .dig_out_nid = ALC883_DIGOUT_NID,
9203 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009204 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009205 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9206 .channel_mode = alc883_3ST_6ch_intel_modes,
9207 .need_dac_fix = 1,
9208 .input_mux = &alc883_3stack_6ch_intel,
9209 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009210 [ALC883_6ST_DIG] = {
9211 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9212 .init_verbs = { alc883_init_verbs },
9213 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9214 .dac_nids = alc883_dac_nids,
9215 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009216 .dig_in_nid = ALC883_DIGIN_NID,
9217 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9218 .channel_mode = alc883_sixstack_modes,
9219 .input_mux = &alc883_capture_source,
9220 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009221 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009222 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
9223 .init_verbs = { alc883_init_verbs, alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009224 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9225 .dac_nids = alc883_dac_nids,
9226 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009227 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9228 .channel_mode = alc883_3ST_6ch_modes,
9229 .need_dac_fix = 1,
9230 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009231 .unsol_event = alc883_targa_unsol_event,
9232 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009233 },
9234 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009235 .mixers = { alc883_targa_2ch_mixer},
9236 .init_verbs = { alc883_init_verbs, alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009237 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9238 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009239 .adc_nids = alc883_adc_nids_alt,
9240 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009241 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009242 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9243 .channel_mode = alc883_3ST_2ch_modes,
9244 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009245 .unsol_event = alc883_targa_unsol_event,
9246 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009247 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009248 [ALC883_TARGA_8ch_DIG] = {
9249 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9250 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009251 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009252 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9253 .dac_nids = alc883_dac_nids,
9254 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9255 .adc_nids = alc883_adc_nids_rev,
9256 .capsrc_nids = alc883_capsrc_nids_rev,
9257 .dig_out_nid = ALC883_DIGOUT_NID,
9258 .dig_in_nid = ALC883_DIGIN_NID,
9259 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9260 .channel_mode = alc883_4ST_8ch_modes,
9261 .need_dac_fix = 1,
9262 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009263 .unsol_event = alc883_targa_unsol_event,
9264 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02009265 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009266 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009267 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009268 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9269 * and the headphone jack. Turn this on and rely on the
9270 * standard mute methods whenever the user wants to turn
9271 * these outputs off.
9272 */
9273 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9274 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9275 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009276 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9277 .channel_mode = alc883_3ST_2ch_modes,
9278 .input_mux = &alc883_capture_source,
9279 },
Tobin Davis2880a862007-08-07 11:50:26 +02009280 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009281 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009282 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009283 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9284 .dac_nids = alc883_dac_nids,
9285 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009286 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9287 .channel_mode = alc883_3ST_2ch_modes,
9288 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009289 .unsol_event = alc_automute_amp_unsol_event,
9290 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009291 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009292 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009293 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009294 alc883_chmode_mixer },
9295 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9296 alc888_acer_aspire_4930g_verbs },
9297 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9298 .dac_nids = alc883_dac_nids,
9299 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9300 .adc_nids = alc883_adc_nids_rev,
9301 .capsrc_nids = alc883_capsrc_nids_rev,
9302 .dig_out_nid = ALC883_DIGOUT_NID,
9303 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9304 .channel_mode = alc883_3ST_6ch_modes,
9305 .need_dac_fix = 1,
9306 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009307 ARRAY_SIZE(alc888_2_capture_sources),
9308 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009309 .unsol_event = alc_automute_amp_unsol_event,
9310 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009311 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009312 [ALC888_ACER_ASPIRE_6530G] = {
9313 .mixers = { alc888_acer_aspire_6530_mixer },
9314 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9315 alc888_acer_aspire_6530g_verbs },
9316 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9317 .dac_nids = alc883_dac_nids,
9318 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9319 .adc_nids = alc883_adc_nids_rev,
9320 .capsrc_nids = alc883_capsrc_nids_rev,
9321 .dig_out_nid = ALC883_DIGOUT_NID,
9322 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9323 .channel_mode = alc883_3ST_2ch_modes,
9324 .num_mux_defs =
9325 ARRAY_SIZE(alc888_2_capture_sources),
9326 .input_mux = alc888_acer_aspire_6530_sources,
9327 .unsol_event = alc_automute_amp_unsol_event,
9328 .init_hook = alc888_acer_aspire_4930g_init_hook,
9329 },
Hector Martin3b315d72009-06-02 10:54:19 +02009330 [ALC888_ACER_ASPIRE_8930G] = {
9331 .mixers = { alc888_base_mixer,
9332 alc883_chmode_mixer },
9333 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009334 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009335 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9336 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009337 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9338 .adc_nids = alc889_adc_nids,
9339 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009340 .dig_out_nid = ALC883_DIGOUT_NID,
9341 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9342 .channel_mode = alc883_3ST_6ch_modes,
9343 .need_dac_fix = 1,
9344 .const_channel_count = 6,
9345 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009346 ARRAY_SIZE(alc889_capture_sources),
9347 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009348 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02009349 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02009350 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009351 [ALC883_MEDION] = {
9352 .mixers = { alc883_fivestack_mixer,
9353 alc883_chmode_mixer },
9354 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009355 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009356 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9357 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009358 .adc_nids = alc883_adc_nids_alt,
9359 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009360 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9361 .channel_mode = alc883_sixstack_modes,
9362 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009363 },
Kailang Yang272a5272007-05-14 11:00:38 +02009364 [ALC883_MEDION_MD2] = {
9365 .mixers = { alc883_medion_md2_mixer},
9366 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9367 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9368 .dac_nids = alc883_dac_nids,
9369 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009370 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9371 .channel_mode = alc883_3ST_2ch_modes,
9372 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009373 .unsol_event = alc_automute_amp_unsol_event,
9374 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009375 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009376 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009377 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009378 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9379 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9380 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009381 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9382 .channel_mode = alc883_3ST_2ch_modes,
9383 .input_mux = &alc883_capture_source,
9384 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009385 [ALC883_CLEVO_M720] = {
9386 .mixers = { alc883_clevo_m720_mixer },
9387 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009388 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9389 .dac_nids = alc883_dac_nids,
9390 .dig_out_nid = ALC883_DIGOUT_NID,
9391 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9392 .channel_mode = alc883_3ST_2ch_modes,
9393 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009394 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009395 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009396 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009397 [ALC883_LENOVO_101E_2ch] = {
9398 .mixers = { alc883_lenovo_101e_2ch_mixer},
9399 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9400 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9401 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009402 .adc_nids = alc883_adc_nids_alt,
9403 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009404 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9405 .channel_mode = alc883_3ST_2ch_modes,
9406 .input_mux = &alc883_lenovo_101e_capture_source,
9407 .unsol_event = alc883_lenovo_101e_unsol_event,
9408 .init_hook = alc883_lenovo_101e_all_automute,
9409 },
Kailang Yang272a5272007-05-14 11:00:38 +02009410 [ALC883_LENOVO_NB0763] = {
9411 .mixers = { alc883_lenovo_nb0763_mixer },
9412 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9413 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9414 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009415 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9416 .channel_mode = alc883_3ST_2ch_modes,
9417 .need_dac_fix = 1,
9418 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009419 .unsol_event = alc_automute_amp_unsol_event,
9420 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009421 },
9422 [ALC888_LENOVO_MS7195_DIG] = {
9423 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9424 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9425 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9426 .dac_nids = alc883_dac_nids,
9427 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009428 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9429 .channel_mode = alc883_3ST_6ch_modes,
9430 .need_dac_fix = 1,
9431 .input_mux = &alc883_capture_source,
9432 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9433 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009434 },
9435 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009436 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009437 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9438 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9439 .dac_nids = alc883_dac_nids,
9440 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009441 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9442 .channel_mode = alc883_3ST_2ch_modes,
9443 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009444 .unsol_event = alc_automute_amp_unsol_event,
9445 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009446 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009447 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009448 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009449 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009450 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9451 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009452 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9453 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009454 .need_dac_fix = 1,
9455 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009456 .unsol_event = alc_automute_amp_unsol_event,
9457 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009458 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009459 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009460 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009461 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9462 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9463 .dac_nids = alc883_dac_nids,
9464 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009465 .dig_in_nid = ALC883_DIGIN_NID,
9466 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9467 .channel_mode = alc883_sixstack_modes,
9468 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009469 .unsol_event = alc_automute_amp_unsol_event,
9470 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009471 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009472 [ALC883_MITAC] = {
9473 .mixers = { alc883_mitac_mixer },
9474 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9475 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9476 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009477 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9478 .channel_mode = alc883_3ST_2ch_modes,
9479 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009480 .unsol_event = alc_automute_amp_unsol_event,
9481 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009482 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009483 [ALC883_FUJITSU_PI2515] = {
9484 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9485 .init_verbs = { alc883_init_verbs,
9486 alc883_2ch_fujitsu_pi2515_verbs},
9487 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9488 .dac_nids = alc883_dac_nids,
9489 .dig_out_nid = ALC883_DIGOUT_NID,
9490 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9491 .channel_mode = alc883_3ST_2ch_modes,
9492 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009493 .unsol_event = alc_automute_amp_unsol_event,
9494 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009495 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009496 [ALC888_FUJITSU_XA3530] = {
9497 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9498 .init_verbs = { alc883_init_verbs,
9499 alc888_fujitsu_xa3530_verbs },
9500 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9501 .dac_nids = alc883_dac_nids,
9502 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9503 .adc_nids = alc883_adc_nids_rev,
9504 .capsrc_nids = alc883_capsrc_nids_rev,
9505 .dig_out_nid = ALC883_DIGOUT_NID,
9506 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9507 .channel_mode = alc888_4ST_8ch_intel_modes,
9508 .num_mux_defs =
9509 ARRAY_SIZE(alc888_2_capture_sources),
9510 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009511 .unsol_event = alc_automute_amp_unsol_event,
9512 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009513 },
Kailang Yange2757d52008-08-26 13:17:46 +02009514 [ALC888_LENOVO_SKY] = {
9515 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9516 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9517 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9518 .dac_nids = alc883_dac_nids,
9519 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009520 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9521 .channel_mode = alc883_sixstack_modes,
9522 .need_dac_fix = 1,
9523 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009524 .unsol_event = alc_automute_amp_unsol_event,
9525 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009526 },
9527 [ALC888_ASUS_M90V] = {
9528 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9529 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9530 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9531 .dac_nids = alc883_dac_nids,
9532 .dig_out_nid = ALC883_DIGOUT_NID,
9533 .dig_in_nid = ALC883_DIGIN_NID,
9534 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9535 .channel_mode = alc883_3ST_6ch_modes,
9536 .need_dac_fix = 1,
9537 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9538 .unsol_event = alc883_mode2_unsol_event,
9539 .init_hook = alc883_mode2_inithook,
9540 },
9541 [ALC888_ASUS_EEE1601] = {
9542 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009543 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009544 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9545 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9546 .dac_nids = alc883_dac_nids,
9547 .dig_out_nid = ALC883_DIGOUT_NID,
9548 .dig_in_nid = ALC883_DIGIN_NID,
9549 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9550 .channel_mode = alc883_3ST_2ch_modes,
9551 .need_dac_fix = 1,
9552 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009553 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009554 .init_hook = alc883_eee1601_inithook,
9555 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009556 [ALC1200_ASUS_P5Q] = {
9557 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9558 .init_verbs = { alc883_init_verbs },
9559 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9560 .dac_nids = alc883_dac_nids,
9561 .dig_out_nid = ALC1200_DIGOUT_NID,
9562 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009563 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009564 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9565 .channel_mode = alc883_sixstack_modes,
9566 .input_mux = &alc883_capture_source,
9567 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009568 [ALC889A_MB31] = {
9569 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9570 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9571 alc880_gpio1_init_verbs },
9572 .adc_nids = alc883_adc_nids,
9573 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9574 .dac_nids = alc883_dac_nids,
9575 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9576 .channel_mode = alc889A_mb31_6ch_modes,
9577 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9578 .input_mux = &alc889A_mb31_capture_source,
9579 .dig_out_nid = ALC883_DIGOUT_NID,
9580 .unsol_event = alc889A_mb31_unsol_event,
9581 .init_hook = alc889A_mb31_automute,
9582 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009583 [ALC883_SONY_VAIO_TT] = {
9584 .mixers = { alc883_vaiott_mixer },
9585 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9586 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9587 .dac_nids = alc883_dac_nids,
9588 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9589 .channel_mode = alc883_3ST_2ch_modes,
9590 .input_mux = &alc883_capture_source,
9591 .unsol_event = alc_automute_amp_unsol_event,
9592 .init_hook = alc883_vaiott_init_hook,
9593 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009594};
9595
9596
9597/*
9598 * BIOS auto configuration
9599 */
9600static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9601 hda_nid_t nid, int pin_type,
9602 int dac_idx)
9603{
9604 /* set as output */
9605 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009606 int idx;
9607
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009608 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009609 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9610 idx = 4;
9611 else
9612 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009613 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9614
9615}
9616
9617static void alc883_auto_init_multi_out(struct hda_codec *codec)
9618{
9619 struct alc_spec *spec = codec->spec;
9620 int i;
9621
9622 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009623 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009624 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009625 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009626 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009627 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009628 }
9629}
9630
9631static void alc883_auto_init_hp_out(struct hda_codec *codec)
9632{
9633 struct alc_spec *spec = codec->spec;
9634 hda_nid_t pin;
9635
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009636 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009637 if (pin) /* connect to front */
9638 /* use dac 0 */
9639 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009640 pin = spec->autocfg.speaker_pins[0];
9641 if (pin)
9642 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009643}
9644
9645#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9646#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9647
9648static void alc883_auto_init_analog_input(struct hda_codec *codec)
9649{
9650 struct alc_spec *spec = codec->spec;
9651 int i;
9652
9653 for (i = 0; i < AUTO_PIN_LAST; i++) {
9654 hda_nid_t nid = spec->autocfg.input_pins[i];
9655 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009656 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009657 if (nid != ALC883_PIN_CD_NID &&
9658 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009659 snd_hda_codec_write(codec, nid, 0,
9660 AC_VERB_SET_AMP_GAIN_MUTE,
9661 AMP_OUT_MUTE);
9662 }
9663 }
9664}
9665
Takashi Iwaif511b012008-08-15 16:46:42 +02009666#define alc883_auto_init_input_src alc882_auto_init_input_src
9667
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009668/* almost identical with ALC880 parser... */
9669static int alc883_parse_auto_config(struct hda_codec *codec)
9670{
9671 struct alc_spec *spec = codec->spec;
9672 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009673 struct auto_pin_cfg *cfg = &spec->autocfg;
9674 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009675
9676 if (err < 0)
9677 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009678 else if (!err)
9679 return 0; /* no config found */
9680
9681 err = alc_auto_add_mic_boost(codec);
9682 if (err < 0)
9683 return err;
9684
9685 /* hack - override the init verbs */
9686 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009687
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009688 /* setup input_mux for ALC889 */
9689 if (codec->vendor_id == 0x10ec0889) {
9690 /* digital-mic input pin is excluded in alc880_auto_create..()
9691 * because it's under 0x18
9692 */
9693 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9694 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9695 struct hda_input_mux *imux = &spec->private_imux[0];
9696 for (i = 1; i < 3; i++)
9697 memcpy(&spec->private_imux[i],
9698 &spec->private_imux[0],
9699 sizeof(spec->private_imux[0]));
9700 imux->items[imux->num_items].label = "Int DMic";
9701 imux->items[imux->num_items].index = 0x0b;
9702 imux->num_items++;
9703 spec->num_mux_defs = 3;
9704 spec->input_mux = spec->private_imux;
9705 }
9706 }
9707
Takashi Iwai776e1842007-08-29 15:07:11 +02009708 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009709}
9710
9711/* additional initialization for auto-configuration model */
9712static void alc883_auto_init(struct hda_codec *codec)
9713{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009714 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009715 alc883_auto_init_multi_out(codec);
9716 alc883_auto_init_hp_out(codec);
9717 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009718 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009719 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009720 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009721}
9722
9723static int patch_alc883(struct hda_codec *codec)
9724{
9725 struct alc_spec *spec;
9726 int err, board_config;
9727
9728 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9729 if (spec == NULL)
9730 return -ENOMEM;
9731
9732 codec->spec = spec;
9733
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009734 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9735
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009736 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9737 alc883_models,
9738 alc883_cfg_tbl);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009739 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
9740 /* Pick up systems that don't supply PCI SSID */
9741 switch (codec->subsystem_id) {
9742 case 0x106b3600: /* Macbook 3.1 */
9743 board_config = ALC889A_MB31;
9744 break;
9745 default:
9746 printk(KERN_INFO
9747 "hda_codec: Unknown model for %s, trying "
9748 "auto-probe from BIOS...\n", codec->chip_name);
9749 board_config = ALC883_AUTO;
9750 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009751 }
9752
9753 if (board_config == ALC883_AUTO) {
9754 /* automatic parse from the BIOS config */
9755 err = alc883_parse_auto_config(codec);
9756 if (err < 0) {
9757 alc_free(codec);
9758 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009759 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009760 printk(KERN_INFO
9761 "hda_codec: Cannot set up configuration "
9762 "from BIOS. Using base mode...\n");
9763 board_config = ALC883_3ST_2ch_DIG;
9764 }
9765 }
9766
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009767 err = snd_hda_attach_beep_device(codec, 0x1);
9768 if (err < 0) {
9769 alc_free(codec);
9770 return err;
9771 }
9772
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009773 if (board_config != ALC883_AUTO)
9774 setup_preset(spec, &alc883_presets[board_config]);
9775
Kailang Yang2f893282008-05-27 12:14:47 +02009776 switch (codec->vendor_id) {
9777 case 0x10ec0888:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009778 if (!spec->num_adc_nids) {
9779 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9780 spec->adc_nids = alc883_adc_nids;
9781 }
9782 if (!spec->capsrc_nids)
9783 spec->capsrc_nids = alc883_capsrc_nids;
9784 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009785 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009786 break;
9787 case 0x10ec0889:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009788 if (!spec->num_adc_nids) {
9789 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9790 spec->adc_nids = alc889_adc_nids;
9791 }
9792 if (!spec->capsrc_nids)
9793 spec->capsrc_nids = alc889_capsrc_nids;
9794 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9795 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009796 break;
9797 default:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009798 if (!spec->num_adc_nids) {
9799 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9800 spec->adc_nids = alc883_adc_nids;
9801 }
9802 if (!spec->capsrc_nids)
9803 spec->capsrc_nids = alc883_capsrc_nids;
9804 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009805 break;
9806 }
9807
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009808 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9809 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009810 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009811
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009812 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9813 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9814
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009815 if (!spec->cap_mixer)
9816 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009817 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009818
Takashi Iwai2134ea42008-01-10 16:53:55 +01009819 spec->vmaster_nid = 0x0c;
9820
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009821 codec->patch_ops = alc_patch_ops;
9822 if (board_config == ALC883_AUTO)
9823 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009824
Takashi Iwaicb53c622007-08-10 17:21:45 +02009825#ifdef CONFIG_SND_HDA_POWER_SAVE
9826 if (!spec->loopback.amplist)
9827 spec->loopback.amplist = alc883_loopbacks;
9828#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009829 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009830
9831 return 0;
9832}
9833
9834/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009835 * ALC262 support
9836 */
9837
9838#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9839#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9840
9841#define alc262_dac_nids alc260_dac_nids
9842#define alc262_adc_nids alc882_adc_nids
9843#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009844#define alc262_capsrc_nids alc882_capsrc_nids
9845#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009846
9847#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009848#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009849
Kailang Yang4e555fe2008-08-26 13:05:55 +02009850static hda_nid_t alc262_dmic_adc_nids[1] = {
9851 /* ADC0 */
9852 0x09
9853};
9854
9855static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9856
Kailang Yangdf694da2005-12-05 19:42:22 +01009857static struct snd_kcontrol_new alc262_base_mixer[] = {
9858 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9859 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9860 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9861 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9862 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9863 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9865 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009866 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009867 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9868 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009869 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009870 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9871 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9872 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9873 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009874 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009875};
9876
Takashi Iwaice875f02008-01-28 18:17:43 +01009877/* update HP, line and mono-out pins according to the master switch */
9878static void alc262_hp_master_update(struct hda_codec *codec)
9879{
9880 struct alc_spec *spec = codec->spec;
9881 int val = spec->master_sw;
9882
9883 /* HP & line-out */
9884 snd_hda_codec_write_cache(codec, 0x1b, 0,
9885 AC_VERB_SET_PIN_WIDGET_CONTROL,
9886 val ? PIN_HP : 0);
9887 snd_hda_codec_write_cache(codec, 0x15, 0,
9888 AC_VERB_SET_PIN_WIDGET_CONTROL,
9889 val ? PIN_HP : 0);
9890 /* mono (speaker) depending on the HP jack sense */
9891 val = val && !spec->jack_present;
9892 snd_hda_codec_write_cache(codec, 0x16, 0,
9893 AC_VERB_SET_PIN_WIDGET_CONTROL,
9894 val ? PIN_OUT : 0);
9895}
9896
9897static void alc262_hp_bpc_automute(struct hda_codec *codec)
9898{
9899 struct alc_spec *spec = codec->spec;
9900 unsigned int presence;
9901 presence = snd_hda_codec_read(codec, 0x1b, 0,
9902 AC_VERB_GET_PIN_SENSE, 0);
9903 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9904 alc262_hp_master_update(codec);
9905}
9906
9907static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9908{
9909 if ((res >> 26) != ALC880_HP_EVENT)
9910 return;
9911 alc262_hp_bpc_automute(codec);
9912}
9913
9914static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9915{
9916 struct alc_spec *spec = codec->spec;
9917 unsigned int presence;
9918 presence = snd_hda_codec_read(codec, 0x15, 0,
9919 AC_VERB_GET_PIN_SENSE, 0);
9920 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9921 alc262_hp_master_update(codec);
9922}
9923
9924static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9925 unsigned int res)
9926{
9927 if ((res >> 26) != ALC880_HP_EVENT)
9928 return;
9929 alc262_hp_wildwest_automute(codec);
9930}
9931
Takashi Iwaib72519b2009-05-08 14:31:55 +02009932#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009933
9934static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9935 struct snd_ctl_elem_value *ucontrol)
9936{
9937 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9938 struct alc_spec *spec = codec->spec;
9939 int val = !!*ucontrol->value.integer.value;
9940
9941 if (val == spec->master_sw)
9942 return 0;
9943 spec->master_sw = val;
9944 alc262_hp_master_update(codec);
9945 return 1;
9946}
9947
Takashi Iwaib72519b2009-05-08 14:31:55 +02009948#define ALC262_HP_MASTER_SWITCH \
9949 { \
9950 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9951 .name = "Master Playback Switch", \
9952 .info = snd_ctl_boolean_mono_info, \
9953 .get = alc262_hp_master_sw_get, \
9954 .put = alc262_hp_master_sw_put, \
9955 }
9956
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009957static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009958 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9960 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9961 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009962 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9963 HDA_OUTPUT),
9964 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9965 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009966 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9967 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009968 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009969 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9970 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009971 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009972 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9973 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9974 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9975 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009976 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9977 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9978 { } /* end */
9979};
9980
Kailang Yangcd7509a2007-01-26 18:33:17 +01009981static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009982 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9984 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9985 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9986 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009987 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9988 HDA_OUTPUT),
9989 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9990 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009991 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9992 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009993 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009994 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9995 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9996 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9997 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009998 { } /* end */
9999};
10000
10001static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10002 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10003 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010004 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010005 { } /* end */
10006};
10007
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010008/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010009static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010010{
10011 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010012
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010013 spec->autocfg.hp_pins[0] = 0x15;
10014 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
10015 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010016}
10017
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010018static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010019 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10020 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010021 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10022 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10024 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10025 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10026 { } /* end */
10027};
10028
10029static struct hda_verb alc262_hp_t5735_verbs[] = {
10030 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10031 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10032
10033 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10034 { }
10035};
10036
Kailang Yang8c427222008-01-10 13:03:59 +010010037static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010038 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10039 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010040 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10041 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010042 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10043 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10044 { } /* end */
10045};
10046
10047static struct hda_verb alc262_hp_rp5700_verbs[] = {
10048 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10049 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10050 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10051 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10052 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10053 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10054 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10055 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10056 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10057 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10058 {}
10059};
10060
10061static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10062 .num_items = 1,
10063 .items = {
10064 { "Line", 0x1 },
10065 },
10066};
10067
Takashi Iwai42171c12009-05-08 14:11:43 +020010068/* bind hp and internal speaker mute (with plug check) as master switch */
10069static void alc262_hippo_master_update(struct hda_codec *codec)
10070{
10071 struct alc_spec *spec = codec->spec;
10072 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10073 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10074 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10075 unsigned int mute;
10076
10077 /* HP */
10078 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10079 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10080 HDA_AMP_MUTE, mute);
10081 /* mute internal speaker per jack sense */
10082 if (spec->jack_present)
10083 mute = HDA_AMP_MUTE;
10084 if (line_nid)
10085 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10086 HDA_AMP_MUTE, mute);
10087 if (speaker_nid && speaker_nid != line_nid)
10088 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10089 HDA_AMP_MUTE, mute);
10090}
10091
10092#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10093
10094static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10095 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010096{
10097 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010098 struct alc_spec *spec = codec->spec;
10099 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010100
Takashi Iwai42171c12009-05-08 14:11:43 +020010101 if (val == spec->master_sw)
10102 return 0;
10103 spec->master_sw = val;
10104 alc262_hippo_master_update(codec);
10105 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010106}
Takashi Iwai5b319542007-07-26 11:49:22 +020010107
Takashi Iwai42171c12009-05-08 14:11:43 +020010108#define ALC262_HIPPO_MASTER_SWITCH \
10109 { \
10110 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10111 .name = "Master Playback Switch", \
10112 .info = snd_ctl_boolean_mono_info, \
10113 .get = alc262_hippo_master_sw_get, \
10114 .put = alc262_hippo_master_sw_put, \
10115 }
10116
10117static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10118 ALC262_HIPPO_MASTER_SWITCH,
10119 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10120 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10121 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10122 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10123 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10125 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10126 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10127 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10128 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10129 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10130 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10131 { } /* end */
10132};
10133
10134static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10135 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10136 ALC262_HIPPO_MASTER_SWITCH,
10137 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10138 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10139 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10140 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10143 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10144 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10145 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10146 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10147 { } /* end */
10148};
10149
10150/* mute/unmute internal speaker according to the hp jack and mute state */
10151static void alc262_hippo_automute(struct hda_codec *codec)
10152{
10153 struct alc_spec *spec = codec->spec;
10154 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10155 unsigned int present;
10156
10157 /* need to execute and sync at first */
10158 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10159 present = snd_hda_codec_read(codec, hp_nid, 0,
10160 AC_VERB_GET_PIN_SENSE, 0);
10161 spec->jack_present = (present & 0x80000000) != 0;
10162 alc262_hippo_master_update(codec);
10163}
10164
10165static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10166{
10167 if ((res >> 26) != ALC880_HP_EVENT)
10168 return;
10169 alc262_hippo_automute(codec);
10170}
10171
10172static void alc262_hippo_init_hook(struct hda_codec *codec)
10173{
10174 struct alc_spec *spec = codec->spec;
10175
10176 spec->autocfg.hp_pins[0] = 0x15;
10177 spec->autocfg.speaker_pins[0] = 0x14;
10178 alc262_hippo_automute(codec);
10179}
10180
10181static void alc262_hippo1_init_hook(struct hda_codec *codec)
10182{
10183 struct alc_spec *spec = codec->spec;
10184
10185 spec->autocfg.hp_pins[0] = 0x1b;
10186 spec->autocfg.speaker_pins[0] = 0x14;
10187 alc262_hippo_automute(codec);
10188}
10189
10190
Kailang Yang272a5272007-05-14 11:00:38 +020010191static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010192 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010193 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10195 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10196 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10197 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10198 { } /* end */
10199};
10200
Kailang Yang83c34212007-07-05 11:43:05 +020010201static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010202 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10203 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010204 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10206 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10207 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10208 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10209 { } /* end */
10210};
Kailang Yang272a5272007-05-14 11:00:38 +020010211
Tony Vroonba340e82009-02-02 19:01:30 +000010212static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10213 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10214 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10215 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10216 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10217 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10218 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10220 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10221 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10222 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10223 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10224 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10225 { } /* end */
10226};
10227
10228static struct hda_verb alc262_tyan_verbs[] = {
10229 /* Headphone automute */
10230 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10231 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10232 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10233
10234 /* P11 AUX_IN, white 4-pin connector */
10235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10236 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10237 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10238 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10239
10240 {}
10241};
10242
10243/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010244static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010245{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010246 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010247
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010248 spec->autocfg.hp_pins[0] = 0x1b;
10249 spec->autocfg.speaker_pins[0] = 0x15;
10250 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +000010251}
10252
Tony Vroonba340e82009-02-02 19:01:30 +000010253
Kailang Yangdf694da2005-12-05 19:42:22 +010010254#define alc262_capture_mixer alc882_capture_mixer
10255#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10256
10257/*
10258 * generic initialization of ADC, input mixers and output mixers
10259 */
10260static struct hda_verb alc262_init_verbs[] = {
10261 /*
10262 * Unmute ADC0-2 and set the default input to mic-in
10263 */
10264 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10266 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10267 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10268 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10269 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10270
Takashi Iwaicb53c622007-08-10 17:21:45 +020010271 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010272 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010273 * Note: PASD motherboards uses the Line In 2 as the input for
10274 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010275 */
10276 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10278 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10279 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10280 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10281 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010282
10283 /*
10284 * Set up output mixers (0x0c - 0x0e)
10285 */
10286 /* set vol=0 to output mixers */
10287 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10288 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10290 /* set up input amps for analog loopback */
10291 /* Amp Indices: DAC = 0, mixer = 1 */
10292 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10293 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10294 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10295 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10296 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10297 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10298
10299 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10300 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10301 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10302 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10304 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10305
10306 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10307 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10308 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10309 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10310 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010311
Kailang Yangdf694da2005-12-05 19:42:22 +010010312 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10313 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010314
Kailang Yangdf694da2005-12-05 19:42:22 +010010315 /* FIXME: use matrix-type input source selection */
10316 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10317 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10322 /* Input mixer2 */
10323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10327 /* Input mixer3 */
10328 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10330 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010332
10333 { }
10334};
10335
Kailang Yang4e555fe2008-08-26 13:05:55 +020010336static struct hda_verb alc262_eapd_verbs[] = {
10337 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10338 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10339 { }
10340};
10341
Kailang Yangccc656c2006-10-17 12:32:26 +020010342static struct hda_verb alc262_hippo_unsol_verbs[] = {
10343 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10344 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10345 {}
10346};
10347
10348static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10349 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10350 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10351 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10352
10353 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10354 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10355 {}
10356};
10357
Kailang Yang272a5272007-05-14 11:00:38 +020010358static struct hda_verb alc262_sony_unsol_verbs[] = {
10359 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10360 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10361 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10362
10363 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10364 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010365 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010366};
10367
Kailang Yang4e555fe2008-08-26 13:05:55 +020010368static struct hda_input_mux alc262_dmic_capture_source = {
10369 .num_items = 2,
10370 .items = {
10371 { "Int DMic", 0x9 },
10372 { "Mic", 0x0 },
10373 },
10374};
10375
10376static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10377 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10378 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10379 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010382 { } /* end */
10383};
10384
10385static struct hda_verb alc262_toshiba_s06_verbs[] = {
10386 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10388 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10390 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10391 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10392 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10393 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10394 {}
10395};
10396
10397static void alc262_dmic_automute(struct hda_codec *codec)
10398{
10399 unsigned int present;
10400
10401 present = snd_hda_codec_read(codec, 0x18, 0,
10402 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10403 snd_hda_codec_write(codec, 0x22, 0,
10404 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10405}
10406
Kailang Yang4e555fe2008-08-26 13:05:55 +020010407
10408/* unsolicited event for HP jack sensing */
10409static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10410 unsigned int res)
10411{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010412 if ((res >> 26) == ALC880_MIC_EVENT)
10413 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010414 else
10415 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010416}
10417
10418static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10419{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010420 struct alc_spec *spec = codec->spec;
10421
10422 spec->autocfg.hp_pins[0] = 0x15;
10423 spec->autocfg.speaker_pins[0] = 0x14;
10424 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010425 alc262_dmic_automute(codec);
10426}
10427
Takashi Iwai834be882006-03-01 14:16:17 +010010428/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010429 * nec model
10430 * 0x15 = headphone
10431 * 0x16 = internal speaker
10432 * 0x18 = external mic
10433 */
10434
10435static struct snd_kcontrol_new alc262_nec_mixer[] = {
10436 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10437 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10438
10439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10440 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10441 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10442
10443 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10444 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10445 { } /* end */
10446};
10447
10448static struct hda_verb alc262_nec_verbs[] = {
10449 /* Unmute Speaker */
10450 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10451
10452 /* Headphone */
10453 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10455
10456 /* External mic to headphone */
10457 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10458 /* External mic to speaker */
10459 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10460 {}
10461};
10462
10463/*
Takashi Iwai834be882006-03-01 14:16:17 +010010464 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010465 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10466 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010467 */
10468
10469#define ALC_HP_EVENT 0x37
10470
10471static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10472 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10473 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010474 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10475 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010476 {}
10477};
10478
Jiang zhe0e31daf2008-03-20 12:12:39 +010010479static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10480 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10482 {}
10483};
10484
Takashi Iwai834be882006-03-01 14:16:17 +010010485static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010486 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010487 .items = {
10488 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010489 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010490 { "CD", 0x4 },
10491 },
10492};
10493
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010494static struct hda_input_mux alc262_HP_capture_source = {
10495 .num_items = 5,
10496 .items = {
10497 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010498 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010499 { "Line", 0x2 },
10500 { "CD", 0x4 },
10501 { "AUX IN", 0x6 },
10502 },
10503};
10504
zhejiangaccbe492007-08-31 12:36:05 +020010505static struct hda_input_mux alc262_HP_D7000_capture_source = {
10506 .num_items = 4,
10507 .items = {
10508 { "Mic", 0x0 },
10509 { "Front Mic", 0x2 },
10510 { "Line", 0x1 },
10511 { "CD", 0x4 },
10512 },
10513};
10514
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010515/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010516static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10517{
10518 struct alc_spec *spec = codec->spec;
10519 unsigned int mute;
10520
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010521 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010522 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010523 /* need to execute and sync at first */
10524 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010525 /* check laptop HP jack */
10526 present = snd_hda_codec_read(codec, 0x14, 0,
10527 AC_VERB_GET_PIN_SENSE, 0);
10528 /* need to execute and sync at first */
10529 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10530 /* check docking HP jack */
10531 present |= snd_hda_codec_read(codec, 0x1b, 0,
10532 AC_VERB_GET_PIN_SENSE, 0);
10533 if (present & AC_PINSENSE_PRESENCE)
10534 spec->jack_present = 1;
10535 else
10536 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010537 spec->sense_updated = 1;
10538 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010539 /* unmute internal speaker only if both HPs are unplugged and
10540 * master switch is on
10541 */
10542 if (spec->jack_present)
10543 mute = HDA_AMP_MUTE;
10544 else
Takashi Iwai834be882006-03-01 14:16:17 +010010545 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010546 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10547 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010548}
10549
10550/* unsolicited event for HP jack sensing */
10551static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10552 unsigned int res)
10553{
10554 if ((res >> 26) != ALC_HP_EVENT)
10555 return;
10556 alc262_fujitsu_automute(codec, 1);
10557}
10558
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010559static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10560{
10561 alc262_fujitsu_automute(codec, 1);
10562}
10563
Takashi Iwai834be882006-03-01 14:16:17 +010010564/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010565static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10566 .ops = &snd_hda_bind_vol,
10567 .values = {
10568 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10569 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10570 0
10571 },
10572};
Takashi Iwai834be882006-03-01 14:16:17 +010010573
Jiang zhe0e31daf2008-03-20 12:12:39 +010010574/* mute/unmute internal speaker according to the hp jack and mute state */
10575static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10576{
10577 struct alc_spec *spec = codec->spec;
10578 unsigned int mute;
10579
10580 if (force || !spec->sense_updated) {
10581 unsigned int present_int_hp;
10582 /* need to execute and sync at first */
10583 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10584 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10585 AC_VERB_GET_PIN_SENSE, 0);
10586 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10587 spec->sense_updated = 1;
10588 }
10589 if (spec->jack_present) {
10590 /* mute internal speaker */
10591 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10592 HDA_AMP_MUTE, HDA_AMP_MUTE);
10593 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10594 HDA_AMP_MUTE, HDA_AMP_MUTE);
10595 } else {
10596 /* unmute internal speaker if necessary */
10597 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10598 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10599 HDA_AMP_MUTE, mute);
10600 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10601 HDA_AMP_MUTE, mute);
10602 }
10603}
10604
10605/* unsolicited event for HP jack sensing */
10606static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10607 unsigned int res)
10608{
10609 if ((res >> 26) != ALC_HP_EVENT)
10610 return;
10611 alc262_lenovo_3000_automute(codec, 1);
10612}
10613
Takashi Iwai834be882006-03-01 14:16:17 +010010614/* bind hp and internal speaker mute (with plug check) */
10615static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10616 struct snd_ctl_elem_value *ucontrol)
10617{
10618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10619 long *valp = ucontrol->value.integer.value;
10620 int change;
10621
Tony Vroon5d9fab22008-03-14 17:09:18 +010010622 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10623 HDA_AMP_MUTE,
10624 valp ? 0 : HDA_AMP_MUTE);
10625 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10626 HDA_AMP_MUTE,
10627 valp ? 0 : HDA_AMP_MUTE);
10628
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010629 if (change)
10630 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010631 return change;
10632}
10633
10634static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010635 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010636 {
10637 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10638 .name = "Master Playback Switch",
10639 .info = snd_hda_mixer_amp_switch_info,
10640 .get = snd_hda_mixer_amp_switch_get,
10641 .put = alc262_fujitsu_master_sw_put,
10642 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10643 },
10644 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10645 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10646 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10647 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10648 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010649 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10650 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10651 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010652 { } /* end */
10653};
10654
Jiang zhe0e31daf2008-03-20 12:12:39 +010010655/* bind hp and internal speaker mute (with plug check) */
10656static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10657 struct snd_ctl_elem_value *ucontrol)
10658{
10659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10660 long *valp = ucontrol->value.integer.value;
10661 int change;
10662
10663 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10664 HDA_AMP_MUTE,
10665 valp ? 0 : HDA_AMP_MUTE);
10666
10667 if (change)
10668 alc262_lenovo_3000_automute(codec, 0);
10669 return change;
10670}
10671
10672static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10673 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10674 {
10675 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10676 .name = "Master Playback Switch",
10677 .info = snd_hda_mixer_amp_switch_info,
10678 .get = snd_hda_mixer_amp_switch_get,
10679 .put = alc262_lenovo_3000_master_sw_put,
10680 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10681 },
10682 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10683 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10684 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10685 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10686 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10687 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10688 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10689 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10690 { } /* end */
10691};
10692
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010693static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10694 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010695 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010696 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10697 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10698 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10699 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10700 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10701 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10702 { } /* end */
10703};
10704
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010705/* additional init verbs for Benq laptops */
10706static struct hda_verb alc262_EAPD_verbs[] = {
10707 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10708 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10709 {}
10710};
10711
Kailang Yang83c34212007-07-05 11:43:05 +020010712static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10713 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10714 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10715
10716 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10717 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10718 {}
10719};
10720
Tobin Davisf651b502007-10-26 12:40:47 +020010721/* Samsung Q1 Ultra Vista model setup */
10722static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010723 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10724 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10726 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10727 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010728 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010729 { } /* end */
10730};
10731
10732static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010733 /* output mixer */
10734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10735 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10737 /* speaker */
10738 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10739 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10740 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10741 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10742 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010743 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10745 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10746 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10747 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10748 /* internal mic */
10749 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10750 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10751 /* ADC, choose mic */
10752 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10753 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10754 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10755 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10756 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10757 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10760 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010762 {}
10763};
10764
Tobin Davisf651b502007-10-26 12:40:47 +020010765/* mute/unmute internal speaker according to the hp jack and mute state */
10766static void alc262_ultra_automute(struct hda_codec *codec)
10767{
10768 struct alc_spec *spec = codec->spec;
10769 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010770
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010771 mute = 0;
10772 /* auto-mute only when HP is used as HP */
10773 if (!spec->cur_mux[0]) {
10774 unsigned int present;
10775 /* need to execute and sync at first */
10776 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10777 present = snd_hda_codec_read(codec, 0x15, 0,
10778 AC_VERB_GET_PIN_SENSE, 0);
10779 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10780 if (spec->jack_present)
10781 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010782 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010783 /* mute/unmute internal speaker */
10784 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10785 HDA_AMP_MUTE, mute);
10786 /* mute/unmute HP */
10787 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10788 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010789}
10790
10791/* unsolicited event for HP jack sensing */
10792static void alc262_ultra_unsol_event(struct hda_codec *codec,
10793 unsigned int res)
10794{
10795 if ((res >> 26) != ALC880_HP_EVENT)
10796 return;
10797 alc262_ultra_automute(codec);
10798}
10799
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010800static struct hda_input_mux alc262_ultra_capture_source = {
10801 .num_items = 2,
10802 .items = {
10803 { "Mic", 0x1 },
10804 { "Headphone", 0x7 },
10805 },
10806};
10807
10808static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10809 struct snd_ctl_elem_value *ucontrol)
10810{
10811 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10812 struct alc_spec *spec = codec->spec;
10813 int ret;
10814
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010815 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010816 if (!ret)
10817 return 0;
10818 /* reprogram the HP pin as mic or HP according to the input source */
10819 snd_hda_codec_write_cache(codec, 0x15, 0,
10820 AC_VERB_SET_PIN_WIDGET_CONTROL,
10821 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10822 alc262_ultra_automute(codec); /* mute/unmute HP */
10823 return ret;
10824}
10825
10826static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10827 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10828 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10829 {
10830 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10831 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010832 .info = alc_mux_enum_info,
10833 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010834 .put = alc262_ultra_mux_enum_put,
10835 },
10836 { } /* end */
10837};
10838
Kailang Yangdf694da2005-12-05 19:42:22 +010010839/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010840static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10841 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010842{
10843 hda_nid_t nid;
10844 int err;
10845
10846 spec->multiout.num_dacs = 1; /* only use one dac */
10847 spec->multiout.dac_nids = spec->private_dac_nids;
10848 spec->multiout.dac_nids[0] = 2;
10849
10850 nid = cfg->line_out_pins[0];
10851 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010852 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10853 "Front Playback Volume",
10854 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10855 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010856 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010857 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10858 "Front Playback Switch",
10859 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10860 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010861 return err;
10862 }
10863
Takashi Iwai82bc9552006-03-21 11:24:42 +010010864 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010865 if (nid) {
10866 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010867 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10868 "Speaker Playback Volume",
10869 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10870 HDA_OUTPUT));
10871 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010872 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010873 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10874 "Speaker Playback Switch",
10875 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10876 HDA_OUTPUT));
10877 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010878 return err;
10879 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010880 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10881 "Speaker Playback Switch",
10882 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10883 HDA_OUTPUT));
10884 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010885 return err;
10886 }
10887 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010888 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010889 if (nid) {
10890 /* spec->multiout.hp_nid = 2; */
10891 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010892 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10893 "Headphone Playback Volume",
10894 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10895 HDA_OUTPUT));
10896 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010897 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010898 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10899 "Headphone Playback Switch",
10900 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10901 HDA_OUTPUT));
10902 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010903 return err;
10904 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010905 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10906 "Headphone Playback Switch",
10907 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10908 HDA_OUTPUT));
10909 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010910 return err;
10911 }
10912 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010913 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010914}
10915
10916/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010917#define alc262_auto_create_analog_input_ctls \
10918 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010919
10920/*
10921 * generic initialization of ADC, input mixers and output mixers
10922 */
10923static struct hda_verb alc262_volume_init_verbs[] = {
10924 /*
10925 * Unmute ADC0-2 and set the default input to mic-in
10926 */
10927 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10929 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10930 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10931 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10932 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10933
Takashi Iwaicb53c622007-08-10 17:21:45 +020010934 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010935 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010936 * Note: PASD motherboards uses the Line In 2 as the input for
10937 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010938 */
10939 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010940 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10941 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10942 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10943 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10944 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010945
10946 /*
10947 * Set up output mixers (0x0c - 0x0f)
10948 */
10949 /* set vol=0 to output mixers */
10950 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10951 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10952 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010953
Kailang Yangdf694da2005-12-05 19:42:22 +010010954 /* set up input amps for analog loopback */
10955 /* Amp Indices: DAC = 0, mixer = 1 */
10956 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10958 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10959 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10960 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10961 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10962
10963 /* FIXME: use matrix-type input source selection */
10964 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10965 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10966 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10967 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10968 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10969 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10970 /* Input mixer2 */
10971 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10972 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10973 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10974 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10975 /* Input mixer3 */
10976 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10977 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10980
10981 { }
10982};
10983
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010984static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10985 /*
10986 * Unmute ADC0-2 and set the default input to mic-in
10987 */
10988 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10989 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10990 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10991 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10992 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10993 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10994
Takashi Iwaicb53c622007-08-10 17:21:45 +020010995 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010996 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010997 * Note: PASD motherboards uses the Line In 2 as the input for
10998 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010999 */
11000 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011001 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11005 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011008
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011009 /*
11010 * Set up output mixers (0x0c - 0x0e)
11011 */
11012 /* set vol=0 to output mixers */
11013 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11014 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11015 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11016
11017 /* set up input amps for analog loopback */
11018 /* Amp Indices: DAC = 0, mixer = 1 */
11019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11021 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11022 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11023 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11024 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11025
Takashi Iwaice875f02008-01-28 18:17:43 +010011026 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011027 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11028 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11029
11030 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11031 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11032
11033 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11034 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11035
11036 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11037 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11038 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11039 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11040 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11041
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011042 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011043 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11044 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011045 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011046 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11047 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11048
11049
11050 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011051 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11052 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011053 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011054 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11055 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11056 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11057 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11058 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11059 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011062 /* Input mixer2 */
11063 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011064 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11069 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11071 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011072 /* Input mixer3 */
11073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11075 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11076 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11077 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11078 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11081 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011082
Takashi Iwaice875f02008-01-28 18:17:43 +010011083 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11084
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011085 { }
11086};
11087
Kailang Yangcd7509a2007-01-26 18:33:17 +010011088static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11089 /*
11090 * Unmute ADC0-2 and set the default input to mic-in
11091 */
11092 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11093 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11094 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11095 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11096 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11097 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11098
Takashi Iwaicb53c622007-08-10 17:21:45 +020011099 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011100 * mixer widget
11101 * Note: PASD motherboards uses the Line In 2 as the input for front
11102 * panel mic (mic 2)
11103 */
11104 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11107 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11108 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11109 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11110 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11111 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011113 /*
11114 * Set up output mixers (0x0c - 0x0e)
11115 */
11116 /* set vol=0 to output mixers */
11117 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11120
11121 /* set up input amps for analog loopback */
11122 /* Amp Indices: DAC = 0, mixer = 1 */
11123 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11124 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11125 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11126 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11127 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11128 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11129
11130
11131 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11132 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11133 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11134 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11135 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11136 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11137 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11138
11139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11140 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11141
11142 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11143 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11144
11145 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11146 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11148 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11149 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11150 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11151
11152 /* FIXME: use matrix-type input source selection */
11153 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11154 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11155 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11157 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11158 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11159 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11160 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11161 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11162 /* Input mixer2 */
11163 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11164 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11166 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11167 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11168 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11169 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11170 /* Input mixer3 */
11171 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11172 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11174 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11175 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11176 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11178
Takashi Iwaice875f02008-01-28 18:17:43 +010011179 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11180
Kailang Yangcd7509a2007-01-26 18:33:17 +010011181 { }
11182};
11183
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011184static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11185
11186 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11187 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11188 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11189
11190 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11191 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11192 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11193 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11194
11195 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11196 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11197 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11198 {}
11199};
11200
11201
Takashi Iwaicb53c622007-08-10 17:21:45 +020011202#ifdef CONFIG_SND_HDA_POWER_SAVE
11203#define alc262_loopbacks alc880_loopbacks
11204#endif
11205
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011206/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011207#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11208#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11209#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11210#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11211
11212/*
11213 * BIOS auto configuration
11214 */
11215static int alc262_parse_auto_config(struct hda_codec *codec)
11216{
11217 struct alc_spec *spec = codec->spec;
11218 int err;
11219 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11220
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011221 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11222 alc262_ignore);
11223 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011224 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011225 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011226 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011227 spec->multiout.max_channels = 2;
11228 spec->no_analog = 1;
11229 goto dig_only;
11230 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011231 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011232 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011233 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11234 if (err < 0)
11235 return err;
11236 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11237 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011238 return err;
11239
11240 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11241
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011242 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011243 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011244 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011245 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011246 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011247 if (spec->autocfg.dig_in_pin)
11248 spec->dig_in_nid = ALC262_DIGIN_NID;
11249
Takashi Iwai603c4012008-07-30 15:01:44 +020011250 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011251 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011252
Takashi Iwaid88897e2008-10-31 15:01:37 +010011253 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011254 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011255 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011256
Takashi Iwai776e1842007-08-29 15:07:11 +020011257 err = alc_auto_add_mic_boost(codec);
11258 if (err < 0)
11259 return err;
11260
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011261 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11262
Kailang Yangdf694da2005-12-05 19:42:22 +010011263 return 1;
11264}
11265
11266#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11267#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11268#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011269#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011270
11271
11272/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011273static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011274{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011275 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011276 alc262_auto_init_multi_out(codec);
11277 alc262_auto_init_hp_out(codec);
11278 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011279 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011280 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011281 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011282}
11283
11284/*
11285 * configuration and preset
11286 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011287static const char *alc262_models[ALC262_MODEL_LAST] = {
11288 [ALC262_BASIC] = "basic",
11289 [ALC262_HIPPO] = "hippo",
11290 [ALC262_HIPPO_1] = "hippo_1",
11291 [ALC262_FUJITSU] = "fujitsu",
11292 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011293 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011294 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011295 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011296 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011297 [ALC262_BENQ_T31] = "benq-t31",
11298 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011299 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011300 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011301 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011302 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011303 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011304 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011305 [ALC262_AUTO] = "auto",
11306};
11307
11308static struct snd_pci_quirk alc262_cfg_tbl[] = {
11309 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011310 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011311 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11312 ALC262_HP_BPC),
11313 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11314 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011315 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11316 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011317 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011318 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011319 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011320 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011321 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011322 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011323 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011324 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011325 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11326 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11327 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011328 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11329 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011330 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011331 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011332 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011333 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011334 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010011335 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11336 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011337 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011338 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011339 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011340 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011341 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011342 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011343 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11344 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011345 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011346 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011347 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011348 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011349 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011350 {}
11351};
11352
11353static struct alc_config_preset alc262_presets[] = {
11354 [ALC262_BASIC] = {
11355 .mixers = { alc262_base_mixer },
11356 .init_verbs = { alc262_init_verbs },
11357 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11358 .dac_nids = alc262_dac_nids,
11359 .hp_nid = 0x03,
11360 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11361 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011362 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011363 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011364 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011365 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020011366 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11367 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11368 .dac_nids = alc262_dac_nids,
11369 .hp_nid = 0x03,
11370 .dig_out_nid = ALC262_DIGOUT_NID,
11371 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11372 .channel_mode = alc262_modes,
11373 .input_mux = &alc262_capture_source,
11374 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011375 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011376 },
11377 [ALC262_HIPPO_1] = {
11378 .mixers = { alc262_hippo1_mixer },
11379 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11380 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11381 .dac_nids = alc262_dac_nids,
11382 .hp_nid = 0x02,
11383 .dig_out_nid = ALC262_DIGOUT_NID,
11384 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11385 .channel_mode = alc262_modes,
11386 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011387 .unsol_event = alc262_hippo_unsol_event,
11388 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011389 },
Takashi Iwai834be882006-03-01 14:16:17 +010011390 [ALC262_FUJITSU] = {
11391 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011392 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11393 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011394 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11395 .dac_nids = alc262_dac_nids,
11396 .hp_nid = 0x03,
11397 .dig_out_nid = ALC262_DIGOUT_NID,
11398 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11399 .channel_mode = alc262_modes,
11400 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011401 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011402 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011403 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011404 [ALC262_HP_BPC] = {
11405 .mixers = { alc262_HP_BPC_mixer },
11406 .init_verbs = { alc262_HP_BPC_init_verbs },
11407 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11408 .dac_nids = alc262_dac_nids,
11409 .hp_nid = 0x03,
11410 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11411 .channel_mode = alc262_modes,
11412 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011413 .unsol_event = alc262_hp_bpc_unsol_event,
11414 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011415 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011416 [ALC262_HP_BPC_D7000_WF] = {
11417 .mixers = { alc262_HP_BPC_WildWest_mixer },
11418 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11419 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11420 .dac_nids = alc262_dac_nids,
11421 .hp_nid = 0x03,
11422 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11423 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011424 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011425 .unsol_event = alc262_hp_wildwest_unsol_event,
11426 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011427 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011428 [ALC262_HP_BPC_D7000_WL] = {
11429 .mixers = { alc262_HP_BPC_WildWest_mixer,
11430 alc262_HP_BPC_WildWest_option_mixer },
11431 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11432 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11433 .dac_nids = alc262_dac_nids,
11434 .hp_nid = 0x03,
11435 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11436 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011437 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011438 .unsol_event = alc262_hp_wildwest_unsol_event,
11439 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011440 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011441 [ALC262_HP_TC_T5735] = {
11442 .mixers = { alc262_hp_t5735_mixer },
11443 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11444 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11445 .dac_nids = alc262_dac_nids,
11446 .hp_nid = 0x03,
11447 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11448 .channel_mode = alc262_modes,
11449 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011450 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011451 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011452 },
11453 [ALC262_HP_RP5700] = {
11454 .mixers = { alc262_hp_rp5700_mixer },
11455 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11456 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11457 .dac_nids = alc262_dac_nids,
11458 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11459 .channel_mode = alc262_modes,
11460 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011461 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011462 [ALC262_BENQ_ED8] = {
11463 .mixers = { alc262_base_mixer },
11464 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11465 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11466 .dac_nids = alc262_dac_nids,
11467 .hp_nid = 0x03,
11468 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11469 .channel_mode = alc262_modes,
11470 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011471 },
Kailang Yang272a5272007-05-14 11:00:38 +020011472 [ALC262_SONY_ASSAMD] = {
11473 .mixers = { alc262_sony_mixer },
11474 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11475 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11476 .dac_nids = alc262_dac_nids,
11477 .hp_nid = 0x02,
11478 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11479 .channel_mode = alc262_modes,
11480 .input_mux = &alc262_capture_source,
11481 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011482 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011483 },
11484 [ALC262_BENQ_T31] = {
11485 .mixers = { alc262_benq_t31_mixer },
11486 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11487 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11488 .dac_nids = alc262_dac_nids,
11489 .hp_nid = 0x03,
11490 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11491 .channel_mode = alc262_modes,
11492 .input_mux = &alc262_capture_source,
11493 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011494 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011495 },
Tobin Davisf651b502007-10-26 12:40:47 +020011496 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011497 .mixers = { alc262_ultra_mixer },
11498 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011499 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011500 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11501 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011502 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11503 .channel_mode = alc262_modes,
11504 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011505 .adc_nids = alc262_adc_nids, /* ADC0 */
11506 .capsrc_nids = alc262_capsrc_nids,
11507 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011508 .unsol_event = alc262_ultra_unsol_event,
11509 .init_hook = alc262_ultra_automute,
11510 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011511 [ALC262_LENOVO_3000] = {
11512 .mixers = { alc262_lenovo_3000_mixer },
11513 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11514 alc262_lenovo_3000_unsol_verbs },
11515 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11516 .dac_nids = alc262_dac_nids,
11517 .hp_nid = 0x03,
11518 .dig_out_nid = ALC262_DIGOUT_NID,
11519 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11520 .channel_mode = alc262_modes,
11521 .input_mux = &alc262_fujitsu_capture_source,
11522 .unsol_event = alc262_lenovo_3000_unsol_event,
11523 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011524 [ALC262_NEC] = {
11525 .mixers = { alc262_nec_mixer },
11526 .init_verbs = { alc262_nec_verbs },
11527 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11528 .dac_nids = alc262_dac_nids,
11529 .hp_nid = 0x03,
11530 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11531 .channel_mode = alc262_modes,
11532 .input_mux = &alc262_capture_source,
11533 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011534 [ALC262_TOSHIBA_S06] = {
11535 .mixers = { alc262_toshiba_s06_mixer },
11536 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11537 alc262_eapd_verbs },
11538 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11539 .capsrc_nids = alc262_dmic_capsrc_nids,
11540 .dac_nids = alc262_dac_nids,
11541 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011542 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011543 .dig_out_nid = ALC262_DIGOUT_NID,
11544 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11545 .channel_mode = alc262_modes,
11546 .input_mux = &alc262_dmic_capture_source,
11547 .unsol_event = alc262_toshiba_s06_unsol_event,
11548 .init_hook = alc262_toshiba_s06_init_hook,
11549 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011550 [ALC262_TOSHIBA_RX1] = {
11551 .mixers = { alc262_toshiba_rx1_mixer },
11552 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11553 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11554 .dac_nids = alc262_dac_nids,
11555 .hp_nid = 0x03,
11556 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11557 .channel_mode = alc262_modes,
11558 .input_mux = &alc262_capture_source,
11559 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011560 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011561 },
Tony Vroonba340e82009-02-02 19:01:30 +000011562 [ALC262_TYAN] = {
11563 .mixers = { alc262_tyan_mixer },
11564 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11565 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11566 .dac_nids = alc262_dac_nids,
11567 .hp_nid = 0x02,
11568 .dig_out_nid = ALC262_DIGOUT_NID,
11569 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11570 .channel_mode = alc262_modes,
11571 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011572 .unsol_event = alc_automute_amp_unsol_event,
11573 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011574 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011575};
11576
11577static int patch_alc262(struct hda_codec *codec)
11578{
11579 struct alc_spec *spec;
11580 int board_config;
11581 int err;
11582
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011583 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011584 if (spec == NULL)
11585 return -ENOMEM;
11586
11587 codec->spec = spec;
11588#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011589 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11590 * under-run
11591 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011592 {
11593 int tmp;
11594 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11595 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11596 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11597 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11598 }
11599#endif
11600
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011601 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11602
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011603 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11604 alc262_models,
11605 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011606
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011607 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020011608 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11609 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011610 board_config = ALC262_AUTO;
11611 }
11612
11613 if (board_config == ALC262_AUTO) {
11614 /* automatic parse from the BIOS config */
11615 err = alc262_parse_auto_config(codec);
11616 if (err < 0) {
11617 alc_free(codec);
11618 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011619 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011620 printk(KERN_INFO
11621 "hda_codec: Cannot set up configuration "
11622 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011623 board_config = ALC262_BASIC;
11624 }
11625 }
11626
Takashi Iwai07eba612009-02-19 08:06:35 +010011627 if (!spec->no_analog) {
11628 err = snd_hda_attach_beep_device(codec, 0x1);
11629 if (err < 0) {
11630 alc_free(codec);
11631 return err;
11632 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011633 }
11634
Kailang Yangdf694da2005-12-05 19:42:22 +010011635 if (board_config != ALC262_AUTO)
11636 setup_preset(spec, &alc262_presets[board_config]);
11637
Kailang Yangdf694da2005-12-05 19:42:22 +010011638 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11639 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011640
Kailang Yangdf694da2005-12-05 19:42:22 +010011641 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11642 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11643
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011644 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011645 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011646 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011647 unsigned int wcap = get_wcaps(codec, 0x07);
11648
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011649 /* get type */
11650 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011651 if (wcap != AC_WID_AUD_IN) {
11652 spec->adc_nids = alc262_adc_nids_alt;
11653 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011654 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011655 } else {
11656 spec->adc_nids = alc262_adc_nids;
11657 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011658 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011659 }
11660 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011661 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011662 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011663 if (!spec->no_analog)
11664 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011665
Takashi Iwai2134ea42008-01-10 16:53:55 +010011666 spec->vmaster_nid = 0x0c;
11667
Kailang Yangdf694da2005-12-05 19:42:22 +010011668 codec->patch_ops = alc_patch_ops;
11669 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011670 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011671#ifdef CONFIG_SND_HDA_POWER_SAVE
11672 if (!spec->loopback.amplist)
11673 spec->loopback.amplist = alc262_loopbacks;
11674#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011675 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011676
Kailang Yangdf694da2005-12-05 19:42:22 +010011677 return 0;
11678}
11679
Kailang Yangdf694da2005-12-05 19:42:22 +010011680/*
Kailang Yanga361d842007-06-05 12:30:55 +020011681 * ALC268 channel source setting (2 channel)
11682 */
11683#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11684#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011685
Kailang Yanga361d842007-06-05 12:30:55 +020011686static hda_nid_t alc268_dac_nids[2] = {
11687 /* front, hp */
11688 0x02, 0x03
11689};
11690
11691static hda_nid_t alc268_adc_nids[2] = {
11692 /* ADC0-1 */
11693 0x08, 0x07
11694};
11695
11696static hda_nid_t alc268_adc_nids_alt[1] = {
11697 /* ADC0 */
11698 0x08
11699};
11700
Takashi Iwaie1406342008-02-11 18:32:32 +010011701static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11702
Kailang Yanga361d842007-06-05 12:30:55 +020011703static struct snd_kcontrol_new alc268_base_mixer[] = {
11704 /* output mixer control */
11705 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11706 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11707 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11708 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011709 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11710 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11711 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011712 { }
11713};
11714
Takashi Iwai42171c12009-05-08 14:11:43 +020011715static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11716 /* output mixer control */
11717 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11718 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11719 ALC262_HIPPO_MASTER_SWITCH,
11720 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11721 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11722 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11723 { }
11724};
11725
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011726/* bind Beep switches of both NID 0x0f and 0x10 */
11727static struct hda_bind_ctls alc268_bind_beep_sw = {
11728 .ops = &snd_hda_bind_sw,
11729 .values = {
11730 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11731 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11732 0
11733 },
11734};
11735
11736static struct snd_kcontrol_new alc268_beep_mixer[] = {
11737 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11738 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11739 { }
11740};
11741
Kailang Yangd1a991a2007-08-15 16:21:59 +020011742static struct hda_verb alc268_eapd_verbs[] = {
11743 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11744 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11745 { }
11746};
11747
Takashi Iwaid2738092007-08-16 14:59:45 +020011748/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011749static struct hda_verb alc268_toshiba_verbs[] = {
11750 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11751 { } /* end */
11752};
11753
Kailang Yang8ef355d2008-08-26 13:10:22 +020011754static struct hda_input_mux alc268_acer_lc_capture_source = {
11755 .num_items = 2,
11756 .items = {
11757 { "i-Mic", 0x6 },
11758 { "E-Mic", 0x0 },
11759 },
11760};
11761
Takashi Iwaid2738092007-08-16 14:59:45 +020011762/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011763/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011764static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11765 .ops = &snd_hda_bind_vol,
11766 .values = {
11767 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11768 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11769 0
11770 },
11771};
11772
Takashi Iwai889c4392007-08-23 18:56:52 +020011773/* mute/unmute internal speaker according to the hp jack and mute state */
11774static void alc268_acer_automute(struct hda_codec *codec, int force)
11775{
11776 struct alc_spec *spec = codec->spec;
11777 unsigned int mute;
11778
11779 if (force || !spec->sense_updated) {
11780 unsigned int present;
11781 present = snd_hda_codec_read(codec, 0x14, 0,
11782 AC_VERB_GET_PIN_SENSE, 0);
11783 spec->jack_present = (present & 0x80000000) != 0;
11784 spec->sense_updated = 1;
11785 }
11786 if (spec->jack_present)
11787 mute = HDA_AMP_MUTE; /* mute internal speaker */
11788 else /* unmute internal speaker if necessary */
11789 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11790 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11791 HDA_AMP_MUTE, mute);
11792}
11793
11794
11795/* bind hp and internal speaker mute (with plug check) */
11796static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11797 struct snd_ctl_elem_value *ucontrol)
11798{
11799 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11800 long *valp = ucontrol->value.integer.value;
11801 int change;
11802
11803 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11804 HDA_AMP_MUTE,
11805 valp[0] ? 0 : HDA_AMP_MUTE);
11806 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11807 HDA_AMP_MUTE,
11808 valp[1] ? 0 : HDA_AMP_MUTE);
11809 if (change)
11810 alc268_acer_automute(codec, 0);
11811 return change;
11812}
Takashi Iwaid2738092007-08-16 14:59:45 +020011813
Kailang Yang8ef355d2008-08-26 13:10:22 +020011814static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11815 /* output mixer control */
11816 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11817 {
11818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11819 .name = "Master Playback Switch",
11820 .info = snd_hda_mixer_amp_switch_info,
11821 .get = snd_hda_mixer_amp_switch_get,
11822 .put = alc268_acer_master_sw_put,
11823 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11824 },
11825 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11826 { }
11827};
11828
Takashi Iwaid2738092007-08-16 14:59:45 +020011829static struct snd_kcontrol_new alc268_acer_mixer[] = {
11830 /* output mixer control */
11831 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11832 {
11833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11834 .name = "Master Playback Switch",
11835 .info = snd_hda_mixer_amp_switch_info,
11836 .get = snd_hda_mixer_amp_switch_get,
11837 .put = alc268_acer_master_sw_put,
11838 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11839 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11841 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11842 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011843 { }
11844};
11845
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011846static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11847 /* output mixer control */
11848 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11849 {
11850 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11851 .name = "Master Playback Switch",
11852 .info = snd_hda_mixer_amp_switch_info,
11853 .get = snd_hda_mixer_amp_switch_get,
11854 .put = alc268_acer_master_sw_put,
11855 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11856 },
11857 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11858 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11859 { }
11860};
11861
Kailang Yang8ef355d2008-08-26 13:10:22 +020011862static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11863 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11865 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11866 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11867 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11869 { }
11870};
11871
Takashi Iwaid2738092007-08-16 14:59:45 +020011872static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011873 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11874 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11876 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011877 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11878 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011879 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11880 { }
11881};
11882
11883/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011884#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11885#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011886
11887static void alc268_acer_unsol_event(struct hda_codec *codec,
11888 unsigned int res)
11889{
Takashi Iwai889c4392007-08-23 18:56:52 +020011890 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011891 return;
11892 alc268_acer_automute(codec, 1);
11893}
11894
Takashi Iwai889c4392007-08-23 18:56:52 +020011895static void alc268_acer_init_hook(struct hda_codec *codec)
11896{
11897 alc268_acer_automute(codec, 1);
11898}
11899
Kailang Yang8ef355d2008-08-26 13:10:22 +020011900/* toggle speaker-output according to the hp-jack state */
11901static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11902{
11903 unsigned int present;
11904 unsigned char bits;
11905
11906 present = snd_hda_codec_read(codec, 0x15, 0,
11907 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11908 bits = present ? AMP_IN_MUTE(0) : 0;
11909 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11910 AMP_IN_MUTE(0), bits);
11911 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11912 AMP_IN_MUTE(0), bits);
11913}
11914
11915
11916static void alc268_acer_mic_automute(struct hda_codec *codec)
11917{
11918 unsigned int present;
11919
11920 present = snd_hda_codec_read(codec, 0x18, 0,
11921 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11922 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11923 present ? 0x0 : 0x6);
11924}
11925
11926static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11927 unsigned int res)
11928{
11929 if ((res >> 26) == ALC880_HP_EVENT)
11930 alc268_aspire_one_speaker_automute(codec);
11931 if ((res >> 26) == ALC880_MIC_EVENT)
11932 alc268_acer_mic_automute(codec);
11933}
11934
11935static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11936{
11937 alc268_aspire_one_speaker_automute(codec);
11938 alc268_acer_mic_automute(codec);
11939}
11940
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011941static struct snd_kcontrol_new alc268_dell_mixer[] = {
11942 /* output mixer control */
11943 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11944 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11945 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11947 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11948 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11949 { }
11950};
11951
11952static struct hda_verb alc268_dell_verbs[] = {
11953 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11954 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11955 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11956 { }
11957};
11958
11959/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011960static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011961{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011962 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011963
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011964 spec->autocfg.hp_pins[0] = 0x15;
11965 spec->autocfg.speaker_pins[0] = 0x14;
11966 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011967}
11968
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011969static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11970 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11971 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11972 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11973 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11974 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11975 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11976 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11977 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11978 { }
11979};
11980
11981static struct hda_verb alc267_quanta_il1_verbs[] = {
11982 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11983 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11984 { }
11985};
11986
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011987static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11988{
11989 unsigned int present;
11990
11991 present = snd_hda_codec_read(codec, 0x18, 0,
11992 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11993 snd_hda_codec_write(codec, 0x23, 0,
11994 AC_VERB_SET_CONNECT_SEL,
11995 present ? 0x00 : 0x01);
11996}
11997
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011998static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011999{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012000 struct alc_spec *spec = codec->spec;
12001
12002 spec->autocfg.hp_pins[0] = 0x15;
12003 spec->autocfg.speaker_pins[0] = 0x14;
12004 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012005 alc267_quanta_il1_mic_automute(codec);
12006}
12007
12008static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
12009 unsigned int res)
12010{
12011 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012012 case ALC880_MIC_EVENT:
12013 alc267_quanta_il1_mic_automute(codec);
12014 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012015 default:
12016 alc_sku_unsol_event(codec, res);
12017 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012018 }
12019}
12020
Kailang Yanga361d842007-06-05 12:30:55 +020012021/*
12022 * generic initialization of ADC, input mixers and output mixers
12023 */
12024static struct hda_verb alc268_base_init_verbs[] = {
12025 /* Unmute DAC0-1 and set vol = 0 */
12026 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012027 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012028
12029 /*
12030 * Set up output mixers (0x0c - 0x0e)
12031 */
12032 /* set vol=0 to output mixers */
12033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012034 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12035
12036 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12037 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12038
12039 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12040 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12041 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12042 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12043 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12044 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12045 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12046 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12047
12048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12049 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12050 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12051 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012052 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012053
12054 /* set PCBEEP vol = 0, mute connections */
12055 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12056 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12057 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012058
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012059 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012060
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012061 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12062 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12063 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012065
Kailang Yanga361d842007-06-05 12:30:55 +020012066 { }
12067};
12068
12069/*
12070 * generic initialization of ADC, input mixers and output mixers
12071 */
12072static struct hda_verb alc268_volume_init_verbs[] = {
12073 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012074 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12075 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012076
12077 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12078 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12079 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12080 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12081 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12082
Kailang Yanga361d842007-06-05 12:30:55 +020012083 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12085 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12086
12087 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012088 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012089
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012090 /* set PCBEEP vol = 0, mute connections */
12091 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12092 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12093 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012094
12095 { }
12096};
12097
Kailang Yanga361d842007-06-05 12:30:55 +020012098static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12099 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12100 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12101 {
12102 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12103 /* The multiple "Capture Source" controls confuse alsamixer
12104 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012105 */
12106 /* .name = "Capture Source", */
12107 .name = "Input Source",
12108 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012109 .info = alc_mux_enum_info,
12110 .get = alc_mux_enum_get,
12111 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012112 },
12113 { } /* end */
12114};
12115
12116static struct snd_kcontrol_new alc268_capture_mixer[] = {
12117 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12118 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12119 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12120 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12121 {
12122 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12123 /* The multiple "Capture Source" controls confuse alsamixer
12124 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012125 */
12126 /* .name = "Capture Source", */
12127 .name = "Input Source",
12128 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012129 .info = alc_mux_enum_info,
12130 .get = alc_mux_enum_get,
12131 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012132 },
12133 { } /* end */
12134};
12135
12136static struct hda_input_mux alc268_capture_source = {
12137 .num_items = 4,
12138 .items = {
12139 { "Mic", 0x0 },
12140 { "Front Mic", 0x1 },
12141 { "Line", 0x2 },
12142 { "CD", 0x3 },
12143 },
12144};
12145
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012146static struct hda_input_mux alc268_acer_capture_source = {
12147 .num_items = 3,
12148 .items = {
12149 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012150 { "Internal Mic", 0x1 },
12151 { "Line", 0x2 },
12152 },
12153};
12154
12155static struct hda_input_mux alc268_acer_dmic_capture_source = {
12156 .num_items = 3,
12157 .items = {
12158 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012159 { "Internal Mic", 0x6 },
12160 { "Line", 0x2 },
12161 },
12162};
12163
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012164#ifdef CONFIG_SND_DEBUG
12165static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012166 /* Volume widgets */
12167 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12168 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12169 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12170 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12171 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12172 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12173 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12174 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12175 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12176 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12177 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12178 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12179 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012180 /* The below appears problematic on some hardwares */
12181 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012182 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12183 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12184 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12185 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12186
12187 /* Modes for retasking pin widgets */
12188 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12189 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12190 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12191 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12192
12193 /* Controls for GPIO pins, assuming they are configured as outputs */
12194 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12195 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12196 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12197 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12198
12199 /* Switches to allow the digital SPDIF output pin to be enabled.
12200 * The ALC268 does not have an SPDIF input.
12201 */
12202 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12203
12204 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12205 * this output to turn on an external amplifier.
12206 */
12207 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12208 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12209
12210 { } /* end */
12211};
12212#endif
12213
Kailang Yanga361d842007-06-05 12:30:55 +020012214/* create input playback/capture controls for the given pin */
12215static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12216 const char *ctlname, int idx)
12217{
12218 char name[32];
12219 int err;
12220
12221 sprintf(name, "%s Playback Volume", ctlname);
12222 if (nid == 0x14) {
12223 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12224 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
12225 HDA_OUTPUT));
12226 if (err < 0)
12227 return err;
12228 } else if (nid == 0x15) {
12229 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12230 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
12231 HDA_OUTPUT));
12232 if (err < 0)
12233 return err;
12234 } else
12235 return -1;
12236 sprintf(name, "%s Playback Switch", ctlname);
12237 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12238 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12239 if (err < 0)
12240 return err;
12241 return 0;
12242}
12243
12244/* add playback controls from the parsed DAC table */
12245static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12246 const struct auto_pin_cfg *cfg)
12247{
12248 hda_nid_t nid;
12249 int err;
12250
12251 spec->multiout.num_dacs = 2; /* only use one dac */
12252 spec->multiout.dac_nids = spec->private_dac_nids;
12253 spec->multiout.dac_nids[0] = 2;
12254 spec->multiout.dac_nids[1] = 3;
12255
12256 nid = cfg->line_out_pins[0];
12257 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020012258 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020012259
12260 nid = cfg->speaker_pins[0];
12261 if (nid == 0x1d) {
12262 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12263 "Speaker Playback Volume",
12264 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12265 if (err < 0)
12266 return err;
12267 }
12268 nid = cfg->hp_pins[0];
12269 if (nid)
12270 alc268_new_analog_output(spec, nid, "Headphone", 0);
12271
12272 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12273 if (nid == 0x16) {
12274 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12275 "Mono Playback Switch",
12276 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
12277 if (err < 0)
12278 return err;
12279 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012280 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012281}
12282
12283/* create playback/capture controls for input pins */
12284static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12285 const struct auto_pin_cfg *cfg)
12286{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012287 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012288 int i, idx1;
12289
12290 for (i = 0; i < AUTO_PIN_LAST; i++) {
12291 switch(cfg->input_pins[i]) {
12292 case 0x18:
12293 idx1 = 0; /* Mic 1 */
12294 break;
12295 case 0x19:
12296 idx1 = 1; /* Mic 2 */
12297 break;
12298 case 0x1a:
12299 idx1 = 2; /* Line In */
12300 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012301 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012302 idx1 = 3; /* CD */
12303 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012304 case 0x12:
12305 case 0x13:
12306 idx1 = 6; /* digital mics */
12307 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012308 default:
12309 continue;
12310 }
12311 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12312 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012313 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012314 }
12315 return 0;
12316}
12317
12318static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12319{
12320 struct alc_spec *spec = codec->spec;
12321 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12322 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12323 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12324 unsigned int dac_vol1, dac_vol2;
12325
12326 if (speaker_nid) {
12327 snd_hda_codec_write(codec, speaker_nid, 0,
12328 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12329 snd_hda_codec_write(codec, 0x0f, 0,
12330 AC_VERB_SET_AMP_GAIN_MUTE,
12331 AMP_IN_UNMUTE(1));
12332 snd_hda_codec_write(codec, 0x10, 0,
12333 AC_VERB_SET_AMP_GAIN_MUTE,
12334 AMP_IN_UNMUTE(1));
12335 } else {
12336 snd_hda_codec_write(codec, 0x0f, 0,
12337 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12338 snd_hda_codec_write(codec, 0x10, 0,
12339 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12340 }
12341
12342 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012343 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012344 dac_vol2 = AMP_OUT_ZERO;
12345 else if (line_nid == 0x15)
12346 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012347 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012348 dac_vol2 = AMP_OUT_ZERO;
12349 else if (hp_nid == 0x15)
12350 dac_vol1 = AMP_OUT_ZERO;
12351 if (line_nid != 0x16 || hp_nid != 0x16 ||
12352 spec->autocfg.line_out_pins[1] != 0x16 ||
12353 spec->autocfg.line_out_pins[2] != 0x16)
12354 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12355
12356 snd_hda_codec_write(codec, 0x02, 0,
12357 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12358 snd_hda_codec_write(codec, 0x03, 0,
12359 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12360}
12361
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012362/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012363#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12364#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012365#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012366#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12367
12368/*
12369 * BIOS auto configuration
12370 */
12371static int alc268_parse_auto_config(struct hda_codec *codec)
12372{
12373 struct alc_spec *spec = codec->spec;
12374 int err;
12375 static hda_nid_t alc268_ignore[] = { 0 };
12376
12377 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12378 alc268_ignore);
12379 if (err < 0)
12380 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012381 if (!spec->autocfg.line_outs) {
12382 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12383 spec->multiout.max_channels = 2;
12384 spec->no_analog = 1;
12385 goto dig_only;
12386 }
Kailang Yanga361d842007-06-05 12:30:55 +020012387 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012388 }
Kailang Yanga361d842007-06-05 12:30:55 +020012389 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12390 if (err < 0)
12391 return err;
12392 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12393 if (err < 0)
12394 return err;
12395
12396 spec->multiout.max_channels = 2;
12397
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012398 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012399 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012400 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012401 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012402 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12403 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012404 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012405 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012406
Takashi Iwai892981f2009-03-02 08:04:35 +010012407 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012408 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012409
Takashi Iwaid88897e2008-10-31 15:01:37 +010012410 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012411 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012412 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012413
Takashi Iwai776e1842007-08-29 15:07:11 +020012414 err = alc_auto_add_mic_boost(codec);
12415 if (err < 0)
12416 return err;
12417
Kailang Yanga361d842007-06-05 12:30:55 +020012418 return 1;
12419}
12420
12421#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12422#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12423#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12424
12425/* init callback for auto-configuration model -- overriding the default init */
12426static void alc268_auto_init(struct hda_codec *codec)
12427{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012428 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012429 alc268_auto_init_multi_out(codec);
12430 alc268_auto_init_hp_out(codec);
12431 alc268_auto_init_mono_speaker_out(codec);
12432 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012433 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012434 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012435}
12436
12437/*
12438 * configuration and preset
12439 */
12440static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012441 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012442 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012443 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012444 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012445 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012446 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012447 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012448 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012449#ifdef CONFIG_SND_DEBUG
12450 [ALC268_TEST] = "test",
12451#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012452 [ALC268_AUTO] = "auto",
12453};
12454
12455static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012456 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012457 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012458 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012459 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012460 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012461 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12462 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012463 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012464 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012465 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12466 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012467 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012468 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12469 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12470 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012471 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012472 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012473 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012474 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012475 {}
12476};
12477
12478static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012479 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012480 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012481 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12482 alc267_quanta_il1_verbs },
12483 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12484 .dac_nids = alc268_dac_nids,
12485 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12486 .adc_nids = alc268_adc_nids_alt,
12487 .hp_nid = 0x03,
12488 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12489 .channel_mode = alc268_modes,
12490 .input_mux = &alc268_capture_source,
12491 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012492 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012493 },
Kailang Yanga361d842007-06-05 12:30:55 +020012494 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012495 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12496 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012497 .init_verbs = { alc268_base_init_verbs },
12498 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12499 .dac_nids = alc268_dac_nids,
12500 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12501 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012502 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012503 .hp_nid = 0x03,
12504 .dig_out_nid = ALC268_DIGOUT_NID,
12505 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12506 .channel_mode = alc268_modes,
12507 .input_mux = &alc268_capture_source,
12508 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012509 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012510 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012511 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012512 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12513 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012514 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12515 .dac_nids = alc268_dac_nids,
12516 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12517 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012518 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012519 .hp_nid = 0x03,
12520 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12521 .channel_mode = alc268_modes,
12522 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012523 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012524 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012525 },
12526 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012527 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12528 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012529 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12530 alc268_acer_verbs },
12531 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12532 .dac_nids = alc268_dac_nids,
12533 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12534 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012535 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012536 .hp_nid = 0x02,
12537 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12538 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012539 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012540 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012541 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012542 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012543 [ALC268_ACER_DMIC] = {
12544 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12545 alc268_beep_mixer },
12546 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12547 alc268_acer_verbs },
12548 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12549 .dac_nids = alc268_dac_nids,
12550 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12551 .adc_nids = alc268_adc_nids_alt,
12552 .capsrc_nids = alc268_capsrc_nids,
12553 .hp_nid = 0x02,
12554 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12555 .channel_mode = alc268_modes,
12556 .input_mux = &alc268_acer_dmic_capture_source,
12557 .unsol_event = alc268_acer_unsol_event,
12558 .init_hook = alc268_acer_init_hook,
12559 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012560 [ALC268_ACER_ASPIRE_ONE] = {
12561 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012562 alc268_beep_mixer,
12563 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012564 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12565 alc268_acer_aspire_one_verbs },
12566 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12567 .dac_nids = alc268_dac_nids,
12568 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12569 .adc_nids = alc268_adc_nids_alt,
12570 .capsrc_nids = alc268_capsrc_nids,
12571 .hp_nid = 0x03,
12572 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12573 .channel_mode = alc268_modes,
12574 .input_mux = &alc268_acer_lc_capture_source,
12575 .unsol_event = alc268_acer_lc_unsol_event,
12576 .init_hook = alc268_acer_lc_init_hook,
12577 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012578 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012579 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012580 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12581 alc268_dell_verbs },
12582 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12583 .dac_nids = alc268_dac_nids,
12584 .hp_nid = 0x02,
12585 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12586 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012587 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012588 .init_hook = alc268_dell_init_hook,
12589 .input_mux = &alc268_capture_source,
12590 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012591 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012592 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12593 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012594 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12595 alc268_toshiba_verbs },
12596 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12597 .dac_nids = alc268_dac_nids,
12598 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12599 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012600 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012601 .hp_nid = 0x03,
12602 .dig_out_nid = ALC268_DIGOUT_NID,
12603 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12604 .channel_mode = alc268_modes,
12605 .input_mux = &alc268_capture_source,
12606 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012607 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012608 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012609#ifdef CONFIG_SND_DEBUG
12610 [ALC268_TEST] = {
12611 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12612 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12613 alc268_volume_init_verbs },
12614 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12615 .dac_nids = alc268_dac_nids,
12616 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12617 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012618 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012619 .hp_nid = 0x03,
12620 .dig_out_nid = ALC268_DIGOUT_NID,
12621 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12622 .channel_mode = alc268_modes,
12623 .input_mux = &alc268_capture_source,
12624 },
12625#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012626};
12627
12628static int patch_alc268(struct hda_codec *codec)
12629{
12630 struct alc_spec *spec;
12631 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012632 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012633
12634 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12635 if (spec == NULL)
12636 return -ENOMEM;
12637
12638 codec->spec = spec;
12639
12640 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12641 alc268_models,
12642 alc268_cfg_tbl);
12643
12644 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012645 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12646 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012647 board_config = ALC268_AUTO;
12648 }
12649
12650 if (board_config == ALC268_AUTO) {
12651 /* automatic parse from the BIOS config */
12652 err = alc268_parse_auto_config(codec);
12653 if (err < 0) {
12654 alc_free(codec);
12655 return err;
12656 } else if (!err) {
12657 printk(KERN_INFO
12658 "hda_codec: Cannot set up configuration "
12659 "from BIOS. Using base mode...\n");
12660 board_config = ALC268_3ST;
12661 }
12662 }
12663
12664 if (board_config != ALC268_AUTO)
12665 setup_preset(spec, &alc268_presets[board_config]);
12666
Kailang Yanga361d842007-06-05 12:30:55 +020012667 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12668 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012669 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012670
Kailang Yanga361d842007-06-05 12:30:55 +020012671 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12672
Takashi Iwai22971e32009-02-10 11:56:44 +010012673 has_beep = 0;
12674 for (i = 0; i < spec->num_mixers; i++) {
12675 if (spec->mixers[i] == alc268_beep_mixer) {
12676 has_beep = 1;
12677 break;
12678 }
12679 }
12680
12681 if (has_beep) {
12682 err = snd_hda_attach_beep_device(codec, 0x1);
12683 if (err < 0) {
12684 alc_free(codec);
12685 return err;
12686 }
12687 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12688 /* override the amp caps for beep generator */
12689 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012690 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12691 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12692 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12693 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012694 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012695
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012696 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012697 /* check whether NID 0x07 is valid */
12698 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012699 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012700
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012701 /* get type */
12702 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012703 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012704 spec->adc_nids = alc268_adc_nids_alt;
12705 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012706 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012707 } else {
12708 spec->adc_nids = alc268_adc_nids;
12709 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012710 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012711 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012712 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012713 /* set default input source */
12714 for (i = 0; i < spec->num_adc_nids; i++)
12715 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12716 0, AC_VERB_SET_CONNECT_SEL,
12717 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012718 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012719
12720 spec->vmaster_nid = 0x02;
12721
Kailang Yanga361d842007-06-05 12:30:55 +020012722 codec->patch_ops = alc_patch_ops;
12723 if (board_config == ALC268_AUTO)
12724 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012725
Takashi Iwaidaead532008-11-28 12:55:36 +010012726 codec->proc_widget_hook = print_realtek_coef;
12727
Kailang Yanga361d842007-06-05 12:30:55 +020012728 return 0;
12729}
12730
12731/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012732 * ALC269 channel source setting (2 channel)
12733 */
12734#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12735
12736#define alc269_dac_nids alc260_dac_nids
12737
12738static hda_nid_t alc269_adc_nids[1] = {
12739 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012740 0x08,
12741};
12742
Takashi Iwaie01bf502008-08-21 16:25:07 +020012743static hda_nid_t alc269_capsrc_nids[1] = {
12744 0x23,
12745};
12746
12747/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12748 * not a mux!
12749 */
12750
Kailang Yangf53281e2008-07-18 12:36:43 +020012751static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12752 .num_items = 2,
12753 .items = {
12754 { "i-Mic", 0x5 },
12755 { "e-Mic", 0x0 },
12756 },
12757};
12758
12759static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12760 .num_items = 2,
12761 .items = {
12762 { "i-Mic", 0x1 },
12763 { "e-Mic", 0x0 },
12764 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012765};
12766
12767#define alc269_modes alc260_modes
12768#define alc269_capture_source alc880_lg_lw_capture_source
12769
12770static struct snd_kcontrol_new alc269_base_mixer[] = {
12771 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12772 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12776 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12777 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12778 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12779 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12780 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12782 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12783 { } /* end */
12784};
12785
Kailang Yang60db6b52008-08-26 13:13:00 +020012786static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12787 /* output mixer control */
12788 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12789 {
12790 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12791 .name = "Master Playback Switch",
12792 .info = snd_hda_mixer_amp_switch_info,
12793 .get = snd_hda_mixer_amp_switch_get,
12794 .put = alc268_acer_master_sw_put,
12795 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12796 },
12797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12799 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12800 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12801 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12802 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012803 { }
12804};
12805
Tony Vroon64154832008-11-06 15:08:49 +000012806static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12807 /* output mixer control */
12808 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12809 {
12810 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12811 .name = "Master Playback Switch",
12812 .info = snd_hda_mixer_amp_switch_info,
12813 .get = snd_hda_mixer_amp_switch_get,
12814 .put = alc268_acer_master_sw_put,
12815 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12816 },
12817 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12818 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12819 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12820 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12821 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12822 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12823 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12824 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12825 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012826 { }
12827};
12828
Kailang Yangf53281e2008-07-18 12:36:43 +020012829/* bind volumes of both NID 0x0c and 0x0d */
12830static struct hda_bind_ctls alc269_epc_bind_vol = {
12831 .ops = &snd_hda_bind_vol,
12832 .values = {
12833 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12834 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12835 0
12836 },
12837};
12838
12839static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12840 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12841 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12842 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12843 { } /* end */
12844};
12845
Kailang Yangf6a92242007-12-13 16:52:54 +010012846/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012847static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12848 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12849 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012850 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12851 { } /* end */
12852};
12853
12854/* FSC amilo */
12855static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12856 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12857 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12858 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012859 { } /* end */
12860};
12861
Kailang Yang60db6b52008-08-26 13:13:00 +020012862static struct hda_verb alc269_quanta_fl1_verbs[] = {
12863 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12864 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12865 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12866 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12867 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12868 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12869 { }
12870};
12871
Tony Vroon64154832008-11-06 15:08:49 +000012872static struct hda_verb alc269_lifebook_verbs[] = {
12873 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12874 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12875 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12876 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12877 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12878 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12879 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12880 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12881 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12882 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12883 { }
12884};
12885
Kailang Yang60db6b52008-08-26 13:13:00 +020012886/* toggle speaker-output according to the hp-jack state */
12887static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12888{
12889 unsigned int present;
12890 unsigned char bits;
12891
12892 present = snd_hda_codec_read(codec, 0x15, 0,
12893 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12894 bits = present ? AMP_IN_MUTE(0) : 0;
12895 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12896 AMP_IN_MUTE(0), bits);
12897 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12898 AMP_IN_MUTE(0), bits);
12899
12900 snd_hda_codec_write(codec, 0x20, 0,
12901 AC_VERB_SET_COEF_INDEX, 0x0c);
12902 snd_hda_codec_write(codec, 0x20, 0,
12903 AC_VERB_SET_PROC_COEF, 0x680);
12904
12905 snd_hda_codec_write(codec, 0x20, 0,
12906 AC_VERB_SET_COEF_INDEX, 0x0c);
12907 snd_hda_codec_write(codec, 0x20, 0,
12908 AC_VERB_SET_PROC_COEF, 0x480);
12909}
12910
Tony Vroon64154832008-11-06 15:08:49 +000012911/* toggle speaker-output according to the hp-jacks state */
12912static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12913{
12914 unsigned int present;
12915 unsigned char bits;
12916
12917 /* Check laptop headphone socket */
12918 present = snd_hda_codec_read(codec, 0x15, 0,
12919 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12920
12921 /* Check port replicator headphone socket */
12922 present |= snd_hda_codec_read(codec, 0x1a, 0,
12923 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12924
12925 bits = present ? AMP_IN_MUTE(0) : 0;
12926 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12927 AMP_IN_MUTE(0), bits);
12928 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12929 AMP_IN_MUTE(0), bits);
12930
12931 snd_hda_codec_write(codec, 0x20, 0,
12932 AC_VERB_SET_COEF_INDEX, 0x0c);
12933 snd_hda_codec_write(codec, 0x20, 0,
12934 AC_VERB_SET_PROC_COEF, 0x680);
12935
12936 snd_hda_codec_write(codec, 0x20, 0,
12937 AC_VERB_SET_COEF_INDEX, 0x0c);
12938 snd_hda_codec_write(codec, 0x20, 0,
12939 AC_VERB_SET_PROC_COEF, 0x480);
12940}
12941
Kailang Yang60db6b52008-08-26 13:13:00 +020012942static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12943{
12944 unsigned int present;
12945
12946 present = snd_hda_codec_read(codec, 0x18, 0,
12947 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12948 snd_hda_codec_write(codec, 0x23, 0,
12949 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12950}
12951
Tony Vroon64154832008-11-06 15:08:49 +000012952static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12953{
12954 unsigned int present_laptop;
12955 unsigned int present_dock;
12956
12957 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12958 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12959
12960 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12961 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12962
12963 /* Laptop mic port overrides dock mic port, design decision */
12964 if (present_dock)
12965 snd_hda_codec_write(codec, 0x23, 0,
12966 AC_VERB_SET_CONNECT_SEL, 0x3);
12967 if (present_laptop)
12968 snd_hda_codec_write(codec, 0x23, 0,
12969 AC_VERB_SET_CONNECT_SEL, 0x0);
12970 if (!present_dock && !present_laptop)
12971 snd_hda_codec_write(codec, 0x23, 0,
12972 AC_VERB_SET_CONNECT_SEL, 0x1);
12973}
12974
Kailang Yang60db6b52008-08-26 13:13:00 +020012975static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12976 unsigned int res)
12977{
12978 if ((res >> 26) == ALC880_HP_EVENT)
12979 alc269_quanta_fl1_speaker_automute(codec);
12980 if ((res >> 26) == ALC880_MIC_EVENT)
12981 alc269_quanta_fl1_mic_automute(codec);
12982}
12983
Tony Vroon64154832008-11-06 15:08:49 +000012984static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12985 unsigned int res)
12986{
12987 if ((res >> 26) == ALC880_HP_EVENT)
12988 alc269_lifebook_speaker_automute(codec);
12989 if ((res >> 26) == ALC880_MIC_EVENT)
12990 alc269_lifebook_mic_autoswitch(codec);
12991}
12992
Kailang Yang60db6b52008-08-26 13:13:00 +020012993static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12994{
12995 alc269_quanta_fl1_speaker_automute(codec);
12996 alc269_quanta_fl1_mic_automute(codec);
12997}
12998
Tony Vroon64154832008-11-06 15:08:49 +000012999static void alc269_lifebook_init_hook(struct hda_codec *codec)
13000{
13001 alc269_lifebook_speaker_automute(codec);
13002 alc269_lifebook_mic_autoswitch(codec);
13003}
13004
Kailang Yang60db6b52008-08-26 13:13:00 +020013005static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13006 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13007 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13008 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13009 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13010 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13011 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13012 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13013 {}
13014};
13015
13016static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13017 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13018 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13019 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13020 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13021 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13022 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13023 {}
13024};
13025
13026/* toggle speaker-output according to the hp-jack state */
13027static void alc269_speaker_automute(struct hda_codec *codec)
13028{
13029 unsigned int present;
13030 unsigned char bits;
13031
13032 present = snd_hda_codec_read(codec, 0x15, 0,
13033 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13034 bits = present ? AMP_IN_MUTE(0) : 0;
13035 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13036 AMP_IN_MUTE(0), bits);
13037 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13038 AMP_IN_MUTE(0), bits);
13039}
13040
13041static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
13042{
13043 unsigned int present;
13044
13045 present = snd_hda_codec_read(codec, 0x18, 0,
13046 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13047 snd_hda_codec_write(codec, 0x23, 0,
13048 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
13049}
13050
13051static void alc269_eeepc_amic_automute(struct hda_codec *codec)
13052{
13053 unsigned int present;
13054
13055 present = snd_hda_codec_read(codec, 0x18, 0,
13056 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13057 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13058 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13059 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13060 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13061}
13062
13063/* unsolicited event for HP jack sensing */
13064static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
13065 unsigned int res)
13066{
13067 if ((res >> 26) == ALC880_HP_EVENT)
13068 alc269_speaker_automute(codec);
13069
13070 if ((res >> 26) == ALC880_MIC_EVENT)
13071 alc269_eeepc_dmic_automute(codec);
13072}
13073
13074static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
13075{
13076 alc269_speaker_automute(codec);
13077 alc269_eeepc_dmic_automute(codec);
13078}
13079
13080/* unsolicited event for HP jack sensing */
13081static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
13082 unsigned int res)
13083{
13084 if ((res >> 26) == ALC880_HP_EVENT)
13085 alc269_speaker_automute(codec);
13086
13087 if ((res >> 26) == ALC880_MIC_EVENT)
13088 alc269_eeepc_amic_automute(codec);
13089}
13090
13091static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
13092{
13093 alc269_speaker_automute(codec);
13094 alc269_eeepc_amic_automute(codec);
13095}
13096
Kailang Yangf6a92242007-12-13 16:52:54 +010013097/*
13098 * generic initialization of ADC, input mixers and output mixers
13099 */
13100static struct hda_verb alc269_init_verbs[] = {
13101 /*
13102 * Unmute ADC0 and set the default input to mic-in
13103 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013104 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013105
13106 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13107 * analog-loopback mixer widget
13108 * Note: PASD motherboards uses the Line In 2 as the input for
13109 * front panel mic (mic 2)
13110 */
13111 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13117
13118 /*
13119 * Set up output mixers (0x0c - 0x0e)
13120 */
13121 /* set vol=0 to output mixers */
13122 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13123 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13124
13125 /* set up input amps for analog loopback */
13126 /* Amp Indices: DAC = 0, mixer = 1 */
13127 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13129 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13130 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13131 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13132 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13133
13134 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13135 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13136 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13137 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13138 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13139 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13140 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13141
13142 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13143 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13144 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13147 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13148 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13149
13150 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13151 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13152
13153 /* FIXME: use matrix-type input source selection */
13154 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13155 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13157 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013158 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13159 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13160
13161 /* set EAPD */
13162 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13163 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13164 { }
13165};
13166
13167/* add playback controls from the parsed DAC table */
13168static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
13169 const struct auto_pin_cfg *cfg)
13170{
13171 hda_nid_t nid;
13172 int err;
13173
13174 spec->multiout.num_dacs = 1; /* only use one dac */
13175 spec->multiout.dac_nids = spec->private_dac_nids;
13176 spec->multiout.dac_nids[0] = 2;
13177
13178 nid = cfg->line_out_pins[0];
13179 if (nid) {
13180 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13181 "Front Playback Volume",
13182 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13183 if (err < 0)
13184 return err;
13185 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13186 "Front Playback Switch",
13187 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13188 if (err < 0)
13189 return err;
13190 }
13191
13192 nid = cfg->speaker_pins[0];
13193 if (nid) {
13194 if (!cfg->line_out_pins[0]) {
13195 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13196 "Speaker Playback Volume",
13197 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13198 HDA_OUTPUT));
13199 if (err < 0)
13200 return err;
13201 }
13202 if (nid == 0x16) {
13203 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13204 "Speaker Playback Switch",
13205 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13206 HDA_OUTPUT));
13207 if (err < 0)
13208 return err;
13209 } else {
13210 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13211 "Speaker Playback Switch",
13212 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13213 HDA_OUTPUT));
13214 if (err < 0)
13215 return err;
13216 }
13217 }
13218 nid = cfg->hp_pins[0];
13219 if (nid) {
13220 /* spec->multiout.hp_nid = 2; */
13221 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13222 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13223 "Headphone Playback Volume",
13224 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13225 HDA_OUTPUT));
13226 if (err < 0)
13227 return err;
13228 }
13229 if (nid == 0x16) {
13230 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13231 "Headphone Playback Switch",
13232 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13233 HDA_OUTPUT));
13234 if (err < 0)
13235 return err;
13236 } else {
13237 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13238 "Headphone Playback Switch",
13239 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13240 HDA_OUTPUT));
13241 if (err < 0)
13242 return err;
13243 }
13244 }
13245 return 0;
13246}
13247
Takashi Iwaiee956e02008-10-31 17:16:31 +010013248static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
13249 const struct auto_pin_cfg *cfg)
13250{
13251 int err;
13252
13253 err = alc880_auto_create_analog_input_ctls(spec, cfg);
13254 if (err < 0)
13255 return err;
13256 /* digital-mic input pin is excluded in alc880_auto_create..()
13257 * because it's under 0x18
13258 */
13259 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
13260 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013261 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010013262 imux->items[imux->num_items].label = "Int Mic";
13263 imux->items[imux->num_items].index = 0x05;
13264 imux->num_items++;
13265 }
13266 return 0;
13267}
Kailang Yangf6a92242007-12-13 16:52:54 +010013268
13269#ifdef CONFIG_SND_HDA_POWER_SAVE
13270#define alc269_loopbacks alc880_loopbacks
13271#endif
13272
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013273/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013274#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13275#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13276#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13277#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13278
Takashi Iwaif03d3112009-03-05 14:18:16 +010013279static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13280 .substreams = 1,
13281 .channels_min = 2,
13282 .channels_max = 8,
13283 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13284 /* NID is set in alc_build_pcms */
13285 .ops = {
13286 .open = alc880_playback_pcm_open,
13287 .prepare = alc880_playback_pcm_prepare,
13288 .cleanup = alc880_playback_pcm_cleanup
13289 },
13290};
13291
13292static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13293 .substreams = 1,
13294 .channels_min = 2,
13295 .channels_max = 2,
13296 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13297 /* NID is set in alc_build_pcms */
13298};
13299
Kailang Yangf6a92242007-12-13 16:52:54 +010013300/*
13301 * BIOS auto configuration
13302 */
13303static int alc269_parse_auto_config(struct hda_codec *codec)
13304{
13305 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013306 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013307 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13308
13309 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13310 alc269_ignore);
13311 if (err < 0)
13312 return err;
13313
13314 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13315 if (err < 0)
13316 return err;
13317 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13318 if (err < 0)
13319 return err;
13320
13321 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13322
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013323 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013324 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13325
Takashi Iwai603c4012008-07-30 15:01:44 +020013326 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013327 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013328
Takashi Iwaid88897e2008-10-31 15:01:37 +010013329 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013330 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013331 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013332 /* set default input source */
13333 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13334 0, AC_VERB_SET_CONNECT_SEL,
13335 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013336
13337 err = alc_auto_add_mic_boost(codec);
13338 if (err < 0)
13339 return err;
13340
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013341 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013342 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013343
Kailang Yangf6a92242007-12-13 16:52:54 +010013344 return 1;
13345}
13346
13347#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13348#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13349#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13350
13351
13352/* init callback for auto-configuration model -- overriding the default init */
13353static void alc269_auto_init(struct hda_codec *codec)
13354{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013355 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013356 alc269_auto_init_multi_out(codec);
13357 alc269_auto_init_hp_out(codec);
13358 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013359 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013360 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013361}
13362
13363/*
13364 * configuration and preset
13365 */
13366static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013367 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013368 [ALC269_QUANTA_FL1] = "quanta",
13369 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013370 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013371 [ALC269_FUJITSU] = "fujitsu",
13372 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013373};
13374
13375static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013376 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013377 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13378 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013379 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13380 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13381 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13382 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13383 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13384 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013385 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13386 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013387 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13388 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013389 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013390 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013391 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013392 {}
13393};
13394
13395static struct alc_config_preset alc269_presets[] = {
13396 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013397 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013398 .init_verbs = { alc269_init_verbs },
13399 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13400 .dac_nids = alc269_dac_nids,
13401 .hp_nid = 0x03,
13402 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13403 .channel_mode = alc269_modes,
13404 .input_mux = &alc269_capture_source,
13405 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013406 [ALC269_QUANTA_FL1] = {
13407 .mixers = { alc269_quanta_fl1_mixer },
13408 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13409 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13410 .dac_nids = alc269_dac_nids,
13411 .hp_nid = 0x03,
13412 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13413 .channel_mode = alc269_modes,
13414 .input_mux = &alc269_capture_source,
13415 .unsol_event = alc269_quanta_fl1_unsol_event,
13416 .init_hook = alc269_quanta_fl1_init_hook,
13417 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013418 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013419 .mixers = { alc269_eeepc_mixer },
13420 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013421 .init_verbs = { alc269_init_verbs,
13422 alc269_eeepc_amic_init_verbs },
13423 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13424 .dac_nids = alc269_dac_nids,
13425 .hp_nid = 0x03,
13426 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13427 .channel_mode = alc269_modes,
13428 .input_mux = &alc269_eeepc_amic_capture_source,
13429 .unsol_event = alc269_eeepc_amic_unsol_event,
13430 .init_hook = alc269_eeepc_amic_inithook,
13431 },
13432 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013433 .mixers = { alc269_eeepc_mixer },
13434 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013435 .init_verbs = { alc269_init_verbs,
13436 alc269_eeepc_dmic_init_verbs },
13437 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13438 .dac_nids = alc269_dac_nids,
13439 .hp_nid = 0x03,
13440 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13441 .channel_mode = alc269_modes,
13442 .input_mux = &alc269_eeepc_dmic_capture_source,
13443 .unsol_event = alc269_eeepc_dmic_unsol_event,
13444 .init_hook = alc269_eeepc_dmic_inithook,
13445 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013446 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013447 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013448 .cap_mixer = alc269_epc_capture_mixer,
13449 .init_verbs = { alc269_init_verbs,
13450 alc269_eeepc_dmic_init_verbs },
13451 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13452 .dac_nids = alc269_dac_nids,
13453 .hp_nid = 0x03,
13454 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13455 .channel_mode = alc269_modes,
13456 .input_mux = &alc269_eeepc_dmic_capture_source,
13457 .unsol_event = alc269_eeepc_dmic_unsol_event,
13458 .init_hook = alc269_eeepc_dmic_inithook,
13459 },
Tony Vroon64154832008-11-06 15:08:49 +000013460 [ALC269_LIFEBOOK] = {
13461 .mixers = { alc269_lifebook_mixer },
13462 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13463 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13464 .dac_nids = alc269_dac_nids,
13465 .hp_nid = 0x03,
13466 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13467 .channel_mode = alc269_modes,
13468 .input_mux = &alc269_capture_source,
13469 .unsol_event = alc269_lifebook_unsol_event,
13470 .init_hook = alc269_lifebook_init_hook,
13471 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013472};
13473
13474static int patch_alc269(struct hda_codec *codec)
13475{
13476 struct alc_spec *spec;
13477 int board_config;
13478 int err;
13479
13480 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13481 if (spec == NULL)
13482 return -ENOMEM;
13483
13484 codec->spec = spec;
13485
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013486 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13487
Kailang Yangf6a92242007-12-13 16:52:54 +010013488 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13489 alc269_models,
13490 alc269_cfg_tbl);
13491
13492 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020013493 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13494 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013495 board_config = ALC269_AUTO;
13496 }
13497
13498 if (board_config == ALC269_AUTO) {
13499 /* automatic parse from the BIOS config */
13500 err = alc269_parse_auto_config(codec);
13501 if (err < 0) {
13502 alc_free(codec);
13503 return err;
13504 } else if (!err) {
13505 printk(KERN_INFO
13506 "hda_codec: Cannot set up configuration "
13507 "from BIOS. Using base mode...\n");
13508 board_config = ALC269_BASIC;
13509 }
13510 }
13511
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013512 err = snd_hda_attach_beep_device(codec, 0x1);
13513 if (err < 0) {
13514 alc_free(codec);
13515 return err;
13516 }
13517
Kailang Yangf6a92242007-12-13 16:52:54 +010013518 if (board_config != ALC269_AUTO)
13519 setup_preset(spec, &alc269_presets[board_config]);
13520
Takashi Iwaif03d3112009-03-05 14:18:16 +010013521 if (codec->subsystem_id == 0x17aa3bf8) {
13522 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13523 * fix the sample rate of analog I/O to 44.1kHz
13524 */
13525 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13526 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13527 } else {
13528 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13529 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13530 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013531 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13532 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13533
13534 spec->adc_nids = alc269_adc_nids;
13535 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013536 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013537 if (!spec->cap_mixer)
13538 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013539 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013540
13541 codec->patch_ops = alc_patch_ops;
13542 if (board_config == ALC269_AUTO)
13543 spec->init_hook = alc269_auto_init;
13544#ifdef CONFIG_SND_HDA_POWER_SAVE
13545 if (!spec->loopback.amplist)
13546 spec->loopback.amplist = alc269_loopbacks;
13547#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013548 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013549
13550 return 0;
13551}
13552
13553/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013554 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13555 */
13556
13557/*
13558 * set the path ways for 2 channel output
13559 * need to set the codec line out and mic 1 pin widgets to inputs
13560 */
13561static struct hda_verb alc861_threestack_ch2_init[] = {
13562 /* set pin widget 1Ah (line in) for input */
13563 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013564 /* set pin widget 18h (mic1/2) for input, for mic also enable
13565 * the vref
13566 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013567 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13568
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013569 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13570#if 0
13571 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13572 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13573#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013574 { } /* end */
13575};
13576/*
13577 * 6ch mode
13578 * need to set the codec line out and mic 1 pin widgets to outputs
13579 */
13580static struct hda_verb alc861_threestack_ch6_init[] = {
13581 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13582 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13583 /* set pin widget 18h (mic1) for output (CLFE)*/
13584 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13585
13586 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013587 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013588
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013589 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13590#if 0
13591 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13592 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13593#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013594 { } /* end */
13595};
13596
13597static struct hda_channel_mode alc861_threestack_modes[2] = {
13598 { 2, alc861_threestack_ch2_init },
13599 { 6, alc861_threestack_ch6_init },
13600};
Takashi Iwai22309c32006-08-09 16:57:28 +020013601/* Set mic1 as input and unmute the mixer */
13602static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13603 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13604 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13605 { } /* end */
13606};
13607/* Set mic1 as output and mute mixer */
13608static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13609 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13610 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13611 { } /* end */
13612};
13613
13614static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13615 { 2, alc861_uniwill_m31_ch2_init },
13616 { 4, alc861_uniwill_m31_ch4_init },
13617};
Kailang Yangdf694da2005-12-05 19:42:22 +010013618
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013619/* Set mic1 and line-in as input and unmute the mixer */
13620static struct hda_verb alc861_asus_ch2_init[] = {
13621 /* set pin widget 1Ah (line in) for input */
13622 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013623 /* set pin widget 18h (mic1/2) for input, for mic also enable
13624 * the vref
13625 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013626 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13627
13628 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13629#if 0
13630 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13631 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13632#endif
13633 { } /* end */
13634};
13635/* Set mic1 nad line-in as output and mute mixer */
13636static struct hda_verb alc861_asus_ch6_init[] = {
13637 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13638 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13639 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13640 /* set pin widget 18h (mic1) for output (CLFE)*/
13641 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13642 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13643 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13644 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13645
13646 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13647#if 0
13648 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13649 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13650#endif
13651 { } /* end */
13652};
13653
13654static struct hda_channel_mode alc861_asus_modes[2] = {
13655 { 2, alc861_asus_ch2_init },
13656 { 6, alc861_asus_ch6_init },
13657};
13658
Kailang Yangdf694da2005-12-05 19:42:22 +010013659/* patch-ALC861 */
13660
13661static struct snd_kcontrol_new alc861_base_mixer[] = {
13662 /* output mixer control */
13663 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13664 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13665 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13666 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13667 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13668
13669 /*Input mixer control */
13670 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13671 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13672 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13673 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13674 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13675 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13677 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13678 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13679 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013680
Kailang Yangdf694da2005-12-05 19:42:22 +010013681 { } /* end */
13682};
13683
13684static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13685 /* output mixer control */
13686 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13687 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13688 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13689 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13690 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13691
13692 /* Input mixer control */
13693 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13694 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13695 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13696 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13697 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13698 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13699 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13700 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13701 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13702 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013703
Kailang Yangdf694da2005-12-05 19:42:22 +010013704 {
13705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13706 .name = "Channel Mode",
13707 .info = alc_ch_mode_info,
13708 .get = alc_ch_mode_get,
13709 .put = alc_ch_mode_put,
13710 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13711 },
13712 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013713};
13714
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013715static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013716 /* output mixer control */
13717 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13719 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013720
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013721 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013722};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013723
Takashi Iwai22309c32006-08-09 16:57:28 +020013724static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13725 /* output mixer control */
13726 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13727 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13728 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13729 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13730 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13731
13732 /* Input mixer control */
13733 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13734 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13735 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13736 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13737 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13738 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13739 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13740 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13741 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13742 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013743
Takashi Iwai22309c32006-08-09 16:57:28 +020013744 {
13745 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13746 .name = "Channel Mode",
13747 .info = alc_ch_mode_info,
13748 .get = alc_ch_mode_get,
13749 .put = alc_ch_mode_put,
13750 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13751 },
13752 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013753};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013754
13755static struct snd_kcontrol_new alc861_asus_mixer[] = {
13756 /* output mixer control */
13757 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13758 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13759 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13760 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13761 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13762
13763 /* Input mixer control */
13764 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13765 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13766 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13767 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13768 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13769 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13770 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13771 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13772 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013773 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13774
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013775 {
13776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13777 .name = "Channel Mode",
13778 .info = alc_ch_mode_info,
13779 .get = alc_ch_mode_get,
13780 .put = alc_ch_mode_put,
13781 .private_value = ARRAY_SIZE(alc861_asus_modes),
13782 },
13783 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013784};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013785
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013786/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013787static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013788 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13789 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013790 { }
13791};
13792
Kailang Yangdf694da2005-12-05 19:42:22 +010013793/*
13794 * generic initialization of ADC, input mixers and output mixers
13795 */
13796static struct hda_verb alc861_base_init_verbs[] = {
13797 /*
13798 * Unmute ADC0 and set the default input to mic-in
13799 */
13800 /* port-A for surround (rear panel) */
13801 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13802 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13803 /* port-B for mic-in (rear panel) with vref */
13804 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13805 /* port-C for line-in (rear panel) */
13806 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13807 /* port-D for Front */
13808 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13809 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13810 /* port-E for HP out (front panel) */
13811 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13812 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013813 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013814 /* port-F for mic-in (front panel) with vref */
13815 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13816 /* port-G for CLFE (rear panel) */
13817 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13818 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13819 /* port-H for side (rear panel) */
13820 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13821 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13822 /* CD-in */
13823 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13824 /* route front mic to ADC1*/
13825 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13826 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013827
Kailang Yangdf694da2005-12-05 19:42:22 +010013828 /* Unmute DAC0~3 & spdif out*/
13829 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13830 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13831 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13832 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13833 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013834
Kailang Yangdf694da2005-12-05 19:42:22 +010013835 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13836 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13837 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13838 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13839 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013840
Kailang Yangdf694da2005-12-05 19:42:22 +010013841 /* Unmute Stereo Mixer 15 */
13842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013846
13847 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13848 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13849 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13850 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13851 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13853 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13854 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013855 /* hp used DAC 3 (Front) */
13856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013857 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13858
13859 { }
13860};
13861
13862static struct hda_verb alc861_threestack_init_verbs[] = {
13863 /*
13864 * Unmute ADC0 and set the default input to mic-in
13865 */
13866 /* port-A for surround (rear panel) */
13867 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13868 /* port-B for mic-in (rear panel) with vref */
13869 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13870 /* port-C for line-in (rear panel) */
13871 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13872 /* port-D for Front */
13873 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13874 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13875 /* port-E for HP out (front panel) */
13876 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13877 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013878 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013879 /* port-F for mic-in (front panel) with vref */
13880 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13881 /* port-G for CLFE (rear panel) */
13882 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13883 /* port-H for side (rear panel) */
13884 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13885 /* CD-in */
13886 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13887 /* route front mic to ADC1*/
13888 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13890 /* Unmute DAC0~3 & spdif out*/
13891 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13892 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13893 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13894 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13895 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013896
Kailang Yangdf694da2005-12-05 19:42:22 +010013897 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13898 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13899 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13900 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13901 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013902
Kailang Yangdf694da2005-12-05 19:42:22 +010013903 /* Unmute Stereo Mixer 15 */
13904 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13906 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013907 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013908
13909 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13910 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13911 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13912 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13913 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13914 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13915 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13916 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013917 /* hp used DAC 3 (Front) */
13918 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013919 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13920 { }
13921};
Takashi Iwai22309c32006-08-09 16:57:28 +020013922
13923static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13924 /*
13925 * Unmute ADC0 and set the default input to mic-in
13926 */
13927 /* port-A for surround (rear panel) */
13928 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13929 /* port-B for mic-in (rear panel) with vref */
13930 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13931 /* port-C for line-in (rear panel) */
13932 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13933 /* port-D for Front */
13934 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13935 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13936 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013937 /* this has to be set to VREF80 */
13938 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013939 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013940 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013941 /* port-F for mic-in (front panel) with vref */
13942 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13943 /* port-G for CLFE (rear panel) */
13944 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13945 /* port-H for side (rear panel) */
13946 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13947 /* CD-in */
13948 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13949 /* route front mic to ADC1*/
13950 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13951 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13952 /* Unmute DAC0~3 & spdif out*/
13953 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13954 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13955 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13956 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13957 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013958
Takashi Iwai22309c32006-08-09 16:57:28 +020013959 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13960 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13961 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13962 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13963 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013964
Takashi Iwai22309c32006-08-09 16:57:28 +020013965 /* Unmute Stereo Mixer 15 */
13966 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13967 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13968 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013970
13971 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13972 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13973 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13974 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13975 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13976 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13977 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13978 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013979 /* hp used DAC 3 (Front) */
13980 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013981 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13982 { }
13983};
13984
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013985static struct hda_verb alc861_asus_init_verbs[] = {
13986 /*
13987 * Unmute ADC0 and set the default input to mic-in
13988 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013989 /* port-A for surround (rear panel)
13990 * according to codec#0 this is the HP jack
13991 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013992 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13993 /* route front PCM to HP */
13994 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13995 /* port-B for mic-in (rear panel) with vref */
13996 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13997 /* port-C for line-in (rear panel) */
13998 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13999 /* port-D for Front */
14000 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14001 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14002 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014003 /* this has to be set to VREF80 */
14004 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014005 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014006 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014007 /* port-F for mic-in (front panel) with vref */
14008 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14009 /* port-G for CLFE (rear panel) */
14010 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14011 /* port-H for side (rear panel) */
14012 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14013 /* CD-in */
14014 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14015 /* route front mic to ADC1*/
14016 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14017 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14018 /* Unmute DAC0~3 & spdif out*/
14019 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14020 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14021 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14022 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14024 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14025 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14026 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14027 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14028 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014029
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014030 /* Unmute Stereo Mixer 15 */
14031 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14032 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14033 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014035
14036 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14037 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14038 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14039 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14040 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14041 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14042 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14043 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014044 /* hp used DAC 3 (Front) */
14045 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014046 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14047 { }
14048};
14049
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014050/* additional init verbs for ASUS laptops */
14051static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14052 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14053 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14054 { }
14055};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014056
Kailang Yangdf694da2005-12-05 19:42:22 +010014057/*
14058 * generic initialization of ADC, input mixers and output mixers
14059 */
14060static struct hda_verb alc861_auto_init_verbs[] = {
14061 /*
14062 * Unmute ADC0 and set the default input to mic-in
14063 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014064 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014065 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014066
Kailang Yangdf694da2005-12-05 19:42:22 +010014067 /* Unmute DAC0~3 & spdif out*/
14068 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14069 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14070 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14071 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14072 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014073
Kailang Yangdf694da2005-12-05 19:42:22 +010014074 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14075 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14076 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14077 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14078 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014079
Kailang Yangdf694da2005-12-05 19:42:22 +010014080 /* Unmute Stereo Mixer 15 */
14081 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14082 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14084 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14085
14086 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14087 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14088 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14089 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14090 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14091 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14092 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14093 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14094
14095 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14096 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014097 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14098 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014099 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14100 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014101 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14102 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014103
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014104 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014105
14106 { }
14107};
14108
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014109static struct hda_verb alc861_toshiba_init_verbs[] = {
14110 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014111
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014112 { }
14113};
14114
14115/* toggle speaker-output according to the hp-jack state */
14116static void alc861_toshiba_automute(struct hda_codec *codec)
14117{
14118 unsigned int present;
14119
14120 present = snd_hda_codec_read(codec, 0x0f, 0,
14121 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014122 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14123 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14124 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14125 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014126}
14127
14128static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14129 unsigned int res)
14130{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014131 if ((res >> 26) == ALC880_HP_EVENT)
14132 alc861_toshiba_automute(codec);
14133}
14134
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014135/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014136#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14137#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14138#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14139#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14140
14141
14142#define ALC861_DIGOUT_NID 0x07
14143
14144static struct hda_channel_mode alc861_8ch_modes[1] = {
14145 { 8, NULL }
14146};
14147
14148static hda_nid_t alc861_dac_nids[4] = {
14149 /* front, surround, clfe, side */
14150 0x03, 0x06, 0x05, 0x04
14151};
14152
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014153static hda_nid_t alc660_dac_nids[3] = {
14154 /* front, clfe, surround */
14155 0x03, 0x05, 0x06
14156};
14157
Kailang Yangdf694da2005-12-05 19:42:22 +010014158static hda_nid_t alc861_adc_nids[1] = {
14159 /* ADC0-2 */
14160 0x08,
14161};
14162
14163static struct hda_input_mux alc861_capture_source = {
14164 .num_items = 5,
14165 .items = {
14166 { "Mic", 0x0 },
14167 { "Front Mic", 0x3 },
14168 { "Line", 0x1 },
14169 { "CD", 0x4 },
14170 { "Mixer", 0x5 },
14171 },
14172};
14173
14174/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014175static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
14176 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014177{
14178 int i;
14179 hda_nid_t nid;
14180
14181 spec->multiout.dac_nids = spec->private_dac_nids;
14182 for (i = 0; i < cfg->line_outs; i++) {
14183 nid = cfg->line_out_pins[i];
14184 if (nid) {
14185 if (i >= ARRAY_SIZE(alc861_dac_nids))
14186 continue;
14187 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
14188 }
14189 }
14190 spec->multiout.num_dacs = cfg->line_outs;
14191 return 0;
14192}
14193
14194/* add playback controls from the parsed DAC table */
14195static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
14196 const struct auto_pin_cfg *cfg)
14197{
14198 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014199 static const char *chname[4] = {
14200 "Front", "Surround", NULL /*CLFE*/, "Side"
14201 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014202 hda_nid_t nid;
14203 int i, idx, err;
14204
14205 for (i = 0; i < cfg->line_outs; i++) {
14206 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014207 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014208 continue;
14209 if (nid == 0x05) {
14210 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014211 err = add_control(spec, ALC_CTL_BIND_MUTE,
14212 "Center Playback Switch",
14213 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14214 HDA_OUTPUT));
14215 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014216 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014217 err = add_control(spec, ALC_CTL_BIND_MUTE,
14218 "LFE Playback Switch",
14219 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14220 HDA_OUTPUT));
14221 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014222 return err;
14223 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014224 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
14225 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010014226 if (nid == alc861_dac_nids[idx])
14227 break;
14228 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014229 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14230 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14231 HDA_OUTPUT));
14232 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014233 return err;
14234 }
14235 }
14236 return 0;
14237}
14238
14239static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
14240{
14241 int err;
14242 hda_nid_t nid;
14243
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014244 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014245 return 0;
14246
14247 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14248 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014249 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
14250 "Headphone Playback Switch",
14251 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14252 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014253 return err;
14254 spec->multiout.hp_nid = nid;
14255 }
14256 return 0;
14257}
14258
14259/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014260static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
14261 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014262{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014263 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014264 int i, err, idx, idx1;
14265
14266 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014267 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014268 case 0x0c:
14269 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014270 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014271 break;
14272 case 0x0f:
14273 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014274 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014275 break;
14276 case 0x0d:
14277 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014278 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014279 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014280 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014281 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014282 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014283 break;
14284 case 0x11:
14285 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014286 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014287 break;
14288 default:
14289 continue;
14290 }
14291
Takashi Iwai4a471b72005-12-07 13:56:29 +010014292 err = new_analog_input(spec, cfg->input_pins[i],
14293 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014294 if (err < 0)
14295 return err;
14296
Takashi Iwai4a471b72005-12-07 13:56:29 +010014297 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014298 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014299 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014300 }
14301 return 0;
14302}
14303
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014304static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14305 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010014306 int pin_type, int dac_idx)
14307{
Jacek Luczak564c5be2008-05-03 18:41:23 +020014308 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14309 pin_type);
14310 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14311 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010014312}
14313
14314static void alc861_auto_init_multi_out(struct hda_codec *codec)
14315{
14316 struct alc_spec *spec = codec->spec;
14317 int i;
14318
14319 for (i = 0; i < spec->autocfg.line_outs; i++) {
14320 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014321 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014322 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014323 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014324 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014325 }
14326}
14327
14328static void alc861_auto_init_hp_out(struct hda_codec *codec)
14329{
14330 struct alc_spec *spec = codec->spec;
14331 hda_nid_t pin;
14332
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014333 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014334 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014335 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14336 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014337 pin = spec->autocfg.speaker_pins[0];
14338 if (pin)
14339 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014340}
14341
14342static void alc861_auto_init_analog_input(struct hda_codec *codec)
14343{
14344 struct alc_spec *spec = codec->spec;
14345 int i;
14346
14347 for (i = 0; i < AUTO_PIN_LAST; i++) {
14348 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014349 if (nid >= 0x0c && nid <= 0x11)
14350 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014351 }
14352}
14353
14354/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014355/* return 1 if successful, 0 if the proper config is not found,
14356 * or a negative error code
14357 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014358static int alc861_parse_auto_config(struct hda_codec *codec)
14359{
14360 struct alc_spec *spec = codec->spec;
14361 int err;
14362 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14363
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014364 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14365 alc861_ignore);
14366 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014367 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014368 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014369 return 0; /* can't find valid BIOS pin config */
14370
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014371 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14372 if (err < 0)
14373 return err;
14374 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14375 if (err < 0)
14376 return err;
14377 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14378 if (err < 0)
14379 return err;
14380 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14381 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014382 return err;
14383
14384 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14385
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014386 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014387 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14388
Takashi Iwai603c4012008-07-30 15:01:44 +020014389 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014390 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014391
Takashi Iwaid88897e2008-10-31 15:01:37 +010014392 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014393
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014394 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014395 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014396
14397 spec->adc_nids = alc861_adc_nids;
14398 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014399 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014400
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014401 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14402
Kailang Yangdf694da2005-12-05 19:42:22 +010014403 return 1;
14404}
14405
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014406/* additional initialization for auto-configuration model */
14407static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014408{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014409 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014410 alc861_auto_init_multi_out(codec);
14411 alc861_auto_init_hp_out(codec);
14412 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014413 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014414 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014415}
14416
Takashi Iwaicb53c622007-08-10 17:21:45 +020014417#ifdef CONFIG_SND_HDA_POWER_SAVE
14418static struct hda_amp_list alc861_loopbacks[] = {
14419 { 0x15, HDA_INPUT, 0 },
14420 { 0x15, HDA_INPUT, 1 },
14421 { 0x15, HDA_INPUT, 2 },
14422 { 0x15, HDA_INPUT, 3 },
14423 { } /* end */
14424};
14425#endif
14426
Kailang Yangdf694da2005-12-05 19:42:22 +010014427
14428/*
14429 * configuration and preset
14430 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014431static const char *alc861_models[ALC861_MODEL_LAST] = {
14432 [ALC861_3ST] = "3stack",
14433 [ALC660_3ST] = "3stack-660",
14434 [ALC861_3ST_DIG] = "3stack-dig",
14435 [ALC861_6ST_DIG] = "6stack-dig",
14436 [ALC861_UNIWILL_M31] = "uniwill-m31",
14437 [ALC861_TOSHIBA] = "toshiba",
14438 [ALC861_ASUS] = "asus",
14439 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14440 [ALC861_AUTO] = "auto",
14441};
14442
14443static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014444 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014445 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14446 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14447 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014448 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014449 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014450 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014451 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14452 * Any other models that need this preset?
14453 */
14454 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014455 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14456 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014457 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14458 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14459 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14460 /* FIXME: the below seems conflict */
14461 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14462 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14463 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014464 {}
14465};
14466
14467static struct alc_config_preset alc861_presets[] = {
14468 [ALC861_3ST] = {
14469 .mixers = { alc861_3ST_mixer },
14470 .init_verbs = { alc861_threestack_init_verbs },
14471 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14472 .dac_nids = alc861_dac_nids,
14473 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14474 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014475 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014476 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14477 .adc_nids = alc861_adc_nids,
14478 .input_mux = &alc861_capture_source,
14479 },
14480 [ALC861_3ST_DIG] = {
14481 .mixers = { alc861_base_mixer },
14482 .init_verbs = { alc861_threestack_init_verbs },
14483 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14484 .dac_nids = alc861_dac_nids,
14485 .dig_out_nid = ALC861_DIGOUT_NID,
14486 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14487 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014488 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014489 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14490 .adc_nids = alc861_adc_nids,
14491 .input_mux = &alc861_capture_source,
14492 },
14493 [ALC861_6ST_DIG] = {
14494 .mixers = { alc861_base_mixer },
14495 .init_verbs = { alc861_base_init_verbs },
14496 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14497 .dac_nids = alc861_dac_nids,
14498 .dig_out_nid = ALC861_DIGOUT_NID,
14499 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14500 .channel_mode = alc861_8ch_modes,
14501 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14502 .adc_nids = alc861_adc_nids,
14503 .input_mux = &alc861_capture_source,
14504 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014505 [ALC660_3ST] = {
14506 .mixers = { alc861_3ST_mixer },
14507 .init_verbs = { alc861_threestack_init_verbs },
14508 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14509 .dac_nids = alc660_dac_nids,
14510 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14511 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014512 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014513 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14514 .adc_nids = alc861_adc_nids,
14515 .input_mux = &alc861_capture_source,
14516 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014517 [ALC861_UNIWILL_M31] = {
14518 .mixers = { alc861_uniwill_m31_mixer },
14519 .init_verbs = { alc861_uniwill_m31_init_verbs },
14520 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14521 .dac_nids = alc861_dac_nids,
14522 .dig_out_nid = ALC861_DIGOUT_NID,
14523 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14524 .channel_mode = alc861_uniwill_m31_modes,
14525 .need_dac_fix = 1,
14526 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14527 .adc_nids = alc861_adc_nids,
14528 .input_mux = &alc861_capture_source,
14529 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014530 [ALC861_TOSHIBA] = {
14531 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014532 .init_verbs = { alc861_base_init_verbs,
14533 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014534 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14535 .dac_nids = alc861_dac_nids,
14536 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14537 .channel_mode = alc883_3ST_2ch_modes,
14538 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14539 .adc_nids = alc861_adc_nids,
14540 .input_mux = &alc861_capture_source,
14541 .unsol_event = alc861_toshiba_unsol_event,
14542 .init_hook = alc861_toshiba_automute,
14543 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014544 [ALC861_ASUS] = {
14545 .mixers = { alc861_asus_mixer },
14546 .init_verbs = { alc861_asus_init_verbs },
14547 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14548 .dac_nids = alc861_dac_nids,
14549 .dig_out_nid = ALC861_DIGOUT_NID,
14550 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14551 .channel_mode = alc861_asus_modes,
14552 .need_dac_fix = 1,
14553 .hp_nid = 0x06,
14554 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14555 .adc_nids = alc861_adc_nids,
14556 .input_mux = &alc861_capture_source,
14557 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014558 [ALC861_ASUS_LAPTOP] = {
14559 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14560 .init_verbs = { alc861_asus_init_verbs,
14561 alc861_asus_laptop_init_verbs },
14562 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14563 .dac_nids = alc861_dac_nids,
14564 .dig_out_nid = ALC861_DIGOUT_NID,
14565 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14566 .channel_mode = alc883_3ST_2ch_modes,
14567 .need_dac_fix = 1,
14568 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14569 .adc_nids = alc861_adc_nids,
14570 .input_mux = &alc861_capture_source,
14571 },
14572};
Kailang Yangdf694da2005-12-05 19:42:22 +010014573
14574
14575static int patch_alc861(struct hda_codec *codec)
14576{
14577 struct alc_spec *spec;
14578 int board_config;
14579 int err;
14580
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014581 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014582 if (spec == NULL)
14583 return -ENOMEM;
14584
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014585 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014586
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014587 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14588 alc861_models,
14589 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014590
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014591 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014592 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14593 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014594 board_config = ALC861_AUTO;
14595 }
14596
14597 if (board_config == ALC861_AUTO) {
14598 /* automatic parse from the BIOS config */
14599 err = alc861_parse_auto_config(codec);
14600 if (err < 0) {
14601 alc_free(codec);
14602 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014603 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014604 printk(KERN_INFO
14605 "hda_codec: Cannot set up configuration "
14606 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014607 board_config = ALC861_3ST_DIG;
14608 }
14609 }
14610
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014611 err = snd_hda_attach_beep_device(codec, 0x23);
14612 if (err < 0) {
14613 alc_free(codec);
14614 return err;
14615 }
14616
Kailang Yangdf694da2005-12-05 19:42:22 +010014617 if (board_config != ALC861_AUTO)
14618 setup_preset(spec, &alc861_presets[board_config]);
14619
Kailang Yangdf694da2005-12-05 19:42:22 +010014620 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14621 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14622
Kailang Yangdf694da2005-12-05 19:42:22 +010014623 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14624 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14625
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014626 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14627
Takashi Iwai2134ea42008-01-10 16:53:55 +010014628 spec->vmaster_nid = 0x03;
14629
Kailang Yangdf694da2005-12-05 19:42:22 +010014630 codec->patch_ops = alc_patch_ops;
14631 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014632 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014633#ifdef CONFIG_SND_HDA_POWER_SAVE
14634 if (!spec->loopback.amplist)
14635 spec->loopback.amplist = alc861_loopbacks;
14636#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014637 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014638
Kailang Yangdf694da2005-12-05 19:42:22 +010014639 return 0;
14640}
14641
14642/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014643 * ALC861-VD support
14644 *
14645 * Based on ALC882
14646 *
14647 * In addition, an independent DAC
14648 */
14649#define ALC861VD_DIGOUT_NID 0x06
14650
14651static hda_nid_t alc861vd_dac_nids[4] = {
14652 /* front, surr, clfe, side surr */
14653 0x02, 0x03, 0x04, 0x05
14654};
14655
14656/* dac_nids for ALC660vd are in a different order - according to
14657 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014658 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014659 * of ALC660vd codecs, but for now there is only 3stack mixer
14660 * - and it is the same as in 861vd.
14661 * adc_nids in ALC660vd are (is) the same as in 861vd
14662 */
14663static hda_nid_t alc660vd_dac_nids[3] = {
14664 /* front, rear, clfe, rear_surr */
14665 0x02, 0x04, 0x03
14666};
14667
14668static hda_nid_t alc861vd_adc_nids[1] = {
14669 /* ADC0 */
14670 0x09,
14671};
14672
Takashi Iwaie1406342008-02-11 18:32:32 +010014673static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14674
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014675/* input MUX */
14676/* FIXME: should be a matrix-type input source selection */
14677static struct hda_input_mux alc861vd_capture_source = {
14678 .num_items = 4,
14679 .items = {
14680 { "Mic", 0x0 },
14681 { "Front Mic", 0x1 },
14682 { "Line", 0x2 },
14683 { "CD", 0x4 },
14684 },
14685};
14686
Kailang Yang272a5272007-05-14 11:00:38 +020014687static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014688 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014689 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014690 { "Ext Mic", 0x0 },
14691 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014692 },
14693};
14694
Kailang Yangd1a991a2007-08-15 16:21:59 +020014695static struct hda_input_mux alc861vd_hp_capture_source = {
14696 .num_items = 2,
14697 .items = {
14698 { "Front Mic", 0x0 },
14699 { "ATAPI Mic", 0x1 },
14700 },
14701};
14702
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014703/*
14704 * 2ch mode
14705 */
14706static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14707 { 2, NULL }
14708};
14709
14710/*
14711 * 6ch mode
14712 */
14713static struct hda_verb alc861vd_6stack_ch6_init[] = {
14714 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14715 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14716 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14717 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14718 { } /* end */
14719};
14720
14721/*
14722 * 8ch mode
14723 */
14724static struct hda_verb alc861vd_6stack_ch8_init[] = {
14725 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14726 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14727 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14728 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14729 { } /* end */
14730};
14731
14732static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14733 { 6, alc861vd_6stack_ch6_init },
14734 { 8, alc861vd_6stack_ch8_init },
14735};
14736
14737static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14738 {
14739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14740 .name = "Channel Mode",
14741 .info = alc_ch_mode_info,
14742 .get = alc_ch_mode_get,
14743 .put = alc_ch_mode_put,
14744 },
14745 { } /* end */
14746};
14747
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014748/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14749 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14750 */
14751static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14752 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14753 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14754
14755 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14756 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14757
14758 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14759 HDA_OUTPUT),
14760 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14761 HDA_OUTPUT),
14762 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14763 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14764
14765 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14766 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14767
14768 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14769
14770 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14773
14774 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14775 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14776 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14777
14778 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14779 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14780
14781 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14782 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14783
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014784 { } /* end */
14785};
14786
14787static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14788 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14789 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14790
14791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14792
14793 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14796
14797 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14798 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14799 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14800
14801 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14802 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14803
14804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14806
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014807 { } /* end */
14808};
14809
Kailang Yangbdd148a2007-05-08 15:19:08 +020014810static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14811 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14812 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14813 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14814
14815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14816
14817 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14819 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14820
14821 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14824
14825 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14826 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14827
14828 { } /* end */
14829};
14830
Tobin Davisb419f342008-03-07 11:57:51 +010014831/* Pin assignment: Speaker=0x14, HP = 0x15,
14832 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014833 */
14834static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014835 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14836 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014837 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14838 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014839 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14840 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14841 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14842 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14843 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14844 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014845 { } /* end */
14846};
14847
Kailang Yangd1a991a2007-08-15 16:21:59 +020014848/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14849 * Front Mic=0x18, ATAPI Mic = 0x19,
14850 */
14851static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14852 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14853 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14854 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14855 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14856 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14857 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14858 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14859 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014860
Kailang Yangd1a991a2007-08-15 16:21:59 +020014861 { } /* end */
14862};
14863
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014864/*
14865 * generic initialization of ADC, input mixers and output mixers
14866 */
14867static struct hda_verb alc861vd_volume_init_verbs[] = {
14868 /*
14869 * Unmute ADC0 and set the default input to mic-in
14870 */
14871 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14872 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14873
14874 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14875 * the analog-loopback mixer widget
14876 */
14877 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14881 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014883
14884 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14886 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14887 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014888 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014889
14890 /*
14891 * Set up output mixers (0x02 - 0x05)
14892 */
14893 /* set vol=0 to output mixers */
14894 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14895 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14896 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14897 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14898
14899 /* set up input amps for analog loopback */
14900 /* Amp Indices: DAC = 0, mixer = 1 */
14901 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14902 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14903 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14904 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14905 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14906 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14908 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14909
14910 { }
14911};
14912
14913/*
14914 * 3-stack pin configuration:
14915 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14916 */
14917static struct hda_verb alc861vd_3stack_init_verbs[] = {
14918 /*
14919 * Set pin mode and muting
14920 */
14921 /* set front pin widgets 0x14 for output */
14922 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14923 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14924 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14925
14926 /* Mic (rear) pin: input vref at 80% */
14927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14929 /* Front Mic pin: input vref at 80% */
14930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14932 /* Line In pin: input */
14933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14934 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14935 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14936 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14937 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14938 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14939 /* CD pin widget for input */
14940 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14941
14942 { }
14943};
14944
14945/*
14946 * 6-stack pin configuration:
14947 */
14948static struct hda_verb alc861vd_6stack_init_verbs[] = {
14949 /*
14950 * Set pin mode and muting
14951 */
14952 /* set front pin widgets 0x14 for output */
14953 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14955 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14956
14957 /* Rear Pin: output 1 (0x0d) */
14958 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14960 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14961 /* CLFE Pin: output 2 (0x0e) */
14962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14963 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14964 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14965 /* Side Pin: output 3 (0x0f) */
14966 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14967 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14968 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14969
14970 /* Mic (rear) pin: input vref at 80% */
14971 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14972 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14973 /* Front Mic pin: input vref at 80% */
14974 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14975 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14976 /* Line In pin: input */
14977 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14978 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14979 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14980 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14981 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14982 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14983 /* CD pin widget for input */
14984 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14985
14986 { }
14987};
14988
Kailang Yangbdd148a2007-05-08 15:19:08 +020014989static struct hda_verb alc861vd_eapd_verbs[] = {
14990 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14991 { }
14992};
14993
Kailang Yangf9423e72008-05-27 12:32:25 +020014994static struct hda_verb alc660vd_eapd_verbs[] = {
14995 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14996 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14997 { }
14998};
14999
Kailang Yangbdd148a2007-05-08 15:19:08 +020015000static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15001 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15002 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15004 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015005 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015006 {}
15007};
15008
Kailang Yangbdd148a2007-05-08 15:19:08 +020015009static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15010{
15011 unsigned int present;
15012 unsigned char bits;
15013
15014 present = snd_hda_codec_read(codec, 0x18, 0,
15015 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015016 bits = present ? HDA_AMP_MUTE : 0;
15017 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15018 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015019}
15020
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015021static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015022{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015023 struct alc_spec *spec = codec->spec;
15024
15025 spec->autocfg.hp_pins[0] = 0x1b;
15026 spec->autocfg.speaker_pins[0] = 0x14;
15027 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015028 alc861vd_lenovo_mic_automute(codec);
15029}
15030
15031static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15032 unsigned int res)
15033{
15034 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015035 case ALC880_MIC_EVENT:
15036 alc861vd_lenovo_mic_automute(codec);
15037 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015038 default:
15039 alc_automute_amp_unsol_event(codec, res);
15040 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015041 }
15042}
15043
Kailang Yang272a5272007-05-14 11:00:38 +020015044static struct hda_verb alc861vd_dallas_verbs[] = {
15045 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15046 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15047 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15048 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15049
15050 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15051 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15052 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15053 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15055 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15056 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15057 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015058
Kailang Yang272a5272007-05-14 11:00:38 +020015059 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15060 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15061 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15063 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15064 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15065 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15066 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15067
15068 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15069 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15070 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15072 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15073 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15074 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15075 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15076
15077 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15078 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15081
15082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015083 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015084 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15085
15086 { } /* end */
15087};
15088
15089/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015090static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015091{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015092 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015093
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015094 spec->autocfg.hp_pins[0] = 0x15;
15095 spec->autocfg.speaker_pins[0] = 0x14;
15096 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020015097}
15098
Takashi Iwaicb53c622007-08-10 17:21:45 +020015099#ifdef CONFIG_SND_HDA_POWER_SAVE
15100#define alc861vd_loopbacks alc880_loopbacks
15101#endif
15102
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015103/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015104#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15105#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15106#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15107#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15108
15109/*
15110 * configuration and preset
15111 */
15112static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15113 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015114 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015115 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015116 [ALC861VD_3ST] = "3stack",
15117 [ALC861VD_3ST_DIG] = "3stack-digout",
15118 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015119 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015120 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015121 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015122 [ALC861VD_AUTO] = "auto",
15123};
15124
15125static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015126 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15127 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015128 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015129 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015130 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015131 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015132 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015133 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015134 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020015135 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015136 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015137 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015138 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015139 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015140 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015141 {}
15142};
15143
15144static struct alc_config_preset alc861vd_presets[] = {
15145 [ALC660VD_3ST] = {
15146 .mixers = { alc861vd_3st_mixer },
15147 .init_verbs = { alc861vd_volume_init_verbs,
15148 alc861vd_3stack_init_verbs },
15149 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15150 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015151 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15152 .channel_mode = alc861vd_3stack_2ch_modes,
15153 .input_mux = &alc861vd_capture_source,
15154 },
Mike Crash6963f842007-06-25 12:12:51 +020015155 [ALC660VD_3ST_DIG] = {
15156 .mixers = { alc861vd_3st_mixer },
15157 .init_verbs = { alc861vd_volume_init_verbs,
15158 alc861vd_3stack_init_verbs },
15159 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15160 .dac_nids = alc660vd_dac_nids,
15161 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015162 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15163 .channel_mode = alc861vd_3stack_2ch_modes,
15164 .input_mux = &alc861vd_capture_source,
15165 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015166 [ALC861VD_3ST] = {
15167 .mixers = { alc861vd_3st_mixer },
15168 .init_verbs = { alc861vd_volume_init_verbs,
15169 alc861vd_3stack_init_verbs },
15170 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15171 .dac_nids = alc861vd_dac_nids,
15172 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15173 .channel_mode = alc861vd_3stack_2ch_modes,
15174 .input_mux = &alc861vd_capture_source,
15175 },
15176 [ALC861VD_3ST_DIG] = {
15177 .mixers = { alc861vd_3st_mixer },
15178 .init_verbs = { alc861vd_volume_init_verbs,
15179 alc861vd_3stack_init_verbs },
15180 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15181 .dac_nids = alc861vd_dac_nids,
15182 .dig_out_nid = ALC861VD_DIGOUT_NID,
15183 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15184 .channel_mode = alc861vd_3stack_2ch_modes,
15185 .input_mux = &alc861vd_capture_source,
15186 },
15187 [ALC861VD_6ST_DIG] = {
15188 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15189 .init_verbs = { alc861vd_volume_init_verbs,
15190 alc861vd_6stack_init_verbs },
15191 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15192 .dac_nids = alc861vd_dac_nids,
15193 .dig_out_nid = ALC861VD_DIGOUT_NID,
15194 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15195 .channel_mode = alc861vd_6stack_modes,
15196 .input_mux = &alc861vd_capture_source,
15197 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015198 [ALC861VD_LENOVO] = {
15199 .mixers = { alc861vd_lenovo_mixer },
15200 .init_verbs = { alc861vd_volume_init_verbs,
15201 alc861vd_3stack_init_verbs,
15202 alc861vd_eapd_verbs,
15203 alc861vd_lenovo_unsol_verbs },
15204 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15205 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015206 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15207 .channel_mode = alc861vd_3stack_2ch_modes,
15208 .input_mux = &alc861vd_capture_source,
15209 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015210 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015211 },
Kailang Yang272a5272007-05-14 11:00:38 +020015212 [ALC861VD_DALLAS] = {
15213 .mixers = { alc861vd_dallas_mixer },
15214 .init_verbs = { alc861vd_dallas_verbs },
15215 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15216 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015217 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15218 .channel_mode = alc861vd_3stack_2ch_modes,
15219 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015220 .unsol_event = alc_automute_amp_unsol_event,
15221 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015222 },
15223 [ALC861VD_HP] = {
15224 .mixers = { alc861vd_hp_mixer },
15225 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15226 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15227 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015228 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015229 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15230 .channel_mode = alc861vd_3stack_2ch_modes,
15231 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015232 .unsol_event = alc_automute_amp_unsol_event,
15233 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020015234 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015235 [ALC660VD_ASUS_V1S] = {
15236 .mixers = { alc861vd_lenovo_mixer },
15237 .init_verbs = { alc861vd_volume_init_verbs,
15238 alc861vd_3stack_init_verbs,
15239 alc861vd_eapd_verbs,
15240 alc861vd_lenovo_unsol_verbs },
15241 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15242 .dac_nids = alc660vd_dac_nids,
15243 .dig_out_nid = ALC861VD_DIGOUT_NID,
15244 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15245 .channel_mode = alc861vd_3stack_2ch_modes,
15246 .input_mux = &alc861vd_capture_source,
15247 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015248 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015249 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015250};
15251
15252/*
15253 * BIOS auto configuration
15254 */
15255static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15256 hda_nid_t nid, int pin_type, int dac_idx)
15257{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015258 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015259}
15260
15261static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15262{
15263 struct alc_spec *spec = codec->spec;
15264 int i;
15265
15266 for (i = 0; i <= HDA_SIDE; i++) {
15267 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015268 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015269 if (nid)
15270 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015271 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015272 }
15273}
15274
15275
15276static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15277{
15278 struct alc_spec *spec = codec->spec;
15279 hda_nid_t pin;
15280
15281 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015282 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015283 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015284 pin = spec->autocfg.speaker_pins[0];
15285 if (pin)
15286 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015287}
15288
15289#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15290#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15291
15292static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15293{
15294 struct alc_spec *spec = codec->spec;
15295 int i;
15296
15297 for (i = 0; i < AUTO_PIN_LAST; i++) {
15298 hda_nid_t nid = spec->autocfg.input_pins[i];
15299 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015300 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015301 if (nid != ALC861VD_PIN_CD_NID &&
15302 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015303 snd_hda_codec_write(codec, nid, 0,
15304 AC_VERB_SET_AMP_GAIN_MUTE,
15305 AMP_OUT_MUTE);
15306 }
15307 }
15308}
15309
Takashi Iwaif511b012008-08-15 16:46:42 +020015310#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15311
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015312#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15313#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15314
15315/* add playback controls from the parsed DAC table */
15316/* Based on ALC880 version. But ALC861VD has separate,
15317 * different NIDs for mute/unmute switch and volume control */
15318static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15319 const struct auto_pin_cfg *cfg)
15320{
15321 char name[32];
15322 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15323 hda_nid_t nid_v, nid_s;
15324 int i, err;
15325
15326 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015327 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015328 continue;
15329 nid_v = alc861vd_idx_to_mixer_vol(
15330 alc880_dac_to_idx(
15331 spec->multiout.dac_nids[i]));
15332 nid_s = alc861vd_idx_to_mixer_switch(
15333 alc880_dac_to_idx(
15334 spec->multiout.dac_nids[i]));
15335
15336 if (i == 2) {
15337 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015338 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15339 "Center Playback Volume",
15340 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15341 HDA_OUTPUT));
15342 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015343 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015344 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15345 "LFE Playback Volume",
15346 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15347 HDA_OUTPUT));
15348 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015349 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015350 err = add_control(spec, ALC_CTL_BIND_MUTE,
15351 "Center Playback Switch",
15352 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15353 HDA_INPUT));
15354 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015355 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015356 err = add_control(spec, ALC_CTL_BIND_MUTE,
15357 "LFE Playback Switch",
15358 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15359 HDA_INPUT));
15360 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015361 return err;
15362 } else {
15363 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015364 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15365 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15366 HDA_OUTPUT));
15367 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015368 return err;
15369 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015370 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015371 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015372 HDA_INPUT));
15373 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015374 return err;
15375 }
15376 }
15377 return 0;
15378}
15379
15380/* add playback controls for speaker and HP outputs */
15381/* Based on ALC880 version. But ALC861VD has separate,
15382 * different NIDs for mute/unmute switch and volume control */
15383static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15384 hda_nid_t pin, const char *pfx)
15385{
15386 hda_nid_t nid_v, nid_s;
15387 int err;
15388 char name[32];
15389
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015390 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015391 return 0;
15392
15393 if (alc880_is_fixed_pin(pin)) {
15394 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15395 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015396 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015397 spec->multiout.hp_nid = nid_v;
15398 else
15399 spec->multiout.extra_out_nid[0] = nid_v;
15400 /* control HP volume/switch on the output mixer amp */
15401 nid_v = alc861vd_idx_to_mixer_vol(
15402 alc880_fixed_pin_idx(pin));
15403 nid_s = alc861vd_idx_to_mixer_switch(
15404 alc880_fixed_pin_idx(pin));
15405
15406 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015407 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15408 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15409 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015410 return err;
15411 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015412 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15413 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15414 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015415 return err;
15416 } else if (alc880_is_multi_pin(pin)) {
15417 /* set manual connection */
15418 /* we have only a switch on HP-out PIN */
15419 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015420 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15421 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15422 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015423 return err;
15424 }
15425 return 0;
15426}
15427
15428/* parse the BIOS configuration and set up the alc_spec
15429 * return 1 if successful, 0 if the proper config is not found,
15430 * or a negative error code
15431 * Based on ALC880 version - had to change it to override
15432 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15433static int alc861vd_parse_auto_config(struct hda_codec *codec)
15434{
15435 struct alc_spec *spec = codec->spec;
15436 int err;
15437 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15438
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015439 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15440 alc861vd_ignore);
15441 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015442 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015443 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015444 return 0; /* can't find valid BIOS pin config */
15445
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015446 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15447 if (err < 0)
15448 return err;
15449 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15450 if (err < 0)
15451 return err;
15452 err = alc861vd_auto_create_extra_out(spec,
15453 spec->autocfg.speaker_pins[0],
15454 "Speaker");
15455 if (err < 0)
15456 return err;
15457 err = alc861vd_auto_create_extra_out(spec,
15458 spec->autocfg.hp_pins[0],
15459 "Headphone");
15460 if (err < 0)
15461 return err;
15462 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15463 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015464 return err;
15465
15466 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15467
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015468 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015469 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15470
Takashi Iwai603c4012008-07-30 15:01:44 +020015471 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015472 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015473
Takashi Iwaid88897e2008-10-31 15:01:37 +010015474 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015475
15476 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015477 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015478
Takashi Iwai776e1842007-08-29 15:07:11 +020015479 err = alc_auto_add_mic_boost(codec);
15480 if (err < 0)
15481 return err;
15482
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015483 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15484
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015485 return 1;
15486}
15487
15488/* additional initialization for auto-configuration model */
15489static void alc861vd_auto_init(struct hda_codec *codec)
15490{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015491 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015492 alc861vd_auto_init_multi_out(codec);
15493 alc861vd_auto_init_hp_out(codec);
15494 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015495 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015496 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015497 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015498}
15499
15500static int patch_alc861vd(struct hda_codec *codec)
15501{
15502 struct alc_spec *spec;
15503 int err, board_config;
15504
15505 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15506 if (spec == NULL)
15507 return -ENOMEM;
15508
15509 codec->spec = spec;
15510
15511 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15512 alc861vd_models,
15513 alc861vd_cfg_tbl);
15514
15515 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020015516 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15517 "trying auto-probe from BIOS...\n", codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015518 board_config = ALC861VD_AUTO;
15519 }
15520
15521 if (board_config == ALC861VD_AUTO) {
15522 /* automatic parse from the BIOS config */
15523 err = alc861vd_parse_auto_config(codec);
15524 if (err < 0) {
15525 alc_free(codec);
15526 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015527 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015528 printk(KERN_INFO
15529 "hda_codec: Cannot set up configuration "
15530 "from BIOS. Using base mode...\n");
15531 board_config = ALC861VD_3ST;
15532 }
15533 }
15534
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015535 err = snd_hda_attach_beep_device(codec, 0x23);
15536 if (err < 0) {
15537 alc_free(codec);
15538 return err;
15539 }
15540
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015541 if (board_config != ALC861VD_AUTO)
15542 setup_preset(spec, &alc861vd_presets[board_config]);
15543
Kailang Yang2f893282008-05-27 12:14:47 +020015544 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015545 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015546 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015547 }
15548
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015549 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15550 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15551
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015552 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15553 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15554
15555 spec->adc_nids = alc861vd_adc_nids;
15556 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015557 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015558 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015559
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015560 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015561 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015562
Takashi Iwai2134ea42008-01-10 16:53:55 +010015563 spec->vmaster_nid = 0x02;
15564
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015565 codec->patch_ops = alc_patch_ops;
15566
15567 if (board_config == ALC861VD_AUTO)
15568 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015569#ifdef CONFIG_SND_HDA_POWER_SAVE
15570 if (!spec->loopback.amplist)
15571 spec->loopback.amplist = alc861vd_loopbacks;
15572#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015573 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015574
15575 return 0;
15576}
15577
15578/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015579 * ALC662 support
15580 *
15581 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15582 * configuration. Each pin widget can choose any input DACs and a mixer.
15583 * Each ADC is connected from a mixer of all inputs. This makes possible
15584 * 6-channel independent captures.
15585 *
15586 * In addition, an independent DAC for the multi-playback (not used in this
15587 * driver yet).
15588 */
15589#define ALC662_DIGOUT_NID 0x06
15590#define ALC662_DIGIN_NID 0x0a
15591
15592static hda_nid_t alc662_dac_nids[4] = {
15593 /* front, rear, clfe, rear_surr */
15594 0x02, 0x03, 0x04
15595};
15596
Kailang Yang622e84c2009-04-21 07:39:04 +020015597static hda_nid_t alc272_dac_nids[2] = {
15598 0x02, 0x03
15599};
15600
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015601static hda_nid_t alc662_adc_nids[1] = {
15602 /* ADC1-2 */
15603 0x09,
15604};
Takashi Iwaie1406342008-02-11 18:32:32 +010015605
Kailang Yang622e84c2009-04-21 07:39:04 +020015606static hda_nid_t alc272_adc_nids[1] = {
15607 /* ADC1-2 */
15608 0x08,
15609};
15610
Kailang Yang77a261b2008-02-19 11:38:05 +010015611static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015612static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15613
Takashi Iwaie1406342008-02-11 18:32:32 +010015614
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015615/* input MUX */
15616/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015617static struct hda_input_mux alc662_capture_source = {
15618 .num_items = 4,
15619 .items = {
15620 { "Mic", 0x0 },
15621 { "Front Mic", 0x1 },
15622 { "Line", 0x2 },
15623 { "CD", 0x4 },
15624 },
15625};
15626
15627static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15628 .num_items = 2,
15629 .items = {
15630 { "Mic", 0x1 },
15631 { "Line", 0x2 },
15632 },
15633};
Kailang Yang291702f2007-10-16 14:28:03 +020015634
15635static struct hda_input_mux alc662_eeepc_capture_source = {
15636 .num_items = 2,
15637 .items = {
15638 { "i-Mic", 0x1 },
15639 { "e-Mic", 0x0 },
15640 },
15641};
15642
Kailang Yang6dda9f42008-05-27 12:05:31 +020015643static struct hda_input_mux alc663_capture_source = {
15644 .num_items = 3,
15645 .items = {
15646 { "Mic", 0x0 },
15647 { "Front Mic", 0x1 },
15648 { "Line", 0x2 },
15649 },
15650};
15651
15652static struct hda_input_mux alc663_m51va_capture_source = {
15653 .num_items = 2,
15654 .items = {
15655 { "Ext-Mic", 0x0 },
15656 { "D-Mic", 0x9 },
15657 },
15658};
15659
Chris Pockelé9541ba12009-05-12 08:08:53 +020015660#if 1 /* set to 0 for testing other input sources below */
15661static struct hda_input_mux alc272_nc10_capture_source = {
15662 .num_items = 2,
15663 .items = {
15664 { "Autoselect Mic", 0x0 },
15665 { "Internal Mic", 0x1 },
15666 },
15667};
15668#else
15669static struct hda_input_mux alc272_nc10_capture_source = {
15670 .num_items = 16,
15671 .items = {
15672 { "Autoselect Mic", 0x0 },
15673 { "Internal Mic", 0x1 },
15674 { "In-0x02", 0x2 },
15675 { "In-0x03", 0x3 },
15676 { "In-0x04", 0x4 },
15677 { "In-0x05", 0x5 },
15678 { "In-0x06", 0x6 },
15679 { "In-0x07", 0x7 },
15680 { "In-0x08", 0x8 },
15681 { "In-0x09", 0x9 },
15682 { "In-0x0a", 0x0a },
15683 { "In-0x0b", 0x0b },
15684 { "In-0x0c", 0x0c },
15685 { "In-0x0d", 0x0d },
15686 { "In-0x0e", 0x0e },
15687 { "In-0x0f", 0x0f },
15688 },
15689};
15690#endif
15691
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015692/*
15693 * 2ch mode
15694 */
15695static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15696 { 2, NULL }
15697};
15698
15699/*
15700 * 2ch mode
15701 */
15702static struct hda_verb alc662_3ST_ch2_init[] = {
15703 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15704 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15705 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15706 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15707 { } /* end */
15708};
15709
15710/*
15711 * 6ch mode
15712 */
15713static struct hda_verb alc662_3ST_ch6_init[] = {
15714 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15715 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15716 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15717 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15718 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15719 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15720 { } /* end */
15721};
15722
15723static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15724 { 2, alc662_3ST_ch2_init },
15725 { 6, alc662_3ST_ch6_init },
15726};
15727
15728/*
15729 * 2ch mode
15730 */
15731static struct hda_verb alc662_sixstack_ch6_init[] = {
15732 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15733 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15734 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15735 { } /* end */
15736};
15737
15738/*
15739 * 6ch mode
15740 */
15741static struct hda_verb alc662_sixstack_ch8_init[] = {
15742 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15743 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15744 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15745 { } /* end */
15746};
15747
15748static struct hda_channel_mode alc662_5stack_modes[2] = {
15749 { 2, alc662_sixstack_ch6_init },
15750 { 6, alc662_sixstack_ch8_init },
15751};
15752
15753/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15754 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15755 */
15756
15757static struct snd_kcontrol_new alc662_base_mixer[] = {
15758 /* output mixer control */
15759 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015760 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015761 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015762 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015763 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15764 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015765 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15766 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015767 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15768
15769 /*Input mixer control */
15770 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15771 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15772 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15773 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15774 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15775 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15776 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15777 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015778 { } /* end */
15779};
15780
15781static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15782 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015783 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015784 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15785 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15786 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15787 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15788 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15789 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15790 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15791 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15792 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015793 { } /* end */
15794};
15795
15796static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15797 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015798 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015799 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015800 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015801 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15802 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015803 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15804 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015805 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15806 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15807 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15808 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15809 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15811 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15812 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15813 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015814 { } /* end */
15815};
15816
15817static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15818 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15819 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015820 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15821 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015822 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15823 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15824 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015827 { } /* end */
15828};
15829
Kailang Yang291702f2007-10-16 14:28:03 +020015830static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015831 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15832 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015833
15834 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15835 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15836 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15837
15838 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15839 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15840 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15841 { } /* end */
15842};
15843
Kailang Yang8c427222008-01-10 13:03:59 +010015844static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015845 ALC262_HIPPO_MASTER_SWITCH,
15846 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015847 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015848 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15849 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015850 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15851 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15852 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15855 { } /* end */
15856};
15857
Kailang Yangf1d4e282008-08-26 14:03:29 +020015858static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15859 .ops = &snd_hda_bind_vol,
15860 .values = {
15861 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15862 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15863 0
15864 },
15865};
15866
15867static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15868 .ops = &snd_hda_bind_sw,
15869 .values = {
15870 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15871 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15872 0
15873 },
15874};
15875
Kailang Yang6dda9f42008-05-27 12:05:31 +020015876static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015877 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15878 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15879 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15880 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15881 { } /* end */
15882};
15883
15884static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15885 .ops = &snd_hda_bind_sw,
15886 .values = {
15887 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15888 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15889 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15890 0
15891 },
15892};
15893
15894static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15895 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15896 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15899 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15900 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15901
15902 { } /* end */
15903};
15904
15905static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15906 .ops = &snd_hda_bind_sw,
15907 .values = {
15908 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15909 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15910 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15911 0
15912 },
15913};
15914
15915static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15916 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15917 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15918 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15919 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15920 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15921 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15922 { } /* end */
15923};
15924
15925static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015926 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15927 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15929 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15930 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15931 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15932 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15933 { } /* end */
15934};
15935
15936static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15937 .ops = &snd_hda_bind_vol,
15938 .values = {
15939 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15940 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15941 0
15942 },
15943};
15944
15945static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15946 .ops = &snd_hda_bind_sw,
15947 .values = {
15948 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15949 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15950 0
15951 },
15952};
15953
15954static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15955 HDA_BIND_VOL("Master Playback Volume",
15956 &alc663_asus_two_bind_master_vol),
15957 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15958 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015959 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015962 { } /* end */
15963};
15964
15965static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15966 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15967 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15968 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15970 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15971 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015972 { } /* end */
15973};
15974
15975static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15976 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15977 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15978 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15979 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15981
15982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15984 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15985 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15986 { } /* end */
15987};
15988
15989static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15990 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15991 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15992 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15993
15994 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15995 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15996 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15997 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15999 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16000 { } /* end */
16001};
16002
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016003static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16004 {
16005 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16006 .name = "Channel Mode",
16007 .info = alc_ch_mode_info,
16008 .get = alc_ch_mode_get,
16009 .put = alc_ch_mode_put,
16010 },
16011 { } /* end */
16012};
16013
16014static struct hda_verb alc662_init_verbs[] = {
16015 /* ADC: mute amp left and right */
16016 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16017 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16018 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16019
Takashi Iwaicb53c622007-08-10 17:21:45 +020016020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16022 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16023 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16024 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016025
Kailang Yangb60dd392007-09-20 12:50:29 +020016026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16028 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16029 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16030 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16031 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016032
16033 /* Front Pin: output 0 (0x0c) */
16034 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16035 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16036
16037 /* Rear Pin: output 1 (0x0d) */
16038 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16039 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16040
16041 /* CLFE Pin: output 2 (0x0e) */
16042 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16043 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16044
16045 /* Mic (rear) pin: input vref at 80% */
16046 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16047 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16048 /* Front Mic pin: input vref at 80% */
16049 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16050 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16051 /* Line In pin: input */
16052 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16053 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16054 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16055 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16056 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16057 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16058 /* CD pin widget for input */
16059 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16060
16061 /* FIXME: use matrix-type input source selection */
16062 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16063 /* Input mixer */
16064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016066
16067 /* always trun on EAPD */
16068 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16069 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16070
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016071 { }
16072};
16073
16074static struct hda_verb alc662_sue_init_verbs[] = {
16075 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16076 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016077 {}
16078};
16079
16080static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16081 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16082 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16083 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016084};
16085
Kailang Yang8c427222008-01-10 13:03:59 +010016086/* Set Unsolicited Event*/
16087static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16088 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16089 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16090 {}
16091};
16092
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016093/*
16094 * generic initialization of ADC, input mixers and output mixers
16095 */
16096static struct hda_verb alc662_auto_init_verbs[] = {
16097 /*
16098 * Unmute ADC and set the default input to mic-in
16099 */
16100 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16101 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16102
16103 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16104 * mixer widget
16105 * Note: PASD motherboards uses the Line In 2 as the input for front
16106 * panel mic (mic 2)
16107 */
16108 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016109 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16110 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16111 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016114
16115 /*
16116 * Set up output mixers (0x0c - 0x0f)
16117 */
16118 /* set vol=0 to output mixers */
16119 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16120 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16121 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16122
16123 /* set up input amps for analog loopback */
16124 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16126 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16127 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16128 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16129 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16130 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016131
16132
16133 /* FIXME: use matrix-type input source selection */
16134 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16135 /* Input mixer */
16136 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016137 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016138 { }
16139};
16140
Takashi Iwai24fb9172008-09-02 14:48:20 +020016141/* additional verbs for ALC663 */
16142static struct hda_verb alc663_auto_init_verbs[] = {
16143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16144 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16145 { }
16146};
16147
Kailang Yang6dda9f42008-05-27 12:05:31 +020016148static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016149 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16150 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016151 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16152 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016153 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16154 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16155 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016156 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16157 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16158 {}
16159};
16160
Kailang Yangf1d4e282008-08-26 14:03:29 +020016161static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16162 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16163 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16164 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16165 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16166 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16167 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16168 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16169 {}
16170};
16171
16172static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16173 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16174 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16175 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16176 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16179 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16180 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16181 {}
16182};
16183
16184static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16185 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16187 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16190 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16191 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16192 {}
16193};
16194
16195static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16196 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16197 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16198 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16199 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16201 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16202 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16204 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16205 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16206 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16207 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16208 {}
16209};
16210
16211static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16212 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16213 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16214 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16215 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16216 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16217 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16218 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16221 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16222 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16223 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16224 {}
16225};
16226
Kailang Yang6dda9f42008-05-27 12:05:31 +020016227static struct hda_verb alc663_g71v_init_verbs[] = {
16228 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16229 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16230 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16231
16232 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16233 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16234 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16235
16236 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16237 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16238 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16239 {}
16240};
16241
16242static struct hda_verb alc663_g50v_init_verbs[] = {
16243 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16244 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16245 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16246
16247 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16248 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16249 {}
16250};
16251
Kailang Yangf1d4e282008-08-26 14:03:29 +020016252static struct hda_verb alc662_ecs_init_verbs[] = {
16253 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16255 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16256 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16257 {}
16258};
16259
Kailang Yang622e84c2009-04-21 07:39:04 +020016260static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16261 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16262 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16263 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16264 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16265 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16266 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16267 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16269 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16270 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16271 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16272 {}
16273};
16274
16275static struct hda_verb alc272_dell_init_verbs[] = {
16276 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16277 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16278 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16279 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16280 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16281 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16282 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16285 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16286 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16287 {}
16288};
16289
Kailang Yangf1d4e282008-08-26 14:03:29 +020016290static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16291 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16292 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16293 { } /* end */
16294};
16295
Kailang Yang622e84c2009-04-21 07:39:04 +020016296static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16297 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16298 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16299 { } /* end */
16300};
16301
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016302static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16303{
16304 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016305 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016306
16307 present = snd_hda_codec_read(codec, 0x14, 0,
16308 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016309 bits = present ? HDA_AMP_MUTE : 0;
16310 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16311 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016312}
16313
16314static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16315{
16316 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016317 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016318
16319 present = snd_hda_codec_read(codec, 0x1b, 0,
16320 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016321 bits = present ? HDA_AMP_MUTE : 0;
16322 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16323 HDA_AMP_MUTE, bits);
16324 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16325 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016326}
16327
16328static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16329 unsigned int res)
16330{
16331 if ((res >> 26) == ALC880_HP_EVENT)
16332 alc662_lenovo_101e_all_automute(codec);
16333 if ((res >> 26) == ALC880_FRONT_EVENT)
16334 alc662_lenovo_101e_ispeaker_automute(codec);
16335}
16336
Kailang Yang291702f2007-10-16 14:28:03 +020016337static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16338{
16339 unsigned int present;
16340
16341 present = snd_hda_codec_read(codec, 0x18, 0,
16342 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16343 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16344 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16345 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16346 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16347 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16348 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16349 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16350 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16351}
16352
16353/* unsolicited event for HP jack sensing */
16354static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16355 unsigned int res)
16356{
Kailang Yang291702f2007-10-16 14:28:03 +020016357 if ((res >> 26) == ALC880_MIC_EVENT)
16358 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016359 else
16360 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016361}
16362
16363static void alc662_eeepc_inithook(struct hda_codec *codec)
16364{
Takashi Iwai42171c12009-05-08 14:11:43 +020016365 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016366 alc662_eeepc_mic_automute(codec);
16367}
16368
Kailang Yang8c427222008-01-10 13:03:59 +010016369static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16370{
Takashi Iwai42171c12009-05-08 14:11:43 +020016371 struct alc_spec *spec = codec->spec;
16372
16373 spec->autocfg.hp_pins[0] = 0x14;
16374 spec->autocfg.speaker_pins[0] = 0x1b;
16375 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016376}
16377
Kailang Yang6dda9f42008-05-27 12:05:31 +020016378static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16379{
16380 unsigned int present;
16381 unsigned char bits;
16382
16383 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016384 AC_VERB_GET_PIN_SENSE, 0)
16385 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016386 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016387 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16388 AMP_IN_MUTE(0), bits);
16389 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16390 AMP_IN_MUTE(0), bits);
16391}
16392
16393static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16394{
16395 unsigned int present;
16396 unsigned char bits;
16397
16398 present = snd_hda_codec_read(codec, 0x21, 0,
16399 AC_VERB_GET_PIN_SENSE, 0)
16400 & AC_PINSENSE_PRESENCE;
16401 bits = present ? HDA_AMP_MUTE : 0;
16402 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16403 AMP_IN_MUTE(0), bits);
16404 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16405 AMP_IN_MUTE(0), bits);
16406 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16407 AMP_IN_MUTE(0), bits);
16408 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16409 AMP_IN_MUTE(0), bits);
16410}
16411
16412static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16413{
16414 unsigned int present;
16415 unsigned char bits;
16416
16417 present = snd_hda_codec_read(codec, 0x15, 0,
16418 AC_VERB_GET_PIN_SENSE, 0)
16419 & AC_PINSENSE_PRESENCE;
16420 bits = present ? HDA_AMP_MUTE : 0;
16421 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16422 AMP_IN_MUTE(0), bits);
16423 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16424 AMP_IN_MUTE(0), bits);
16425 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16426 AMP_IN_MUTE(0), bits);
16427 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16428 AMP_IN_MUTE(0), bits);
16429}
16430
16431static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16432{
16433 unsigned int present;
16434 unsigned char bits;
16435
16436 present = snd_hda_codec_read(codec, 0x1b, 0,
16437 AC_VERB_GET_PIN_SENSE, 0)
16438 & AC_PINSENSE_PRESENCE;
16439 bits = present ? 0 : PIN_OUT;
16440 snd_hda_codec_write(codec, 0x14, 0,
16441 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16442}
16443
16444static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16445{
16446 unsigned int present1, present2;
16447
16448 present1 = snd_hda_codec_read(codec, 0x21, 0,
16449 AC_VERB_GET_PIN_SENSE, 0)
16450 & AC_PINSENSE_PRESENCE;
16451 present2 = snd_hda_codec_read(codec, 0x15, 0,
16452 AC_VERB_GET_PIN_SENSE, 0)
16453 & AC_PINSENSE_PRESENCE;
16454
16455 if (present1 || present2) {
16456 snd_hda_codec_write_cache(codec, 0x14, 0,
16457 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16458 } else {
16459 snd_hda_codec_write_cache(codec, 0x14, 0,
16460 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16461 }
16462}
16463
16464static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16465{
16466 unsigned int present1, present2;
16467
16468 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16469 AC_VERB_GET_PIN_SENSE, 0)
16470 & AC_PINSENSE_PRESENCE;
16471 present2 = snd_hda_codec_read(codec, 0x15, 0,
16472 AC_VERB_GET_PIN_SENSE, 0)
16473 & AC_PINSENSE_PRESENCE;
16474
16475 if (present1 || present2) {
16476 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16477 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16478 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16479 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16480 } else {
16481 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16482 AMP_IN_MUTE(0), 0);
16483 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16484 AMP_IN_MUTE(0), 0);
16485 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016486}
16487
16488static void alc663_m51va_mic_automute(struct hda_codec *codec)
16489{
16490 unsigned int present;
16491
16492 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016493 AC_VERB_GET_PIN_SENSE, 0)
16494 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016495 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016496 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016497 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016498 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016499 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016500 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016501 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016502 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016503}
16504
16505static void alc663_m51va_unsol_event(struct hda_codec *codec,
16506 unsigned int res)
16507{
16508 switch (res >> 26) {
16509 case ALC880_HP_EVENT:
16510 alc663_m51va_speaker_automute(codec);
16511 break;
16512 case ALC880_MIC_EVENT:
16513 alc663_m51va_mic_automute(codec);
16514 break;
16515 }
16516}
16517
16518static void alc663_m51va_inithook(struct hda_codec *codec)
16519{
16520 alc663_m51va_speaker_automute(codec);
16521 alc663_m51va_mic_automute(codec);
16522}
16523
Kailang Yangf1d4e282008-08-26 14:03:29 +020016524/* ***************** Mode1 ******************************/
16525static void alc663_mode1_unsol_event(struct hda_codec *codec,
16526 unsigned int res)
16527{
16528 switch (res >> 26) {
16529 case ALC880_HP_EVENT:
16530 alc663_m51va_speaker_automute(codec);
16531 break;
16532 case ALC880_MIC_EVENT:
16533 alc662_eeepc_mic_automute(codec);
16534 break;
16535 }
16536}
16537
16538static void alc663_mode1_inithook(struct hda_codec *codec)
16539{
16540 alc663_m51va_speaker_automute(codec);
16541 alc662_eeepc_mic_automute(codec);
16542}
16543/* ***************** Mode2 ******************************/
16544static void alc662_mode2_unsol_event(struct hda_codec *codec,
16545 unsigned int res)
16546{
16547 switch (res >> 26) {
16548 case ALC880_HP_EVENT:
16549 alc662_f5z_speaker_automute(codec);
16550 break;
16551 case ALC880_MIC_EVENT:
16552 alc662_eeepc_mic_automute(codec);
16553 break;
16554 }
16555}
16556
16557static void alc662_mode2_inithook(struct hda_codec *codec)
16558{
16559 alc662_f5z_speaker_automute(codec);
16560 alc662_eeepc_mic_automute(codec);
16561}
16562/* ***************** Mode3 ******************************/
16563static void alc663_mode3_unsol_event(struct hda_codec *codec,
16564 unsigned int res)
16565{
16566 switch (res >> 26) {
16567 case ALC880_HP_EVENT:
16568 alc663_two_hp_m1_speaker_automute(codec);
16569 break;
16570 case ALC880_MIC_EVENT:
16571 alc662_eeepc_mic_automute(codec);
16572 break;
16573 }
16574}
16575
16576static void alc663_mode3_inithook(struct hda_codec *codec)
16577{
16578 alc663_two_hp_m1_speaker_automute(codec);
16579 alc662_eeepc_mic_automute(codec);
16580}
16581/* ***************** Mode4 ******************************/
16582static void alc663_mode4_unsol_event(struct hda_codec *codec,
16583 unsigned int res)
16584{
16585 switch (res >> 26) {
16586 case ALC880_HP_EVENT:
16587 alc663_21jd_two_speaker_automute(codec);
16588 break;
16589 case ALC880_MIC_EVENT:
16590 alc662_eeepc_mic_automute(codec);
16591 break;
16592 }
16593}
16594
16595static void alc663_mode4_inithook(struct hda_codec *codec)
16596{
16597 alc663_21jd_two_speaker_automute(codec);
16598 alc662_eeepc_mic_automute(codec);
16599}
16600/* ***************** Mode5 ******************************/
16601static void alc663_mode5_unsol_event(struct hda_codec *codec,
16602 unsigned int res)
16603{
16604 switch (res >> 26) {
16605 case ALC880_HP_EVENT:
16606 alc663_15jd_two_speaker_automute(codec);
16607 break;
16608 case ALC880_MIC_EVENT:
16609 alc662_eeepc_mic_automute(codec);
16610 break;
16611 }
16612}
16613
16614static void alc663_mode5_inithook(struct hda_codec *codec)
16615{
16616 alc663_15jd_two_speaker_automute(codec);
16617 alc662_eeepc_mic_automute(codec);
16618}
16619/* ***************** Mode6 ******************************/
16620static void alc663_mode6_unsol_event(struct hda_codec *codec,
16621 unsigned int res)
16622{
16623 switch (res >> 26) {
16624 case ALC880_HP_EVENT:
16625 alc663_two_hp_m2_speaker_automute(codec);
16626 break;
16627 case ALC880_MIC_EVENT:
16628 alc662_eeepc_mic_automute(codec);
16629 break;
16630 }
16631}
16632
16633static void alc663_mode6_inithook(struct hda_codec *codec)
16634{
16635 alc663_two_hp_m2_speaker_automute(codec);
16636 alc662_eeepc_mic_automute(codec);
16637}
16638
Kailang Yang6dda9f42008-05-27 12:05:31 +020016639static void alc663_g71v_hp_automute(struct hda_codec *codec)
16640{
16641 unsigned int present;
16642 unsigned char bits;
16643
16644 present = snd_hda_codec_read(codec, 0x21, 0,
16645 AC_VERB_GET_PIN_SENSE, 0)
16646 & AC_PINSENSE_PRESENCE;
16647 bits = present ? HDA_AMP_MUTE : 0;
16648 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16649 HDA_AMP_MUTE, bits);
16650 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16651 HDA_AMP_MUTE, bits);
16652}
16653
16654static void alc663_g71v_front_automute(struct hda_codec *codec)
16655{
16656 unsigned int present;
16657 unsigned char bits;
16658
16659 present = snd_hda_codec_read(codec, 0x15, 0,
16660 AC_VERB_GET_PIN_SENSE, 0)
16661 & AC_PINSENSE_PRESENCE;
16662 bits = present ? HDA_AMP_MUTE : 0;
16663 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16664 HDA_AMP_MUTE, bits);
16665}
16666
16667static void alc663_g71v_unsol_event(struct hda_codec *codec,
16668 unsigned int res)
16669{
16670 switch (res >> 26) {
16671 case ALC880_HP_EVENT:
16672 alc663_g71v_hp_automute(codec);
16673 break;
16674 case ALC880_FRONT_EVENT:
16675 alc663_g71v_front_automute(codec);
16676 break;
16677 case ALC880_MIC_EVENT:
16678 alc662_eeepc_mic_automute(codec);
16679 break;
16680 }
16681}
16682
16683static void alc663_g71v_inithook(struct hda_codec *codec)
16684{
16685 alc663_g71v_front_automute(codec);
16686 alc663_g71v_hp_automute(codec);
16687 alc662_eeepc_mic_automute(codec);
16688}
16689
16690static void alc663_g50v_unsol_event(struct hda_codec *codec,
16691 unsigned int res)
16692{
16693 switch (res >> 26) {
16694 case ALC880_HP_EVENT:
16695 alc663_m51va_speaker_automute(codec);
16696 break;
16697 case ALC880_MIC_EVENT:
16698 alc662_eeepc_mic_automute(codec);
16699 break;
16700 }
16701}
16702
16703static void alc663_g50v_inithook(struct hda_codec *codec)
16704{
16705 alc663_m51va_speaker_automute(codec);
16706 alc662_eeepc_mic_automute(codec);
16707}
16708
Kailang Yangf1d4e282008-08-26 14:03:29 +020016709static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16710 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016711 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016712
16713 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16714 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16715 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16716
16717 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16718 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16719 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16720 { } /* end */
16721};
16722
Chris Pockelé9541ba12009-05-12 08:08:53 +020016723static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16724 /* Master Playback automatically created from Speaker and Headphone */
16725 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16726 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16727 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16728 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16729
16730 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16731 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16732 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16733
16734 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16735 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16736 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16737 { } /* end */
16738};
16739
Takashi Iwaicb53c622007-08-10 17:21:45 +020016740#ifdef CONFIG_SND_HDA_POWER_SAVE
16741#define alc662_loopbacks alc880_loopbacks
16742#endif
16743
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016744
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016745/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016746#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16747#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16748#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16749#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16750
16751/*
16752 * configuration and preset
16753 */
16754static const char *alc662_models[ALC662_MODEL_LAST] = {
16755 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16756 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16757 [ALC662_3ST_6ch] = "3stack-6ch",
16758 [ALC662_5ST_DIG] = "6stack-dig",
16759 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016760 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016761 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016762 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016763 [ALC663_ASUS_M51VA] = "m51va",
16764 [ALC663_ASUS_G71V] = "g71v",
16765 [ALC663_ASUS_H13] = "h13",
16766 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016767 [ALC663_ASUS_MODE1] = "asus-mode1",
16768 [ALC662_ASUS_MODE2] = "asus-mode2",
16769 [ALC663_ASUS_MODE3] = "asus-mode3",
16770 [ALC663_ASUS_MODE4] = "asus-mode4",
16771 [ALC663_ASUS_MODE5] = "asus-mode5",
16772 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016773 [ALC272_DELL] = "dell",
16774 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016775 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016776 [ALC662_AUTO] = "auto",
16777};
16778
16779static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016780 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016781 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16782 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016783 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16784 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16785 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16786 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16787 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16788 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16789 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16790 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16791 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16792 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16793 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16794 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016795 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16796 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16797 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016798 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16799 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16800 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16801 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016802 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016803 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16804 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016805 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016806 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16807 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16808 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016809 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16810 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16811 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016812 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16813 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16814 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016815 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016816 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16817 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016818 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016819 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016820 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016821 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16822 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16823 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016824 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016825 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16826 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016827 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016828 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016829 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016830 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016831 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16832 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016833 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016834 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16835 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016836 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016837 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016838 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016839 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016840 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016841 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16842 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016843 {}
16844};
16845
16846static struct alc_config_preset alc662_presets[] = {
16847 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016848 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016849 .init_verbs = { alc662_init_verbs },
16850 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16851 .dac_nids = alc662_dac_nids,
16852 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016853 .dig_in_nid = ALC662_DIGIN_NID,
16854 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16855 .channel_mode = alc662_3ST_2ch_modes,
16856 .input_mux = &alc662_capture_source,
16857 },
16858 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016859 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016860 .init_verbs = { alc662_init_verbs },
16861 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16862 .dac_nids = alc662_dac_nids,
16863 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016864 .dig_in_nid = ALC662_DIGIN_NID,
16865 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16866 .channel_mode = alc662_3ST_6ch_modes,
16867 .need_dac_fix = 1,
16868 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016869 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016870 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016871 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016872 .init_verbs = { alc662_init_verbs },
16873 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16874 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016875 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16876 .channel_mode = alc662_3ST_6ch_modes,
16877 .need_dac_fix = 1,
16878 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016879 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016880 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016881 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016882 .init_verbs = { alc662_init_verbs },
16883 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16884 .dac_nids = alc662_dac_nids,
16885 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016886 .dig_in_nid = ALC662_DIGIN_NID,
16887 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16888 .channel_mode = alc662_5stack_modes,
16889 .input_mux = &alc662_capture_source,
16890 },
16891 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016892 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016893 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16894 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16895 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016896 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16897 .channel_mode = alc662_3ST_2ch_modes,
16898 .input_mux = &alc662_lenovo_101e_capture_source,
16899 .unsol_event = alc662_lenovo_101e_unsol_event,
16900 .init_hook = alc662_lenovo_101e_all_automute,
16901 },
Kailang Yang291702f2007-10-16 14:28:03 +020016902 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016903 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016904 .init_verbs = { alc662_init_verbs,
16905 alc662_eeepc_sue_init_verbs },
16906 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16907 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016908 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16909 .channel_mode = alc662_3ST_2ch_modes,
16910 .input_mux = &alc662_eeepc_capture_source,
16911 .unsol_event = alc662_eeepc_unsol_event,
16912 .init_hook = alc662_eeepc_inithook,
16913 },
Kailang Yang8c427222008-01-10 13:03:59 +010016914 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016915 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016916 alc662_chmode_mixer },
16917 .init_verbs = { alc662_init_verbs,
16918 alc662_eeepc_ep20_sue_init_verbs },
16919 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16920 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016921 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16922 .channel_mode = alc662_3ST_6ch_modes,
16923 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016924 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016925 .init_hook = alc662_eeepc_ep20_inithook,
16926 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016927 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016928 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016929 .init_verbs = { alc662_init_verbs,
16930 alc662_ecs_init_verbs },
16931 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16932 .dac_nids = alc662_dac_nids,
16933 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16934 .channel_mode = alc662_3ST_2ch_modes,
16935 .input_mux = &alc662_eeepc_capture_source,
16936 .unsol_event = alc662_eeepc_unsol_event,
16937 .init_hook = alc662_eeepc_inithook,
16938 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016939 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016940 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016941 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16942 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16943 .dac_nids = alc662_dac_nids,
16944 .dig_out_nid = ALC662_DIGOUT_NID,
16945 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16946 .channel_mode = alc662_3ST_2ch_modes,
16947 .input_mux = &alc663_m51va_capture_source,
16948 .unsol_event = alc663_m51va_unsol_event,
16949 .init_hook = alc663_m51va_inithook,
16950 },
16951 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016952 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016953 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16954 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16955 .dac_nids = alc662_dac_nids,
16956 .dig_out_nid = ALC662_DIGOUT_NID,
16957 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16958 .channel_mode = alc662_3ST_2ch_modes,
16959 .input_mux = &alc662_eeepc_capture_source,
16960 .unsol_event = alc663_g71v_unsol_event,
16961 .init_hook = alc663_g71v_inithook,
16962 },
16963 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016964 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016965 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16966 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16967 .dac_nids = alc662_dac_nids,
16968 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16969 .channel_mode = alc662_3ST_2ch_modes,
16970 .input_mux = &alc663_m51va_capture_source,
16971 .unsol_event = alc663_m51va_unsol_event,
16972 .init_hook = alc663_m51va_inithook,
16973 },
16974 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016975 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016976 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16977 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16978 .dac_nids = alc662_dac_nids,
16979 .dig_out_nid = ALC662_DIGOUT_NID,
16980 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16981 .channel_mode = alc662_3ST_6ch_modes,
16982 .input_mux = &alc663_capture_source,
16983 .unsol_event = alc663_g50v_unsol_event,
16984 .init_hook = alc663_g50v_inithook,
16985 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016986 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016987 .mixers = { alc663_m51va_mixer },
16988 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016989 .init_verbs = { alc662_init_verbs,
16990 alc663_21jd_amic_init_verbs },
16991 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16992 .hp_nid = 0x03,
16993 .dac_nids = alc662_dac_nids,
16994 .dig_out_nid = ALC662_DIGOUT_NID,
16995 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16996 .channel_mode = alc662_3ST_2ch_modes,
16997 .input_mux = &alc662_eeepc_capture_source,
16998 .unsol_event = alc663_mode1_unsol_event,
16999 .init_hook = alc663_mode1_inithook,
17000 },
17001 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017002 .mixers = { alc662_1bjd_mixer },
17003 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017004 .init_verbs = { alc662_init_verbs,
17005 alc662_1bjd_amic_init_verbs },
17006 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17007 .dac_nids = alc662_dac_nids,
17008 .dig_out_nid = ALC662_DIGOUT_NID,
17009 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17010 .channel_mode = alc662_3ST_2ch_modes,
17011 .input_mux = &alc662_eeepc_capture_source,
17012 .unsol_event = alc662_mode2_unsol_event,
17013 .init_hook = alc662_mode2_inithook,
17014 },
17015 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017016 .mixers = { alc663_two_hp_m1_mixer },
17017 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017018 .init_verbs = { alc662_init_verbs,
17019 alc663_two_hp_amic_m1_init_verbs },
17020 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17021 .hp_nid = 0x03,
17022 .dac_nids = alc662_dac_nids,
17023 .dig_out_nid = ALC662_DIGOUT_NID,
17024 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17025 .channel_mode = alc662_3ST_2ch_modes,
17026 .input_mux = &alc662_eeepc_capture_source,
17027 .unsol_event = alc663_mode3_unsol_event,
17028 .init_hook = alc663_mode3_inithook,
17029 },
17030 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017031 .mixers = { alc663_asus_21jd_clfe_mixer },
17032 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017033 .init_verbs = { alc662_init_verbs,
17034 alc663_21jd_amic_init_verbs},
17035 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17036 .hp_nid = 0x03,
17037 .dac_nids = alc662_dac_nids,
17038 .dig_out_nid = ALC662_DIGOUT_NID,
17039 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17040 .channel_mode = alc662_3ST_2ch_modes,
17041 .input_mux = &alc662_eeepc_capture_source,
17042 .unsol_event = alc663_mode4_unsol_event,
17043 .init_hook = alc663_mode4_inithook,
17044 },
17045 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017046 .mixers = { alc663_asus_15jd_clfe_mixer },
17047 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017048 .init_verbs = { alc662_init_verbs,
17049 alc663_15jd_amic_init_verbs },
17050 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17051 .hp_nid = 0x03,
17052 .dac_nids = alc662_dac_nids,
17053 .dig_out_nid = ALC662_DIGOUT_NID,
17054 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17055 .channel_mode = alc662_3ST_2ch_modes,
17056 .input_mux = &alc662_eeepc_capture_source,
17057 .unsol_event = alc663_mode5_unsol_event,
17058 .init_hook = alc663_mode5_inithook,
17059 },
17060 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017061 .mixers = { alc663_two_hp_m2_mixer },
17062 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017063 .init_verbs = { alc662_init_verbs,
17064 alc663_two_hp_amic_m2_init_verbs },
17065 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17066 .hp_nid = 0x03,
17067 .dac_nids = alc662_dac_nids,
17068 .dig_out_nid = ALC662_DIGOUT_NID,
17069 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17070 .channel_mode = alc662_3ST_2ch_modes,
17071 .input_mux = &alc662_eeepc_capture_source,
17072 .unsol_event = alc663_mode6_unsol_event,
17073 .init_hook = alc663_mode6_inithook,
17074 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017075 [ALC272_DELL] = {
17076 .mixers = { alc663_m51va_mixer },
17077 .cap_mixer = alc272_auto_capture_mixer,
17078 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17079 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17080 .dac_nids = alc662_dac_nids,
17081 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17082 .adc_nids = alc272_adc_nids,
17083 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17084 .capsrc_nids = alc272_capsrc_nids,
17085 .channel_mode = alc662_3ST_2ch_modes,
17086 .input_mux = &alc663_m51va_capture_source,
17087 .unsol_event = alc663_m51va_unsol_event,
17088 .init_hook = alc663_m51va_inithook,
17089 },
17090 [ALC272_DELL_ZM1] = {
17091 .mixers = { alc663_m51va_mixer },
17092 .cap_mixer = alc662_auto_capture_mixer,
17093 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17094 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17095 .dac_nids = alc662_dac_nids,
17096 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17097 .adc_nids = alc662_adc_nids,
17098 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
17099 .capsrc_nids = alc662_capsrc_nids,
17100 .channel_mode = alc662_3ST_2ch_modes,
17101 .input_mux = &alc663_m51va_capture_source,
17102 .unsol_event = alc663_m51va_unsol_event,
17103 .init_hook = alc663_m51va_inithook,
17104 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017105 [ALC272_SAMSUNG_NC10] = {
17106 .mixers = { alc272_nc10_mixer },
17107 .init_verbs = { alc662_init_verbs,
17108 alc663_21jd_amic_init_verbs },
17109 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17110 .dac_nids = alc272_dac_nids,
17111 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17112 .channel_mode = alc662_3ST_2ch_modes,
17113 .input_mux = &alc272_nc10_capture_source,
17114 .unsol_event = alc663_mode4_unsol_event,
17115 .init_hook = alc663_mode4_inithook,
17116 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017117};
17118
17119
17120/*
17121 * BIOS auto configuration
17122 */
17123
17124/* add playback controls from the parsed DAC table */
17125static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17126 const struct auto_pin_cfg *cfg)
17127{
17128 char name[32];
17129 static const char *chname[4] = {
17130 "Front", "Surround", NULL /*CLFE*/, "Side"
17131 };
17132 hda_nid_t nid;
17133 int i, err;
17134
17135 for (i = 0; i < cfg->line_outs; i++) {
17136 if (!spec->multiout.dac_nids[i])
17137 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017138 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017139 if (i == 2) {
17140 /* Center/LFE */
17141 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17142 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017143 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17144 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017145 if (err < 0)
17146 return err;
17147 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17148 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017149 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17150 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017151 if (err < 0)
17152 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017153 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017154 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017155 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017156 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017157 if (err < 0)
17158 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017159 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017160 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017161 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017162 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017163 if (err < 0)
17164 return err;
17165 } else {
17166 sprintf(name, "%s Playback Volume", chname[i]);
17167 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017168 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17169 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017170 if (err < 0)
17171 return err;
17172 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017173 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17174 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17175 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017176 if (err < 0)
17177 return err;
17178 }
17179 }
17180 return 0;
17181}
17182
17183/* add playback controls for speaker and HP outputs */
17184static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17185 const char *pfx)
17186{
17187 hda_nid_t nid;
17188 int err;
17189 char name[32];
17190
17191 if (!pin)
17192 return 0;
17193
Takashi Iwai24fb9172008-09-02 14:48:20 +020017194 if (pin == 0x17) {
17195 /* ALC663 has a mono output pin on 0x17 */
17196 sprintf(name, "%s Playback Switch", pfx);
17197 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17198 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17199 return err;
17200 }
17201
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017202 if (alc880_is_fixed_pin(pin)) {
17203 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017204 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017205 /* specify the DAC as the extra output */
17206 if (!spec->multiout.hp_nid)
17207 spec->multiout.hp_nid = nid;
17208 else
17209 spec->multiout.extra_out_nid[0] = nid;
17210 /* control HP volume/switch on the output mixer amp */
17211 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17212 sprintf(name, "%s Playback Volume", pfx);
17213 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17214 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17215 if (err < 0)
17216 return err;
17217 sprintf(name, "%s Playback Switch", pfx);
17218 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17219 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17220 if (err < 0)
17221 return err;
17222 } else if (alc880_is_multi_pin(pin)) {
17223 /* set manual connection */
17224 /* we have only a switch on HP-out PIN */
17225 sprintf(name, "%s Playback Switch", pfx);
17226 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17227 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17228 if (err < 0)
17229 return err;
17230 }
17231 return 0;
17232}
17233
Takashi Iwai2d864c42009-03-20 12:52:47 +010017234/* return the index of the src widget from the connection list of the nid.
17235 * return -1 if not found
17236 */
17237static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
17238 hda_nid_t src)
17239{
17240 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
17241 int i, conns;
17242
17243 conns = snd_hda_get_connections(codec, nid, conn_list,
17244 ARRAY_SIZE(conn_list));
17245 if (conns < 0)
17246 return -1;
17247 for (i = 0; i < conns; i++)
17248 if (conn_list[i] == src)
17249 return i;
17250 return -1;
17251}
17252
17253static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17254{
Takashi Iwai1327a322009-03-23 13:07:47 +010017255 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017256 return (pincap & AC_PINCAP_IN) != 0;
17257}
17258
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017259/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017260static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017261 const struct auto_pin_cfg *cfg)
17262{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017263 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017264 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017265 int i, err, idx;
17266
17267 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017268 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17269 idx = alc662_input_pin_idx(codec, 0x0b,
17270 cfg->input_pins[i]);
17271 if (idx >= 0) {
17272 err = new_analog_input(spec, cfg->input_pins[i],
17273 auto_pin_cfg_labels[i],
17274 idx, 0x0b);
17275 if (err < 0)
17276 return err;
17277 }
17278 idx = alc662_input_pin_idx(codec, 0x22,
17279 cfg->input_pins[i]);
17280 if (idx >= 0) {
17281 imux->items[imux->num_items].label =
17282 auto_pin_cfg_labels[i];
17283 imux->items[imux->num_items].index = idx;
17284 imux->num_items++;
17285 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017286 }
17287 }
17288 return 0;
17289}
17290
17291static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17292 hda_nid_t nid, int pin_type,
17293 int dac_idx)
17294{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017295 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017296 /* need the manual connection? */
17297 if (alc880_is_multi_pin(nid)) {
17298 struct alc_spec *spec = codec->spec;
17299 int idx = alc880_multi_pin_idx(nid);
17300 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17301 AC_VERB_SET_CONNECT_SEL,
17302 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17303 }
17304}
17305
17306static void alc662_auto_init_multi_out(struct hda_codec *codec)
17307{
17308 struct alc_spec *spec = codec->spec;
17309 int i;
17310
17311 for (i = 0; i <= HDA_SIDE; i++) {
17312 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017313 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017314 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017315 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017316 i);
17317 }
17318}
17319
17320static void alc662_auto_init_hp_out(struct hda_codec *codec)
17321{
17322 struct alc_spec *spec = codec->spec;
17323 hda_nid_t pin;
17324
17325 pin = spec->autocfg.hp_pins[0];
17326 if (pin) /* connect to front */
17327 /* use dac 0 */
17328 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017329 pin = spec->autocfg.speaker_pins[0];
17330 if (pin)
17331 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017332}
17333
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017334#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17335
17336static void alc662_auto_init_analog_input(struct hda_codec *codec)
17337{
17338 struct alc_spec *spec = codec->spec;
17339 int i;
17340
17341 for (i = 0; i < AUTO_PIN_LAST; i++) {
17342 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017343 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017344 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017345 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017346 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017347 snd_hda_codec_write(codec, nid, 0,
17348 AC_VERB_SET_AMP_GAIN_MUTE,
17349 AMP_OUT_MUTE);
17350 }
17351 }
17352}
17353
Takashi Iwaif511b012008-08-15 16:46:42 +020017354#define alc662_auto_init_input_src alc882_auto_init_input_src
17355
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017356static int alc662_parse_auto_config(struct hda_codec *codec)
17357{
17358 struct alc_spec *spec = codec->spec;
17359 int err;
17360 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17361
17362 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17363 alc662_ignore);
17364 if (err < 0)
17365 return err;
17366 if (!spec->autocfg.line_outs)
17367 return 0; /* can't find valid BIOS pin config */
17368
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017369 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17370 if (err < 0)
17371 return err;
17372 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17373 if (err < 0)
17374 return err;
17375 err = alc662_auto_create_extra_out(spec,
17376 spec->autocfg.speaker_pins[0],
17377 "Speaker");
17378 if (err < 0)
17379 return err;
17380 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17381 "Headphone");
17382 if (err < 0)
17383 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017384 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017385 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017386 return err;
17387
17388 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17389
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017390 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017391 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17392
Takashi Iwai603c4012008-07-30 15:01:44 +020017393 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017394 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017395
17396 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017397 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017398
Takashi Iwaid88897e2008-10-31 15:01:37 +010017399 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017400 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017401 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017402
17403 err = alc_auto_add_mic_boost(codec);
17404 if (err < 0)
17405 return err;
17406
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017407 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17408
Takashi Iwai8c872862007-06-19 12:11:16 +020017409 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017410}
17411
17412/* additional initialization for auto-configuration model */
17413static void alc662_auto_init(struct hda_codec *codec)
17414{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017415 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017416 alc662_auto_init_multi_out(codec);
17417 alc662_auto_init_hp_out(codec);
17418 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017419 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017420 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017421 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017422}
17423
17424static int patch_alc662(struct hda_codec *codec)
17425{
17426 struct alc_spec *spec;
17427 int err, board_config;
17428
17429 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17430 if (!spec)
17431 return -ENOMEM;
17432
17433 codec->spec = spec;
17434
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017435 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17436
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017437 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17438 alc662_models,
17439 alc662_cfg_tbl);
17440 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020017441 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17442 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017443 board_config = ALC662_AUTO;
17444 }
17445
17446 if (board_config == ALC662_AUTO) {
17447 /* automatic parse from the BIOS config */
17448 err = alc662_parse_auto_config(codec);
17449 if (err < 0) {
17450 alc_free(codec);
17451 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020017452 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017453 printk(KERN_INFO
17454 "hda_codec: Cannot set up configuration "
17455 "from BIOS. Using base mode...\n");
17456 board_config = ALC662_3ST_2ch_DIG;
17457 }
17458 }
17459
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017460 err = snd_hda_attach_beep_device(codec, 0x1);
17461 if (err < 0) {
17462 alc_free(codec);
17463 return err;
17464 }
17465
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017466 if (board_config != ALC662_AUTO)
17467 setup_preset(spec, &alc662_presets[board_config]);
17468
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017469 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17470 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17471
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017472 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17473 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17474
Takashi Iwaie1406342008-02-11 18:32:32 +010017475 spec->adc_nids = alc662_adc_nids;
17476 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17477 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017478 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017479
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017480 if (!spec->cap_mixer)
17481 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017482 if (codec->vendor_id == 0x10ec0662)
17483 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17484 else
17485 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017486
Takashi Iwai2134ea42008-01-10 16:53:55 +010017487 spec->vmaster_nid = 0x02;
17488
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017489 codec->patch_ops = alc_patch_ops;
17490 if (board_config == ALC662_AUTO)
17491 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017492#ifdef CONFIG_SND_HDA_POWER_SAVE
17493 if (!spec->loopback.amplist)
17494 spec->loopback.amplist = alc662_loopbacks;
17495#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017496 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017497
17498 return 0;
17499}
17500
17501/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017502 * patch entries
17503 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017504static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017505 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017506 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017507 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017508 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017509 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017510 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017511 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017512 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017513 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17514 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17515 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017516 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17517 .patch = patch_alc883 },
17518 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17519 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017520 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017521 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017522 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017523 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017524 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17525 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017526 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017527 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017528 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017529 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017530 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17531 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017532 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017533 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017534 {} /* terminator */
17535};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017536
17537MODULE_ALIAS("snd-hda-codec-id:10ec*");
17538
17539MODULE_LICENSE("GPL");
17540MODULE_DESCRIPTION("Realtek HD-audio codec");
17541
17542static struct hda_codec_preset_list realtek_list = {
17543 .preset = snd_hda_preset_realtek,
17544 .owner = THIS_MODULE,
17545};
17546
17547static int __init patch_realtek_init(void)
17548{
17549 return snd_hda_add_codec_preset(&realtek_list);
17550}
17551
17552static void __exit patch_realtek_exit(void)
17553{
17554 snd_hda_delete_codec_preset(&realtek_list);
17555}
17556
17557module_init(patch_realtek_init)
17558module_exit(patch_realtek_exit)