blob: b9495342c9214d70df0e694ee384cb51953e5aab [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yang622e84c2009-04-21 07:39:04 +0200191 ALC272_DELL,
192 ALC272_DELL_ZM1,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200193 ALC662_AUTO,
194 ALC662_MODEL_LAST,
195};
196
Kailang Yangdf694da2005-12-05 19:42:22 +0100197/* ALC882 models */
198enum {
199 ALC882_3ST_DIG,
200 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200201 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200202 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200203 ALC882_TARGA,
204 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200205 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100206 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200207 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200208 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200209 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100211 ALC882_MODEL_LAST,
212};
213
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200214/* ALC883 models */
215enum {
216 ALC883_3ST_2ch_DIG,
217 ALC883_3ST_6ch_DIG,
218 ALC883_3ST_6ch,
219 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200220 ALC883_TARGA_DIG,
221 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200222 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200223 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800224 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200225 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200226 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100227 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200228 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200229 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200230 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200231 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200232 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200233 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100234 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100235 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100236 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100237 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800238 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200239 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200240 ALC888_ASUS_M90V,
241 ALC888_ASUS_EEE1601,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100242 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200243 ALC883_AUTO,
244 ALC883_MODEL_LAST,
245};
246
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200247/* styles of capture selection */
248enum {
249 CAPT_MUX = 0, /* only mux based */
250 CAPT_MIX, /* only mixer based */
251 CAPT_1MUX_MIX, /* first mux and other mixers */
252};
253
Kailang Yangdf694da2005-12-05 19:42:22 +0100254/* for GPIO Poll */
255#define GPIO_MASK 0x03
256
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200257/* extra amp-initialization sequence types */
258enum {
259 ALC_INIT_NONE,
260 ALC_INIT_DEFAULT,
261 ALC_INIT_GPIO1,
262 ALC_INIT_GPIO2,
263 ALC_INIT_GPIO3,
264};
265
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266struct alc_spec {
267 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100268 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100270 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100271 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
Kailang Yangdf694da2005-12-05 19:42:22 +0100273 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200274 * don't forget NULL
275 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200276 */
277 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Takashi Iwai16ded522005-06-10 19:58:24 +0200279 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 struct hda_pcm_stream *stream_analog_playback;
281 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100282 struct hda_pcm_stream *stream_analog_alt_playback;
283 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200285 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 struct hda_pcm_stream *stream_digital_playback;
287 struct hda_pcm_stream *stream_digital_capture;
288
289 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200290 struct hda_multi_out multiout; /* playback set-up
291 * max_channels, dacs must be set
292 * dig_out_nid and hp_nid are optional
293 */
Takashi Iwai63300792008-01-24 15:31:36 +0100294 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100295 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100296 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
298 /* capture */
299 unsigned int num_adc_nids;
300 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100301 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200302 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200303 int capture_style; /* capture style (CAPT_*) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
305 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200306 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 const struct hda_input_mux *input_mux;
308 unsigned int cur_mux[3];
309
310 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100311 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200313 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
315 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100316 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200317
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200318 /* dynamic controls, init_verbs and input_mux */
319 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200320 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200321 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200322 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100323
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100324 /* hooks */
325 void (*init_hook)(struct hda_codec *codec);
326 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
327
Takashi Iwai834be882006-03-01 14:16:17 +0100328 /* for pin sensing */
329 unsigned int sense_updated: 1;
330 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100331 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200332
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100333 /* other flags */
334 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200335 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100336
Takashi Iwai2134ea42008-01-10 16:53:55 +0100337 /* for virtual master */
338 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200339#ifdef CONFIG_SND_HDA_POWER_SAVE
340 struct hda_loopback_check loopback;
341#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200342
343 /* for PLL fix */
344 hda_nid_t pll_nid;
345 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100346};
347
348/*
349 * configuration template - to be copied to the spec instance
350 */
351struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200352 struct snd_kcontrol_new *mixers[5]; /* should be identical size
353 * with spec
354 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100355 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100356 const struct hda_verb *init_verbs[5];
357 unsigned int num_dacs;
358 hda_nid_t *dac_nids;
359 hda_nid_t dig_out_nid; /* optional */
360 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800361 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100362 unsigned int num_adc_nids;
363 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100364 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100365 hda_nid_t dig_in_nid;
366 unsigned int num_channel_mode;
367 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200368 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200369 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100370 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100371 void (*unsol_event)(struct hda_codec *, unsigned int);
372 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200373#ifdef CONFIG_SND_HDA_POWER_SAVE
374 struct hda_amp_list *loopbacks;
375#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376};
377
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378
379/*
380 * input MUX handling
381 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200382static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
383 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384{
385 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
386 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200387 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
388 if (mux_idx >= spec->num_mux_defs)
389 mux_idx = 0;
390 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391}
392
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200393static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
394 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395{
396 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
397 struct alc_spec *spec = codec->spec;
398 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
399
400 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
401 return 0;
402}
403
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200404static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
405 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406{
407 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
408 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100409 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100411 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100412 hda_nid_t nid = spec->capsrc_nids ?
413 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414
Takashi Iwaicd896c32008-11-18 12:36:33 +0100415 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
416 imux = &spec->input_mux[mux_idx];
417
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200418 if (spec->capture_style &&
419 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100420 /* Matrix-mixer style (e.g. ALC882) */
421 unsigned int *cur_val = &spec->cur_mux[adc_idx];
422 unsigned int i, idx;
423
424 idx = ucontrol->value.enumerated.item[0];
425 if (idx >= imux->num_items)
426 idx = imux->num_items - 1;
427 if (*cur_val == idx)
428 return 0;
429 for (i = 0; i < imux->num_items; i++) {
430 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
431 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
432 imux->items[i].index,
433 HDA_AMP_MUTE, v);
434 }
435 *cur_val = idx;
436 return 1;
437 } else {
438 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100439 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100440 &spec->cur_mux[adc_idx]);
441 }
442}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200443
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444/*
445 * channel mode setting
446 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200447static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
448 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449{
450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
451 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100452 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
453 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454}
455
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200456static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
457 struct snd_ctl_elem_value *ucontrol)
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_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200462 spec->num_channel_mode,
463 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464}
465
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200466static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
467 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468{
469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
470 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200471 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
472 spec->num_channel_mode,
473 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200474 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200475 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
476 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477}
478
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100480 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200481 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100482 * being part of a format specifier. Maximum allowed length of a value is
483 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100484 *
485 * Note: some retasking pin complexes seem to ignore requests for input
486 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
487 * are requested. Therefore order this list so that this behaviour will not
488 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200489 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
490 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200491 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100492static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100493 "Mic 50pc bias", "Mic 80pc bias",
494 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100495};
496static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100497 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100498};
499/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200500 * in the pin being assumed to be exclusively an input or an output pin. In
501 * addition, "input" pins may or may not process the mic bias option
502 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
503 * accept requests for bias as of chip versions up to March 2006) and/or
504 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100505 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200506#define ALC_PIN_DIR_IN 0x00
507#define ALC_PIN_DIR_OUT 0x01
508#define ALC_PIN_DIR_INOUT 0x02
509#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
510#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100511
Kailang Yangea1fb292008-08-26 12:58:38 +0200512/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100513 * For each direction the minimum and maximum values are given.
514 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200515static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100516 { 0, 2 }, /* ALC_PIN_DIR_IN */
517 { 3, 4 }, /* ALC_PIN_DIR_OUT */
518 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200519 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
520 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100521};
522#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
523#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
524#define alc_pin_mode_n_items(_dir) \
525 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
526
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200527static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
528 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200529{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100530 unsigned int item_num = uinfo->value.enumerated.item;
531 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
532
533 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200534 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100535 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
536
537 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
538 item_num = alc_pin_mode_min(dir);
539 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200540 return 0;
541}
542
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200543static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
544 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200545{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100546 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
548 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100549 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200550 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
552 AC_VERB_GET_PIN_WIDGET_CONTROL,
553 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200554
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100555 /* Find enumerated value for current pinctl setting */
556 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200557 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100558 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200559 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100560 return 0;
561}
562
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200563static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
564 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100565{
566 signed int change;
567 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
568 hda_nid_t nid = kcontrol->private_value & 0xffff;
569 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
570 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200571 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
572 AC_VERB_GET_PIN_WIDGET_CONTROL,
573 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100574
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200575 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576 val = alc_pin_mode_min(dir);
577
578 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100579 if (change) {
580 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200581 snd_hda_codec_write_cache(codec, nid, 0,
582 AC_VERB_SET_PIN_WIDGET_CONTROL,
583 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100584
Kailang Yangea1fb292008-08-26 12:58:38 +0200585 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100586 * for the requested pin mode. Enum values of 2 or less are
587 * input modes.
588 *
589 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200590 * reduces noise slightly (particularly on input) so we'll
591 * do it. However, having both input and output buffers
592 * enabled simultaneously doesn't seem to be problematic if
593 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100594 */
595 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200596 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
597 HDA_AMP_MUTE, HDA_AMP_MUTE);
598 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
599 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100600 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200601 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
602 HDA_AMP_MUTE, HDA_AMP_MUTE);
603 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
604 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100605 }
606 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200607 return change;
608}
609
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100610#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200611 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100612 .info = alc_pin_mode_info, \
613 .get = alc_pin_mode_get, \
614 .put = alc_pin_mode_put, \
615 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100616
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100617/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
618 * together using a mask with more than one bit set. This control is
619 * currently used only by the ALC260 test model. At this stage they are not
620 * needed for any "production" models.
621 */
622#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200623#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200624
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200625static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100627{
628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
629 hda_nid_t nid = kcontrol->private_value & 0xffff;
630 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
631 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200632 unsigned int val = snd_hda_codec_read(codec, nid, 0,
633 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100634
635 *valp = (val & mask) != 0;
636 return 0;
637}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200638static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
639 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100640{
641 signed int change;
642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
643 hda_nid_t nid = kcontrol->private_value & 0xffff;
644 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
645 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200646 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
647 AC_VERB_GET_GPIO_DATA,
648 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100649
650 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200651 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
652 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100653 gpio_data &= ~mask;
654 else
655 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200656 snd_hda_codec_write_cache(codec, nid, 0,
657 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100658
659 return change;
660}
661#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
662 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
663 .info = alc_gpio_data_info, \
664 .get = alc_gpio_data_get, \
665 .put = alc_gpio_data_put, \
666 .private_value = nid | (mask<<16) }
667#endif /* CONFIG_SND_DEBUG */
668
Jonathan Woithe92621f12006-02-28 11:47:47 +0100669/* A switch control to allow the enabling of the digital IO pins on the
670 * ALC260. This is incredibly simplistic; the intention of this control is
671 * to provide something in the test model allowing digital outputs to be
672 * identified if present. If models are found which can utilise these
673 * outputs a more complete mixer control can be devised for those models if
674 * necessary.
675 */
676#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200677#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200678
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
680 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100681{
682 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
683 hda_nid_t nid = kcontrol->private_value & 0xffff;
684 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
685 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200686 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100687 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100688
689 *valp = (val & mask) != 0;
690 return 0;
691}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200692static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
693 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100694{
695 signed int change;
696 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
697 hda_nid_t nid = kcontrol->private_value & 0xffff;
698 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
699 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200700 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100701 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200702 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100703
704 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200705 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100706 if (val==0)
707 ctrl_data &= ~mask;
708 else
709 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200710 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
711 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100712
713 return change;
714}
715#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
716 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
717 .info = alc_spdif_ctrl_info, \
718 .get = alc_spdif_ctrl_get, \
719 .put = alc_spdif_ctrl_put, \
720 .private_value = nid | (mask<<16) }
721#endif /* CONFIG_SND_DEBUG */
722
Jonathan Woithef8225f62008-01-08 12:16:54 +0100723/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
724 * Again, this is only used in the ALC26x test models to help identify when
725 * the EAPD line must be asserted for features to work.
726 */
727#ifdef CONFIG_SND_DEBUG
728#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
729
730static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
731 struct snd_ctl_elem_value *ucontrol)
732{
733 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
734 hda_nid_t nid = kcontrol->private_value & 0xffff;
735 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
736 long *valp = ucontrol->value.integer.value;
737 unsigned int val = snd_hda_codec_read(codec, nid, 0,
738 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
739
740 *valp = (val & mask) != 0;
741 return 0;
742}
743
744static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
745 struct snd_ctl_elem_value *ucontrol)
746{
747 int change;
748 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
749 hda_nid_t nid = kcontrol->private_value & 0xffff;
750 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
751 long val = *ucontrol->value.integer.value;
752 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
753 AC_VERB_GET_EAPD_BTLENABLE,
754 0x00);
755
756 /* Set/unset the masked control bit(s) as needed */
757 change = (!val ? 0 : mask) != (ctrl_data & mask);
758 if (!val)
759 ctrl_data &= ~mask;
760 else
761 ctrl_data |= mask;
762 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
763 ctrl_data);
764
765 return change;
766}
767
768#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
769 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
770 .info = alc_eapd_ctrl_info, \
771 .get = alc_eapd_ctrl_get, \
772 .put = alc_eapd_ctrl_put, \
773 .private_value = nid | (mask<<16) }
774#endif /* CONFIG_SND_DEBUG */
775
Kailang Yangdf694da2005-12-05 19:42:22 +0100776/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100777 * set up the input pin config (depending on the given auto-pin type)
778 */
779static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
780 int auto_pin_type)
781{
782 unsigned int val = PIN_IN;
783
784 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
785 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100786 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100787 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
788 if (pincap & AC_PINCAP_VREF_80)
789 val = PIN_VREF80;
790 }
791 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
792}
793
794/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100795 */
796static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
797{
798 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
799 return;
800 spec->mixers[spec->num_mixers++] = mix;
801}
802
803static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
804{
805 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
806 return;
807 spec->init_verbs[spec->num_init_verbs++] = verb;
808}
809
Takashi Iwaidaead532008-11-28 12:55:36 +0100810#ifdef CONFIG_PROC_FS
811/*
812 * hook for proc
813 */
814static void print_realtek_coef(struct snd_info_buffer *buffer,
815 struct hda_codec *codec, hda_nid_t nid)
816{
817 int coeff;
818
819 if (nid != 0x20)
820 return;
821 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
822 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
823 coeff = snd_hda_codec_read(codec, nid, 0,
824 AC_VERB_GET_COEF_INDEX, 0);
825 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
826}
827#else
828#define print_realtek_coef NULL
829#endif
830
Takashi Iwaid88897e2008-10-31 15:01:37 +0100831/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100832 * set up from the preset table
833 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200834static void setup_preset(struct alc_spec *spec,
835 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100836{
837 int i;
838
839 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100840 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100841 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200842 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
843 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100844 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200845
Kailang Yangdf694da2005-12-05 19:42:22 +0100846 spec->channel_mode = preset->channel_mode;
847 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200848 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100849
850 spec->multiout.max_channels = spec->channel_mode[0].channels;
851
852 spec->multiout.num_dacs = preset->num_dacs;
853 spec->multiout.dac_nids = preset->dac_nids;
854 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800855 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100856 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200857
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200858 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200859 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200860 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100861 spec->input_mux = preset->input_mux;
862
863 spec->num_adc_nids = preset->num_adc_nids;
864 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100865 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100866 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100867
868 spec->unsol_event = preset->unsol_event;
869 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200870#ifdef CONFIG_SND_HDA_POWER_SAVE
871 spec->loopback.amplist = preset->loopbacks;
872#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100873}
874
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200875/* Enable GPIO mask and set output */
876static struct hda_verb alc_gpio1_init_verbs[] = {
877 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
878 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
879 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
880 { }
881};
882
883static struct hda_verb alc_gpio2_init_verbs[] = {
884 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
885 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
886 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
887 { }
888};
889
Kailang Yangbdd148a2007-05-08 15:19:08 +0200890static struct hda_verb alc_gpio3_init_verbs[] = {
891 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
892 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
893 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
894 { }
895};
896
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200897/*
898 * Fix hardware PLL issue
899 * On some codecs, the analog PLL gating control must be off while
900 * the default value is 1.
901 */
902static void alc_fix_pll(struct hda_codec *codec)
903{
904 struct alc_spec *spec = codec->spec;
905 unsigned int val;
906
907 if (!spec->pll_nid)
908 return;
909 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
910 spec->pll_coef_idx);
911 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
912 AC_VERB_GET_PROC_COEF, 0);
913 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
914 spec->pll_coef_idx);
915 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
916 val & ~(1 << spec->pll_coef_bit));
917}
918
919static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
920 unsigned int coef_idx, unsigned int coef_bit)
921{
922 struct alc_spec *spec = codec->spec;
923 spec->pll_nid = nid;
924 spec->pll_coef_idx = coef_idx;
925 spec->pll_coef_bit = coef_bit;
926 alc_fix_pll(codec);
927}
928
Kailang Yangc9b58002007-10-16 14:30:01 +0200929static void alc_sku_automute(struct hda_codec *codec)
930{
931 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200932 unsigned int present;
933 unsigned int hp_nid = spec->autocfg.hp_pins[0];
934 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
935
936 /* need to execute and sync at first */
937 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
938 present = snd_hda_codec_read(codec, hp_nid, 0,
939 AC_VERB_GET_PIN_SENSE, 0);
940 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100941 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
942 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200943}
944
Takashi Iwai4605b712008-10-31 14:18:24 +0100945#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200946static void alc_mic_automute(struct hda_codec *codec)
947{
948 struct alc_spec *spec = codec->spec;
949 unsigned int present;
950 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
951 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
952 unsigned int mix_nid = spec->capsrc_nids[0];
953 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
954
955 capsrc_idx_mic = mic_nid - 0x18;
956 capsrc_idx_fmic = fmic_nid - 0x18;
957 present = snd_hda_codec_read(codec, mic_nid, 0,
958 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
959 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
960 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
961 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
962 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
963 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
964 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
965}
Takashi Iwai4605b712008-10-31 14:18:24 +0100966#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100967#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100968#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200969
Kailang Yangc9b58002007-10-16 14:30:01 +0200970/* unsolicited event for HP jack sensing */
971static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
972{
973 if (codec->vendor_id == 0x10ec0880)
974 res >>= 28;
975 else
976 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200977 if (res == ALC880_HP_EVENT)
978 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200979
Kailang Yang7fb0d782008-10-15 11:12:35 +0200980 if (res == ALC880_MIC_EVENT)
981 alc_mic_automute(codec);
982}
983
984static void alc_inithook(struct hda_codec *codec)
985{
Kailang Yangc9b58002007-10-16 14:30:01 +0200986 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200987 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200988}
989
Kailang Yangf9423e72008-05-27 12:32:25 +0200990/* additional initialization for ALC888 variants */
991static void alc888_coef_init(struct hda_codec *codec)
992{
993 unsigned int tmp;
994
995 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
996 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
997 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +0100998 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +0200999 /* alc888S-VC */
1000 snd_hda_codec_read(codec, 0x20, 0,
1001 AC_VERB_SET_PROC_COEF, 0x830);
1002 else
1003 /* alc888-VB */
1004 snd_hda_codec_read(codec, 0x20, 0,
1005 AC_VERB_SET_PROC_COEF, 0x3030);
1006}
1007
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001008static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001009{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001010 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001011
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001012 switch (type) {
1013 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001014 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1015 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001016 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001017 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1018 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001019 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001020 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1021 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001022 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001023 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001024 case 0x10ec0260:
1025 snd_hda_codec_write(codec, 0x0f, 0,
1026 AC_VERB_SET_EAPD_BTLENABLE, 2);
1027 snd_hda_codec_write(codec, 0x10, 0,
1028 AC_VERB_SET_EAPD_BTLENABLE, 2);
1029 break;
1030 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001031 case 0x10ec0267:
1032 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001033 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001034 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001035 case 0x10ec0660:
1036 case 0x10ec0662:
1037 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001038 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001039 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001040 snd_hda_codec_write(codec, 0x14, 0,
1041 AC_VERB_SET_EAPD_BTLENABLE, 2);
1042 snd_hda_codec_write(codec, 0x15, 0,
1043 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001044 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001045 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001046 switch (codec->vendor_id) {
1047 case 0x10ec0260:
1048 snd_hda_codec_write(codec, 0x1a, 0,
1049 AC_VERB_SET_COEF_INDEX, 7);
1050 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1051 AC_VERB_GET_PROC_COEF, 0);
1052 snd_hda_codec_write(codec, 0x1a, 0,
1053 AC_VERB_SET_COEF_INDEX, 7);
1054 snd_hda_codec_write(codec, 0x1a, 0,
1055 AC_VERB_SET_PROC_COEF,
1056 tmp | 0x2010);
1057 break;
1058 case 0x10ec0262:
1059 case 0x10ec0880:
1060 case 0x10ec0882:
1061 case 0x10ec0883:
1062 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001063 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001064 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001065 snd_hda_codec_write(codec, 0x20, 0,
1066 AC_VERB_SET_COEF_INDEX, 7);
1067 tmp = snd_hda_codec_read(codec, 0x20, 0,
1068 AC_VERB_GET_PROC_COEF, 0);
1069 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001070 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001071 snd_hda_codec_write(codec, 0x20, 0,
1072 AC_VERB_SET_PROC_COEF,
1073 tmp | 0x2010);
1074 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001075 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001076 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001077 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001078 case 0x10ec0267:
1079 case 0x10ec0268:
1080 snd_hda_codec_write(codec, 0x20, 0,
1081 AC_VERB_SET_COEF_INDEX, 7);
1082 tmp = snd_hda_codec_read(codec, 0x20, 0,
1083 AC_VERB_GET_PROC_COEF, 0);
1084 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001085 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001086 snd_hda_codec_write(codec, 0x20, 0,
1087 AC_VERB_SET_PROC_COEF,
1088 tmp | 0x3000);
1089 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001090 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001091 break;
1092 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001093}
Kailang Yangea1fb292008-08-26 12:58:38 +02001094
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001095static void alc_init_auto_hp(struct hda_codec *codec)
1096{
1097 struct alc_spec *spec = codec->spec;
1098
1099 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001100 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001101
Kailang Yangc9b58002007-10-16 14:30:01 +02001102 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001103 if (spec->autocfg.line_out_pins[0] &&
1104 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001105 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001106 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001107 else
1108 return;
1109 }
1110
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001111 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1112 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001113 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1114 AC_VERB_SET_UNSOLICITED_ENABLE,
1115 AC_USRSP_EN | ALC880_HP_EVENT);
1116 spec->unsol_event = alc_sku_unsol_event;
1117}
1118
1119/* check subsystem ID and set up device-specific initialization;
1120 * return 1 if initialized, 0 if invalid SSID
1121 */
1122/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1123 * 31 ~ 16 : Manufacture ID
1124 * 15 ~ 8 : SKU ID
1125 * 7 ~ 0 : Assembly ID
1126 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1127 */
1128static int alc_subsystem_id(struct hda_codec *codec,
1129 hda_nid_t porta, hda_nid_t porte,
1130 hda_nid_t portd)
1131{
1132 unsigned int ass, tmp, i;
1133 unsigned nid;
1134 struct alc_spec *spec = codec->spec;
1135
1136 ass = codec->subsystem_id & 0xffff;
1137 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1138 goto do_sku;
1139
1140 /* invalid SSID, check the special NID pin defcfg instead */
1141 /*
1142 * 31~30 : port conetcivity
1143 * 29~21 : reserve
1144 * 20 : PCBEEP input
1145 * 19~16 : Check sum (15:1)
1146 * 15~1 : Custom
1147 * 0 : override
1148 */
1149 nid = 0x1d;
1150 if (codec->vendor_id == 0x10ec0260)
1151 nid = 0x17;
1152 ass = snd_hda_codec_get_pincfg(codec, nid);
1153 snd_printd("realtek: No valid SSID, "
1154 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001155 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001156 if (!(ass & 1) && !(ass & 0x100000))
1157 return 0;
1158 if ((ass >> 30) != 1) /* no physical connection */
1159 return 0;
1160
1161 /* check sum */
1162 tmp = 0;
1163 for (i = 1; i < 16; i++) {
1164 if ((ass >> i) & 1)
1165 tmp++;
1166 }
1167 if (((ass >> 16) & 0xf) != tmp)
1168 return 0;
1169do_sku:
1170 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1171 ass & 0xffff, codec->vendor_id);
1172 /*
1173 * 0 : override
1174 * 1 : Swap Jack
1175 * 2 : 0 --> Desktop, 1 --> Laptop
1176 * 3~5 : External Amplifier control
1177 * 7~6 : Reserved
1178 */
1179 tmp = (ass & 0x38) >> 3; /* external Amp control */
1180 switch (tmp) {
1181 case 1:
1182 spec->init_amp = ALC_INIT_GPIO1;
1183 break;
1184 case 3:
1185 spec->init_amp = ALC_INIT_GPIO2;
1186 break;
1187 case 7:
1188 spec->init_amp = ALC_INIT_GPIO3;
1189 break;
1190 case 5:
1191 spec->init_amp = ALC_INIT_DEFAULT;
1192 break;
1193 }
1194
1195 /* is laptop or Desktop and enable the function "Mute internal speaker
1196 * when the external headphone out jack is plugged"
1197 */
1198 if (!(ass & 0x8000))
1199 return 1;
1200 /*
1201 * 10~8 : Jack location
1202 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1203 * 14~13: Resvered
1204 * 15 : 1 --> enable the function "Mute internal speaker
1205 * when the external headphone out jack is plugged"
1206 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001207 if (!spec->autocfg.hp_pins[0]) {
1208 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1209 if (tmp == 0)
1210 spec->autocfg.hp_pins[0] = porta;
1211 else if (tmp == 1)
1212 spec->autocfg.hp_pins[0] = porte;
1213 else if (tmp == 2)
1214 spec->autocfg.hp_pins[0] = portd;
1215 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001216 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001217 }
1218
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001219 alc_init_auto_hp(codec);
1220 return 1;
1221}
Kailang Yangea1fb292008-08-26 12:58:38 +02001222
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001223static void alc_ssid_check(struct hda_codec *codec,
1224 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1225{
1226 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1227 struct alc_spec *spec = codec->spec;
1228 snd_printd("realtek: "
1229 "Enable default setup for auto mode as fallback\n");
1230 spec->init_amp = ALC_INIT_DEFAULT;
1231 alc_init_auto_hp(codec);
1232 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001233}
1234
Takashi Iwai41e41f12005-06-08 14:48:49 +02001235/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001236 * Fix-up pin default configurations
1237 */
1238
1239struct alc_pincfg {
1240 hda_nid_t nid;
1241 u32 val;
1242};
1243
1244static void alc_fix_pincfg(struct hda_codec *codec,
1245 const struct snd_pci_quirk *quirk,
1246 const struct alc_pincfg **pinfix)
1247{
1248 const struct alc_pincfg *cfg;
1249
1250 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1251 if (!quirk)
1252 return;
1253
1254 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001255 for (; cfg->nid; cfg++)
1256 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001257}
1258
1259/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001260 * ALC888
1261 */
1262
1263/*
1264 * 2ch mode
1265 */
1266static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1267/* Mic-in jack as mic in */
1268 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1269 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1270/* Line-in jack as Line in */
1271 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1272 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1273/* Line-Out as Front */
1274 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1275 { } /* end */
1276};
1277
1278/*
1279 * 4ch mode
1280 */
1281static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1282/* Mic-in jack as mic in */
1283 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1284 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1285/* Line-in jack as Surround */
1286 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1287 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1288/* Line-Out as Front */
1289 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1290 { } /* end */
1291};
1292
1293/*
1294 * 6ch mode
1295 */
1296static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1297/* Mic-in jack as CLFE */
1298 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1299 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1300/* Line-in jack as Surround */
1301 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1302 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1303/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1304 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1305 { } /* end */
1306};
1307
1308/*
1309 * 8ch mode
1310 */
1311static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1312/* Mic-in jack as CLFE */
1313 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1314 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1315/* Line-in jack as Surround */
1316 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1317 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1318/* Line-Out as Side */
1319 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1320 { } /* end */
1321};
1322
1323static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1324 { 2, alc888_4ST_ch2_intel_init },
1325 { 4, alc888_4ST_ch4_intel_init },
1326 { 6, alc888_4ST_ch6_intel_init },
1327 { 8, alc888_4ST_ch8_intel_init },
1328};
1329
1330/*
1331 * ALC888 Fujitsu Siemens Amillo xa3530
1332 */
1333
1334static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1335/* Front Mic: set to PIN_IN (empty by default) */
1336 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1337/* Connect Internal HP to Front */
1338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1339 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1340 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1341/* Connect Bass HP to Front */
1342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1343 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1344 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1345/* Connect Line-Out side jack (SPDIF) to Side */
1346 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1347 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1348 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1349/* Connect Mic jack to CLFE */
1350 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1351 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1352 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1353/* Connect Line-in jack to Surround */
1354 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1355 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1356 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1357/* Connect HP out jack to Front */
1358 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1359 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1360 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1361/* Enable unsolicited event for HP jack and Line-out jack */
1362 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1363 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1364 {}
1365};
1366
1367static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1368{
1369 unsigned int present;
1370 unsigned int bits;
1371 /* Line out presence */
1372 present = snd_hda_codec_read(codec, 0x17, 0,
1373 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1374 /* HP out presence */
1375 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1376 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1377 bits = present ? HDA_AMP_MUTE : 0;
1378 /* Toggle internal speakers muting */
1379 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1380 HDA_AMP_MUTE, bits);
1381 /* Toggle internal bass muting */
1382 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1383 HDA_AMP_MUTE, bits);
1384}
1385
1386static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1387 unsigned int res)
1388{
1389 if (res >> 26 == ALC880_HP_EVENT)
1390 alc888_fujitsu_xa3530_automute(codec);
1391}
1392
1393
1394/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001395 * ALC888 Acer Aspire 4930G model
1396 */
1397
1398static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1399/* Front Mic: set to PIN_IN (empty by default) */
1400 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1401/* Unselect Front Mic by default in input mixer 3 */
1402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001403/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001404 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1405/* Connect Internal HP to front */
1406 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1407 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1408 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1409/* Connect HP out to front */
1410 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1411 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1412 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1413 { }
1414};
1415
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001416static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001417 /* Front mic only available on one ADC */
1418 {
1419 .num_items = 4,
1420 .items = {
1421 { "Mic", 0x0 },
1422 { "Line", 0x2 },
1423 { "CD", 0x4 },
1424 { "Front Mic", 0xb },
1425 },
1426 },
1427 {
1428 .num_items = 3,
1429 .items = {
1430 { "Mic", 0x0 },
1431 { "Line", 0x2 },
1432 { "CD", 0x4 },
1433 },
1434 }
1435};
1436
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001437static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001438 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1439 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1440 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1441 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1442 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1443 HDA_OUTPUT),
1444 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1445 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1446 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1447 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1448 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1449 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1450 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1451 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1452 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1454 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1455 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001456 { } /* end */
1457};
1458
1459static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1460{
1461 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001462 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001463 present = snd_hda_codec_read(codec, 0x15, 0,
1464 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001465 bits = present ? HDA_AMP_MUTE : 0;
1466 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1467 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001468}
1469
1470static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1471 unsigned int res)
1472{
1473 if (res >> 26 == ALC880_HP_EVENT)
1474 alc888_acer_aspire_4930g_automute(codec);
1475}
1476
1477/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001478 * ALC880 3-stack model
1479 *
1480 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001481 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1482 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 */
1484
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001485static hda_nid_t alc880_dac_nids[4] = {
1486 /* front, rear, clfe, rear_surr */
1487 0x02, 0x05, 0x04, 0x03
1488};
1489
1490static hda_nid_t alc880_adc_nids[3] = {
1491 /* ADC0-2 */
1492 0x07, 0x08, 0x09,
1493};
1494
1495/* The datasheet says the node 0x07 is connected from inputs,
1496 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001497 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001499static hda_nid_t alc880_adc_nids_alt[2] = {
1500 /* ADC1-2 */
1501 0x08, 0x09,
1502};
1503
1504#define ALC880_DIGOUT_NID 0x06
1505#define ALC880_DIGIN_NID 0x0a
1506
1507static struct hda_input_mux alc880_capture_source = {
1508 .num_items = 4,
1509 .items = {
1510 { "Mic", 0x0 },
1511 { "Front Mic", 0x3 },
1512 { "Line", 0x2 },
1513 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001515};
1516
1517/* channel source setting (2/6 channel selection for 3-stack) */
1518/* 2ch mode */
1519static struct hda_verb alc880_threestack_ch2_init[] = {
1520 /* set line-in to input, mute it */
1521 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1522 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1523 /* set mic-in to input vref 80%, mute it */
1524 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1525 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526 { } /* end */
1527};
1528
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001529/* 6ch mode */
1530static struct hda_verb alc880_threestack_ch6_init[] = {
1531 /* set line-in to output, unmute it */
1532 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1533 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1534 /* set mic-in to output, unmute it */
1535 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1536 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1537 { } /* end */
1538};
1539
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001540static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001541 { 2, alc880_threestack_ch2_init },
1542 { 6, alc880_threestack_ch6_init },
1543};
1544
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001545static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001546 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001547 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001548 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001549 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001550 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1551 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001552 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1553 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1555 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1556 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1557 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1558 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1559 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1560 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1561 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001563 {
1564 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1565 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001566 .info = alc_ch_mode_info,
1567 .get = alc_ch_mode_get,
1568 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001569 },
1570 { } /* end */
1571};
1572
1573/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001574static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1575 struct snd_ctl_elem_info *uinfo)
1576{
1577 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1578 struct alc_spec *spec = codec->spec;
1579 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001580
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001581 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001582 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1583 HDA_INPUT);
1584 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001585 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001586 return err;
1587}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001588
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001589static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1590 unsigned int size, unsigned int __user *tlv)
1591{
1592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1593 struct alc_spec *spec = codec->spec;
1594 int err;
1595
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001596 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001597 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1598 HDA_INPUT);
1599 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001600 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001601 return err;
1602}
1603
1604typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1605 struct snd_ctl_elem_value *ucontrol);
1606
1607static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1608 struct snd_ctl_elem_value *ucontrol,
1609 getput_call_t func)
1610{
1611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1612 struct alc_spec *spec = codec->spec;
1613 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1614 int err;
1615
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001616 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001617 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1618 3, 0, HDA_INPUT);
1619 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001620 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001621 return err;
1622}
1623
1624static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1625 struct snd_ctl_elem_value *ucontrol)
1626{
1627 return alc_cap_getput_caller(kcontrol, ucontrol,
1628 snd_hda_mixer_amp_volume_get);
1629}
1630
1631static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1632 struct snd_ctl_elem_value *ucontrol)
1633{
1634 return alc_cap_getput_caller(kcontrol, ucontrol,
1635 snd_hda_mixer_amp_volume_put);
1636}
1637
1638/* capture mixer elements */
1639#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1640
1641static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1642 struct snd_ctl_elem_value *ucontrol)
1643{
1644 return alc_cap_getput_caller(kcontrol, ucontrol,
1645 snd_hda_mixer_amp_switch_get);
1646}
1647
1648static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1649 struct snd_ctl_elem_value *ucontrol)
1650{
1651 return alc_cap_getput_caller(kcontrol, ucontrol,
1652 snd_hda_mixer_amp_switch_put);
1653}
1654
Takashi Iwaia23b6882009-03-23 15:21:36 +01001655#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001656 { \
1657 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1658 .name = "Capture Switch", \
1659 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1660 .count = num, \
1661 .info = alc_cap_sw_info, \
1662 .get = alc_cap_sw_get, \
1663 .put = alc_cap_sw_put, \
1664 }, \
1665 { \
1666 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1667 .name = "Capture Volume", \
1668 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1669 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1670 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1671 .count = num, \
1672 .info = alc_cap_vol_info, \
1673 .get = alc_cap_vol_get, \
1674 .put = alc_cap_vol_put, \
1675 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001676 }
1677
1678#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001679 { \
1680 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1681 /* .name = "Capture Source", */ \
1682 .name = "Input Source", \
1683 .count = num, \
1684 .info = alc_mux_enum_info, \
1685 .get = alc_mux_enum_get, \
1686 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001687 }
1688
1689#define DEFINE_CAPMIX(num) \
1690static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1691 _DEFINE_CAPMIX(num), \
1692 _DEFINE_CAPSRC(num), \
1693 { } /* end */ \
1694}
1695
1696#define DEFINE_CAPMIX_NOSRC(num) \
1697static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1698 _DEFINE_CAPMIX(num), \
1699 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001700}
1701
1702/* up to three ADCs */
1703DEFINE_CAPMIX(1);
1704DEFINE_CAPMIX(2);
1705DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001706DEFINE_CAPMIX_NOSRC(1);
1707DEFINE_CAPMIX_NOSRC(2);
1708DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001709
1710/*
1711 * ALC880 5-stack model
1712 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001713 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1714 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001715 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1716 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1717 */
1718
1719/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001720static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001721 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001722 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001723 { } /* end */
1724};
1725
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001726/* channel source setting (6/8 channel selection for 5-stack) */
1727/* 6ch mode */
1728static struct hda_verb alc880_fivestack_ch6_init[] = {
1729 /* set line-in to input, mute it */
1730 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1731 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001732 { } /* end */
1733};
1734
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001735/* 8ch mode */
1736static struct hda_verb alc880_fivestack_ch8_init[] = {
1737 /* set line-in to output, unmute it */
1738 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1739 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1740 { } /* end */
1741};
1742
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001743static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001744 { 6, alc880_fivestack_ch6_init },
1745 { 8, alc880_fivestack_ch8_init },
1746};
1747
1748
1749/*
1750 * ALC880 6-stack model
1751 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001752 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1753 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001754 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1755 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1756 */
1757
1758static hda_nid_t alc880_6st_dac_nids[4] = {
1759 /* front, rear, clfe, rear_surr */
1760 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001761};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001762
1763static struct hda_input_mux alc880_6stack_capture_source = {
1764 .num_items = 4,
1765 .items = {
1766 { "Mic", 0x0 },
1767 { "Front Mic", 0x1 },
1768 { "Line", 0x2 },
1769 { "CD", 0x4 },
1770 },
1771};
1772
1773/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001774static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001775 { 8, NULL },
1776};
1777
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001778static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001779 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001780 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001781 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001782 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001783 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1784 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001785 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1786 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001787 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001788 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001789 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1790 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1791 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1792 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1793 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1794 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1795 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1796 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001797 {
1798 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1799 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001800 .info = alc_ch_mode_info,
1801 .get = alc_ch_mode_get,
1802 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001803 },
1804 { } /* end */
1805};
1806
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001807
1808/*
1809 * ALC880 W810 model
1810 *
1811 * W810 has rear IO for:
1812 * Front (DAC 02)
1813 * Surround (DAC 03)
1814 * Center/LFE (DAC 04)
1815 * Digital out (06)
1816 *
1817 * The system also has a pair of internal speakers, and a headphone jack.
1818 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001819 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001820 * There is a variable resistor to control the speaker or headphone
1821 * volume. This is a hardware-only device without a software API.
1822 *
1823 * Plugging headphones in will disable the internal speakers. This is
1824 * implemented in hardware, not via the driver using jack sense. In
1825 * a similar fashion, plugging into the rear socket marked "front" will
1826 * disable both the speakers and headphones.
1827 *
1828 * For input, there's a microphone jack, and an "audio in" jack.
1829 * These may not do anything useful with this driver yet, because I
1830 * haven't setup any initialization verbs for these yet...
1831 */
1832
1833static hda_nid_t alc880_w810_dac_nids[3] = {
1834 /* front, rear/surround, clfe */
1835 0x02, 0x03, 0x04
1836};
1837
1838/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001839static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001840 { 6, NULL }
1841};
1842
1843/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001844static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001845 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001846 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001847 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001848 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001849 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1850 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001851 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1852 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001853 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1854 { } /* end */
1855};
1856
1857
1858/*
1859 * Z710V model
1860 *
1861 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001862 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1863 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001864 */
1865
1866static hda_nid_t alc880_z71v_dac_nids[1] = {
1867 0x02
1868};
1869#define ALC880_Z71V_HP_DAC 0x03
1870
1871/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001872static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001873 { 2, NULL }
1874};
1875
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001876static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001877 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001878 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001879 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001880 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001881 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1882 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1883 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1884 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1885 { } /* end */
1886};
1887
1888
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001889/*
1890 * ALC880 F1734 model
1891 *
1892 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1893 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1894 */
1895
1896static hda_nid_t alc880_f1734_dac_nids[1] = {
1897 0x03
1898};
1899#define ALC880_F1734_HP_DAC 0x02
1900
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001901static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001902 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001903 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001904 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1905 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001906 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1907 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001908 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1909 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001910 { } /* end */
1911};
1912
Takashi Iwai937b4162008-02-11 14:52:36 +01001913static struct hda_input_mux alc880_f1734_capture_source = {
1914 .num_items = 2,
1915 .items = {
1916 { "Mic", 0x1 },
1917 { "CD", 0x4 },
1918 },
1919};
1920
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001921
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001922/*
1923 * ALC880 ASUS model
1924 *
1925 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1926 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1927 * Mic = 0x18, Line = 0x1a
1928 */
1929
1930#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1931#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1932
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001933static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001934 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001935 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001936 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001937 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001938 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1939 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001940 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1941 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001942 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1943 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1944 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1945 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1946 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1947 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001948 {
1949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1950 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001951 .info = alc_ch_mode_info,
1952 .get = alc_ch_mode_get,
1953 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001954 },
1955 { } /* end */
1956};
1957
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001958/*
1959 * ALC880 ASUS W1V model
1960 *
1961 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1962 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1963 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1964 */
1965
1966/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001967static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001968 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1969 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001970 { } /* end */
1971};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001972
Kailang Yangdf694da2005-12-05 19:42:22 +01001973/* TCL S700 */
1974static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1975 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1976 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1978 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1979 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1981 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1982 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1983 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001984 { } /* end */
1985};
1986
Kailang Yangccc656c2006-10-17 12:32:26 +02001987/* Uniwill */
1988static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001989 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1990 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1991 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1992 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001993 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1994 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1995 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1996 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1997 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1998 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1999 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2000 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2001 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2003 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2004 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002005 {
2006 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2007 .name = "Channel Mode",
2008 .info = alc_ch_mode_info,
2009 .get = alc_ch_mode_get,
2010 .put = alc_ch_mode_put,
2011 },
2012 { } /* end */
2013};
2014
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002015static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2016 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2017 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2018 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2019 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2022 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2023 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2024 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2025 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2026 { } /* end */
2027};
2028
Kailang Yangccc656c2006-10-17 12:32:26 +02002029static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002030 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2031 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2032 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2033 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002034 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2035 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2036 { } /* end */
2037};
2038
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002040 * virtual master controls
2041 */
2042
2043/*
2044 * slave controls for virtual master
2045 */
2046static const char *alc_slave_vols[] = {
2047 "Front Playback Volume",
2048 "Surround Playback Volume",
2049 "Center Playback Volume",
2050 "LFE Playback Volume",
2051 "Side Playback Volume",
2052 "Headphone Playback Volume",
2053 "Speaker Playback Volume",
2054 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002055 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002056 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002057 NULL,
2058};
2059
2060static const char *alc_slave_sws[] = {
2061 "Front Playback Switch",
2062 "Surround Playback Switch",
2063 "Center Playback Switch",
2064 "LFE Playback Switch",
2065 "Side Playback Switch",
2066 "Headphone Playback Switch",
2067 "Speaker Playback Switch",
2068 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002069 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002070 NULL,
2071};
2072
2073/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002074 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002075 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002076
2077static void alc_free_kctls(struct hda_codec *codec);
2078
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002079/* additional beep mixers; the actual parameters are overwritten at build */
2080static struct snd_kcontrol_new alc_beep_mixer[] = {
2081 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2082 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2083 { } /* end */
2084};
2085
Linus Torvalds1da177e2005-04-16 15:20:36 -07002086static int alc_build_controls(struct hda_codec *codec)
2087{
2088 struct alc_spec *spec = codec->spec;
2089 int err;
2090 int i;
2091
2092 for (i = 0; i < spec->num_mixers; i++) {
2093 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2094 if (err < 0)
2095 return err;
2096 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002097 if (spec->cap_mixer) {
2098 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2099 if (err < 0)
2100 return err;
2101 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002103 err = snd_hda_create_spdif_out_ctls(codec,
2104 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002105 if (err < 0)
2106 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002107 if (!spec->no_analog) {
2108 err = snd_hda_create_spdif_share_sw(codec,
2109 &spec->multiout);
2110 if (err < 0)
2111 return err;
2112 spec->multiout.share_spdif = 1;
2113 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002114 }
2115 if (spec->dig_in_nid) {
2116 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2117 if (err < 0)
2118 return err;
2119 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002120
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002121 /* create beep controls if needed */
2122 if (spec->beep_amp) {
2123 struct snd_kcontrol_new *knew;
2124 for (knew = alc_beep_mixer; knew->name; knew++) {
2125 struct snd_kcontrol *kctl;
2126 kctl = snd_ctl_new1(knew, codec);
2127 if (!kctl)
2128 return -ENOMEM;
2129 kctl->private_value = spec->beep_amp;
2130 err = snd_hda_ctl_add(codec, kctl);
2131 if (err < 0)
2132 return err;
2133 }
2134 }
2135
Takashi Iwai2134ea42008-01-10 16:53:55 +01002136 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002137 if (!spec->no_analog &&
2138 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002139 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002140 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002141 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002142 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002143 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002144 if (err < 0)
2145 return err;
2146 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002147 if (!spec->no_analog &&
2148 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002149 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2150 NULL, alc_slave_sws);
2151 if (err < 0)
2152 return err;
2153 }
2154
Takashi Iwai603c4012008-07-30 15:01:44 +02002155 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002156 return 0;
2157}
2158
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002159
Linus Torvalds1da177e2005-04-16 15:20:36 -07002160/*
2161 * initialize the codec volumes, etc
2162 */
2163
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002164/*
2165 * generic initialization of ADC, input mixers and output mixers
2166 */
2167static struct hda_verb alc880_volume_init_verbs[] = {
2168 /*
2169 * Unmute ADC0-2 and set the default input to mic-in
2170 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002171 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002172 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002173 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002174 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002175 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002176 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002177
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002178 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2179 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002180 * Note: PASD motherboards uses the Line In 2 as the input for front
2181 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002183 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002184 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2186 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2187 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2188 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2189 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2190 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002192 /*
2193 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002195 /* set vol=0 to output mixers */
2196 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2197 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2198 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2199 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2200 /* set up input amps for analog loopback */
2201 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002204 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2205 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002206 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2207 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002208 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2209 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210
2211 { }
2212};
2213
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002214/*
2215 * 3-stack pin configuration:
2216 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2217 */
2218static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2219 /*
2220 * preset connection lists of input pins
2221 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2222 */
2223 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2224 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2225 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2226
2227 /*
2228 * Set pin mode and muting
2229 */
2230 /* set front pin widgets 0x14 for output */
2231 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2233 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2234 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2235 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2236 /* Mic2 (as headphone out) for HP output */
2237 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2238 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2239 /* Line In pin widget for input */
2240 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2241 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2242 /* Line2 (as front mic) pin widget for input and vref at 80% */
2243 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2244 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2245 /* CD pin widget for input */
2246 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2247
2248 { }
2249};
2250
2251/*
2252 * 5-stack pin configuration:
2253 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2254 * line-in/side = 0x1a, f-mic = 0x1b
2255 */
2256static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2257 /*
2258 * preset connection lists of input pins
2259 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2260 */
2261 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2262 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2263
2264 /*
2265 * Set pin mode and muting
2266 */
2267 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2269 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2270 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2271 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002272 /* unmute pins for output (no gain on this amp) */
2273 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2275 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2276 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2277
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002279 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002280 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2281 /* Mic2 (as headphone out) for HP output */
2282 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002283 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002284 /* Line In pin widget for input */
2285 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2286 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2287 /* Line2 (as front mic) pin widget for input and vref at 80% */
2288 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2289 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2290 /* CD pin widget for input */
2291 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292
2293 { }
2294};
2295
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002296/*
2297 * W810 pin configuration:
2298 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2299 */
2300static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002301 /* hphone/speaker input selector: front DAC */
2302 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2303
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002304 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2305 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2306 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2307 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2308 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2309 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2310
2311 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002312 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313
Linus Torvalds1da177e2005-04-16 15:20:36 -07002314 { }
2315};
2316
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002317/*
2318 * Z71V pin configuration:
2319 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2320 */
2321static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002322 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002323 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002324 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002325 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002326
Takashi Iwai16ded522005-06-10 19:58:24 +02002327 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002328 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002329 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002330 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002331
2332 { }
2333};
2334
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002335/*
2336 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002337 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2338 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002339 */
2340static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2341 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2342
Takashi Iwai16ded522005-06-10 19:58:24 +02002343 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002344 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002345 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002346 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002347 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002348 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002349 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002350 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2351
Takashi Iwai16ded522005-06-10 19:58:24 +02002352 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002353 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002354 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002355 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002356 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002357 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002358 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002359 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002360 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002361
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002362 { }
2363};
Takashi Iwai16ded522005-06-10 19:58:24 +02002364
Kailang Yangccc656c2006-10-17 12:32:26 +02002365/*
2366 * Uniwill pin configuration:
2367 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2368 * line = 0x1a
2369 */
2370static struct hda_verb alc880_uniwill_init_verbs[] = {
2371 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2372
2373 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2374 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2375 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2376 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2377 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2378 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2379 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2380 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2383 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2387
2388 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2389 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2390 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2391 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2392 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2393 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2394 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2395 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2396 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2397
2398 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2399 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2400
2401 { }
2402};
2403
2404/*
2405* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002406* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002407 */
2408static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2409 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2410
2411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2412 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2413 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2414 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2415 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2416 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2418 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2419 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2420 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2421 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2422 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2423
2424 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2425 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2426 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2427 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2428 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2429 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2430
2431 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2432 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2433
2434 { }
2435};
2436
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002437static struct hda_verb alc880_beep_init_verbs[] = {
2438 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2439 { }
2440};
2441
Kailang Yangccc656c2006-10-17 12:32:26 +02002442/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002443static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002444{
2445 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002446 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002447
2448 present = snd_hda_codec_read(codec, 0x14, 0,
2449 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002450 bits = present ? HDA_AMP_MUTE : 0;
2451 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2452 HDA_AMP_MUTE, bits);
2453 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2454 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002455}
2456
2457/* auto-toggle front mic */
2458static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2459{
2460 unsigned int present;
2461 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002462
2463 present = snd_hda_codec_read(codec, 0x18, 0,
2464 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002465 bits = present ? HDA_AMP_MUTE : 0;
2466 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002467}
2468
2469static void alc880_uniwill_automute(struct hda_codec *codec)
2470{
2471 alc880_uniwill_hp_automute(codec);
2472 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002473}
2474
2475static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2476 unsigned int res)
2477{
2478 /* Looks like the unsol event is incompatible with the standard
2479 * definition. 4bit tag is placed at 28 bit!
2480 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002481 switch (res >> 28) {
2482 case ALC880_HP_EVENT:
2483 alc880_uniwill_hp_automute(codec);
2484 break;
2485 case ALC880_MIC_EVENT:
2486 alc880_uniwill_mic_automute(codec);
2487 break;
2488 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002489}
2490
2491static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2492{
2493 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002494 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002495
2496 present = snd_hda_codec_read(codec, 0x14, 0,
2497 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002498 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002499 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002500}
2501
2502static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2503{
2504 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002505
Kailang Yangccc656c2006-10-17 12:32:26 +02002506 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002507 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2508 present &= HDA_AMP_VOLMASK;
2509 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2510 HDA_AMP_VOLMASK, present);
2511 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2512 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002513}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002514
Kailang Yangccc656c2006-10-17 12:32:26 +02002515static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2516 unsigned int res)
2517{
2518 /* Looks like the unsol event is incompatible with the standard
2519 * definition. 4bit tag is placed at 28 bit!
2520 */
2521 if ((res >> 28) == ALC880_HP_EVENT)
2522 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002523 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002524 alc880_uniwill_p53_dcvol_automute(codec);
2525}
2526
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002527/*
2528 * F1734 pin configuration:
2529 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2530 */
2531static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002532 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002533 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2534 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2535 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2536 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2537
2538 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2539 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2540 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2541 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2542
2543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2544 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002545 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2547 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2548 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2549 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2550 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2551 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002552
Takashi Iwai937b4162008-02-11 14:52:36 +01002553 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2554 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2555
Takashi Iwai16ded522005-06-10 19:58:24 +02002556 { }
2557};
2558
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002559/*
2560 * ASUS pin configuration:
2561 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2562 */
2563static struct hda_verb alc880_pin_asus_init_verbs[] = {
2564 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2565 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2566 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2567 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2568
2569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2570 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2571 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2572 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2573 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2574 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2575 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2576 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2577
2578 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2579 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2580 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2581 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2582 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2583 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2584 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2585 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2586 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002587
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002588 { }
2589};
2590
2591/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002592#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2593#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002594
Kailang Yangdf694da2005-12-05 19:42:22 +01002595/* Clevo m520g init */
2596static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2597 /* headphone output */
2598 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2599 /* line-out */
2600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2601 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2602 /* Line-in */
2603 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2604 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2605 /* CD */
2606 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2607 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2608 /* Mic1 (rear panel) */
2609 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2610 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2611 /* Mic2 (front panel) */
2612 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2613 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2614 /* headphone */
2615 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2616 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2617 /* change to EAPD mode */
2618 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2619 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2620
2621 { }
2622};
2623
2624static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002625 /* change to EAPD mode */
2626 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2627 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2628
Kailang Yangdf694da2005-12-05 19:42:22 +01002629 /* Headphone output */
2630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2631 /* Front output*/
2632 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2633 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2634
2635 /* Line In pin widget for input */
2636 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2637 /* CD pin widget for input */
2638 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2639 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2640 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2641
2642 /* change to EAPD mode */
2643 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2644 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2645
2646 { }
2647};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002648
2649/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002650 * LG m1 express dual
2651 *
2652 * Pin assignment:
2653 * Rear Line-In/Out (blue): 0x14
2654 * Build-in Mic-In: 0x15
2655 * Speaker-out: 0x17
2656 * HP-Out (green): 0x1b
2657 * Mic-In/Out (red): 0x19
2658 * SPDIF-Out: 0x1e
2659 */
2660
2661/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2662static hda_nid_t alc880_lg_dac_nids[3] = {
2663 0x05, 0x02, 0x03
2664};
2665
2666/* seems analog CD is not working */
2667static struct hda_input_mux alc880_lg_capture_source = {
2668 .num_items = 3,
2669 .items = {
2670 { "Mic", 0x1 },
2671 { "Line", 0x5 },
2672 { "Internal Mic", 0x6 },
2673 },
2674};
2675
2676/* 2,4,6 channel modes */
2677static struct hda_verb alc880_lg_ch2_init[] = {
2678 /* set line-in and mic-in to input */
2679 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2680 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2681 { }
2682};
2683
2684static struct hda_verb alc880_lg_ch4_init[] = {
2685 /* set line-in to out and mic-in to input */
2686 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2687 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2688 { }
2689};
2690
2691static struct hda_verb alc880_lg_ch6_init[] = {
2692 /* set line-in and mic-in to output */
2693 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2694 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2695 { }
2696};
2697
2698static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2699 { 2, alc880_lg_ch2_init },
2700 { 4, alc880_lg_ch4_init },
2701 { 6, alc880_lg_ch6_init },
2702};
2703
2704static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002705 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2706 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002707 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2708 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2709 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2710 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2711 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2712 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2713 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2714 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2715 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2716 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2717 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2718 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2719 {
2720 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2721 .name = "Channel Mode",
2722 .info = alc_ch_mode_info,
2723 .get = alc_ch_mode_get,
2724 .put = alc_ch_mode_put,
2725 },
2726 { } /* end */
2727};
2728
2729static struct hda_verb alc880_lg_init_verbs[] = {
2730 /* set capture source to mic-in */
2731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2733 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2734 /* mute all amp mixer inputs */
2735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002736 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2737 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002738 /* line-in to input */
2739 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2740 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2741 /* built-in mic */
2742 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2743 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2744 /* speaker-out */
2745 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2746 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 /* mic-in to input */
2748 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2749 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2750 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2751 /* HP-out */
2752 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2753 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2754 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2755 /* jack sense */
2756 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2757 { }
2758};
2759
2760/* toggle speaker-output according to the hp-jack state */
2761static void alc880_lg_automute(struct hda_codec *codec)
2762{
2763 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002764 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002765
2766 present = snd_hda_codec_read(codec, 0x1b, 0,
2767 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002768 bits = present ? HDA_AMP_MUTE : 0;
2769 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2770 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002771}
2772
2773static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2774{
2775 /* Looks like the unsol event is incompatible with the standard
2776 * definition. 4bit tag is placed at 28 bit!
2777 */
2778 if ((res >> 28) == 0x01)
2779 alc880_lg_automute(codec);
2780}
2781
2782/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002783 * LG LW20
2784 *
2785 * Pin assignment:
2786 * Speaker-out: 0x14
2787 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002788 * Built-in Mic-In: 0x19
2789 * Line-In: 0x1b
2790 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002791 * SPDIF-Out: 0x1e
2792 */
2793
Takashi Iwaid6815182006-03-23 16:06:23 +01002794static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002795 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002796 .items = {
2797 { "Mic", 0x0 },
2798 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002799 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002800 },
2801};
2802
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002803#define alc880_lg_lw_modes alc880_threestack_modes
2804
Takashi Iwaid6815182006-03-23 16:06:23 +01002805static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002806 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2807 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2808 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2809 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2810 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2811 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2812 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2813 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2814 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2815 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002816 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2817 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2818 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2819 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002820 {
2821 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2822 .name = "Channel Mode",
2823 .info = alc_ch_mode_info,
2824 .get = alc_ch_mode_get,
2825 .put = alc_ch_mode_put,
2826 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002827 { } /* end */
2828};
2829
2830static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002831 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2832 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2833 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2834
Takashi Iwaid6815182006-03-23 16:06:23 +01002835 /* set capture source to mic-in */
2836 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2837 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2838 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002840 /* speaker-out */
2841 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2842 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2843 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002844 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2845 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2846 /* mic-in to input */
2847 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2848 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2849 /* built-in mic */
2850 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2851 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2852 /* jack sense */
2853 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2854 { }
2855};
2856
2857/* toggle speaker-output according to the hp-jack state */
2858static void alc880_lg_lw_automute(struct hda_codec *codec)
2859{
2860 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002861 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002862
2863 present = snd_hda_codec_read(codec, 0x1b, 0,
2864 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002865 bits = present ? HDA_AMP_MUTE : 0;
2866 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2867 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002868}
2869
2870static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2871{
2872 /* Looks like the unsol event is incompatible with the standard
2873 * definition. 4bit tag is placed at 28 bit!
2874 */
2875 if ((res >> 28) == 0x01)
2876 alc880_lg_lw_automute(codec);
2877}
2878
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002879static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2880 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2881 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2884 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2885 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2886 { } /* end */
2887};
2888
2889static struct hda_input_mux alc880_medion_rim_capture_source = {
2890 .num_items = 2,
2891 .items = {
2892 { "Mic", 0x0 },
2893 { "Internal Mic", 0x1 },
2894 },
2895};
2896
2897static struct hda_verb alc880_medion_rim_init_verbs[] = {
2898 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2899
2900 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2902
2903 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2904 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2905 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2906 /* Mic2 (as headphone out) for HP output */
2907 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2908 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2909 /* Internal Speaker */
2910 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2911 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2912
2913 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2914 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2915
2916 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2917 { }
2918};
2919
2920/* toggle speaker-output according to the hp-jack state */
2921static void alc880_medion_rim_automute(struct hda_codec *codec)
2922{
2923 unsigned int present;
2924 unsigned char bits;
2925
2926 present = snd_hda_codec_read(codec, 0x14, 0,
2927 AC_VERB_GET_PIN_SENSE, 0)
2928 & AC_PINSENSE_PRESENCE;
2929 bits = present ? HDA_AMP_MUTE : 0;
2930 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2931 HDA_AMP_MUTE, bits);
2932 if (present)
2933 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2934 else
2935 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2936}
2937
2938static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2939 unsigned int res)
2940{
2941 /* Looks like the unsol event is incompatible with the standard
2942 * definition. 4bit tag is placed at 28 bit!
2943 */
2944 if ((res >> 28) == ALC880_HP_EVENT)
2945 alc880_medion_rim_automute(codec);
2946}
2947
Takashi Iwaicb53c622007-08-10 17:21:45 +02002948#ifdef CONFIG_SND_HDA_POWER_SAVE
2949static struct hda_amp_list alc880_loopbacks[] = {
2950 { 0x0b, HDA_INPUT, 0 },
2951 { 0x0b, HDA_INPUT, 1 },
2952 { 0x0b, HDA_INPUT, 2 },
2953 { 0x0b, HDA_INPUT, 3 },
2954 { 0x0b, HDA_INPUT, 4 },
2955 { } /* end */
2956};
2957
2958static struct hda_amp_list alc880_lg_loopbacks[] = {
2959 { 0x0b, HDA_INPUT, 1 },
2960 { 0x0b, HDA_INPUT, 6 },
2961 { 0x0b, HDA_INPUT, 7 },
2962 { } /* end */
2963};
2964#endif
2965
Takashi Iwaid6815182006-03-23 16:06:23 +01002966/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002967 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002968 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002969
Linus Torvalds1da177e2005-04-16 15:20:36 -07002970static int alc_init(struct hda_codec *codec)
2971{
2972 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002973 unsigned int i;
2974
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002975 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02002976 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002977
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002978 for (i = 0; i < spec->num_init_verbs; i++)
2979 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002980
2981 if (spec->init_hook)
2982 spec->init_hook(codec);
2983
Linus Torvalds1da177e2005-04-16 15:20:36 -07002984 return 0;
2985}
2986
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002987static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2988{
2989 struct alc_spec *spec = codec->spec;
2990
2991 if (spec->unsol_event)
2992 spec->unsol_event(codec, res);
2993}
2994
Takashi Iwaicb53c622007-08-10 17:21:45 +02002995#ifdef CONFIG_SND_HDA_POWER_SAVE
2996static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2997{
2998 struct alc_spec *spec = codec->spec;
2999 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3000}
3001#endif
3002
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003/*
3004 * Analog playback callbacks
3005 */
3006static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3007 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003008 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003009{
3010 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003011 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3012 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003013}
3014
3015static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3016 struct hda_codec *codec,
3017 unsigned int stream_tag,
3018 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003019 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003020{
3021 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003022 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3023 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003024}
3025
3026static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3027 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003028 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003029{
3030 struct alc_spec *spec = codec->spec;
3031 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3032}
3033
3034/*
3035 * Digital out
3036 */
3037static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3038 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003039 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003040{
3041 struct alc_spec *spec = codec->spec;
3042 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3043}
3044
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003045static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3046 struct hda_codec *codec,
3047 unsigned int stream_tag,
3048 unsigned int format,
3049 struct snd_pcm_substream *substream)
3050{
3051 struct alc_spec *spec = codec->spec;
3052 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3053 stream_tag, format, substream);
3054}
3055
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003056static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3057 struct hda_codec *codec,
3058 struct snd_pcm_substream *substream)
3059{
3060 struct alc_spec *spec = codec->spec;
3061 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3062}
3063
Linus Torvalds1da177e2005-04-16 15:20:36 -07003064static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3065 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003066 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003067{
3068 struct alc_spec *spec = codec->spec;
3069 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3070}
3071
3072/*
3073 * Analog capture
3074 */
Takashi Iwai63300792008-01-24 15:31:36 +01003075static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003076 struct hda_codec *codec,
3077 unsigned int stream_tag,
3078 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003079 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003080{
3081 struct alc_spec *spec = codec->spec;
3082
Takashi Iwai63300792008-01-24 15:31:36 +01003083 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003084 stream_tag, 0, format);
3085 return 0;
3086}
3087
Takashi Iwai63300792008-01-24 15:31:36 +01003088static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003089 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003090 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003091{
3092 struct alc_spec *spec = codec->spec;
3093
Takashi Iwai888afa12008-03-18 09:57:50 +01003094 snd_hda_codec_cleanup_stream(codec,
3095 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003096 return 0;
3097}
3098
3099
3100/*
3101 */
3102static struct hda_pcm_stream alc880_pcm_analog_playback = {
3103 .substreams = 1,
3104 .channels_min = 2,
3105 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003106 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003107 .ops = {
3108 .open = alc880_playback_pcm_open,
3109 .prepare = alc880_playback_pcm_prepare,
3110 .cleanup = alc880_playback_pcm_cleanup
3111 },
3112};
3113
3114static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003115 .substreams = 1,
3116 .channels_min = 2,
3117 .channels_max = 2,
3118 /* NID is set in alc_build_pcms */
3119};
3120
3121static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3122 .substreams = 1,
3123 .channels_min = 2,
3124 .channels_max = 2,
3125 /* NID is set in alc_build_pcms */
3126};
3127
3128static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3129 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003130 .channels_min = 2,
3131 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003132 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003133 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003134 .prepare = alc880_alt_capture_pcm_prepare,
3135 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003136 },
3137};
3138
3139static struct hda_pcm_stream alc880_pcm_digital_playback = {
3140 .substreams = 1,
3141 .channels_min = 2,
3142 .channels_max = 2,
3143 /* NID is set in alc_build_pcms */
3144 .ops = {
3145 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003146 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003147 .prepare = alc880_dig_playback_pcm_prepare,
3148 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003149 },
3150};
3151
3152static struct hda_pcm_stream alc880_pcm_digital_capture = {
3153 .substreams = 1,
3154 .channels_min = 2,
3155 .channels_max = 2,
3156 /* NID is set in alc_build_pcms */
3157};
3158
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003159/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003160static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003161 .substreams = 0,
3162 .channels_min = 0,
3163 .channels_max = 0,
3164};
3165
Linus Torvalds1da177e2005-04-16 15:20:36 -07003166static int alc_build_pcms(struct hda_codec *codec)
3167{
3168 struct alc_spec *spec = codec->spec;
3169 struct hda_pcm *info = spec->pcm_rec;
3170 int i;
3171
3172 codec->num_pcms = 1;
3173 codec->pcm_info = info;
3174
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003175 if (spec->no_analog)
3176 goto skip_analog;
3177
Linus Torvalds1da177e2005-04-16 15:20:36 -07003178 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003179 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003180 if (snd_BUG_ON(!spec->multiout.dac_nids))
3181 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003182 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3183 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3184 }
3185 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003186 if (snd_BUG_ON(!spec->adc_nids))
3187 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003188 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3189 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3190 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003191
Takashi Iwai4a471b72005-12-07 13:56:29 +01003192 if (spec->channel_mode) {
3193 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3194 for (i = 0; i < spec->num_channel_mode; i++) {
3195 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3196 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3197 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003198 }
3199 }
3200
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003201 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003202 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003203 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003204 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003205 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003206 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003207 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003208 if (spec->dig_out_type)
3209 info->pcm_type = spec->dig_out_type;
3210 else
3211 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003212 if (spec->multiout.dig_out_nid &&
3213 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003214 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3215 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3216 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003217 if (spec->dig_in_nid &&
3218 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003219 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3220 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3221 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003222 /* FIXME: do we need this for all Realtek codec models? */
3223 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003224 }
3225
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003226 if (spec->no_analog)
3227 return 0;
3228
Takashi Iwaie08a0072006-09-07 17:52:14 +02003229 /* If the use of more than one ADC is requested for the current
3230 * model, configure a second analog capture-only PCM.
3231 */
3232 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003233 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3234 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003235 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003236 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003237 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003238 if (spec->alt_dac_nid) {
3239 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3240 *spec->stream_analog_alt_playback;
3241 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3242 spec->alt_dac_nid;
3243 } else {
3244 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3245 alc_pcm_null_stream;
3246 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3247 }
3248 if (spec->num_adc_nids > 1) {
3249 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3250 *spec->stream_analog_alt_capture;
3251 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3252 spec->adc_nids[1];
3253 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3254 spec->num_adc_nids - 1;
3255 } else {
3256 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3257 alc_pcm_null_stream;
3258 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003259 }
3260 }
3261
Linus Torvalds1da177e2005-04-16 15:20:36 -07003262 return 0;
3263}
3264
Takashi Iwai603c4012008-07-30 15:01:44 +02003265static void alc_free_kctls(struct hda_codec *codec)
3266{
3267 struct alc_spec *spec = codec->spec;
3268
3269 if (spec->kctls.list) {
3270 struct snd_kcontrol_new *kctl = spec->kctls.list;
3271 int i;
3272 for (i = 0; i < spec->kctls.used; i++)
3273 kfree(kctl[i].name);
3274 }
3275 snd_array_free(&spec->kctls);
3276}
3277
Linus Torvalds1da177e2005-04-16 15:20:36 -07003278static void alc_free(struct hda_codec *codec)
3279{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003281
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003282 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003283 return;
3284
Takashi Iwai603c4012008-07-30 15:01:44 +02003285 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003286 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003287 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003288}
3289
Takashi Iwaie044c392008-10-27 16:56:24 +01003290#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003291static int alc_resume(struct hda_codec *codec)
3292{
Takashi Iwaie044c392008-10-27 16:56:24 +01003293 codec->patch_ops.init(codec);
3294 snd_hda_codec_resume_amp(codec);
3295 snd_hda_codec_resume_cache(codec);
3296 return 0;
3297}
Takashi Iwaie044c392008-10-27 16:56:24 +01003298#endif
3299
Linus Torvalds1da177e2005-04-16 15:20:36 -07003300/*
3301 */
3302static struct hda_codec_ops alc_patch_ops = {
3303 .build_controls = alc_build_controls,
3304 .build_pcms = alc_build_pcms,
3305 .init = alc_init,
3306 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003307 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003308#ifdef SND_HDA_NEEDS_RESUME
3309 .resume = alc_resume,
3310#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003311#ifdef CONFIG_SND_HDA_POWER_SAVE
3312 .check_power_status = alc_check_power_status,
3313#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003314};
3315
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003316
3317/*
3318 * Test configuration for debugging
3319 *
3320 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3321 * enum controls.
3322 */
3323#ifdef CONFIG_SND_DEBUG
3324static hda_nid_t alc880_test_dac_nids[4] = {
3325 0x02, 0x03, 0x04, 0x05
3326};
3327
3328static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003329 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003330 .items = {
3331 { "In-1", 0x0 },
3332 { "In-2", 0x1 },
3333 { "In-3", 0x2 },
3334 { "In-4", 0x3 },
3335 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003336 { "Front", 0x5 },
3337 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003338 },
3339};
3340
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003341static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003342 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003343 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003344 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003345 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003346};
3347
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003348static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3349 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003350{
3351 static char *texts[] = {
3352 "N/A", "Line Out", "HP Out",
3353 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3354 };
3355 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3356 uinfo->count = 1;
3357 uinfo->value.enumerated.items = 8;
3358 if (uinfo->value.enumerated.item >= 8)
3359 uinfo->value.enumerated.item = 7;
3360 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3361 return 0;
3362}
3363
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003364static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3365 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003366{
3367 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3368 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3369 unsigned int pin_ctl, item = 0;
3370
3371 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3372 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3373 if (pin_ctl & AC_PINCTL_OUT_EN) {
3374 if (pin_ctl & AC_PINCTL_HP_EN)
3375 item = 2;
3376 else
3377 item = 1;
3378 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3379 switch (pin_ctl & AC_PINCTL_VREFEN) {
3380 case AC_PINCTL_VREF_HIZ: item = 3; break;
3381 case AC_PINCTL_VREF_50: item = 4; break;
3382 case AC_PINCTL_VREF_GRD: item = 5; break;
3383 case AC_PINCTL_VREF_80: item = 6; break;
3384 case AC_PINCTL_VREF_100: item = 7; break;
3385 }
3386 }
3387 ucontrol->value.enumerated.item[0] = item;
3388 return 0;
3389}
3390
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003391static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3392 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003393{
3394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3395 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3396 static unsigned int ctls[] = {
3397 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3398 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3399 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3400 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3401 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3402 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3403 };
3404 unsigned int old_ctl, new_ctl;
3405
3406 old_ctl = snd_hda_codec_read(codec, nid, 0,
3407 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3408 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3409 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003410 int val;
3411 snd_hda_codec_write_cache(codec, nid, 0,
3412 AC_VERB_SET_PIN_WIDGET_CONTROL,
3413 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003414 val = ucontrol->value.enumerated.item[0] >= 3 ?
3415 HDA_AMP_MUTE : 0;
3416 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3417 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003418 return 1;
3419 }
3420 return 0;
3421}
3422
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003423static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3424 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003425{
3426 static char *texts[] = {
3427 "Front", "Surround", "CLFE", "Side"
3428 };
3429 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3430 uinfo->count = 1;
3431 uinfo->value.enumerated.items = 4;
3432 if (uinfo->value.enumerated.item >= 4)
3433 uinfo->value.enumerated.item = 3;
3434 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3435 return 0;
3436}
3437
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003438static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3439 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003440{
3441 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3442 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3443 unsigned int sel;
3444
3445 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3446 ucontrol->value.enumerated.item[0] = sel & 3;
3447 return 0;
3448}
3449
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003450static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3451 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003452{
3453 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3454 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3455 unsigned int sel;
3456
3457 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3458 if (ucontrol->value.enumerated.item[0] != sel) {
3459 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003460 snd_hda_codec_write_cache(codec, nid, 0,
3461 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003462 return 1;
3463 }
3464 return 0;
3465}
3466
3467#define PIN_CTL_TEST(xname,nid) { \
3468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3469 .name = xname, \
3470 .info = alc_test_pin_ctl_info, \
3471 .get = alc_test_pin_ctl_get, \
3472 .put = alc_test_pin_ctl_put, \
3473 .private_value = nid \
3474 }
3475
3476#define PIN_SRC_TEST(xname,nid) { \
3477 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3478 .name = xname, \
3479 .info = alc_test_pin_src_info, \
3480 .get = alc_test_pin_src_get, \
3481 .put = alc_test_pin_src_put, \
3482 .private_value = nid \
3483 }
3484
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003485static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003486 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3487 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3488 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3489 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003490 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3491 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3492 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3493 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003494 PIN_CTL_TEST("Front Pin Mode", 0x14),
3495 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3496 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3497 PIN_CTL_TEST("Side Pin Mode", 0x17),
3498 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3499 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3500 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3501 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3502 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3503 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3504 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3505 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3506 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3507 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3508 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3509 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3510 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3511 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3512 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3513 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3514 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3515 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003516 {
3517 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3518 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003519 .info = alc_ch_mode_info,
3520 .get = alc_ch_mode_get,
3521 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003522 },
3523 { } /* end */
3524};
3525
3526static struct hda_verb alc880_test_init_verbs[] = {
3527 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3533 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3535 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003536 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003541 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3543 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3544 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3545 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003546 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003547 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3548 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3549 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3550 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003551 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003552 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003554 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3555 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3556 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003557 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003558 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3559 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3560 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3561 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003562 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003563 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003564 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003565 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003566 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003567 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003568 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003569 /* Analog input/passthru */
3570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003575 { }
3576};
3577#endif
3578
Linus Torvalds1da177e2005-04-16 15:20:36 -07003579/*
3580 */
3581
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003582static const char *alc880_models[ALC880_MODEL_LAST] = {
3583 [ALC880_3ST] = "3stack",
3584 [ALC880_TCL_S700] = "tcl",
3585 [ALC880_3ST_DIG] = "3stack-digout",
3586 [ALC880_CLEVO] = "clevo",
3587 [ALC880_5ST] = "5stack",
3588 [ALC880_5ST_DIG] = "5stack-digout",
3589 [ALC880_W810] = "w810",
3590 [ALC880_Z71V] = "z71v",
3591 [ALC880_6ST] = "6stack",
3592 [ALC880_6ST_DIG] = "6stack-digout",
3593 [ALC880_ASUS] = "asus",
3594 [ALC880_ASUS_W1V] = "asus-w1v",
3595 [ALC880_ASUS_DIG] = "asus-dig",
3596 [ALC880_ASUS_DIG2] = "asus-dig2",
3597 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003598 [ALC880_UNIWILL_P53] = "uniwill-p53",
3599 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003600 [ALC880_F1734] = "F1734",
3601 [ALC880_LG] = "lg",
3602 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003603 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003604#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003605 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003606#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003607 [ALC880_AUTO] = "auto",
3608};
3609
3610static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003611 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003612 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3613 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3614 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3615 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3616 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3617 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3618 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3619 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003620 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3621 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003622 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3623 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3624 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3625 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3626 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3627 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3628 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3629 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3630 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3631 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003632 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003633 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3634 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3635 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003636 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003637 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003638 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3639 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003640 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3641 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003642 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3643 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3644 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3645 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003646 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3647 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003648 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003649 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003650 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003651 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003652 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3653 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003654 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003655 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003656 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003657 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003658 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003659 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003660 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003661 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003662 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003663 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3664 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003665 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003666 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3667 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3668 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3669 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003670 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3671 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003672 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003673 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003674 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3675 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003676 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3677 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3678 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003679 /* default Intel */
3680 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003681 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3682 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003683 {}
3684};
3685
Takashi Iwai16ded522005-06-10 19:58:24 +02003686/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003687 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003688 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003689static struct alc_config_preset alc880_presets[] = {
3690 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003691 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003692 .init_verbs = { alc880_volume_init_verbs,
3693 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003694 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003695 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003696 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3697 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003698 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003699 .input_mux = &alc880_capture_source,
3700 },
3701 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003702 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003703 .init_verbs = { alc880_volume_init_verbs,
3704 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003705 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003706 .dac_nids = alc880_dac_nids,
3707 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003708 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3709 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003710 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003711 .input_mux = &alc880_capture_source,
3712 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003713 [ALC880_TCL_S700] = {
3714 .mixers = { alc880_tcl_s700_mixer },
3715 .init_verbs = { alc880_volume_init_verbs,
3716 alc880_pin_tcl_S700_init_verbs,
3717 alc880_gpio2_init_verbs },
3718 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3719 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003720 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3721 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003722 .hp_nid = 0x03,
3723 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3724 .channel_mode = alc880_2_jack_modes,
3725 .input_mux = &alc880_capture_source,
3726 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003727 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003728 .mixers = { alc880_three_stack_mixer,
3729 alc880_five_stack_mixer},
3730 .init_verbs = { alc880_volume_init_verbs,
3731 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003732 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3733 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003734 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3735 .channel_mode = alc880_fivestack_modes,
3736 .input_mux = &alc880_capture_source,
3737 },
3738 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003739 .mixers = { alc880_three_stack_mixer,
3740 alc880_five_stack_mixer },
3741 .init_verbs = { alc880_volume_init_verbs,
3742 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003743 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3744 .dac_nids = alc880_dac_nids,
3745 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003746 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3747 .channel_mode = alc880_fivestack_modes,
3748 .input_mux = &alc880_capture_source,
3749 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003750 [ALC880_6ST] = {
3751 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003752 .init_verbs = { alc880_volume_init_verbs,
3753 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003754 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3755 .dac_nids = alc880_6st_dac_nids,
3756 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3757 .channel_mode = alc880_sixstack_modes,
3758 .input_mux = &alc880_6stack_capture_source,
3759 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003760 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003761 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003762 .init_verbs = { alc880_volume_init_verbs,
3763 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003764 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3765 .dac_nids = alc880_6st_dac_nids,
3766 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003767 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3768 .channel_mode = alc880_sixstack_modes,
3769 .input_mux = &alc880_6stack_capture_source,
3770 },
3771 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003772 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003773 .init_verbs = { alc880_volume_init_verbs,
3774 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003775 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003776 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3777 .dac_nids = alc880_w810_dac_nids,
3778 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003779 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3780 .channel_mode = alc880_w810_modes,
3781 .input_mux = &alc880_capture_source,
3782 },
3783 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003784 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003785 .init_verbs = { alc880_volume_init_verbs,
3786 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003787 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3788 .dac_nids = alc880_z71v_dac_nids,
3789 .dig_out_nid = ALC880_DIGOUT_NID,
3790 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003791 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3792 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003793 .input_mux = &alc880_capture_source,
3794 },
3795 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003796 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003797 .init_verbs = { alc880_volume_init_verbs,
3798 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003799 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3800 .dac_nids = alc880_f1734_dac_nids,
3801 .hp_nid = 0x02,
3802 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3803 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003804 .input_mux = &alc880_f1734_capture_source,
3805 .unsol_event = alc880_uniwill_p53_unsol_event,
3806 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003807 },
3808 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003809 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003810 .init_verbs = { alc880_volume_init_verbs,
3811 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003812 alc880_gpio1_init_verbs },
3813 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3814 .dac_nids = alc880_asus_dac_nids,
3815 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3816 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003817 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003818 .input_mux = &alc880_capture_source,
3819 },
3820 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003821 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003822 .init_verbs = { alc880_volume_init_verbs,
3823 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003824 alc880_gpio1_init_verbs },
3825 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3826 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003827 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003828 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3829 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003830 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003831 .input_mux = &alc880_capture_source,
3832 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003833 [ALC880_ASUS_DIG2] = {
3834 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003835 .init_verbs = { alc880_volume_init_verbs,
3836 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003837 alc880_gpio2_init_verbs }, /* use GPIO2 */
3838 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3839 .dac_nids = alc880_asus_dac_nids,
3840 .dig_out_nid = ALC880_DIGOUT_NID,
3841 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3842 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003843 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003844 .input_mux = &alc880_capture_source,
3845 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003846 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003847 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003848 .init_verbs = { alc880_volume_init_verbs,
3849 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003850 alc880_gpio1_init_verbs },
3851 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3852 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003853 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003854 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3855 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003856 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003857 .input_mux = &alc880_capture_source,
3858 },
3859 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003860 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003861 .init_verbs = { alc880_volume_init_verbs,
3862 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003863 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3864 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003865 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003866 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3867 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003868 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003869 .input_mux = &alc880_capture_source,
3870 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003871 [ALC880_UNIWILL] = {
3872 .mixers = { alc880_uniwill_mixer },
3873 .init_verbs = { alc880_volume_init_verbs,
3874 alc880_uniwill_init_verbs },
3875 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3876 .dac_nids = alc880_asus_dac_nids,
3877 .dig_out_nid = ALC880_DIGOUT_NID,
3878 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3879 .channel_mode = alc880_threestack_modes,
3880 .need_dac_fix = 1,
3881 .input_mux = &alc880_capture_source,
3882 .unsol_event = alc880_uniwill_unsol_event,
3883 .init_hook = alc880_uniwill_automute,
3884 },
3885 [ALC880_UNIWILL_P53] = {
3886 .mixers = { alc880_uniwill_p53_mixer },
3887 .init_verbs = { alc880_volume_init_verbs,
3888 alc880_uniwill_p53_init_verbs },
3889 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3890 .dac_nids = alc880_asus_dac_nids,
3891 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003892 .channel_mode = alc880_threestack_modes,
3893 .input_mux = &alc880_capture_source,
3894 .unsol_event = alc880_uniwill_p53_unsol_event,
3895 .init_hook = alc880_uniwill_p53_hp_automute,
3896 },
3897 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003898 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003899 .init_verbs = { alc880_volume_init_verbs,
3900 alc880_uniwill_p53_init_verbs,
3901 alc880_beep_init_verbs },
3902 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3903 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003904 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003905 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3906 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003907 .input_mux = &alc880_capture_source,
3908 .unsol_event = alc880_uniwill_p53_unsol_event,
3909 .init_hook = alc880_uniwill_p53_hp_automute,
3910 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003911 [ALC880_CLEVO] = {
3912 .mixers = { alc880_three_stack_mixer },
3913 .init_verbs = { alc880_volume_init_verbs,
3914 alc880_pin_clevo_init_verbs },
3915 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3916 .dac_nids = alc880_dac_nids,
3917 .hp_nid = 0x03,
3918 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3919 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003920 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003921 .input_mux = &alc880_capture_source,
3922 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003923 [ALC880_LG] = {
3924 .mixers = { alc880_lg_mixer },
3925 .init_verbs = { alc880_volume_init_verbs,
3926 alc880_lg_init_verbs },
3927 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3928 .dac_nids = alc880_lg_dac_nids,
3929 .dig_out_nid = ALC880_DIGOUT_NID,
3930 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3931 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003932 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003933 .input_mux = &alc880_lg_capture_source,
3934 .unsol_event = alc880_lg_unsol_event,
3935 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003936#ifdef CONFIG_SND_HDA_POWER_SAVE
3937 .loopbacks = alc880_lg_loopbacks,
3938#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003939 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003940 [ALC880_LG_LW] = {
3941 .mixers = { alc880_lg_lw_mixer },
3942 .init_verbs = { alc880_volume_init_verbs,
3943 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003944 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003945 .dac_nids = alc880_dac_nids,
3946 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003947 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3948 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003949 .input_mux = &alc880_lg_lw_capture_source,
3950 .unsol_event = alc880_lg_lw_unsol_event,
3951 .init_hook = alc880_lg_lw_automute,
3952 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003953 [ALC880_MEDION_RIM] = {
3954 .mixers = { alc880_medion_rim_mixer },
3955 .init_verbs = { alc880_volume_init_verbs,
3956 alc880_medion_rim_init_verbs,
3957 alc_gpio2_init_verbs },
3958 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3959 .dac_nids = alc880_dac_nids,
3960 .dig_out_nid = ALC880_DIGOUT_NID,
3961 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3962 .channel_mode = alc880_2_jack_modes,
3963 .input_mux = &alc880_medion_rim_capture_source,
3964 .unsol_event = alc880_medion_rim_unsol_event,
3965 .init_hook = alc880_medion_rim_automute,
3966 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003967#ifdef CONFIG_SND_DEBUG
3968 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003969 .mixers = { alc880_test_mixer },
3970 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003971 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3972 .dac_nids = alc880_test_dac_nids,
3973 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003974 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3975 .channel_mode = alc880_test_modes,
3976 .input_mux = &alc880_test_capture_source,
3977 },
3978#endif
3979};
3980
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003981/*
3982 * Automatic parse of I/O pins from the BIOS configuration
3983 */
3984
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003985enum {
3986 ALC_CTL_WIDGET_VOL,
3987 ALC_CTL_WIDGET_MUTE,
3988 ALC_CTL_BIND_MUTE,
3989};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003990static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003991 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3992 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003993 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003994};
3995
3996/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003997static int add_control(struct alc_spec *spec, int type, const char *name,
3998 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003999{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004000 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004001
Takashi Iwai603c4012008-07-30 15:01:44 +02004002 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4003 knew = snd_array_new(&spec->kctls);
4004 if (!knew)
4005 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004006 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004007 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004008 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004009 return -ENOMEM;
4010 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004011 return 0;
4012}
4013
4014#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4015#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4016#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4017#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4018#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4019#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4020#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4021#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4022#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4023#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4024#define ALC880_PIN_CD_NID 0x1c
4025
4026/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004027static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4028 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004029{
4030 hda_nid_t nid;
4031 int assigned[4];
4032 int i, j;
4033
4034 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004035 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004036
4037 /* check the pins hardwired to audio widget */
4038 for (i = 0; i < cfg->line_outs; i++) {
4039 nid = cfg->line_out_pins[i];
4040 if (alc880_is_fixed_pin(nid)) {
4041 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004042 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004043 assigned[idx] = 1;
4044 }
4045 }
4046 /* left pins can be connect to any audio widget */
4047 for (i = 0; i < cfg->line_outs; i++) {
4048 nid = cfg->line_out_pins[i];
4049 if (alc880_is_fixed_pin(nid))
4050 continue;
4051 /* search for an empty channel */
4052 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004053 if (!assigned[j]) {
4054 spec->multiout.dac_nids[i] =
4055 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004056 assigned[j] = 1;
4057 break;
4058 }
4059 }
4060 }
4061 spec->multiout.num_dacs = cfg->line_outs;
4062 return 0;
4063}
4064
4065/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004066static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4067 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004068{
4069 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004070 static const char *chname[4] = {
4071 "Front", "Surround", NULL /*CLFE*/, "Side"
4072 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004073 hda_nid_t nid;
4074 int i, err;
4075
4076 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004077 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004078 continue;
4079 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4080 if (i == 2) {
4081 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004082 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4083 "Center Playback Volume",
4084 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4085 HDA_OUTPUT));
4086 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004087 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004088 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4089 "LFE Playback Volume",
4090 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4091 HDA_OUTPUT));
4092 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004093 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004094 err = add_control(spec, ALC_CTL_BIND_MUTE,
4095 "Center Playback Switch",
4096 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4097 HDA_INPUT));
4098 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004099 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004100 err = add_control(spec, ALC_CTL_BIND_MUTE,
4101 "LFE Playback Switch",
4102 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4103 HDA_INPUT));
4104 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004105 return err;
4106 } else {
4107 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004108 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4109 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4110 HDA_OUTPUT));
4111 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004112 return err;
4113 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004114 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4115 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4116 HDA_INPUT));
4117 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004118 return err;
4119 }
4120 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004121 return 0;
4122}
4123
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004124/* add playback controls for speaker and HP outputs */
4125static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4126 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004127{
4128 hda_nid_t nid;
4129 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004130 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004131
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004132 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004133 return 0;
4134
4135 if (alc880_is_fixed_pin(pin)) {
4136 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004137 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004138 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004139 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004140 else
4141 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004142 /* control HP volume/switch on the output mixer amp */
4143 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004144 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004145 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4146 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4147 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004148 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004149 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004150 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4151 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4152 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004153 return err;
4154 } else if (alc880_is_multi_pin(pin)) {
4155 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004156 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004157 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004158 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4159 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4160 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004161 return err;
4162 }
4163 return 0;
4164}
4165
4166/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004167static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4168 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004169 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004170{
4171 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004172 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004173
4174 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004175 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4176 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4177 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004178 return err;
4179 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004180 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4181 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4182 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004183 return err;
4184 return 0;
4185}
4186
4187/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004188static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4189 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004190{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004191 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004192 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004193
4194 for (i = 0; i < AUTO_PIN_LAST; i++) {
4195 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004196 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004197 err = new_analog_input(spec, cfg->input_pins[i],
4198 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004199 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004200 if (err < 0)
4201 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004202 imux->items[imux->num_items].label =
4203 auto_pin_cfg_labels[i];
4204 imux->items[imux->num_items].index =
4205 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004206 imux->num_items++;
4207 }
4208 }
4209 return 0;
4210}
4211
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004212static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4213 unsigned int pin_type)
4214{
4215 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4216 pin_type);
4217 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004218 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4219 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004220}
4221
Kailang Yangdf694da2005-12-05 19:42:22 +01004222static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4223 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004224 int dac_idx)
4225{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004226 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004227 /* need the manual connection? */
4228 if (alc880_is_multi_pin(nid)) {
4229 struct alc_spec *spec = codec->spec;
4230 int idx = alc880_multi_pin_idx(nid);
4231 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4232 AC_VERB_SET_CONNECT_SEL,
4233 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4234 }
4235}
4236
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004237static int get_pin_type(int line_out_type)
4238{
4239 if (line_out_type == AUTO_PIN_HP_OUT)
4240 return PIN_HP;
4241 else
4242 return PIN_OUT;
4243}
4244
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004245static void alc880_auto_init_multi_out(struct hda_codec *codec)
4246{
4247 struct alc_spec *spec = codec->spec;
4248 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004249
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004250 for (i = 0; i < spec->autocfg.line_outs; i++) {
4251 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004252 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4253 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004254 }
4255}
4256
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004257static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004258{
4259 struct alc_spec *spec = codec->spec;
4260 hda_nid_t pin;
4261
Takashi Iwai82bc9552006-03-21 11:24:42 +01004262 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004263 if (pin) /* connect to front */
4264 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004265 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004266 if (pin) /* connect to front */
4267 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4268}
4269
4270static void alc880_auto_init_analog_input(struct hda_codec *codec)
4271{
4272 struct alc_spec *spec = codec->spec;
4273 int i;
4274
4275 for (i = 0; i < AUTO_PIN_LAST; i++) {
4276 hda_nid_t nid = spec->autocfg.input_pins[i];
4277 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004278 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004279 if (nid != ALC880_PIN_CD_NID &&
4280 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004281 snd_hda_codec_write(codec, nid, 0,
4282 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004283 AMP_OUT_MUTE);
4284 }
4285 }
4286}
4287
4288/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004289/* return 1 if successful, 0 if the proper config is not found,
4290 * or a negative error code
4291 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004292static int alc880_parse_auto_config(struct hda_codec *codec)
4293{
4294 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004295 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004296 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004297
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004298 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4299 alc880_ignore);
4300 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004301 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004302 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004303 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004304
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004305 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4306 if (err < 0)
4307 return err;
4308 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4309 if (err < 0)
4310 return err;
4311 err = alc880_auto_create_extra_out(spec,
4312 spec->autocfg.speaker_pins[0],
4313 "Speaker");
4314 if (err < 0)
4315 return err;
4316 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4317 "Headphone");
4318 if (err < 0)
4319 return err;
4320 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4321 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004322 return err;
4323
4324 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4325
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004326 /* check multiple SPDIF-out (for recent codecs) */
4327 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4328 hda_nid_t dig_nid;
4329 err = snd_hda_get_connections(codec,
4330 spec->autocfg.dig_out_pins[i],
4331 &dig_nid, 1);
4332 if (err < 0)
4333 continue;
4334 if (!i)
4335 spec->multiout.dig_out_nid = dig_nid;
4336 else {
4337 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4338 spec->slave_dig_outs[i - 1] = dig_nid;
4339 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4340 break;
4341 }
4342 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004343 if (spec->autocfg.dig_in_pin)
4344 spec->dig_in_nid = ALC880_DIGIN_NID;
4345
Takashi Iwai603c4012008-07-30 15:01:44 +02004346 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004347 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004348
Takashi Iwaid88897e2008-10-31 15:01:37 +01004349 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004350
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004351 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004352 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004353
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004354 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4355
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004356 return 1;
4357}
4358
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004359/* additional initialization for auto-configuration model */
4360static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004361{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004362 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004363 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004364 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004365 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004366 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004367 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004368}
4369
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004370static void set_capture_mixer(struct alc_spec *spec)
4371{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004372 static struct snd_kcontrol_new *caps[2][3] = {
4373 { alc_capture_mixer_nosrc1,
4374 alc_capture_mixer_nosrc2,
4375 alc_capture_mixer_nosrc3 },
4376 { alc_capture_mixer1,
4377 alc_capture_mixer2,
4378 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004379 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004380 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4381 int mux;
4382 if (spec->input_mux && spec->input_mux->num_items > 1)
4383 mux = 1;
4384 else
4385 mux = 0;
4386 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4387 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004388}
4389
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004390#define set_beep_amp(spec, nid, idx, dir) \
4391 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4392
4393/*
4394 * OK, here we have finally the patch for ALC880
4395 */
4396
Linus Torvalds1da177e2005-04-16 15:20:36 -07004397static int patch_alc880(struct hda_codec *codec)
4398{
4399 struct alc_spec *spec;
4400 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004401 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004402
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004403 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004404 if (spec == NULL)
4405 return -ENOMEM;
4406
4407 codec->spec = spec;
4408
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004409 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4410 alc880_models,
4411 alc880_cfg_tbl);
4412 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004413 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4414 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004415 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004416 }
4417
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004418 if (board_config == ALC880_AUTO) {
4419 /* automatic parse from the BIOS config */
4420 err = alc880_parse_auto_config(codec);
4421 if (err < 0) {
4422 alc_free(codec);
4423 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004424 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004425 printk(KERN_INFO
4426 "hda_codec: Cannot set up configuration "
4427 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004428 board_config = ALC880_3ST;
4429 }
4430 }
4431
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004432 err = snd_hda_attach_beep_device(codec, 0x1);
4433 if (err < 0) {
4434 alc_free(codec);
4435 return err;
4436 }
4437
Kailang Yangdf694da2005-12-05 19:42:22 +01004438 if (board_config != ALC880_AUTO)
4439 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004440
4441 spec->stream_name_analog = "ALC880 Analog";
4442 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4443 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004444 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004445
4446 spec->stream_name_digital = "ALC880 Digital";
4447 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4448 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4449
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004450 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004451 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004452 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004453 /* get type */
4454 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004455 if (wcap != AC_WID_AUD_IN) {
4456 spec->adc_nids = alc880_adc_nids_alt;
4457 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004458 } else {
4459 spec->adc_nids = alc880_adc_nids;
4460 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004461 }
4462 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004463 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004464 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004465
Takashi Iwai2134ea42008-01-10 16:53:55 +01004466 spec->vmaster_nid = 0x0c;
4467
Linus Torvalds1da177e2005-04-16 15:20:36 -07004468 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004469 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004470 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004471#ifdef CONFIG_SND_HDA_POWER_SAVE
4472 if (!spec->loopback.amplist)
4473 spec->loopback.amplist = alc880_loopbacks;
4474#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004475 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004476
4477 return 0;
4478}
4479
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004480
Linus Torvalds1da177e2005-04-16 15:20:36 -07004481/*
4482 * ALC260 support
4483 */
4484
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004485static hda_nid_t alc260_dac_nids[1] = {
4486 /* front */
4487 0x02,
4488};
4489
4490static hda_nid_t alc260_adc_nids[1] = {
4491 /* ADC0 */
4492 0x04,
4493};
4494
Kailang Yangdf694da2005-12-05 19:42:22 +01004495static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004496 /* ADC1 */
4497 0x05,
4498};
4499
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004500/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4501 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4502 */
4503static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004504 /* ADC0, ADC1 */
4505 0x04, 0x05
4506};
4507
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004508#define ALC260_DIGOUT_NID 0x03
4509#define ALC260_DIGIN_NID 0x06
4510
4511static struct hda_input_mux alc260_capture_source = {
4512 .num_items = 4,
4513 .items = {
4514 { "Mic", 0x0 },
4515 { "Front Mic", 0x1 },
4516 { "Line", 0x2 },
4517 { "CD", 0x4 },
4518 },
4519};
4520
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004521/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004522 * headphone jack and the internal CD lines since these are the only pins at
4523 * which audio can appear. For flexibility, also allow the option of
4524 * recording the mixer output on the second ADC (ADC0 doesn't have a
4525 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004526 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004527static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4528 {
4529 .num_items = 3,
4530 .items = {
4531 { "Mic/Line", 0x0 },
4532 { "CD", 0x4 },
4533 { "Headphone", 0x2 },
4534 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004535 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004536 {
4537 .num_items = 4,
4538 .items = {
4539 { "Mic/Line", 0x0 },
4540 { "CD", 0x4 },
4541 { "Headphone", 0x2 },
4542 { "Mixer", 0x5 },
4543 },
4544 },
4545
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004546};
4547
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004548/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4549 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004550 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004551static struct hda_input_mux alc260_acer_capture_sources[2] = {
4552 {
4553 .num_items = 4,
4554 .items = {
4555 { "Mic", 0x0 },
4556 { "Line", 0x2 },
4557 { "CD", 0x4 },
4558 { "Headphone", 0x5 },
4559 },
4560 },
4561 {
4562 .num_items = 5,
4563 .items = {
4564 { "Mic", 0x0 },
4565 { "Line", 0x2 },
4566 { "CD", 0x4 },
4567 { "Headphone", 0x6 },
4568 { "Mixer", 0x5 },
4569 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004570 },
4571};
Michael Schwingencc959482009-02-22 18:58:45 +01004572
4573/* Maxdata Favorit 100XS */
4574static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4575 {
4576 .num_items = 2,
4577 .items = {
4578 { "Line/Mic", 0x0 },
4579 { "CD", 0x4 },
4580 },
4581 },
4582 {
4583 .num_items = 3,
4584 .items = {
4585 { "Line/Mic", 0x0 },
4586 { "CD", 0x4 },
4587 { "Mixer", 0x5 },
4588 },
4589 },
4590};
4591
Linus Torvalds1da177e2005-04-16 15:20:36 -07004592/*
4593 * This is just place-holder, so there's something for alc_build_pcms to look
4594 * at when it calculates the maximum number of channels. ALC260 has no mixer
4595 * element which allows changing the channel mode, so the verb list is
4596 * never used.
4597 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004598static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004599 { 2, NULL },
4600};
4601
Kailang Yangdf694da2005-12-05 19:42:22 +01004602
4603/* Mixer combinations
4604 *
4605 * basic: base_output + input + pc_beep + capture
4606 * HP: base_output + input + capture_alt
4607 * HP_3013: hp_3013 + input + capture
4608 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004609 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004610 */
4611
4612static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004613 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004614 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004615 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4616 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4617 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4618 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4619 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004620};
Kailang Yangdf694da2005-12-05 19:42:22 +01004621
4622static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004623 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4624 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4625 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4626 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4628 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4629 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4630 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004631 { } /* end */
4632};
4633
Takashi Iwaibec15c32008-01-28 18:16:30 +01004634/* update HP, line and mono out pins according to the master switch */
4635static void alc260_hp_master_update(struct hda_codec *codec,
4636 hda_nid_t hp, hda_nid_t line,
4637 hda_nid_t mono)
4638{
4639 struct alc_spec *spec = codec->spec;
4640 unsigned int val = spec->master_sw ? PIN_HP : 0;
4641 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004642 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004643 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004644 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004645 val);
4646 /* mono (speaker) depending on the HP jack sense */
4647 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004648 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004649 val);
4650}
4651
4652static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4653 struct snd_ctl_elem_value *ucontrol)
4654{
4655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4656 struct alc_spec *spec = codec->spec;
4657 *ucontrol->value.integer.value = spec->master_sw;
4658 return 0;
4659}
4660
4661static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4662 struct snd_ctl_elem_value *ucontrol)
4663{
4664 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4665 struct alc_spec *spec = codec->spec;
4666 int val = !!*ucontrol->value.integer.value;
4667 hda_nid_t hp, line, mono;
4668
4669 if (val == spec->master_sw)
4670 return 0;
4671 spec->master_sw = val;
4672 hp = (kcontrol->private_value >> 16) & 0xff;
4673 line = (kcontrol->private_value >> 8) & 0xff;
4674 mono = kcontrol->private_value & 0xff;
4675 alc260_hp_master_update(codec, hp, line, mono);
4676 return 1;
4677}
4678
4679static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4680 {
4681 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4682 .name = "Master Playback Switch",
4683 .info = snd_ctl_boolean_mono_info,
4684 .get = alc260_hp_master_sw_get,
4685 .put = alc260_hp_master_sw_put,
4686 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4687 },
4688 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4689 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4690 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4691 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4692 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4693 HDA_OUTPUT),
4694 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4695 { } /* end */
4696};
4697
4698static struct hda_verb alc260_hp_unsol_verbs[] = {
4699 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4700 {},
4701};
4702
4703static void alc260_hp_automute(struct hda_codec *codec)
4704{
4705 struct alc_spec *spec = codec->spec;
4706 unsigned int present;
4707
4708 present = snd_hda_codec_read(codec, 0x10, 0,
4709 AC_VERB_GET_PIN_SENSE, 0);
4710 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4711 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4712}
4713
4714static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4715{
4716 if ((res >> 26) == ALC880_HP_EVENT)
4717 alc260_hp_automute(codec);
4718}
4719
Kailang Yangdf694da2005-12-05 19:42:22 +01004720static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004721 {
4722 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4723 .name = "Master Playback Switch",
4724 .info = snd_ctl_boolean_mono_info,
4725 .get = alc260_hp_master_sw_get,
4726 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004727 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004728 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004729 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4730 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4731 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4732 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4733 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4734 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004735 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4736 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004737 { } /* end */
4738};
4739
Kailang Yang3f878302008-08-26 13:02:23 +02004740static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4741 .ops = &snd_hda_bind_vol,
4742 .values = {
4743 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4744 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4745 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4746 0
4747 },
4748};
4749
4750static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4751 .ops = &snd_hda_bind_sw,
4752 .values = {
4753 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4754 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4755 0
4756 },
4757};
4758
4759static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4760 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4761 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4762 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4763 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4764 { } /* end */
4765};
4766
Takashi Iwaibec15c32008-01-28 18:16:30 +01004767static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4768 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4769 {},
4770};
4771
4772static void alc260_hp_3013_automute(struct hda_codec *codec)
4773{
4774 struct alc_spec *spec = codec->spec;
4775 unsigned int present;
4776
4777 present = snd_hda_codec_read(codec, 0x15, 0,
4778 AC_VERB_GET_PIN_SENSE, 0);
4779 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004780 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004781}
4782
4783static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4784 unsigned int res)
4785{
4786 if ((res >> 26) == ALC880_HP_EVENT)
4787 alc260_hp_3013_automute(codec);
4788}
4789
Kailang Yang3f878302008-08-26 13:02:23 +02004790static void alc260_hp_3012_automute(struct hda_codec *codec)
4791{
4792 unsigned int present, bits;
4793
4794 present = snd_hda_codec_read(codec, 0x10, 0,
4795 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4796
4797 bits = present ? 0 : PIN_OUT;
4798 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4799 bits);
4800 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4801 bits);
4802 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4803 bits);
4804}
4805
4806static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4807 unsigned int res)
4808{
4809 if ((res >> 26) == ALC880_HP_EVENT)
4810 alc260_hp_3012_automute(codec);
4811}
4812
4813/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004814 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4815 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004816static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004817 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004818 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004819 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004820 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4821 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4822 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4823 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004824 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004825 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4826 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004827 { } /* end */
4828};
4829
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004830/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4831 * versions of the ALC260 don't act on requests to enable mic bias from NID
4832 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4833 * datasheet doesn't mention this restriction. At this stage it's not clear
4834 * whether this behaviour is intentional or is a hardware bug in chip
4835 * revisions available in early 2006. Therefore for now allow the
4836 * "Headphone Jack Mode" control to span all choices, but if it turns out
4837 * that the lack of mic bias for this NID is intentional we could change the
4838 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4839 *
4840 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4841 * don't appear to make the mic bias available from the "line" jack, even
4842 * though the NID used for this jack (0x14) can supply it. The theory is
4843 * that perhaps Acer have included blocking capacitors between the ALC260
4844 * and the output jack. If this turns out to be the case for all such
4845 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4846 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004847 *
4848 * The C20x Tablet series have a mono internal speaker which is controlled
4849 * via the chip's Mono sum widget and pin complex, so include the necessary
4850 * controls for such models. On models without a "mono speaker" the control
4851 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004852 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004853static struct snd_kcontrol_new alc260_acer_mixer[] = {
4854 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4855 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004856 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004857 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004858 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004859 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004860 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004861 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4862 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4864 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4865 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4866 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4867 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4868 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004869 { } /* end */
4870};
4871
Michael Schwingencc959482009-02-22 18:58:45 +01004872/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4873 */
4874static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4875 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4876 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4877 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4878 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4879 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4880 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4881 { } /* end */
4882};
4883
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004884/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4885 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4886 */
4887static struct snd_kcontrol_new alc260_will_mixer[] = {
4888 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4889 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4891 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4892 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4893 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4894 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4895 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4896 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4897 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004898 { } /* end */
4899};
4900
4901/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4902 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4903 */
4904static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4905 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4906 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4908 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4909 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4910 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4911 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4912 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4913 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4914 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4915 { } /* end */
4916};
4917
Kailang Yangdf694da2005-12-05 19:42:22 +01004918/*
4919 * initialization verbs
4920 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004921static struct hda_verb alc260_init_verbs[] = {
4922 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004923 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004924 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004925 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004926 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004927 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004928 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004929 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004930 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004931 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004932 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004933 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004934 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004935 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004936 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004937 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004938 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004939 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4940 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004941 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004942 /* set connection select to line in (default select for this ADC) */
4943 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004944 /* mute capture amp left and right */
4945 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4946 /* set connection select to line in (default select for this ADC) */
4947 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004948 /* set vol=0 Line-Out mixer amp left and right */
4949 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4950 /* unmute pin widget amp left and right (no gain on this amp) */
4951 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4952 /* set vol=0 HP mixer amp left and right */
4953 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4954 /* unmute pin widget amp left and right (no gain on this amp) */
4955 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4956 /* set vol=0 Mono mixer amp left and right */
4957 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4958 /* unmute pin widget amp left and right (no gain on this amp) */
4959 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4960 /* unmute LINE-2 out pin */
4961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004962 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4963 * Line In 2 = 0x03
4964 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004965 /* mute analog inputs */
4966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004971 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004972 /* mute Front out path */
4973 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4974 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4975 /* mute Headphone out path */
4976 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4977 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4978 /* mute Mono out path */
4979 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4980 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004981 { }
4982};
4983
Takashi Iwai474167d2006-05-17 17:17:43 +02004984#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004985static struct hda_verb alc260_hp_init_verbs[] = {
4986 /* Headphone and output */
4987 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4988 /* mono output */
4989 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4990 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4991 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4992 /* Mic2 (front panel) pin widget for input and vref at 80% */
4993 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4994 /* Line In pin widget for input */
4995 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4996 /* Line-2 pin widget for output */
4997 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4998 /* CD pin widget for input */
4999 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5000 /* unmute amp left and right */
5001 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5002 /* set connection select to line in (default select for this ADC) */
5003 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5004 /* unmute Line-Out mixer amp left and right (volume = 0) */
5005 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5006 /* mute pin widget amp left and right (no gain on this amp) */
5007 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5008 /* unmute HP mixer amp left and right (volume = 0) */
5009 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5010 /* mute pin widget amp left and right (no gain on this amp) */
5011 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005012 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5013 * Line In 2 = 0x03
5014 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005015 /* mute analog inputs */
5016 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5019 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5020 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005021 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5022 /* Unmute Front out path */
5023 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5024 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5025 /* Unmute Headphone out path */
5026 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5027 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5028 /* Unmute Mono out path */
5029 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5030 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5031 { }
5032};
Takashi Iwai474167d2006-05-17 17:17:43 +02005033#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005034
5035static struct hda_verb alc260_hp_3013_init_verbs[] = {
5036 /* Line out and output */
5037 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5038 /* mono output */
5039 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5040 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5041 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5042 /* Mic2 (front panel) pin widget for input and vref at 80% */
5043 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5044 /* Line In pin widget for input */
5045 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5046 /* Headphone pin widget for output */
5047 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5048 /* CD pin widget for input */
5049 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5050 /* unmute amp left and right */
5051 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5052 /* set connection select to line in (default select for this ADC) */
5053 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5054 /* unmute Line-Out mixer amp left and right (volume = 0) */
5055 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5056 /* mute pin widget amp left and right (no gain on this amp) */
5057 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5058 /* unmute HP mixer amp left and right (volume = 0) */
5059 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5060 /* mute pin widget amp left and right (no gain on this amp) */
5061 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005062 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5063 * Line In 2 = 0x03
5064 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005065 /* mute analog inputs */
5066 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5067 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5069 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5070 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005071 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5072 /* Unmute Front out path */
5073 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5074 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5075 /* Unmute Headphone out path */
5076 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5077 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5078 /* Unmute Mono out path */
5079 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5080 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5081 { }
5082};
5083
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005084/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005085 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5086 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005087 */
5088static struct hda_verb alc260_fujitsu_init_verbs[] = {
5089 /* Disable all GPIOs */
5090 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5091 /* Internal speaker is connected to headphone pin */
5092 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5093 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005095 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5096 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5097 /* Ensure all other unused pins are disabled and muted. */
5098 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5099 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005100 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005101 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005102 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005103 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5104 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5105 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005106
Jonathan Woithef7ace402006-02-28 11:46:14 +01005107 /* Disable digital (SPDIF) pins */
5108 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5109 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005110
Kailang Yangea1fb292008-08-26 12:58:38 +02005111 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005112 * when acting as an output.
5113 */
5114 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5115
5116 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005117 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5118 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5119 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5121 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5122 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5123 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5124 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5125 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005126
Jonathan Woithef7ace402006-02-28 11:46:14 +01005127 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5128 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5129 /* Unmute Line1 pin widget output buffer since it starts as an output.
5130 * If the pin mode is changed by the user the pin mode control will
5131 * take care of enabling the pin's input/output buffers as needed.
5132 * Therefore there's no need to enable the input buffer at this
5133 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005134 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005135 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005136 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005137 * mixer ctrl)
5138 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005139 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005140
Jonathan Woithef7ace402006-02-28 11:46:14 +01005141 /* Mute capture amp left and right */
5142 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005143 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005144 * in (on mic1 pin)
5145 */
5146 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005147
Jonathan Woithef7ace402006-02-28 11:46:14 +01005148 /* Do the same for the second ADC: mute capture input amp and
5149 * set ADC connection to line in (on mic1 pin)
5150 */
5151 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5152 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005153
Jonathan Woithef7ace402006-02-28 11:46:14 +01005154 /* Mute all inputs to mixer widget (even unconnected ones) */
5155 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5156 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5158 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5161 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5162 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005163
5164 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005165};
5166
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005167/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5168 * similar laptops (adapted from Fujitsu init verbs).
5169 */
5170static struct hda_verb alc260_acer_init_verbs[] = {
5171 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5172 * the headphone jack. Turn this on and rely on the standard mute
5173 * methods whenever the user wants to turn these outputs off.
5174 */
5175 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5176 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5177 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5178 /* Internal speaker/Headphone jack is connected to Line-out pin */
5179 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5180 /* Internal microphone/Mic jack is connected to Mic1 pin */
5181 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5182 /* Line In jack is connected to Line1 pin */
5183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005184 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5185 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005186 /* Ensure all other unused pins are disabled and muted. */
5187 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5188 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005189 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5190 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5193 /* Disable digital (SPDIF) pins */
5194 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5195 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5196
Kailang Yangea1fb292008-08-26 12:58:38 +02005197 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005198 * bus when acting as outputs.
5199 */
5200 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5201 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5202
5203 /* Start with output sum widgets muted and their output gains at min */
5204 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5205 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5206 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5207 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5208 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5209 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5210 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5211 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5212 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5213
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005214 /* Unmute Line-out pin widget amp left and right
5215 * (no equiv mixer ctrl)
5216 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005217 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005218 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5219 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005220 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5221 * inputs. If the pin mode is changed by the user the pin mode control
5222 * will take care of enabling the pin's input/output buffers as needed.
5223 * Therefore there's no need to enable the input buffer at this
5224 * stage.
5225 */
5226 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5227 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5228
5229 /* Mute capture amp left and right */
5230 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5231 /* Set ADC connection select to match default mixer setting - mic
5232 * (on mic1 pin)
5233 */
5234 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5235
5236 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005237 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005238 */
5239 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005240 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005241
5242 /* Mute all inputs to mixer widget (even unconnected ones) */
5243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5251
5252 { }
5253};
5254
Michael Schwingencc959482009-02-22 18:58:45 +01005255/* Initialisation sequence for Maxdata Favorit 100XS
5256 * (adapted from Acer init verbs).
5257 */
5258static struct hda_verb alc260_favorit100_init_verbs[] = {
5259 /* GPIO 0 enables the output jack.
5260 * Turn this on and rely on the standard mute
5261 * methods whenever the user wants to turn these outputs off.
5262 */
5263 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5264 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5265 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5266 /* Line/Mic input jack is connected to Mic1 pin */
5267 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5268 /* Ensure all other unused pins are disabled and muted. */
5269 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5270 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5271 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5272 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5273 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5274 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5275 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5276 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5277 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5279 /* Disable digital (SPDIF) pins */
5280 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5281 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5282
5283 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5284 * bus when acting as outputs.
5285 */
5286 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5287 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5288
5289 /* Start with output sum widgets muted and their output gains at min */
5290 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5291 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5292 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5295 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5296 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5297 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5298 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5299
5300 /* Unmute Line-out pin widget amp left and right
5301 * (no equiv mixer ctrl)
5302 */
5303 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5304 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5305 * inputs. If the pin mode is changed by the user the pin mode control
5306 * will take care of enabling the pin's input/output buffers as needed.
5307 * Therefore there's no need to enable the input buffer at this
5308 * stage.
5309 */
5310 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5311
5312 /* Mute capture amp left and right */
5313 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5314 /* Set ADC connection select to match default mixer setting - mic
5315 * (on mic1 pin)
5316 */
5317 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5318
5319 /* Do similar with the second ADC: mute capture input amp and
5320 * set ADC connection to mic to match ALSA's default state.
5321 */
5322 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5323 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5324
5325 /* Mute all inputs to mixer widget (even unconnected ones) */
5326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5334
5335 { }
5336};
5337
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005338static struct hda_verb alc260_will_verbs[] = {
5339 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5340 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5341 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5342 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5343 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5344 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5345 {}
5346};
5347
5348static struct hda_verb alc260_replacer_672v_verbs[] = {
5349 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5350 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5351 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5352
5353 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5354 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5355 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5356
5357 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5358 {}
5359};
5360
5361/* toggle speaker-output according to the hp-jack state */
5362static void alc260_replacer_672v_automute(struct hda_codec *codec)
5363{
5364 unsigned int present;
5365
5366 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5367 present = snd_hda_codec_read(codec, 0x0f, 0,
5368 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5369 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005370 snd_hda_codec_write_cache(codec, 0x01, 0,
5371 AC_VERB_SET_GPIO_DATA, 1);
5372 snd_hda_codec_write_cache(codec, 0x0f, 0,
5373 AC_VERB_SET_PIN_WIDGET_CONTROL,
5374 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005375 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005376 snd_hda_codec_write_cache(codec, 0x01, 0,
5377 AC_VERB_SET_GPIO_DATA, 0);
5378 snd_hda_codec_write_cache(codec, 0x0f, 0,
5379 AC_VERB_SET_PIN_WIDGET_CONTROL,
5380 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005381 }
5382}
5383
5384static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5385 unsigned int res)
5386{
5387 if ((res >> 26) == ALC880_HP_EVENT)
5388 alc260_replacer_672v_automute(codec);
5389}
5390
Kailang Yang3f878302008-08-26 13:02:23 +02005391static struct hda_verb alc260_hp_dc7600_verbs[] = {
5392 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5393 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5394 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5395 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5396 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5397 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5398 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5399 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5400 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5401 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5402 {}
5403};
5404
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005405/* Test configuration for debugging, modelled after the ALC880 test
5406 * configuration.
5407 */
5408#ifdef CONFIG_SND_DEBUG
5409static hda_nid_t alc260_test_dac_nids[1] = {
5410 0x02,
5411};
5412static hda_nid_t alc260_test_adc_nids[2] = {
5413 0x04, 0x05,
5414};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005415/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005416 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005417 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005418 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005419static struct hda_input_mux alc260_test_capture_sources[2] = {
5420 {
5421 .num_items = 7,
5422 .items = {
5423 { "MIC1 pin", 0x0 },
5424 { "MIC2 pin", 0x1 },
5425 { "LINE1 pin", 0x2 },
5426 { "LINE2 pin", 0x3 },
5427 { "CD pin", 0x4 },
5428 { "LINE-OUT pin", 0x5 },
5429 { "HP-OUT pin", 0x6 },
5430 },
5431 },
5432 {
5433 .num_items = 8,
5434 .items = {
5435 { "MIC1 pin", 0x0 },
5436 { "MIC2 pin", 0x1 },
5437 { "LINE1 pin", 0x2 },
5438 { "LINE2 pin", 0x3 },
5439 { "CD pin", 0x4 },
5440 { "Mixer", 0x5 },
5441 { "LINE-OUT pin", 0x6 },
5442 { "HP-OUT pin", 0x7 },
5443 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005444 },
5445};
5446static struct snd_kcontrol_new alc260_test_mixer[] = {
5447 /* Output driver widgets */
5448 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5449 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5450 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5451 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5452 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5453 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5454
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005455 /* Modes for retasking pin widgets
5456 * Note: the ALC260 doesn't seem to act on requests to enable mic
5457 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5458 * mention this restriction. At this stage it's not clear whether
5459 * this behaviour is intentional or is a hardware bug in chip
5460 * revisions available at least up until early 2006. Therefore for
5461 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5462 * choices, but if it turns out that the lack of mic bias for these
5463 * NIDs is intentional we could change their modes from
5464 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5465 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005466 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5467 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5468 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5469 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5470 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5471 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5472
5473 /* Loopback mixer controls */
5474 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5475 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5476 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5477 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5478 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5479 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5480 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5481 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5482 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5483 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005484 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5485 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5486 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5487 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005488
5489 /* Controls for GPIO pins, assuming they are configured as outputs */
5490 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5491 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5492 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5493 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5494
Jonathan Woithe92621f12006-02-28 11:47:47 +01005495 /* Switches to allow the digital IO pins to be enabled. The datasheet
5496 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005497 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005498 */
5499 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5500 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5501
Jonathan Woithef8225f62008-01-08 12:16:54 +01005502 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5503 * this output to turn on an external amplifier.
5504 */
5505 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5506 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5507
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005508 { } /* end */
5509};
5510static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005511 /* Enable all GPIOs as outputs with an initial value of 0 */
5512 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5513 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5514 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5515
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005516 /* Enable retasking pins as output, initially without power amp */
5517 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5518 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5520 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5521 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5522 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5523
Jonathan Woithe92621f12006-02-28 11:47:47 +01005524 /* Disable digital (SPDIF) pins initially, but users can enable
5525 * them via a mixer switch. In the case of SPDIF-out, this initverb
5526 * payload also sets the generation to 0, output to be in "consumer"
5527 * PCM format, copyright asserted, no pre-emphasis and no validity
5528 * control.
5529 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005530 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5531 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5532
Kailang Yangea1fb292008-08-26 12:58:38 +02005533 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005534 * OUT1 sum bus when acting as an output.
5535 */
5536 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5537 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5538 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5539 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5540
5541 /* Start with output sum widgets muted and their output gains at min */
5542 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5543 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5544 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5545 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5546 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5547 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5548 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5549 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5550 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5551
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005552 /* Unmute retasking pin widget output buffers since the default
5553 * state appears to be output. As the pin mode is changed by the
5554 * user the pin mode control will take care of enabling the pin's
5555 * input/output buffers as needed.
5556 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005557 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5558 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5560 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5561 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5562 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5563 /* Also unmute the mono-out pin widget */
5564 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5565
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005566 /* Mute capture amp left and right */
5567 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005568 /* Set ADC connection select to match default mixer setting (mic1
5569 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005570 */
5571 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5572
5573 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005574 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005575 */
5576 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5577 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5578
5579 /* Mute all inputs to mixer widget (even unconnected ones) */
5580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5582 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5583 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5584 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5585 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5586 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5588
5589 { }
5590};
5591#endif
5592
Takashi Iwai63300792008-01-24 15:31:36 +01005593#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5594#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005595
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005596#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5597#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5598
Kailang Yangdf694da2005-12-05 19:42:22 +01005599/*
5600 * for BIOS auto-configuration
5601 */
5602
5603static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005604 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005605{
5606 hda_nid_t nid_vol;
5607 unsigned long vol_val, sw_val;
5608 char name[32];
5609 int err;
5610
5611 if (nid >= 0x0f && nid < 0x11) {
5612 nid_vol = nid - 0x7;
5613 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5614 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5615 } else if (nid == 0x11) {
5616 nid_vol = nid - 0x7;
5617 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5618 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5619 } else if (nid >= 0x12 && nid <= 0x15) {
5620 nid_vol = 0x08;
5621 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5622 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5623 } else
5624 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005625
Takashi Iwai863b4512008-10-21 17:01:47 +02005626 if (!(*vol_bits & (1 << nid_vol))) {
5627 /* first control for the volume widget */
5628 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5629 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5630 if (err < 0)
5631 return err;
5632 *vol_bits |= (1 << nid_vol);
5633 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005634 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005635 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5636 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005637 return err;
5638 return 1;
5639}
5640
5641/* add playback controls from the parsed DAC table */
5642static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5643 const struct auto_pin_cfg *cfg)
5644{
5645 hda_nid_t nid;
5646 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005647 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005648
5649 spec->multiout.num_dacs = 1;
5650 spec->multiout.dac_nids = spec->private_dac_nids;
5651 spec->multiout.dac_nids[0] = 0x02;
5652
5653 nid = cfg->line_out_pins[0];
5654 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005655 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005656 if (err < 0)
5657 return err;
5658 }
5659
Takashi Iwai82bc9552006-03-21 11:24:42 +01005660 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005661 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005662 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005663 if (err < 0)
5664 return err;
5665 }
5666
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005667 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005668 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005669 err = alc260_add_playback_controls(spec, nid, "Headphone",
5670 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005671 if (err < 0)
5672 return err;
5673 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005674 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005675}
5676
5677/* create playback/capture controls for input pins */
5678static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5679 const struct auto_pin_cfg *cfg)
5680{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005681 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005682 int i, err, idx;
5683
5684 for (i = 0; i < AUTO_PIN_LAST; i++) {
5685 if (cfg->input_pins[i] >= 0x12) {
5686 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005687 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005688 auto_pin_cfg_labels[i], idx,
5689 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005690 if (err < 0)
5691 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005692 imux->items[imux->num_items].label =
5693 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005694 imux->items[imux->num_items].index = idx;
5695 imux->num_items++;
5696 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005697 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005698 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005699 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005700 auto_pin_cfg_labels[i], idx,
5701 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005702 if (err < 0)
5703 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005704 imux->items[imux->num_items].label =
5705 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005706 imux->items[imux->num_items].index = idx;
5707 imux->num_items++;
5708 }
5709 }
5710 return 0;
5711}
5712
5713static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5714 hda_nid_t nid, int pin_type,
5715 int sel_idx)
5716{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005717 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005718 /* need the manual connection? */
5719 if (nid >= 0x12) {
5720 int idx = nid - 0x12;
5721 snd_hda_codec_write(codec, idx + 0x0b, 0,
5722 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005723 }
5724}
5725
5726static void alc260_auto_init_multi_out(struct hda_codec *codec)
5727{
5728 struct alc_spec *spec = codec->spec;
5729 hda_nid_t nid;
5730
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005731 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005732 if (nid) {
5733 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5734 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5735 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005736
Takashi Iwai82bc9552006-03-21 11:24:42 +01005737 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005738 if (nid)
5739 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5740
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005741 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005742 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005743 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005744}
Kailang Yangdf694da2005-12-05 19:42:22 +01005745
5746#define ALC260_PIN_CD_NID 0x16
5747static void alc260_auto_init_analog_input(struct hda_codec *codec)
5748{
5749 struct alc_spec *spec = codec->spec;
5750 int i;
5751
5752 for (i = 0; i < AUTO_PIN_LAST; i++) {
5753 hda_nid_t nid = spec->autocfg.input_pins[i];
5754 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005755 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005756 if (nid != ALC260_PIN_CD_NID &&
5757 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005758 snd_hda_codec_write(codec, nid, 0,
5759 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005760 AMP_OUT_MUTE);
5761 }
5762 }
5763}
5764
5765/*
5766 * generic initialization of ADC, input mixers and output mixers
5767 */
5768static struct hda_verb alc260_volume_init_verbs[] = {
5769 /*
5770 * Unmute ADC0-1 and set the default input to mic-in
5771 */
5772 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5773 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5774 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5775 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005776
Kailang Yangdf694da2005-12-05 19:42:22 +01005777 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5778 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005779 * Note: PASD motherboards uses the Line In 2 as the input for
5780 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005781 */
5782 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005783 /* mute analog inputs */
5784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5785 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5786 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5788 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005789
5790 /*
5791 * Set up output mixers (0x08 - 0x0a)
5792 */
5793 /* set vol=0 to output mixers */
5794 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5795 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5796 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5797 /* set up input amps for analog loopback */
5798 /* Amp Indices: DAC = 0, mixer = 1 */
5799 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5800 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5801 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5802 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5803 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5804 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005805
Kailang Yangdf694da2005-12-05 19:42:22 +01005806 { }
5807};
5808
5809static int alc260_parse_auto_config(struct hda_codec *codec)
5810{
5811 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005812 int err;
5813 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5814
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005815 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5816 alc260_ignore);
5817 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005818 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005819 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5820 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005821 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005822 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005823 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005824 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5825 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005826 return err;
5827
5828 spec->multiout.max_channels = 2;
5829
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005830 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005831 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005832 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005833 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005834
Takashi Iwaid88897e2008-10-31 15:01:37 +01005835 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005836
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005837 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005838 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005839
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005840 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5841
Kailang Yangdf694da2005-12-05 19:42:22 +01005842 return 1;
5843}
5844
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005845/* additional initialization for auto-configuration model */
5846static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005847{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005848 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005849 alc260_auto_init_multi_out(codec);
5850 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005851 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005852 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005853}
5854
Takashi Iwaicb53c622007-08-10 17:21:45 +02005855#ifdef CONFIG_SND_HDA_POWER_SAVE
5856static struct hda_amp_list alc260_loopbacks[] = {
5857 { 0x07, HDA_INPUT, 0 },
5858 { 0x07, HDA_INPUT, 1 },
5859 { 0x07, HDA_INPUT, 2 },
5860 { 0x07, HDA_INPUT, 3 },
5861 { 0x07, HDA_INPUT, 4 },
5862 { } /* end */
5863};
5864#endif
5865
Kailang Yangdf694da2005-12-05 19:42:22 +01005866/*
5867 * ALC260 configurations
5868 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005869static const char *alc260_models[ALC260_MODEL_LAST] = {
5870 [ALC260_BASIC] = "basic",
5871 [ALC260_HP] = "hp",
5872 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005873 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005874 [ALC260_FUJITSU_S702X] = "fujitsu",
5875 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005876 [ALC260_WILL] = "will",
5877 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005878 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005879#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005880 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005881#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005882 [ALC260_AUTO] = "auto",
5883};
5884
5885static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005886 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005887 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01005888 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01005889 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005890 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005891 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005892 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005893 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005894 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5895 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5896 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5897 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5898 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5899 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5900 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5901 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5902 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005903 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005904 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005905 {}
5906};
5907
Kailang Yangdf694da2005-12-05 19:42:22 +01005908static struct alc_config_preset alc260_presets[] = {
5909 [ALC260_BASIC] = {
5910 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005911 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005912 .init_verbs = { alc260_init_verbs },
5913 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5914 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005915 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005916 .adc_nids = alc260_adc_nids,
5917 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5918 .channel_mode = alc260_modes,
5919 .input_mux = &alc260_capture_source,
5920 },
5921 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005922 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005923 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005924 .init_verbs = { alc260_init_verbs,
5925 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005926 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5927 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005928 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5929 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005930 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5931 .channel_mode = alc260_modes,
5932 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005933 .unsol_event = alc260_hp_unsol_event,
5934 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005935 },
Kailang Yang3f878302008-08-26 13:02:23 +02005936 [ALC260_HP_DC7600] = {
5937 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005938 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005939 .init_verbs = { alc260_init_verbs,
5940 alc260_hp_dc7600_verbs },
5941 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5942 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005943 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5944 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005945 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5946 .channel_mode = alc260_modes,
5947 .input_mux = &alc260_capture_source,
5948 .unsol_event = alc260_hp_3012_unsol_event,
5949 .init_hook = alc260_hp_3012_automute,
5950 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005951 [ALC260_HP_3013] = {
5952 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005953 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005954 .init_verbs = { alc260_hp_3013_init_verbs,
5955 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005956 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5957 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005958 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5959 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005960 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5961 .channel_mode = alc260_modes,
5962 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005963 .unsol_event = alc260_hp_3013_unsol_event,
5964 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005965 },
5966 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005967 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005968 .init_verbs = { alc260_fujitsu_init_verbs },
5969 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5970 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005971 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5972 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005973 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5974 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005975 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5976 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005977 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005978 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005979 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005980 .init_verbs = { alc260_acer_init_verbs },
5981 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5982 .dac_nids = alc260_dac_nids,
5983 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5984 .adc_nids = alc260_dual_adc_nids,
5985 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5986 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005987 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5988 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005989 },
Michael Schwingencc959482009-02-22 18:58:45 +01005990 [ALC260_FAVORIT100] = {
5991 .mixers = { alc260_favorit100_mixer },
5992 .init_verbs = { alc260_favorit100_init_verbs },
5993 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5994 .dac_nids = alc260_dac_nids,
5995 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5996 .adc_nids = alc260_dual_adc_nids,
5997 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5998 .channel_mode = alc260_modes,
5999 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6000 .input_mux = alc260_favorit100_capture_sources,
6001 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006002 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006003 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006004 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6005 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6006 .dac_nids = alc260_dac_nids,
6007 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6008 .adc_nids = alc260_adc_nids,
6009 .dig_out_nid = ALC260_DIGOUT_NID,
6010 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6011 .channel_mode = alc260_modes,
6012 .input_mux = &alc260_capture_source,
6013 },
6014 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006015 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006016 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6017 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6018 .dac_nids = alc260_dac_nids,
6019 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6020 .adc_nids = alc260_adc_nids,
6021 .dig_out_nid = ALC260_DIGOUT_NID,
6022 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6023 .channel_mode = alc260_modes,
6024 .input_mux = &alc260_capture_source,
6025 .unsol_event = alc260_replacer_672v_unsol_event,
6026 .init_hook = alc260_replacer_672v_automute,
6027 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006028#ifdef CONFIG_SND_DEBUG
6029 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006030 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006031 .init_verbs = { alc260_test_init_verbs },
6032 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6033 .dac_nids = alc260_test_dac_nids,
6034 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6035 .adc_nids = alc260_test_adc_nids,
6036 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6037 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006038 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6039 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006040 },
6041#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006042};
6043
Linus Torvalds1da177e2005-04-16 15:20:36 -07006044static int patch_alc260(struct hda_codec *codec)
6045{
6046 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006047 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006048
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006049 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006050 if (spec == NULL)
6051 return -ENOMEM;
6052
6053 codec->spec = spec;
6054
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006055 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6056 alc260_models,
6057 alc260_cfg_tbl);
6058 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006059 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
6060 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006061 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006062 }
6063
Kailang Yangdf694da2005-12-05 19:42:22 +01006064 if (board_config == ALC260_AUTO) {
6065 /* automatic parse from the BIOS config */
6066 err = alc260_parse_auto_config(codec);
6067 if (err < 0) {
6068 alc_free(codec);
6069 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006070 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006071 printk(KERN_INFO
6072 "hda_codec: Cannot set up configuration "
6073 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006074 board_config = ALC260_BASIC;
6075 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006076 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006077
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006078 err = snd_hda_attach_beep_device(codec, 0x1);
6079 if (err < 0) {
6080 alc_free(codec);
6081 return err;
6082 }
6083
Kailang Yangdf694da2005-12-05 19:42:22 +01006084 if (board_config != ALC260_AUTO)
6085 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006086
6087 spec->stream_name_analog = "ALC260 Analog";
6088 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6089 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6090
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006091 spec->stream_name_digital = "ALC260 Digital";
6092 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6093 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6094
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006095 if (!spec->adc_nids && spec->input_mux) {
6096 /* check whether NID 0x04 is valid */
6097 unsigned int wcap = get_wcaps(codec, 0x04);
6098 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6099 /* get type */
6100 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6101 spec->adc_nids = alc260_adc_nids_alt;
6102 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6103 } else {
6104 spec->adc_nids = alc260_adc_nids;
6105 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6106 }
6107 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006108 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006109 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006110
Takashi Iwai2134ea42008-01-10 16:53:55 +01006111 spec->vmaster_nid = 0x08;
6112
Linus Torvalds1da177e2005-04-16 15:20:36 -07006113 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006114 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006115 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006116#ifdef CONFIG_SND_HDA_POWER_SAVE
6117 if (!spec->loopback.amplist)
6118 spec->loopback.amplist = alc260_loopbacks;
6119#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006120 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006121
6122 return 0;
6123}
6124
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006125
Linus Torvalds1da177e2005-04-16 15:20:36 -07006126/*
6127 * ALC882 support
6128 *
6129 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6130 * configuration. Each pin widget can choose any input DACs and a mixer.
6131 * Each ADC is connected from a mixer of all inputs. This makes possible
6132 * 6-channel independent captures.
6133 *
6134 * In addition, an independent DAC for the multi-playback (not used in this
6135 * driver yet).
6136 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006137#define ALC882_DIGOUT_NID 0x06
6138#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006139
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006140static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006141 { 8, NULL }
6142};
6143
6144static hda_nid_t alc882_dac_nids[4] = {
6145 /* front, rear, clfe, rear_surr */
6146 0x02, 0x03, 0x04, 0x05
6147};
6148
Kailang Yangdf694da2005-12-05 19:42:22 +01006149/* identical with ALC880 */
6150#define alc882_adc_nids alc880_adc_nids
6151#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006152
Takashi Iwaie1406342008-02-11 18:32:32 +01006153static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6154static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6155
Linus Torvalds1da177e2005-04-16 15:20:36 -07006156/* input MUX */
6157/* FIXME: should be a matrix-type input source selection */
6158
6159static struct hda_input_mux alc882_capture_source = {
6160 .num_items = 4,
6161 .items = {
6162 { "Mic", 0x0 },
6163 { "Front Mic", 0x1 },
6164 { "Line", 0x2 },
6165 { "CD", 0x4 },
6166 },
6167};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006168
6169static struct hda_input_mux mb5_capture_source = {
6170 .num_items = 3,
6171 .items = {
6172 { "Mic", 0x1 },
6173 { "Line", 0x2 },
6174 { "CD", 0x4 },
6175 },
6176};
6177
Kailang Yangdf694da2005-12-05 19:42:22 +01006178/*
Kailang Yang272a5272007-05-14 11:00:38 +02006179 * 2ch mode
6180 */
6181static struct hda_verb alc882_3ST_ch2_init[] = {
6182 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6183 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6184 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6185 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6186 { } /* end */
6187};
6188
6189/*
6190 * 6ch mode
6191 */
6192static struct hda_verb alc882_3ST_ch6_init[] = {
6193 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6194 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6195 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6196 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6197 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6198 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6199 { } /* end */
6200};
6201
6202static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6203 { 2, alc882_3ST_ch2_init },
6204 { 6, alc882_3ST_ch6_init },
6205};
6206
6207/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006208 * 6ch mode
6209 */
6210static struct hda_verb alc882_sixstack_ch6_init[] = {
6211 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6212 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6213 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6214 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6215 { } /* end */
6216};
6217
6218/*
6219 * 8ch mode
6220 */
6221static struct hda_verb alc882_sixstack_ch8_init[] = {
6222 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6223 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6224 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6225 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6226 { } /* end */
6227};
6228
6229static struct hda_channel_mode alc882_sixstack_modes[2] = {
6230 { 6, alc882_sixstack_ch6_init },
6231 { 8, alc882_sixstack_ch8_init },
6232};
6233
Takashi Iwai87350ad2007-08-16 18:19:38 +02006234/*
6235 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6236 */
6237
6238/*
6239 * 2ch mode
6240 */
6241static struct hda_verb alc885_mbp_ch2_init[] = {
6242 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6243 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6244 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6245 { } /* end */
6246};
6247
6248/*
6249 * 6ch mode
6250 */
6251static struct hda_verb alc885_mbp_ch6_init[] = {
6252 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6253 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6254 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6255 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6256 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6257 { } /* end */
6258};
6259
6260static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6261 { 2, alc885_mbp_ch2_init },
6262 { 6, alc885_mbp_ch6_init },
6263};
6264
6265
Linus Torvalds1da177e2005-04-16 15:20:36 -07006266/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6267 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6268 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006269static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006270 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006271 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006272 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006273 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006274 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6275 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006276 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6277 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006278 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006279 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006280 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6281 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6282 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6283 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6284 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6285 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006286 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006287 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6288 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006289 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006290 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006291 { } /* end */
6292};
6293
Takashi Iwai87350ad2007-08-16 18:19:38 +02006294static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006295 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6296 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6297 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6298 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6299 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6300 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006301 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6302 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006303 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006304 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6305 { } /* end */
6306};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006307
6308static struct snd_kcontrol_new alc885_mb5_mixer[] = {
6309 HDA_CODEC_VOLUME("Front Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6310 HDA_BIND_MUTE ("Front Playback Switch", 0x0d, 0x02, HDA_INPUT),
6311 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6312 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
6313 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6314 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6316 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6317 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6318 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6319 { } /* end */
6320};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006321static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6322 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6323 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6324 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6325 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6326 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6327 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6328 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6329 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6330 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006331 { } /* end */
6332};
6333
Kailang Yang272a5272007-05-14 11:00:38 +02006334static struct snd_kcontrol_new alc882_targa_mixer[] = {
6335 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6336 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6337 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6338 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6339 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6340 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6341 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6342 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6343 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006344 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006345 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6346 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006347 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006348 { } /* end */
6349};
6350
6351/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6352 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6353 */
6354static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6355 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6356 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6357 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6358 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6359 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6360 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6361 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6362 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6363 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6364 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6365 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6366 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006367 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006368 { } /* end */
6369};
6370
Takashi Iwai914759b2007-09-06 14:52:04 +02006371static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6372 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6373 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6374 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6375 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6376 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6377 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6378 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6379 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6380 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006382 { } /* end */
6383};
6384
Kailang Yangdf694da2005-12-05 19:42:22 +01006385static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6386 {
6387 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6388 .name = "Channel Mode",
6389 .info = alc_ch_mode_info,
6390 .get = alc_ch_mode_get,
6391 .put = alc_ch_mode_put,
6392 },
6393 { } /* end */
6394};
6395
Linus Torvalds1da177e2005-04-16 15:20:36 -07006396static struct hda_verb alc882_init_verbs[] = {
6397 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6399 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6400 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006401 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006402 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6403 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6404 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006405 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006406 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6407 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6408 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006409 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006410 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6411 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6412 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006413
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006414 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006416 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006417 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006418 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006419 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006420 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006421 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006422 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006423 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006424 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006425 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006426 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006427 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006428 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006429 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006430 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006431 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006432 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6433 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006434 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006435 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6436 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006437 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006438 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6439 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6440 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6441 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6442 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006443 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006444 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006445
6446 /* FIXME: use matrix-type input source selection */
6447 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6448 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6452 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006453 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6456 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6457 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006458 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6461 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6462 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6463 /* ADC1: mute amp left and right */
6464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006465 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006466 /* ADC2: mute amp left and right */
6467 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006468 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006469 /* ADC3: mute amp left and right */
6470 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006471 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006472
6473 { }
6474};
6475
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006476static struct hda_verb alc882_eapd_verbs[] = {
6477 /* change to EAPD mode */
6478 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006479 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006480 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006481};
6482
Tobin Davis9102cd12006-12-15 10:02:12 +01006483/* Mac Pro test */
6484static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6485 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6486 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6487 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6488 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6489 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006490 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006491 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6492 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006493 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006494 { } /* end */
6495};
6496
6497static struct hda_verb alc882_macpro_init_verbs[] = {
6498 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6499 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6502 /* Front Pin: output 0 (0x0c) */
6503 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6504 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6505 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6506 /* Front Mic pin: input vref at 80% */
6507 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6508 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6509 /* Speaker: output */
6510 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6511 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6512 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6513 /* Headphone output (output 0 - 0x0c) */
6514 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6515 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6516 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6517
6518 /* FIXME: use matrix-type input source selection */
6519 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6520 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6521 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6523 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6524 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6525 /* Input mixer2 */
6526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6527 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6528 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6529 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6530 /* Input mixer3 */
6531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6533 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6534 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6535 /* ADC1: mute amp left and right */
6536 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6537 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6538 /* ADC2: mute amp left and right */
6539 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6540 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6541 /* ADC3: mute amp left and right */
6542 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6543 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6544
6545 { }
6546};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006547
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006548/* Macbook 5,1 */
6549static struct hda_verb alc885_mb5_init_verbs[] = {
6550 /* Front mixer */
6551 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6552 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6553 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6554 /* LineOut mixer */
6555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6558 /* Front Pin: output 0 (0x0d) */
6559 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6560 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6561 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01},
6562 /* HP Pin: output 0 (0x0c) */
6563 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6564 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6565 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6566 /* Front Mic pin: input vref at 80% */
6567 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6568 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6569 /* Line In pin */
6570 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6571 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6572
6573 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6574 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6575 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6576 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6577 { }
6578};
6579
Takashi Iwai87350ad2007-08-16 18:19:38 +02006580/* Macbook Pro rev3 */
6581static struct hda_verb alc885_mbp3_init_verbs[] = {
6582 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6584 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6586 /* Rear mixer */
6587 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6588 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6589 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6590 /* Front Pin: output 0 (0x0c) */
6591 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6592 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6593 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6594 /* HP Pin: output 0 (0x0d) */
6595 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6596 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6597 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6598 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6599 /* Mic (rear) pin: input vref at 80% */
6600 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6601 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6602 /* Front Mic pin: input vref at 80% */
6603 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6604 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6605 /* Line In pin: use output 1 when in LineOut mode */
6606 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6607 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6608 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6609
6610 /* FIXME: use matrix-type input source selection */
6611 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6612 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6613 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6614 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6615 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6616 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6617 /* Input mixer2 */
6618 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6619 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6620 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6621 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6622 /* Input mixer3 */
6623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6625 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6626 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6627 /* ADC1: mute amp left and right */
6628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6629 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6630 /* ADC2: mute amp left and right */
6631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6632 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6633 /* ADC3: mute amp left and right */
6634 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6635 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6636
6637 { }
6638};
6639
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006640/* iMac 24 mixer. */
6641static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6642 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6643 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6644 { } /* end */
6645};
6646
6647/* iMac 24 init verbs. */
6648static struct hda_verb alc885_imac24_init_verbs[] = {
6649 /* Internal speakers: output 0 (0x0c) */
6650 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6651 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6652 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6653 /* Internal speakers: output 0 (0x0c) */
6654 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6655 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6656 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6657 /* Headphone: output 0 (0x0c) */
6658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6660 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6661 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6662 /* Front Mic: input vref at 80% */
6663 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6664 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6665 { }
6666};
6667
6668/* Toggle speaker-output according to the hp-jack state */
6669static void alc885_imac24_automute(struct hda_codec *codec)
6670{
6671 unsigned int present;
6672
6673 present = snd_hda_codec_read(codec, 0x14, 0,
6674 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006675 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6676 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6677 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6678 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006679}
6680
6681/* Processes unsolicited events. */
6682static void alc885_imac24_unsol_event(struct hda_codec *codec,
6683 unsigned int res)
6684{
6685 /* Headphone insertion or removal. */
6686 if ((res >> 26) == ALC880_HP_EVENT)
6687 alc885_imac24_automute(codec);
6688}
6689
Takashi Iwai87350ad2007-08-16 18:19:38 +02006690static void alc885_mbp3_automute(struct hda_codec *codec)
6691{
6692 unsigned int present;
6693
6694 present = snd_hda_codec_read(codec, 0x15, 0,
6695 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6696 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6697 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6698 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6699 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6700
6701}
6702static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6703 unsigned int res)
6704{
6705 /* Headphone insertion or removal. */
6706 if ((res >> 26) == ALC880_HP_EVENT)
6707 alc885_mbp3_automute(codec);
6708}
6709
6710
Kailang Yang272a5272007-05-14 11:00:38 +02006711static struct hda_verb alc882_targa_verbs[] = {
6712 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6713 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6714
6715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6716 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006717
Kailang Yang272a5272007-05-14 11:00:38 +02006718 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6719 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6720 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6721
6722 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6723 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6724 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6725 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6726 { } /* end */
6727};
6728
6729/* toggle speaker-output according to the hp-jack state */
6730static void alc882_targa_automute(struct hda_codec *codec)
6731{
6732 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006733
Kailang Yang272a5272007-05-14 11:00:38 +02006734 present = snd_hda_codec_read(codec, 0x14, 0,
6735 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006736 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6737 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006738 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6739 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006740}
6741
6742static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6743{
6744 /* Looks like the unsol event is incompatible with the standard
6745 * definition. 4bit tag is placed at 26 bit!
6746 */
6747 if (((res >> 26) == ALC880_HP_EVENT)) {
6748 alc882_targa_automute(codec);
6749 }
6750}
6751
6752static struct hda_verb alc882_asus_a7j_verbs[] = {
6753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6754 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6755
6756 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6758 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006759
Kailang Yang272a5272007-05-14 11:00:38 +02006760 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6761 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6762 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6763
6764 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6765 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6766 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6767 { } /* end */
6768};
6769
Takashi Iwai914759b2007-09-06 14:52:04 +02006770static struct hda_verb alc882_asus_a7m_verbs[] = {
6771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6772 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6773
6774 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6775 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6776 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006777
Takashi Iwai914759b2007-09-06 14:52:04 +02006778 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6779 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6780 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6781
6782 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6783 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6784 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6785 { } /* end */
6786};
6787
Tobin Davis9102cd12006-12-15 10:02:12 +01006788static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6789{
6790 unsigned int gpiostate, gpiomask, gpiodir;
6791
6792 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6793 AC_VERB_GET_GPIO_DATA, 0);
6794
6795 if (!muted)
6796 gpiostate |= (1 << pin);
6797 else
6798 gpiostate &= ~(1 << pin);
6799
6800 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6801 AC_VERB_GET_GPIO_MASK, 0);
6802 gpiomask |= (1 << pin);
6803
6804 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6805 AC_VERB_GET_GPIO_DIRECTION, 0);
6806 gpiodir |= (1 << pin);
6807
6808
6809 snd_hda_codec_write(codec, codec->afg, 0,
6810 AC_VERB_SET_GPIO_MASK, gpiomask);
6811 snd_hda_codec_write(codec, codec->afg, 0,
6812 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6813
6814 msleep(1);
6815
6816 snd_hda_codec_write(codec, codec->afg, 0,
6817 AC_VERB_SET_GPIO_DATA, gpiostate);
6818}
6819
Takashi Iwai7debbe52007-08-16 15:01:03 +02006820/* set up GPIO at initialization */
6821static void alc885_macpro_init_hook(struct hda_codec *codec)
6822{
6823 alc882_gpio_mute(codec, 0, 0);
6824 alc882_gpio_mute(codec, 1, 0);
6825}
6826
6827/* set up GPIO and update auto-muting at initialization */
6828static void alc885_imac24_init_hook(struct hda_codec *codec)
6829{
6830 alc885_macpro_init_hook(codec);
6831 alc885_imac24_automute(codec);
6832}
6833
Kailang Yangdf694da2005-12-05 19:42:22 +01006834/*
6835 * generic initialization of ADC, input mixers and output mixers
6836 */
6837static struct hda_verb alc882_auto_init_verbs[] = {
6838 /*
6839 * Unmute ADC0-2 and set the default input to mic-in
6840 */
6841 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6843 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6844 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6845 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6846 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6847
Takashi Iwaicb53c622007-08-10 17:21:45 +02006848 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006849 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006850 * Note: PASD motherboards uses the Line In 2 as the input for
6851 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006852 */
6853 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6858 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006859
6860 /*
6861 * Set up output mixers (0x0c - 0x0f)
6862 */
6863 /* set vol=0 to output mixers */
6864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6865 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6866 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6867 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6868 /* set up input amps for analog loopback */
6869 /* Amp Indices: DAC = 0, mixer = 1 */
6870 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6871 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6872 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6873 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6874 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6875 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6876 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6877 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6878 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6879 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6880
6881 /* FIXME: use matrix-type input source selection */
6882 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6883 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6884 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6885 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6886 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6887 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6888 /* Input mixer2 */
6889 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6890 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6891 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6892 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6893 /* Input mixer3 */
6894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6895 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6897 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6898
6899 { }
6900};
6901
Takashi Iwaicb53c622007-08-10 17:21:45 +02006902#ifdef CONFIG_SND_HDA_POWER_SAVE
6903#define alc882_loopbacks alc880_loopbacks
6904#endif
6905
Kailang Yangdf694da2005-12-05 19:42:22 +01006906/* pcm configuration: identiacal with ALC880 */
6907#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6908#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6909#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6910#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6911
6912/*
6913 * configuration and preset
6914 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006915static const char *alc882_models[ALC882_MODEL_LAST] = {
6916 [ALC882_3ST_DIG] = "3stack-dig",
6917 [ALC882_6ST_DIG] = "6stack-dig",
6918 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006919 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006920 [ALC882_TARGA] = "targa",
6921 [ALC882_ASUS_A7J] = "asus-a7j",
6922 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006923 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006924 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006925 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006926 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006927 [ALC882_AUTO] = "auto",
6928};
6929
6930static struct snd_pci_quirk alc882_cfg_tbl[] = {
6931 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006932 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006933 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006934 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006935 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006936 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006937 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006938 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006939 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006940 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6941 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6942 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006943 {}
6944};
6945
6946static struct alc_config_preset alc882_presets[] = {
6947 [ALC882_3ST_DIG] = {
6948 .mixers = { alc882_base_mixer },
6949 .init_verbs = { alc882_init_verbs },
6950 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6951 .dac_nids = alc882_dac_nids,
6952 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006953 .dig_in_nid = ALC882_DIGIN_NID,
6954 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6955 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006956 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006957 .input_mux = &alc882_capture_source,
6958 },
6959 [ALC882_6ST_DIG] = {
6960 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6961 .init_verbs = { alc882_init_verbs },
6962 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6963 .dac_nids = alc882_dac_nids,
6964 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006965 .dig_in_nid = ALC882_DIGIN_NID,
6966 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6967 .channel_mode = alc882_sixstack_modes,
6968 .input_mux = &alc882_capture_source,
6969 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006970 [ALC882_ARIMA] = {
6971 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6972 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6973 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6974 .dac_nids = alc882_dac_nids,
6975 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6976 .channel_mode = alc882_sixstack_modes,
6977 .input_mux = &alc882_capture_source,
6978 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006979 [ALC882_W2JC] = {
6980 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6981 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6982 alc880_gpio1_init_verbs },
6983 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6984 .dac_nids = alc882_dac_nids,
6985 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6986 .channel_mode = alc880_threestack_modes,
6987 .need_dac_fix = 1,
6988 .input_mux = &alc882_capture_source,
6989 .dig_out_nid = ALC882_DIGOUT_NID,
6990 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006991 [ALC885_MBP3] = {
6992 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6993 .init_verbs = { alc885_mbp3_init_verbs,
6994 alc880_gpio1_init_verbs },
6995 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6996 .dac_nids = alc882_dac_nids,
6997 .channel_mode = alc885_mbp_6ch_modes,
6998 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6999 .input_mux = &alc882_capture_source,
7000 .dig_out_nid = ALC882_DIGOUT_NID,
7001 .dig_in_nid = ALC882_DIGIN_NID,
7002 .unsol_event = alc885_mbp3_unsol_event,
7003 .init_hook = alc885_mbp3_automute,
7004 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007005 [ALC885_MB5] = {
7006 .mixers = { alc885_mb5_mixer },
7007 .init_verbs = { alc885_mb5_init_verbs,
7008 alc880_gpio1_init_verbs },
7009 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7010 .dac_nids = alc882_dac_nids,
7011 .channel_mode = alc885_mbp_6ch_modes,
7012 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
7013 .input_mux = &mb5_capture_source,
7014 .dig_out_nid = ALC882_DIGOUT_NID,
7015 .dig_in_nid = ALC882_DIGIN_NID,
7016 },
Tobin Davis9102cd12006-12-15 10:02:12 +01007017 [ALC885_MACPRO] = {
7018 .mixers = { alc882_macpro_mixer },
7019 .init_verbs = { alc882_macpro_init_verbs },
7020 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7021 .dac_nids = alc882_dac_nids,
7022 .dig_out_nid = ALC882_DIGOUT_NID,
7023 .dig_in_nid = ALC882_DIGIN_NID,
7024 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7025 .channel_mode = alc882_ch_modes,
7026 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007027 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007028 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007029 [ALC885_IMAC24] = {
7030 .mixers = { alc885_imac24_mixer },
7031 .init_verbs = { alc885_imac24_init_verbs },
7032 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7033 .dac_nids = alc882_dac_nids,
7034 .dig_out_nid = ALC882_DIGOUT_NID,
7035 .dig_in_nid = ALC882_DIGIN_NID,
7036 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7037 .channel_mode = alc882_ch_modes,
7038 .input_mux = &alc882_capture_source,
7039 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007040 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007041 },
Kailang Yang272a5272007-05-14 11:00:38 +02007042 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007043 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007044 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7045 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7046 .dac_nids = alc882_dac_nids,
7047 .dig_out_nid = ALC882_DIGOUT_NID,
7048 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7049 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007050 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007051 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7052 .channel_mode = alc882_3ST_6ch_modes,
7053 .need_dac_fix = 1,
7054 .input_mux = &alc882_capture_source,
7055 .unsol_event = alc882_targa_unsol_event,
7056 .init_hook = alc882_targa_automute,
7057 },
7058 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007059 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007060 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7061 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7062 .dac_nids = alc882_dac_nids,
7063 .dig_out_nid = ALC882_DIGOUT_NID,
7064 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7065 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007066 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007067 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7068 .channel_mode = alc882_3ST_6ch_modes,
7069 .need_dac_fix = 1,
7070 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007071 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007072 [ALC882_ASUS_A7M] = {
7073 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7074 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7075 alc880_gpio1_init_verbs,
7076 alc882_asus_a7m_verbs },
7077 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7078 .dac_nids = alc882_dac_nids,
7079 .dig_out_nid = ALC882_DIGOUT_NID,
7080 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7081 .channel_mode = alc880_threestack_modes,
7082 .need_dac_fix = 1,
7083 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007084 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007085};
7086
7087
7088/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007089 * Pin config fixes
7090 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007091enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007092 PINFIX_ABIT_AW9D_MAX
7093};
7094
7095static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7096 { 0x15, 0x01080104 }, /* side */
7097 { 0x16, 0x01011012 }, /* rear */
7098 { 0x17, 0x01016011 }, /* clfe */
7099 { }
7100};
7101
7102static const struct alc_pincfg *alc882_pin_fixes[] = {
7103 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7104};
7105
7106static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7107 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7108 {}
7109};
7110
7111/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007112 * BIOS auto configuration
7113 */
7114static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7115 hda_nid_t nid, int pin_type,
7116 int dac_idx)
7117{
7118 /* set as output */
7119 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007120 int idx;
7121
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007122 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007123 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7124 idx = 4;
7125 else
7126 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007127 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7128
7129}
7130
7131static void alc882_auto_init_multi_out(struct hda_codec *codec)
7132{
7133 struct alc_spec *spec = codec->spec;
7134 int i;
7135
7136 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007137 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007138 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007139 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007140 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007141 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007142 }
7143}
7144
7145static void alc882_auto_init_hp_out(struct hda_codec *codec)
7146{
7147 struct alc_spec *spec = codec->spec;
7148 hda_nid_t pin;
7149
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007150 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007151 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007152 /* use dac 0 */
7153 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007154 pin = spec->autocfg.speaker_pins[0];
7155 if (pin)
7156 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007157}
7158
7159#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7160#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7161
7162static void alc882_auto_init_analog_input(struct hda_codec *codec)
7163{
7164 struct alc_spec *spec = codec->spec;
7165 int i;
7166
7167 for (i = 0; i < AUTO_PIN_LAST; i++) {
7168 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007169 if (!nid)
7170 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007171 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007172 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7173 snd_hda_codec_write(codec, nid, 0,
7174 AC_VERB_SET_AMP_GAIN_MUTE,
7175 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007176 }
7177}
7178
Takashi Iwaif511b012008-08-15 16:46:42 +02007179static void alc882_auto_init_input_src(struct hda_codec *codec)
7180{
7181 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007182 int c;
7183
7184 for (c = 0; c < spec->num_adc_nids; c++) {
7185 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7186 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007187 unsigned int mux_idx;
7188 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007189 int conns, mute, idx, item;
7190
7191 conns = snd_hda_get_connections(codec, nid, conn_list,
7192 ARRAY_SIZE(conn_list));
7193 if (conns < 0)
7194 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007195 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7196 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007197 for (idx = 0; idx < conns; idx++) {
7198 /* if the current connection is the selected one,
7199 * unmute it as default - otherwise mute it
7200 */
7201 mute = AMP_IN_MUTE(idx);
7202 for (item = 0; item < imux->num_items; item++) {
7203 if (imux->items[item].index == idx) {
7204 if (spec->cur_mux[c] == item)
7205 mute = AMP_IN_UNMUTE(idx);
7206 break;
7207 }
7208 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007209 /* check if we have a selector or mixer
7210 * we could check for the widget type instead, but
7211 * just check for Amp-In presence (in case of mixer
7212 * without amp-in there is something wrong, this
7213 * function shouldn't be used or capsrc nid is wrong)
7214 */
7215 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7216 snd_hda_codec_write(codec, nid, 0,
7217 AC_VERB_SET_AMP_GAIN_MUTE,
7218 mute);
7219 else if (mute != AMP_IN_MUTE(idx))
7220 snd_hda_codec_write(codec, nid, 0,
7221 AC_VERB_SET_CONNECT_SEL,
7222 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007223 }
7224 }
7225}
7226
Takashi Iwai776e1842007-08-29 15:07:11 +02007227/* add mic boosts if needed */
7228static int alc_auto_add_mic_boost(struct hda_codec *codec)
7229{
7230 struct alc_spec *spec = codec->spec;
7231 int err;
7232 hda_nid_t nid;
7233
7234 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007235 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007236 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7237 "Mic Boost",
7238 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7239 if (err < 0)
7240 return err;
7241 }
7242 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007243 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007244 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7245 "Front Mic Boost",
7246 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7247 if (err < 0)
7248 return err;
7249 }
7250 return 0;
7251}
7252
Kailang Yangdf694da2005-12-05 19:42:22 +01007253/* almost identical with ALC880 parser... */
7254static int alc882_parse_auto_config(struct hda_codec *codec)
7255{
7256 struct alc_spec *spec = codec->spec;
7257 int err = alc880_parse_auto_config(codec);
7258
7259 if (err < 0)
7260 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007261 else if (!err)
7262 return 0; /* no config found */
7263
7264 err = alc_auto_add_mic_boost(codec);
7265 if (err < 0)
7266 return err;
7267
7268 /* hack - override the init verbs */
7269 spec->init_verbs[0] = alc882_auto_init_verbs;
7270
7271 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007272}
7273
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007274/* additional initialization for auto-configuration model */
7275static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007276{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007277 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007278 alc882_auto_init_multi_out(codec);
7279 alc882_auto_init_hp_out(codec);
7280 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007281 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007282 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007283 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007284}
7285
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007286static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7287
Linus Torvalds1da177e2005-04-16 15:20:36 -07007288static int patch_alc882(struct hda_codec *codec)
7289{
7290 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007291 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007292
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007293 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007294 if (spec == NULL)
7295 return -ENOMEM;
7296
Linus Torvalds1da177e2005-04-16 15:20:36 -07007297 codec->spec = spec;
7298
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007299 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7300 alc882_models,
7301 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007302
Kailang Yangdf694da2005-12-05 19:42:22 +01007303 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007304 /* Pick up systems that don't supply PCI SSID */
7305 switch (codec->subsystem_id) {
7306 case 0x106b0c00: /* Mac Pro */
7307 board_config = ALC885_MACPRO;
7308 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007309 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007310 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007311 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007312 board_config = ALC885_IMAC24;
7313 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007314 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007315 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007316 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007317 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007318 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007319 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007320 board_config = ALC885_MBP3;
7321 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007322 case 0x106b3f00: /* Macbook 5,1 */
7323 board_config = ALC885_MB5;
7324 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007325 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007326 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007327 if (codec->revision_id == 0x100101 ||
7328 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007329 alc_free(codec);
7330 return patch_alc883(codec);
7331 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007332 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7333 "trying auto-probe from BIOS...\n");
7334 board_config = ALC882_AUTO;
7335 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007336 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007337
Takashi Iwaif95474e2007-07-10 00:47:43 +02007338 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7339
Kailang Yangdf694da2005-12-05 19:42:22 +01007340 if (board_config == ALC882_AUTO) {
7341 /* automatic parse from the BIOS config */
7342 err = alc882_parse_auto_config(codec);
7343 if (err < 0) {
7344 alc_free(codec);
7345 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007346 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007347 printk(KERN_INFO
7348 "hda_codec: Cannot set up configuration "
7349 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007350 board_config = ALC882_3ST_DIG;
7351 }
7352 }
7353
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007354 err = snd_hda_attach_beep_device(codec, 0x1);
7355 if (err < 0) {
7356 alc_free(codec);
7357 return err;
7358 }
7359
Kailang Yangdf694da2005-12-05 19:42:22 +01007360 if (board_config != ALC882_AUTO)
7361 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007362
Kailang Yang2f893282008-05-27 12:14:47 +02007363 if (codec->vendor_id == 0x10ec0885) {
7364 spec->stream_name_analog = "ALC885 Analog";
7365 spec->stream_name_digital = "ALC885 Digital";
7366 } else {
7367 spec->stream_name_analog = "ALC882 Analog";
7368 spec->stream_name_digital = "ALC882 Digital";
7369 }
7370
Kailang Yangdf694da2005-12-05 19:42:22 +01007371 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7372 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007373 /* FIXME: setup DAC5 */
7374 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7375 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007376
Kailang Yangdf694da2005-12-05 19:42:22 +01007377 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7378 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007379
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007380 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007381 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007382 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007383 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007384 /* get type */
7385 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007386 if (wcap != AC_WID_AUD_IN) {
7387 spec->adc_nids = alc882_adc_nids_alt;
7388 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007389 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007390 } else {
7391 spec->adc_nids = alc882_adc_nids;
7392 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007393 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007394 }
7395 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007396 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007397 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007398
Takashi Iwai2134ea42008-01-10 16:53:55 +01007399 spec->vmaster_nid = 0x0c;
7400
Linus Torvalds1da177e2005-04-16 15:20:36 -07007401 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007402 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007403 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007404#ifdef CONFIG_SND_HDA_POWER_SAVE
7405 if (!spec->loopback.amplist)
7406 spec->loopback.amplist = alc882_loopbacks;
7407#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007408 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007409
7410 return 0;
7411}
7412
7413/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007414 * ALC883 support
7415 *
7416 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7417 * configuration. Each pin widget can choose any input DACs and a mixer.
7418 * Each ADC is connected from a mixer of all inputs. This makes possible
7419 * 6-channel independent captures.
7420 *
7421 * In addition, an independent DAC for the multi-playback (not used in this
7422 * driver yet).
7423 */
7424#define ALC883_DIGOUT_NID 0x06
7425#define ALC883_DIGIN_NID 0x0a
7426
Wu Fengguang3ab90932008-11-17 09:51:09 +01007427#define ALC1200_DIGOUT_NID 0x10
7428
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007429static hda_nid_t alc883_dac_nids[4] = {
7430 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007431 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007432};
7433
7434static hda_nid_t alc883_adc_nids[2] = {
7435 /* ADC1-2 */
7436 0x08, 0x09,
7437};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007438
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007439static hda_nid_t alc883_adc_nids_alt[1] = {
7440 /* ADC1 */
7441 0x08,
7442};
7443
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007444static hda_nid_t alc883_adc_nids_rev[2] = {
7445 /* ADC2-1 */
7446 0x09, 0x08
7447};
7448
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007449#define alc889_adc_nids alc880_adc_nids
7450
Takashi Iwaie1406342008-02-11 18:32:32 +01007451static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7452
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007453static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7454
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007455#define alc889_capsrc_nids alc882_capsrc_nids
7456
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007457/* input MUX */
7458/* FIXME: should be a matrix-type input source selection */
7459
7460static struct hda_input_mux alc883_capture_source = {
7461 .num_items = 4,
7462 .items = {
7463 { "Mic", 0x0 },
7464 { "Front Mic", 0x1 },
7465 { "Line", 0x2 },
7466 { "CD", 0x4 },
7467 },
7468};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007469
Jiang zhe17bba1b2008-06-04 12:11:07 +02007470static struct hda_input_mux alc883_3stack_6ch_intel = {
7471 .num_items = 4,
7472 .items = {
7473 { "Mic", 0x1 },
7474 { "Front Mic", 0x0 },
7475 { "Line", 0x2 },
7476 { "CD", 0x4 },
7477 },
7478};
7479
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007480static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7481 .num_items = 2,
7482 .items = {
7483 { "Mic", 0x1 },
7484 { "Line", 0x2 },
7485 },
7486};
7487
Kailang Yang272a5272007-05-14 11:00:38 +02007488static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7489 .num_items = 4,
7490 .items = {
7491 { "Mic", 0x0 },
7492 { "iMic", 0x1 },
7493 { "Line", 0x2 },
7494 { "CD", 0x4 },
7495 },
7496};
7497
Jiang zhefb97dc62008-03-06 11:07:11 +01007498static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7499 .num_items = 2,
7500 .items = {
7501 { "Mic", 0x0 },
7502 { "Int Mic", 0x1 },
7503 },
7504};
7505
Kailang Yange2757d52008-08-26 13:17:46 +02007506static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7507 .num_items = 3,
7508 .items = {
7509 { "Mic", 0x0 },
7510 { "Front Mic", 0x1 },
7511 { "Line", 0x4 },
7512 },
7513};
7514
7515static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7516 .num_items = 2,
7517 .items = {
7518 { "Mic", 0x0 },
7519 { "Line", 0x2 },
7520 },
7521};
7522
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007523/*
7524 * 2ch mode
7525 */
7526static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7527 { 2, NULL }
7528};
7529
7530/*
7531 * 2ch mode
7532 */
7533static struct hda_verb alc883_3ST_ch2_init[] = {
7534 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7535 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7536 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7537 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7538 { } /* end */
7539};
7540
7541/*
Tobin Davisb2011312007-09-17 12:45:11 +02007542 * 4ch mode
7543 */
7544static struct hda_verb alc883_3ST_ch4_init[] = {
7545 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7546 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7547 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7548 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7549 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7550 { } /* end */
7551};
7552
7553/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007554 * 6ch mode
7555 */
7556static struct hda_verb alc883_3ST_ch6_init[] = {
7557 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7558 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7559 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7560 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7561 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7562 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7563 { } /* end */
7564};
7565
Tobin Davisb2011312007-09-17 12:45:11 +02007566static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007567 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007568 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007569 { 6, alc883_3ST_ch6_init },
7570};
7571
7572/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007573 * 2ch mode
7574 */
7575static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7576 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7577 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7578 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7579 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7580 { } /* end */
7581};
7582
7583/*
7584 * 4ch mode
7585 */
7586static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7587 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7588 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7589 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7590 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7591 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7592 { } /* end */
7593};
7594
7595/*
7596 * 6ch mode
7597 */
7598static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7599 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7600 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7601 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7602 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7603 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7604 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7605 { } /* end */
7606};
7607
7608static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7609 { 2, alc883_3ST_ch2_intel_init },
7610 { 4, alc883_3ST_ch4_intel_init },
7611 { 6, alc883_3ST_ch6_intel_init },
7612};
7613
7614/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007615 * 6ch mode
7616 */
7617static struct hda_verb alc883_sixstack_ch6_init[] = {
7618 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7619 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7620 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7621 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7622 { } /* end */
7623};
7624
7625/*
7626 * 8ch mode
7627 */
7628static struct hda_verb alc883_sixstack_ch8_init[] = {
7629 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7630 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7631 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7632 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7633 { } /* end */
7634};
7635
7636static struct hda_channel_mode alc883_sixstack_modes[2] = {
7637 { 6, alc883_sixstack_ch6_init },
7638 { 8, alc883_sixstack_ch8_init },
7639};
7640
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007641static struct hda_verb alc883_medion_eapd_verbs[] = {
7642 /* eanable EAPD on medion laptop */
7643 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7644 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7645 { }
7646};
7647
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007648/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7649 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7650 */
7651
7652static struct snd_kcontrol_new alc883_base_mixer[] = {
7653 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7654 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7655 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7656 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7657 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7658 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7659 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7660 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7661 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7662 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7663 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7664 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7665 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7666 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7667 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7668 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007669 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7671 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007672 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007673 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007674 { } /* end */
7675};
7676
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007677static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7678 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7679 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7680 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7681 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7682 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7683 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7685 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7686 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7687 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7688 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7689 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7690 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007691 { } /* end */
7692};
7693
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007694static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007695 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7696 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7697 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7698 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7699 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7700 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7701 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7702 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7703 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7704 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007705 { } /* end */
7706};
7707
Jiang zhefb97dc62008-03-06 11:07:11 +01007708static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7709 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7710 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7711 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7712 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7713 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7714 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7715 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7716 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7717 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7718 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007719 { } /* end */
7720};
7721
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007722static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7723 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7724 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7725 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7726 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7727 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7728 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7729 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007731 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7733 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007734 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007735 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007736 { } /* end */
7737};
7738
7739static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7740 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7741 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7742 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7743 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7744 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7745 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7746 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7747 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7748 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7749 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7750 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7751 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7752 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7753 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007754 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007755 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7756 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007757 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007758 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007759 { } /* end */
7760};
7761
Jiang zhe17bba1b2008-06-04 12:11:07 +02007762static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7763 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7764 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7765 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7766 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7767 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7768 HDA_OUTPUT),
7769 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7770 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7771 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7772 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7773 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7774 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7775 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7776 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7778 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7780 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7781 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7782 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007783 { } /* end */
7784};
7785
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007786static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007787 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007788 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007789 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007790 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007791 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7792 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007793 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7794 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7796 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7797 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7798 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7799 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7800 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007801 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007802 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7803 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007804 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007805 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007806 { } /* end */
7807};
7808
Kailang Yangccc656c2006-10-17 12:32:26 +02007809static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7810 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7811 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7812 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7813 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7814 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7815 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7816 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7817 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7818 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7819 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7820 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7821 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7822 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7823 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007824 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007826 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007827};
Kailang Yangccc656c2006-10-17 12:32:26 +02007828
7829static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7830 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7831 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7832 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7833 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7834 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007836 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007838 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7839 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7840 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007841 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007842};
Kailang Yangccc656c2006-10-17 12:32:26 +02007843
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007844static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7845 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7846 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007847 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7848 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007849 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7851 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7852 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007853 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007854};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007855
Kailang Yang272a5272007-05-14 11:00:38 +02007856static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7857 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7858 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7860 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7861 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7863 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7864 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7865 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007866 { } /* end */
7867};
7868
7869static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7870 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7871 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7872 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7873 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7874 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7876 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7877 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7878 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007879 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007880};
Kailang Yang272a5272007-05-14 11:00:38 +02007881
Tobin Davis2880a862007-08-07 11:50:26 +02007882static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007883 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7884 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007885 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007886 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7887 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007891 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007892};
Tobin Davis2880a862007-08-07 11:50:26 +02007893
Kailang Yange2757d52008-08-26 13:17:46 +02007894static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7895 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7896 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7897 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7898 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7899 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7900 0x0d, 1, 0x0, HDA_OUTPUT),
7901 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7902 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7903 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7904 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7905 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7906 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7907 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7908 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7909 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7910 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7911 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7913 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7915 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7916 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7917 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007918 { } /* end */
7919};
7920
7921static struct hda_bind_ctls alc883_bind_cap_vol = {
7922 .ops = &snd_hda_bind_vol,
7923 .values = {
7924 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7925 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7926 0
7927 },
7928};
7929
7930static struct hda_bind_ctls alc883_bind_cap_switch = {
7931 .ops = &snd_hda_bind_sw,
7932 .values = {
7933 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7934 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7935 0
7936 },
7937};
7938
7939static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7940 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7941 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7943 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7944 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7945 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7946 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7947 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007948 { } /* end */
7949};
7950
7951static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007952 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7953 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7954 {
7955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7956 /* .name = "Capture Source", */
7957 .name = "Input Source",
7958 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007959 .info = alc_mux_enum_info,
7960 .get = alc_mux_enum_get,
7961 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007962 },
7963 { } /* end */
7964};
7965
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007966static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7967 {
7968 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7969 .name = "Channel Mode",
7970 .info = alc_ch_mode_info,
7971 .get = alc_ch_mode_get,
7972 .put = alc_ch_mode_put,
7973 },
7974 { } /* end */
7975};
7976
7977static struct hda_verb alc883_init_verbs[] = {
7978 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007979 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007980 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7981 /* ADC2: mute amp left and right */
7982 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7983 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7984 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7985 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7986 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7987 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7988 /* Rear mixer */
7989 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7990 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7991 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7992 /* CLFE mixer */
7993 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7994 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7995 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7996 /* Side mixer */
7997 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7998 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7999 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8000
Takashi Iwaicb53c622007-08-10 17:21:45 +02008001 /* mute analog input loopbacks */
8002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8005 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008007
8008 /* Front Pin: output 0 (0x0c) */
8009 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8010 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8011 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8012 /* Rear Pin: output 1 (0x0d) */
8013 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8014 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8015 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8016 /* CLFE Pin: output 2 (0x0e) */
8017 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8018 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8019 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8020 /* Side Pin: output 3 (0x0f) */
8021 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8022 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8023 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8024 /* Mic (rear) pin: input vref at 80% */
8025 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8026 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8027 /* Front Mic pin: input vref at 80% */
8028 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8029 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8030 /* Line In pin: input */
8031 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8032 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8033 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8034 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8035 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8036 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8037 /* CD pin widget for input */
8038 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8039
8040 /* FIXME: use matrix-type input source selection */
8041 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8042 /* Input mixer2 */
8043 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8045 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8046 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008047 /* Input mixer3 */
8048 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008049 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8050 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008052 { }
8053};
8054
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008055/* toggle speaker-output according to the hp-jack state */
8056static void alc883_mitac_hp_automute(struct hda_codec *codec)
8057{
8058 unsigned int present;
8059
8060 present = snd_hda_codec_read(codec, 0x15, 0,
8061 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8062 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8063 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8064 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8065 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8066}
8067
8068/* auto-toggle front mic */
8069/*
8070static void alc883_mitac_mic_automute(struct hda_codec *codec)
8071{
8072 unsigned int present;
8073 unsigned char bits;
8074
8075 present = snd_hda_codec_read(codec, 0x18, 0,
8076 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8077 bits = present ? HDA_AMP_MUTE : 0;
8078 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8079}
8080*/
8081
8082static void alc883_mitac_automute(struct hda_codec *codec)
8083{
8084 alc883_mitac_hp_automute(codec);
8085 /* alc883_mitac_mic_automute(codec); */
8086}
8087
8088static void alc883_mitac_unsol_event(struct hda_codec *codec,
8089 unsigned int res)
8090{
8091 switch (res >> 26) {
8092 case ALC880_HP_EVENT:
8093 alc883_mitac_hp_automute(codec);
8094 break;
8095 case ALC880_MIC_EVENT:
8096 /* alc883_mitac_mic_automute(codec); */
8097 break;
8098 }
8099}
8100
8101static struct hda_verb alc883_mitac_verbs[] = {
8102 /* HP */
8103 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8104 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8105 /* Subwoofer */
8106 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8107 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8108
8109 /* enable unsolicited event */
8110 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8111 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8112
8113 { } /* end */
8114};
8115
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008116static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008117 /* HP */
8118 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8119 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8120 /* Int speaker */
8121 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8122 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8123
8124 /* enable unsolicited event */
8125 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008126 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008127
8128 { } /* end */
8129};
8130
Jiang zhefb97dc62008-03-06 11:07:11 +01008131static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8132 /* HP */
8133 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8134 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8135 /* Subwoofer */
8136 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8137 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8138
8139 /* enable unsolicited event */
8140 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8141
8142 { } /* end */
8143};
8144
Kailang Yangccc656c2006-10-17 12:32:26 +02008145static struct hda_verb alc883_tagra_verbs[] = {
8146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8148
8149 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8150 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008151
Kailang Yangccc656c2006-10-17 12:32:26 +02008152 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8153 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8154 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8155
8156 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008157 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8158 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8159 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02008160
8161 { } /* end */
8162};
8163
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008164static struct hda_verb alc883_lenovo_101e_verbs[] = {
8165 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8166 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8167 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8168 { } /* end */
8169};
8170
Kailang Yang272a5272007-05-14 11:00:38 +02008171static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8172 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8173 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8174 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8175 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8176 { } /* end */
8177};
8178
8179static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8181 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8182 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8183 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8184 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8185 { } /* end */
8186};
8187
Kailang Yang189609a2007-08-20 11:31:23 +02008188static struct hda_verb alc883_haier_w66_verbs[] = {
8189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8191
8192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8193
8194 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8195 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8196 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8197 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8198 { } /* end */
8199};
8200
Kailang Yange2757d52008-08-26 13:17:46 +02008201static struct hda_verb alc888_lenovo_sky_verbs[] = {
8202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8204 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8205 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8206 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8207 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8208 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8209 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8210 { } /* end */
8211};
8212
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008213static struct hda_verb alc888_6st_dell_verbs[] = {
8214 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8215 { }
8216};
8217
8218static void alc888_3st_hp_front_automute(struct hda_codec *codec)
8219{
8220 unsigned int present, bits;
8221
8222 present = snd_hda_codec_read(codec, 0x1b, 0,
8223 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8224 bits = present ? HDA_AMP_MUTE : 0;
8225 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8226 HDA_AMP_MUTE, bits);
8227 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8228 HDA_AMP_MUTE, bits);
8229 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
8230 HDA_AMP_MUTE, bits);
8231}
8232
8233static void alc888_3st_hp_unsol_event(struct hda_codec *codec,
8234 unsigned int res)
8235{
8236 switch (res >> 26) {
8237 case ALC880_HP_EVENT:
8238 alc888_3st_hp_front_automute(codec);
8239 break;
8240 }
8241}
8242
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008243static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008244 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008245 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8246 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008247 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008248 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008249};
8250
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008251/*
8252 * 2ch mode
8253 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008254static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008255 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8256 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8257 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8258 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008259 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008260};
8261
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008262/*
8263 * 4ch mode
8264 */
8265static struct hda_verb alc888_3st_hp_4ch_init[] = {
8266 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8267 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8268 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8269 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8270 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8271 { } /* end */
8272};
8273
8274/*
8275 * 6ch mode
8276 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008277static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008278 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8279 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008280 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008281 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8282 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008283 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8284 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008285};
8286
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008287static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008288 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008289 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008290 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008291};
8292
Kailang Yang272a5272007-05-14 11:00:38 +02008293/* toggle front-jack and RCA according to the hp-jack state */
8294static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8295{
8296 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008297
Kailang Yang272a5272007-05-14 11:00:38 +02008298 present = snd_hda_codec_read(codec, 0x1b, 0,
8299 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008300 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8301 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8302 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8303 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008304}
8305
8306/* toggle RCA according to the front-jack state */
8307static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8308{
8309 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008310
Kailang Yang272a5272007-05-14 11:00:38 +02008311 present = snd_hda_codec_read(codec, 0x14, 0,
8312 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008313 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8314 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008315}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008316
Kailang Yang272a5272007-05-14 11:00:38 +02008317static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8318 unsigned int res)
8319{
8320 if ((res >> 26) == ALC880_HP_EVENT)
8321 alc888_lenovo_ms7195_front_automute(codec);
8322 if ((res >> 26) == ALC880_FRONT_EVENT)
8323 alc888_lenovo_ms7195_rca_automute(codec);
8324}
8325
8326static struct hda_verb alc883_medion_md2_verbs[] = {
8327 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8328 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8329
8330 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8331
8332 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8333 { } /* end */
8334};
8335
8336/* toggle speaker-output according to the hp-jack state */
8337static void alc883_medion_md2_automute(struct hda_codec *codec)
8338{
8339 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008340
Kailang Yang272a5272007-05-14 11:00:38 +02008341 present = snd_hda_codec_read(codec, 0x14, 0,
8342 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008343 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8344 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008345}
8346
8347static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8348 unsigned int res)
8349{
8350 if ((res >> 26) == ALC880_HP_EVENT)
8351 alc883_medion_md2_automute(codec);
8352}
8353
Kailang Yangccc656c2006-10-17 12:32:26 +02008354/* toggle speaker-output according to the hp-jack state */
8355static void alc883_tagra_automute(struct hda_codec *codec)
8356{
8357 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008358 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008359
8360 present = snd_hda_codec_read(codec, 0x14, 0,
8361 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008362 bits = present ? HDA_AMP_MUTE : 0;
8363 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8364 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008365 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8366 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008367}
8368
8369static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8370{
8371 if ((res >> 26) == ALC880_HP_EVENT)
8372 alc883_tagra_automute(codec);
8373}
8374
Jiang zhe368c7a92008-03-04 11:20:33 +01008375/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008376static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008377{
8378 unsigned int present;
8379 unsigned char bits;
8380
8381 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8382 & AC_PINSENSE_PRESENCE;
8383 bits = present ? HDA_AMP_MUTE : 0;
8384 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8385 HDA_AMP_MUTE, bits);
8386}
8387
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008388static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8389{
8390 unsigned int present;
8391
8392 present = snd_hda_codec_read(codec, 0x18, 0,
8393 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8394 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8395 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8396}
8397
8398static void alc883_clevo_m720_automute(struct hda_codec *codec)
8399{
8400 alc883_clevo_m720_hp_automute(codec);
8401 alc883_clevo_m720_mic_automute(codec);
8402}
8403
8404static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008405 unsigned int res)
8406{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008407 switch (res >> 26) {
8408 case ALC880_HP_EVENT:
8409 alc883_clevo_m720_hp_automute(codec);
8410 break;
8411 case ALC880_MIC_EVENT:
8412 alc883_clevo_m720_mic_automute(codec);
8413 break;
8414 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008415}
8416
Jiang zhefb97dc62008-03-06 11:07:11 +01008417/* toggle speaker-output according to the hp-jack state */
8418static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8419{
8420 unsigned int present;
8421 unsigned char bits;
8422
8423 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8424 & AC_PINSENSE_PRESENCE;
8425 bits = present ? HDA_AMP_MUTE : 0;
8426 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8427 HDA_AMP_MUTE, bits);
8428}
8429
8430static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8431 unsigned int res)
8432{
8433 if ((res >> 26) == ALC880_HP_EVENT)
8434 alc883_2ch_fujitsu_pi2515_automute(codec);
8435}
8436
Kailang Yang189609a2007-08-20 11:31:23 +02008437static void alc883_haier_w66_automute(struct hda_codec *codec)
8438{
8439 unsigned int present;
8440 unsigned char bits;
8441
8442 present = snd_hda_codec_read(codec, 0x1b, 0,
8443 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8444 bits = present ? 0x80 : 0;
8445 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8446 0x80, bits);
8447}
8448
8449static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8450 unsigned int res)
8451{
8452 if ((res >> 26) == ALC880_HP_EVENT)
8453 alc883_haier_w66_automute(codec);
8454}
8455
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008456static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8457{
8458 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008459 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008460
8461 present = snd_hda_codec_read(codec, 0x14, 0,
8462 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008463 bits = present ? HDA_AMP_MUTE : 0;
8464 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8465 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008466}
8467
8468static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8469{
8470 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008471 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008472
8473 present = snd_hda_codec_read(codec, 0x1b, 0,
8474 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008475 bits = present ? HDA_AMP_MUTE : 0;
8476 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8477 HDA_AMP_MUTE, bits);
8478 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8479 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008480}
8481
8482static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8483 unsigned int res)
8484{
8485 if ((res >> 26) == ALC880_HP_EVENT)
8486 alc883_lenovo_101e_all_automute(codec);
8487 if ((res >> 26) == ALC880_FRONT_EVENT)
8488 alc883_lenovo_101e_ispeaker_automute(codec);
8489}
8490
Takashi Iwai676a9b52007-08-16 15:23:35 +02008491/* toggle speaker-output according to the hp-jack state */
8492static void alc883_acer_aspire_automute(struct hda_codec *codec)
8493{
8494 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008495
Takashi Iwai676a9b52007-08-16 15:23:35 +02008496 present = snd_hda_codec_read(codec, 0x14, 0,
8497 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8498 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8499 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8500 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8501 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8502}
8503
8504static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8505 unsigned int res)
8506{
8507 if ((res >> 26) == ALC880_HP_EVENT)
8508 alc883_acer_aspire_automute(codec);
8509}
8510
Kailang Yangd1a991a2007-08-15 16:21:59 +02008511static struct hda_verb alc883_acer_eapd_verbs[] = {
8512 /* HP Pin: output 0 (0x0c) */
8513 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8514 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8515 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8516 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008517 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8518 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008519 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008520 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8521 /* eanable EAPD on medion laptop */
8522 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8523 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008524 /* enable unsolicited event */
8525 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008526 { }
8527};
8528
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008529static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8530{
8531 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008532
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008533 present = snd_hda_codec_read(codec, 0x1b, 0,
8534 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8535 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8536 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8537 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8538 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8539 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8540 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8541 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8542 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8543}
8544
8545static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8546 unsigned int res)
8547{
8548 switch (res >> 26) {
8549 case ALC880_HP_EVENT:
Takashi Iwai939778a2009-02-05 15:57:55 +01008550 /* printk(KERN_DEBUG "hp_event\n"); */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008551 alc888_6st_dell_front_automute(codec);
8552 break;
8553 }
8554}
8555
Kailang Yange2757d52008-08-26 13:17:46 +02008556static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8557{
8558 unsigned int mute;
8559 unsigned int present;
8560
8561 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8562 present = snd_hda_codec_read(codec, 0x1b, 0,
8563 AC_VERB_GET_PIN_SENSE, 0);
8564 present = (present & 0x80000000) != 0;
8565 if (present) {
8566 /* mute internal speaker */
8567 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8568 HDA_AMP_MUTE, HDA_AMP_MUTE);
8569 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8570 HDA_AMP_MUTE, HDA_AMP_MUTE);
8571 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8572 HDA_AMP_MUTE, HDA_AMP_MUTE);
8573 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8574 HDA_AMP_MUTE, HDA_AMP_MUTE);
8575 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8576 HDA_AMP_MUTE, HDA_AMP_MUTE);
8577 } else {
8578 /* unmute internal speaker if necessary */
8579 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8580 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8581 HDA_AMP_MUTE, mute);
8582 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8583 HDA_AMP_MUTE, mute);
8584 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8585 HDA_AMP_MUTE, mute);
8586 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8587 HDA_AMP_MUTE, mute);
8588 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8589 HDA_AMP_MUTE, mute);
8590 }
8591}
8592
8593static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8594 unsigned int res)
8595{
8596 if ((res >> 26) == ALC880_HP_EVENT)
8597 alc888_lenovo_sky_front_automute(codec);
8598}
8599
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008600/*
8601 * generic initialization of ADC, input mixers and output mixers
8602 */
8603static struct hda_verb alc883_auto_init_verbs[] = {
8604 /*
8605 * Unmute ADC0-2 and set the default input to mic-in
8606 */
8607 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8608 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8609 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8610 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8611
Takashi Iwaicb53c622007-08-10 17:21:45 +02008612 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008613 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008614 * Note: PASD motherboards uses the Line In 2 as the input for
8615 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008616 */
8617 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008618 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8619 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8620 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8621 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8622 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008623
8624 /*
8625 * Set up output mixers (0x0c - 0x0f)
8626 */
8627 /* set vol=0 to output mixers */
8628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8629 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8630 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8631 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8632 /* set up input amps for analog loopback */
8633 /* Amp Indices: DAC = 0, mixer = 1 */
8634 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8635 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8636 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8637 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8638 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8639 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8640 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8641 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8642 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8643 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8644
8645 /* FIXME: use matrix-type input source selection */
8646 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8647 /* Input mixer1 */
8648 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8649 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8650 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008651 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8653 /* Input mixer2 */
8654 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8655 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8656 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008657 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008658 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008659
8660 { }
8661};
8662
Kailang Yange2757d52008-08-26 13:17:46 +02008663static struct hda_verb alc888_asus_m90v_verbs[] = {
8664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8667 /* enable unsolicited event */
8668 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8669 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8670 { } /* end */
8671};
8672
8673static void alc883_nb_mic_automute(struct hda_codec *codec)
8674{
8675 unsigned int present;
8676
8677 present = snd_hda_codec_read(codec, 0x18, 0,
8678 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8679 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8680 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8681 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8682 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8683}
8684
8685static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8686{
8687 unsigned int present;
8688 unsigned char bits;
8689
8690 present = snd_hda_codec_read(codec, 0x1b, 0,
8691 AC_VERB_GET_PIN_SENSE, 0)
8692 & AC_PINSENSE_PRESENCE;
8693 bits = present ? 0 : PIN_OUT;
8694 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8695 bits);
8696 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8697 bits);
8698 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8699 bits);
8700}
8701
8702static void alc883_mode2_unsol_event(struct hda_codec *codec,
8703 unsigned int res)
8704{
8705 switch (res >> 26) {
8706 case ALC880_HP_EVENT:
8707 alc883_M90V_speaker_automute(codec);
8708 break;
8709 case ALC880_MIC_EVENT:
8710 alc883_nb_mic_automute(codec);
8711 break;
8712 }
8713}
8714
8715static void alc883_mode2_inithook(struct hda_codec *codec)
8716{
8717 alc883_M90V_speaker_automute(codec);
8718 alc883_nb_mic_automute(codec);
8719}
8720
8721static struct hda_verb alc888_asus_eee1601_verbs[] = {
8722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8723 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8724 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8726 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8727 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8728 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8729 /* enable unsolicited event */
8730 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8731 { } /* end */
8732};
8733
8734static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8735{
8736 unsigned int present;
8737 unsigned char bits;
8738
8739 present = snd_hda_codec_read(codec, 0x14, 0,
8740 AC_VERB_GET_PIN_SENSE, 0)
8741 & AC_PINSENSE_PRESENCE;
8742 bits = present ? 0 : PIN_OUT;
8743 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8744 bits);
8745}
8746
8747static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8748 unsigned int res)
8749{
8750 switch (res >> 26) {
8751 case ALC880_HP_EVENT:
8752 alc883_eee1601_speaker_automute(codec);
8753 break;
8754 }
8755}
8756
8757static void alc883_eee1601_inithook(struct hda_codec *codec)
8758{
8759 alc883_eee1601_speaker_automute(codec);
8760}
8761
Takashi Iwaicb53c622007-08-10 17:21:45 +02008762#ifdef CONFIG_SND_HDA_POWER_SAVE
8763#define alc883_loopbacks alc880_loopbacks
8764#endif
8765
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008766/* pcm configuration: identiacal with ALC880 */
8767#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8768#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008769#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008770#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8771#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8772
8773/*
8774 * configuration and preset
8775 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008776static const char *alc883_models[ALC883_MODEL_LAST] = {
8777 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8778 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8779 [ALC883_3ST_6ch] = "3stack-6ch",
8780 [ALC883_6ST_DIG] = "6stack-dig",
8781 [ALC883_TARGA_DIG] = "targa-dig",
8782 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008783 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008784 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008785 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008786 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008787 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008788 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008789 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008790 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8791 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008792 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008793 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008794 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008795 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008796 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008797 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008798 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008799 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008800 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008801 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008802 [ALC883_AUTO] = "auto",
8803};
8804
8805static struct snd_pci_quirk alc883_cfg_tbl[] = {
8806 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008807 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008808 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008809 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008810 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8811 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008812 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008813 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8814 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008815 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8816 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01008817 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008818 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008819 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8820 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008821 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8822 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008823 /* default Acer */
8824 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008825 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008826 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008827 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8828 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008829 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008830 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008831 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008832 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008833 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008834 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008835 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008836 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008837 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008838 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008839 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008840 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8841 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008842 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008843 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008844 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008845 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8846 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8847 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008848 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008849 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008850 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008851 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8852 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8853 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8854 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8855 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8856 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8857 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8858 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8859 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008860 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8861 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008862 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008863 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008864 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008865 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008866 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008867 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008868 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008869 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8870 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008871 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008872 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008873 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008874 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008875 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008876 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008877 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008878 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008879 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008880 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8881 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008882 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008883 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008884 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008885 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008886 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008887 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8888 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008889 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008890 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008891 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008892 {}
8893};
8894
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008895static hda_nid_t alc883_slave_dig_outs[] = {
8896 ALC1200_DIGOUT_NID, 0,
8897};
8898
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008899static hda_nid_t alc1200_slave_dig_outs[] = {
8900 ALC883_DIGOUT_NID, 0,
8901};
8902
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008903static struct alc_config_preset alc883_presets[] = {
8904 [ALC883_3ST_2ch_DIG] = {
8905 .mixers = { alc883_3ST_2ch_mixer },
8906 .init_verbs = { alc883_init_verbs },
8907 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8908 .dac_nids = alc883_dac_nids,
8909 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008910 .dig_in_nid = ALC883_DIGIN_NID,
8911 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8912 .channel_mode = alc883_3ST_2ch_modes,
8913 .input_mux = &alc883_capture_source,
8914 },
8915 [ALC883_3ST_6ch_DIG] = {
8916 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8917 .init_verbs = { alc883_init_verbs },
8918 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8919 .dac_nids = alc883_dac_nids,
8920 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008921 .dig_in_nid = ALC883_DIGIN_NID,
8922 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8923 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008924 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008925 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008926 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008927 [ALC883_3ST_6ch] = {
8928 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8929 .init_verbs = { alc883_init_verbs },
8930 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8931 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008932 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8933 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008934 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008935 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008936 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008937 [ALC883_3ST_6ch_INTEL] = {
8938 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8939 .init_verbs = { alc883_init_verbs },
8940 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8941 .dac_nids = alc883_dac_nids,
8942 .dig_out_nid = ALC883_DIGOUT_NID,
8943 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008944 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008945 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8946 .channel_mode = alc883_3ST_6ch_intel_modes,
8947 .need_dac_fix = 1,
8948 .input_mux = &alc883_3stack_6ch_intel,
8949 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008950 [ALC883_6ST_DIG] = {
8951 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8952 .init_verbs = { alc883_init_verbs },
8953 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8954 .dac_nids = alc883_dac_nids,
8955 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008956 .dig_in_nid = ALC883_DIGIN_NID,
8957 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8958 .channel_mode = alc883_sixstack_modes,
8959 .input_mux = &alc883_capture_source,
8960 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008961 [ALC883_TARGA_DIG] = {
8962 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8963 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8964 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8965 .dac_nids = alc883_dac_nids,
8966 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008967 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8968 .channel_mode = alc883_3ST_6ch_modes,
8969 .need_dac_fix = 1,
8970 .input_mux = &alc883_capture_source,
8971 .unsol_event = alc883_tagra_unsol_event,
8972 .init_hook = alc883_tagra_automute,
8973 },
8974 [ALC883_TARGA_2ch_DIG] = {
8975 .mixers = { alc883_tagra_2ch_mixer},
8976 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8977 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8978 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008979 .adc_nids = alc883_adc_nids_alt,
8980 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008981 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008982 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8983 .channel_mode = alc883_3ST_2ch_modes,
8984 .input_mux = &alc883_capture_source,
8985 .unsol_event = alc883_tagra_unsol_event,
8986 .init_hook = alc883_tagra_automute,
8987 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008988 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008989 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008990 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8991 * and the headphone jack. Turn this on and rely on the
8992 * standard mute methods whenever the user wants to turn
8993 * these outputs off.
8994 */
8995 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8996 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8997 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008998 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8999 .channel_mode = alc883_3ST_2ch_modes,
9000 .input_mux = &alc883_capture_source,
9001 },
Tobin Davis2880a862007-08-07 11:50:26 +02009002 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009003 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009004 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009005 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9006 .dac_nids = alc883_dac_nids,
9007 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009008 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9009 .channel_mode = alc883_3ST_2ch_modes,
9010 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02009011 .unsol_event = alc883_acer_aspire_unsol_event,
9012 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009013 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009014 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009015 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009016 alc883_chmode_mixer },
9017 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9018 alc888_acer_aspire_4930g_verbs },
9019 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9020 .dac_nids = alc883_dac_nids,
9021 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9022 .adc_nids = alc883_adc_nids_rev,
9023 .capsrc_nids = alc883_capsrc_nids_rev,
9024 .dig_out_nid = ALC883_DIGOUT_NID,
9025 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9026 .channel_mode = alc883_3ST_6ch_modes,
9027 .need_dac_fix = 1,
9028 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009029 ARRAY_SIZE(alc888_2_capture_sources),
9030 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009031 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
9032 .init_hook = alc888_acer_aspire_4930g_automute,
9033 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009034 [ALC883_MEDION] = {
9035 .mixers = { alc883_fivestack_mixer,
9036 alc883_chmode_mixer },
9037 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009038 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009039 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9040 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009041 .adc_nids = alc883_adc_nids_alt,
9042 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009043 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9044 .channel_mode = alc883_sixstack_modes,
9045 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009046 },
Kailang Yang272a5272007-05-14 11:00:38 +02009047 [ALC883_MEDION_MD2] = {
9048 .mixers = { alc883_medion_md2_mixer},
9049 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9050 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9051 .dac_nids = alc883_dac_nids,
9052 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009053 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9054 .channel_mode = alc883_3ST_2ch_modes,
9055 .input_mux = &alc883_capture_source,
9056 .unsol_event = alc883_medion_md2_unsol_event,
9057 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02009058 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009059 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009060 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009061 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9062 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9063 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009064 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9065 .channel_mode = alc883_3ST_2ch_modes,
9066 .input_mux = &alc883_capture_source,
9067 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009068 [ALC883_CLEVO_M720] = {
9069 .mixers = { alc883_clevo_m720_mixer },
9070 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009071 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9072 .dac_nids = alc883_dac_nids,
9073 .dig_out_nid = ALC883_DIGOUT_NID,
9074 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9075 .channel_mode = alc883_3ST_2ch_modes,
9076 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009077 .unsol_event = alc883_clevo_m720_unsol_event,
9078 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01009079 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009080 [ALC883_LENOVO_101E_2ch] = {
9081 .mixers = { alc883_lenovo_101e_2ch_mixer},
9082 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9083 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9084 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009085 .adc_nids = alc883_adc_nids_alt,
9086 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009087 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9088 .channel_mode = alc883_3ST_2ch_modes,
9089 .input_mux = &alc883_lenovo_101e_capture_source,
9090 .unsol_event = alc883_lenovo_101e_unsol_event,
9091 .init_hook = alc883_lenovo_101e_all_automute,
9092 },
Kailang Yang272a5272007-05-14 11:00:38 +02009093 [ALC883_LENOVO_NB0763] = {
9094 .mixers = { alc883_lenovo_nb0763_mixer },
9095 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9096 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9097 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009098 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9099 .channel_mode = alc883_3ST_2ch_modes,
9100 .need_dac_fix = 1,
9101 .input_mux = &alc883_lenovo_nb0763_capture_source,
9102 .unsol_event = alc883_medion_md2_unsol_event,
9103 .init_hook = alc883_medion_md2_automute,
9104 },
9105 [ALC888_LENOVO_MS7195_DIG] = {
9106 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9107 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9108 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9109 .dac_nids = alc883_dac_nids,
9110 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009111 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9112 .channel_mode = alc883_3ST_6ch_modes,
9113 .need_dac_fix = 1,
9114 .input_mux = &alc883_capture_source,
9115 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9116 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009117 },
9118 [ALC883_HAIER_W66] = {
9119 .mixers = { alc883_tagra_2ch_mixer},
9120 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9121 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9122 .dac_nids = alc883_dac_nids,
9123 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009124 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9125 .channel_mode = alc883_3ST_2ch_modes,
9126 .input_mux = &alc883_capture_source,
9127 .unsol_event = alc883_haier_w66_unsol_event,
9128 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009129 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009130 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009131 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009132 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009133 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9134 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009135 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9136 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009137 .need_dac_fix = 1,
9138 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009139 .unsol_event = alc888_3st_hp_unsol_event,
9140 .init_hook = alc888_3st_hp_front_automute,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009141 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009142 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009143 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009144 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9145 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9146 .dac_nids = alc883_dac_nids,
9147 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009148 .dig_in_nid = ALC883_DIGIN_NID,
9149 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9150 .channel_mode = alc883_sixstack_modes,
9151 .input_mux = &alc883_capture_source,
9152 .unsol_event = alc888_6st_dell_unsol_event,
9153 .init_hook = alc888_6st_dell_front_automute,
9154 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009155 [ALC883_MITAC] = {
9156 .mixers = { alc883_mitac_mixer },
9157 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9158 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9159 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009160 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9161 .channel_mode = alc883_3ST_2ch_modes,
9162 .input_mux = &alc883_capture_source,
9163 .unsol_event = alc883_mitac_unsol_event,
9164 .init_hook = alc883_mitac_automute,
9165 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009166 [ALC883_FUJITSU_PI2515] = {
9167 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9168 .init_verbs = { alc883_init_verbs,
9169 alc883_2ch_fujitsu_pi2515_verbs},
9170 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9171 .dac_nids = alc883_dac_nids,
9172 .dig_out_nid = ALC883_DIGOUT_NID,
9173 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9174 .channel_mode = alc883_3ST_2ch_modes,
9175 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9176 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
9177 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
9178 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009179 [ALC888_FUJITSU_XA3530] = {
9180 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9181 .init_verbs = { alc883_init_verbs,
9182 alc888_fujitsu_xa3530_verbs },
9183 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9184 .dac_nids = alc883_dac_nids,
9185 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9186 .adc_nids = alc883_adc_nids_rev,
9187 .capsrc_nids = alc883_capsrc_nids_rev,
9188 .dig_out_nid = ALC883_DIGOUT_NID,
9189 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9190 .channel_mode = alc888_4ST_8ch_intel_modes,
9191 .num_mux_defs =
9192 ARRAY_SIZE(alc888_2_capture_sources),
9193 .input_mux = alc888_2_capture_sources,
9194 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
9195 .init_hook = alc888_fujitsu_xa3530_automute,
9196 },
Kailang Yange2757d52008-08-26 13:17:46 +02009197 [ALC888_LENOVO_SKY] = {
9198 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9199 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9200 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9201 .dac_nids = alc883_dac_nids,
9202 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009203 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9204 .channel_mode = alc883_sixstack_modes,
9205 .need_dac_fix = 1,
9206 .input_mux = &alc883_lenovo_sky_capture_source,
9207 .unsol_event = alc883_lenovo_sky_unsol_event,
9208 .init_hook = alc888_lenovo_sky_front_automute,
9209 },
9210 [ALC888_ASUS_M90V] = {
9211 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9212 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9213 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9214 .dac_nids = alc883_dac_nids,
9215 .dig_out_nid = ALC883_DIGOUT_NID,
9216 .dig_in_nid = ALC883_DIGIN_NID,
9217 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9218 .channel_mode = alc883_3ST_6ch_modes,
9219 .need_dac_fix = 1,
9220 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9221 .unsol_event = alc883_mode2_unsol_event,
9222 .init_hook = alc883_mode2_inithook,
9223 },
9224 [ALC888_ASUS_EEE1601] = {
9225 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009226 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009227 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9228 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9229 .dac_nids = alc883_dac_nids,
9230 .dig_out_nid = ALC883_DIGOUT_NID,
9231 .dig_in_nid = ALC883_DIGIN_NID,
9232 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9233 .channel_mode = alc883_3ST_2ch_modes,
9234 .need_dac_fix = 1,
9235 .input_mux = &alc883_asus_eee1601_capture_source,
9236 .unsol_event = alc883_eee1601_unsol_event,
9237 .init_hook = alc883_eee1601_inithook,
9238 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009239 [ALC1200_ASUS_P5Q] = {
9240 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9241 .init_verbs = { alc883_init_verbs },
9242 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9243 .dac_nids = alc883_dac_nids,
9244 .dig_out_nid = ALC1200_DIGOUT_NID,
9245 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009246 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009247 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9248 .channel_mode = alc883_sixstack_modes,
9249 .input_mux = &alc883_capture_source,
9250 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009251};
9252
9253
9254/*
9255 * BIOS auto configuration
9256 */
9257static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9258 hda_nid_t nid, int pin_type,
9259 int dac_idx)
9260{
9261 /* set as output */
9262 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009263 int idx;
9264
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009265 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009266 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9267 idx = 4;
9268 else
9269 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009270 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9271
9272}
9273
9274static void alc883_auto_init_multi_out(struct hda_codec *codec)
9275{
9276 struct alc_spec *spec = codec->spec;
9277 int i;
9278
9279 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009280 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009281 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009282 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009283 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009284 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009285 }
9286}
9287
9288static void alc883_auto_init_hp_out(struct hda_codec *codec)
9289{
9290 struct alc_spec *spec = codec->spec;
9291 hda_nid_t pin;
9292
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009293 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009294 if (pin) /* connect to front */
9295 /* use dac 0 */
9296 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009297 pin = spec->autocfg.speaker_pins[0];
9298 if (pin)
9299 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009300}
9301
9302#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9303#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9304
9305static void alc883_auto_init_analog_input(struct hda_codec *codec)
9306{
9307 struct alc_spec *spec = codec->spec;
9308 int i;
9309
9310 for (i = 0; i < AUTO_PIN_LAST; i++) {
9311 hda_nid_t nid = spec->autocfg.input_pins[i];
9312 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009313 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009314 if (nid != ALC883_PIN_CD_NID &&
9315 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009316 snd_hda_codec_write(codec, nid, 0,
9317 AC_VERB_SET_AMP_GAIN_MUTE,
9318 AMP_OUT_MUTE);
9319 }
9320 }
9321}
9322
Takashi Iwaif511b012008-08-15 16:46:42 +02009323#define alc883_auto_init_input_src alc882_auto_init_input_src
9324
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009325/* almost identical with ALC880 parser... */
9326static int alc883_parse_auto_config(struct hda_codec *codec)
9327{
9328 struct alc_spec *spec = codec->spec;
9329 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009330 struct auto_pin_cfg *cfg = &spec->autocfg;
9331 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009332
9333 if (err < 0)
9334 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009335 else if (!err)
9336 return 0; /* no config found */
9337
9338 err = alc_auto_add_mic_boost(codec);
9339 if (err < 0)
9340 return err;
9341
9342 /* hack - override the init verbs */
9343 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009344
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009345 /* setup input_mux for ALC889 */
9346 if (codec->vendor_id == 0x10ec0889) {
9347 /* digital-mic input pin is excluded in alc880_auto_create..()
9348 * because it's under 0x18
9349 */
9350 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9351 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9352 struct hda_input_mux *imux = &spec->private_imux[0];
9353 for (i = 1; i < 3; i++)
9354 memcpy(&spec->private_imux[i],
9355 &spec->private_imux[0],
9356 sizeof(spec->private_imux[0]));
9357 imux->items[imux->num_items].label = "Int DMic";
9358 imux->items[imux->num_items].index = 0x0b;
9359 imux->num_items++;
9360 spec->num_mux_defs = 3;
9361 spec->input_mux = spec->private_imux;
9362 }
9363 }
9364
Takashi Iwai776e1842007-08-29 15:07:11 +02009365 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009366}
9367
9368/* additional initialization for auto-configuration model */
9369static void alc883_auto_init(struct hda_codec *codec)
9370{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009371 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009372 alc883_auto_init_multi_out(codec);
9373 alc883_auto_init_hp_out(codec);
9374 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009375 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009376 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009377 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009378}
9379
9380static int patch_alc883(struct hda_codec *codec)
9381{
9382 struct alc_spec *spec;
9383 int err, board_config;
9384
9385 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9386 if (spec == NULL)
9387 return -ENOMEM;
9388
9389 codec->spec = spec;
9390
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009391 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9392
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009393 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9394 alc883_models,
9395 alc883_cfg_tbl);
9396 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009397 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9398 "trying auto-probe from BIOS...\n");
9399 board_config = ALC883_AUTO;
9400 }
9401
9402 if (board_config == ALC883_AUTO) {
9403 /* automatic parse from the BIOS config */
9404 err = alc883_parse_auto_config(codec);
9405 if (err < 0) {
9406 alc_free(codec);
9407 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009408 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009409 printk(KERN_INFO
9410 "hda_codec: Cannot set up configuration "
9411 "from BIOS. Using base mode...\n");
9412 board_config = ALC883_3ST_2ch_DIG;
9413 }
9414 }
9415
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009416 err = snd_hda_attach_beep_device(codec, 0x1);
9417 if (err < 0) {
9418 alc_free(codec);
9419 return err;
9420 }
9421
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009422 if (board_config != ALC883_AUTO)
9423 setup_preset(spec, &alc883_presets[board_config]);
9424
Kailang Yang2f893282008-05-27 12:14:47 +02009425 switch (codec->vendor_id) {
9426 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009427 if (codec->revision_id == 0x100101) {
9428 spec->stream_name_analog = "ALC1200 Analog";
9429 spec->stream_name_digital = "ALC1200 Digital";
9430 } else {
9431 spec->stream_name_analog = "ALC888 Analog";
9432 spec->stream_name_digital = "ALC888 Digital";
9433 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009434 if (!spec->num_adc_nids) {
9435 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9436 spec->adc_nids = alc883_adc_nids;
9437 }
9438 if (!spec->capsrc_nids)
9439 spec->capsrc_nids = alc883_capsrc_nids;
9440 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009441 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009442 break;
9443 case 0x10ec0889:
9444 spec->stream_name_analog = "ALC889 Analog";
9445 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009446 if (!spec->num_adc_nids) {
9447 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9448 spec->adc_nids = alc889_adc_nids;
9449 }
9450 if (!spec->capsrc_nids)
9451 spec->capsrc_nids = alc889_capsrc_nids;
9452 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9453 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009454 break;
9455 default:
9456 spec->stream_name_analog = "ALC883 Analog";
9457 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009458 if (!spec->num_adc_nids) {
9459 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9460 spec->adc_nids = alc883_adc_nids;
9461 }
9462 if (!spec->capsrc_nids)
9463 spec->capsrc_nids = alc883_capsrc_nids;
9464 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009465 break;
9466 }
9467
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009468 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9469 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009470 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009471
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009472 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9473 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9474
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009475 if (!spec->cap_mixer)
9476 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009477 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009478
Takashi Iwai2134ea42008-01-10 16:53:55 +01009479 spec->vmaster_nid = 0x0c;
9480
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009481 codec->patch_ops = alc_patch_ops;
9482 if (board_config == ALC883_AUTO)
9483 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009484
Takashi Iwaicb53c622007-08-10 17:21:45 +02009485#ifdef CONFIG_SND_HDA_POWER_SAVE
9486 if (!spec->loopback.amplist)
9487 spec->loopback.amplist = alc883_loopbacks;
9488#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009489 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009490
9491 return 0;
9492}
9493
9494/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009495 * ALC262 support
9496 */
9497
9498#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9499#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9500
9501#define alc262_dac_nids alc260_dac_nids
9502#define alc262_adc_nids alc882_adc_nids
9503#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009504#define alc262_capsrc_nids alc882_capsrc_nids
9505#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009506
9507#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009508#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009509
Kailang Yang4e555fe2008-08-26 13:05:55 +02009510static hda_nid_t alc262_dmic_adc_nids[1] = {
9511 /* ADC0 */
9512 0x09
9513};
9514
9515static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9516
Kailang Yangdf694da2005-12-05 19:42:22 +01009517static struct snd_kcontrol_new alc262_base_mixer[] = {
9518 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9519 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9520 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9521 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9522 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9523 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9524 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9525 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009526 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009527 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9528 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009529 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009530 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9531 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9532 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9533 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009534 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009535};
9536
Kailang Yangccc656c2006-10-17 12:32:26 +02009537static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9538 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9539 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9540 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9541 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9542 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9543 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9544 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9545 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009546 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009547 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9548 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009549 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009550 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9552 { } /* end */
9553};
9554
Takashi Iwaice875f02008-01-28 18:17:43 +01009555/* update HP, line and mono-out pins according to the master switch */
9556static void alc262_hp_master_update(struct hda_codec *codec)
9557{
9558 struct alc_spec *spec = codec->spec;
9559 int val = spec->master_sw;
9560
9561 /* HP & line-out */
9562 snd_hda_codec_write_cache(codec, 0x1b, 0,
9563 AC_VERB_SET_PIN_WIDGET_CONTROL,
9564 val ? PIN_HP : 0);
9565 snd_hda_codec_write_cache(codec, 0x15, 0,
9566 AC_VERB_SET_PIN_WIDGET_CONTROL,
9567 val ? PIN_HP : 0);
9568 /* mono (speaker) depending on the HP jack sense */
9569 val = val && !spec->jack_present;
9570 snd_hda_codec_write_cache(codec, 0x16, 0,
9571 AC_VERB_SET_PIN_WIDGET_CONTROL,
9572 val ? PIN_OUT : 0);
9573}
9574
9575static void alc262_hp_bpc_automute(struct hda_codec *codec)
9576{
9577 struct alc_spec *spec = codec->spec;
9578 unsigned int presence;
9579 presence = snd_hda_codec_read(codec, 0x1b, 0,
9580 AC_VERB_GET_PIN_SENSE, 0);
9581 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9582 alc262_hp_master_update(codec);
9583}
9584
9585static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9586{
9587 if ((res >> 26) != ALC880_HP_EVENT)
9588 return;
9589 alc262_hp_bpc_automute(codec);
9590}
9591
9592static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9593{
9594 struct alc_spec *spec = codec->spec;
9595 unsigned int presence;
9596 presence = snd_hda_codec_read(codec, 0x15, 0,
9597 AC_VERB_GET_PIN_SENSE, 0);
9598 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9599 alc262_hp_master_update(codec);
9600}
9601
9602static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9603 unsigned int res)
9604{
9605 if ((res >> 26) != ALC880_HP_EVENT)
9606 return;
9607 alc262_hp_wildwest_automute(codec);
9608}
9609
9610static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9611 struct snd_ctl_elem_value *ucontrol)
9612{
9613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9614 struct alc_spec *spec = codec->spec;
9615 *ucontrol->value.integer.value = spec->master_sw;
9616 return 0;
9617}
9618
9619static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9620 struct snd_ctl_elem_value *ucontrol)
9621{
9622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9623 struct alc_spec *spec = codec->spec;
9624 int val = !!*ucontrol->value.integer.value;
9625
9626 if (val == spec->master_sw)
9627 return 0;
9628 spec->master_sw = val;
9629 alc262_hp_master_update(codec);
9630 return 1;
9631}
9632
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009633static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009634 {
9635 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9636 .name = "Master Playback Switch",
9637 .info = snd_ctl_boolean_mono_info,
9638 .get = alc262_hp_master_sw_get,
9639 .put = alc262_hp_master_sw_put,
9640 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009641 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9642 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009644 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9645 HDA_OUTPUT),
9646 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9647 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9649 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009650 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009651 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9652 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009653 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009654 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9655 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9656 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9657 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009658 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9659 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9660 { } /* end */
9661};
9662
Kailang Yangcd7509a2007-01-26 18:33:17 +01009663static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009664 {
9665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9666 .name = "Master Playback Switch",
9667 .info = snd_ctl_boolean_mono_info,
9668 .get = alc262_hp_master_sw_get,
9669 .put = alc262_hp_master_sw_put,
9670 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009671 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9672 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9673 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9674 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009675 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9676 HDA_OUTPUT),
9677 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9678 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009679 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9680 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009681 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009682 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9683 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9684 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9685 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009686 { } /* end */
9687};
9688
9689static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9690 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9691 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009692 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009693 { } /* end */
9694};
9695
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009696/* mute/unmute internal speaker according to the hp jack and mute state */
9697static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9698{
9699 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009700
9701 if (force || !spec->sense_updated) {
9702 unsigned int present;
9703 present = snd_hda_codec_read(codec, 0x15, 0,
9704 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009705 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009706 spec->sense_updated = 1;
9707 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009708 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9709 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009710}
9711
9712static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9713 unsigned int res)
9714{
9715 if ((res >> 26) != ALC880_HP_EVENT)
9716 return;
9717 alc262_hp_t5735_automute(codec, 1);
9718}
9719
9720static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9721{
9722 alc262_hp_t5735_automute(codec, 1);
9723}
9724
9725static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009726 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9727 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009728 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9729 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9732 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9733 { } /* end */
9734};
9735
9736static struct hda_verb alc262_hp_t5735_verbs[] = {
9737 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9738 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9739
9740 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9741 { }
9742};
9743
Kailang Yang8c427222008-01-10 13:03:59 +01009744static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009745 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9746 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009747 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9748 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009749 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9750 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9751 { } /* end */
9752};
9753
9754static struct hda_verb alc262_hp_rp5700_verbs[] = {
9755 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9756 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9757 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9758 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9760 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9761 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9762 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9764 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9765 {}
9766};
9767
9768static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9769 .num_items = 1,
9770 .items = {
9771 { "Line", 0x1 },
9772 },
9773};
9774
Takashi Iwai0724ea22007-08-23 00:31:43 +02009775/* bind hp and internal speaker mute (with plug check) */
9776static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9777 struct snd_ctl_elem_value *ucontrol)
9778{
9779 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9780 long *valp = ucontrol->value.integer.value;
9781 int change;
9782
9783 /* change hp mute */
9784 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9785 HDA_AMP_MUTE,
9786 valp[0] ? 0 : HDA_AMP_MUTE);
9787 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9788 HDA_AMP_MUTE,
9789 valp[1] ? 0 : HDA_AMP_MUTE);
9790 if (change) {
9791 /* change speaker according to HP jack state */
9792 struct alc_spec *spec = codec->spec;
9793 unsigned int mute;
9794 if (spec->jack_present)
9795 mute = HDA_AMP_MUTE;
9796 else
9797 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9798 HDA_OUTPUT, 0);
9799 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9800 HDA_AMP_MUTE, mute);
9801 }
9802 return change;
9803}
Takashi Iwai5b319542007-07-26 11:49:22 +02009804
Kailang Yang272a5272007-05-14 11:00:38 +02009805static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009806 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9807 {
9808 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9809 .name = "Master Playback Switch",
9810 .info = snd_hda_mixer_amp_switch_info,
9811 .get = snd_hda_mixer_amp_switch_get,
9812 .put = alc262_sony_master_sw_put,
9813 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9814 },
Kailang Yang272a5272007-05-14 11:00:38 +02009815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9816 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9817 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9818 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9819 { } /* end */
9820};
9821
Kailang Yang83c34212007-07-05 11:43:05 +02009822static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9823 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9824 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9825 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9828 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9829 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9830 { } /* end */
9831};
Kailang Yang272a5272007-05-14 11:00:38 +02009832
Tony Vroonba340e82009-02-02 19:01:30 +00009833static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9834 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9835 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9836 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9837 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9838 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9839 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9840 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9841 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9842 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9843 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9844 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9845 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9846 { } /* end */
9847};
9848
9849static struct hda_verb alc262_tyan_verbs[] = {
9850 /* Headphone automute */
9851 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9852 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9853 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9854
9855 /* P11 AUX_IN, white 4-pin connector */
9856 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9857 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9858 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9859 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9860
9861 {}
9862};
9863
9864/* unsolicited event for HP jack sensing */
9865static void alc262_tyan_automute(struct hda_codec *codec)
9866{
9867 unsigned int mute;
9868 unsigned int present;
9869
9870 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9871 present = snd_hda_codec_read(codec, 0x1b, 0,
9872 AC_VERB_GET_PIN_SENSE, 0);
9873 present = (present & 0x80000000) != 0;
9874 if (present) {
9875 /* mute line output on ATX panel */
9876 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9877 HDA_AMP_MUTE, HDA_AMP_MUTE);
9878 } else {
9879 /* unmute line output if necessary */
9880 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9881 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9882 HDA_AMP_MUTE, mute);
9883 }
9884}
9885
9886static void alc262_tyan_unsol_event(struct hda_codec *codec,
9887 unsigned int res)
9888{
9889 if ((res >> 26) != ALC880_HP_EVENT)
9890 return;
9891 alc262_tyan_automute(codec);
9892}
9893
Kailang Yangdf694da2005-12-05 19:42:22 +01009894#define alc262_capture_mixer alc882_capture_mixer
9895#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9896
9897/*
9898 * generic initialization of ADC, input mixers and output mixers
9899 */
9900static struct hda_verb alc262_init_verbs[] = {
9901 /*
9902 * Unmute ADC0-2 and set the default input to mic-in
9903 */
9904 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9906 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9907 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9908 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9909 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9910
Takashi Iwaicb53c622007-08-10 17:21:45 +02009911 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009912 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009913 * Note: PASD motherboards uses the Line In 2 as the input for
9914 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009915 */
9916 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009917 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9921 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009922
9923 /*
9924 * Set up output mixers (0x0c - 0x0e)
9925 */
9926 /* set vol=0 to output mixers */
9927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9928 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9929 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9930 /* set up input amps for analog loopback */
9931 /* Amp Indices: DAC = 0, mixer = 1 */
9932 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9933 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9934 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9935 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9937 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9938
9939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9940 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9941 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9942 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9943 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9944 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9945
9946 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9948 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9949 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9950 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009951
Kailang Yangdf694da2005-12-05 19:42:22 +01009952 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9953 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009954
Kailang Yangdf694da2005-12-05 19:42:22 +01009955 /* FIXME: use matrix-type input source selection */
9956 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9957 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9958 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9959 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9960 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9961 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9962 /* Input mixer2 */
9963 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9964 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9965 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9966 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9967 /* Input mixer3 */
9968 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009972
9973 { }
9974};
9975
Kailang Yang4e555fe2008-08-26 13:05:55 +02009976static struct hda_verb alc262_eapd_verbs[] = {
9977 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9978 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9979 { }
9980};
9981
Kailang Yangccc656c2006-10-17 12:32:26 +02009982static struct hda_verb alc262_hippo_unsol_verbs[] = {
9983 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9984 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9985 {}
9986};
9987
9988static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9989 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9990 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9991 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9992
9993 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9994 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9995 {}
9996};
9997
Kailang Yang272a5272007-05-14 11:00:38 +02009998static struct hda_verb alc262_sony_unsol_verbs[] = {
9999 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10000 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10001 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10002
10003 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010005 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010006};
10007
Kailang Yang4e555fe2008-08-26 13:05:55 +020010008static struct hda_input_mux alc262_dmic_capture_source = {
10009 .num_items = 2,
10010 .items = {
10011 { "Int DMic", 0x9 },
10012 { "Mic", 0x0 },
10013 },
10014};
10015
10016static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10017 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10018 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010022 { } /* end */
10023};
10024
10025static struct hda_verb alc262_toshiba_s06_verbs[] = {
10026 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10027 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10029 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10030 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10031 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10032 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10033 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10034 {}
10035};
10036
10037static void alc262_dmic_automute(struct hda_codec *codec)
10038{
10039 unsigned int present;
10040
10041 present = snd_hda_codec_read(codec, 0x18, 0,
10042 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10043 snd_hda_codec_write(codec, 0x22, 0,
10044 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10045}
10046
10047/* toggle speaker-output according to the hp-jack state */
10048static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
10049{
10050 unsigned int present;
10051 unsigned char bits;
10052
10053 present = snd_hda_codec_read(codec, 0x15, 0,
10054 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10055 bits = present ? 0 : PIN_OUT;
10056 snd_hda_codec_write(codec, 0x14, 0,
10057 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
10058}
10059
10060
10061
10062/* unsolicited event for HP jack sensing */
10063static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10064 unsigned int res)
10065{
10066 if ((res >> 26) == ALC880_HP_EVENT)
10067 alc262_toshiba_s06_speaker_automute(codec);
10068 if ((res >> 26) == ALC880_MIC_EVENT)
10069 alc262_dmic_automute(codec);
10070
10071}
10072
10073static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10074{
10075 alc262_toshiba_s06_speaker_automute(codec);
10076 alc262_dmic_automute(codec);
10077}
10078
Kailang Yangccc656c2006-10-17 12:32:26 +020010079/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +020010080static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +020010081{
10082 struct alc_spec *spec = codec->spec;
10083 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +020010084 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +020010085
Takashi Iwai5b319542007-07-26 11:49:22 +020010086 /* need to execute and sync at first */
10087 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10088 present = snd_hda_codec_read(codec, 0x15, 0,
10089 AC_VERB_GET_PIN_SENSE, 0);
10090 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +020010091 if (spec->jack_present) {
10092 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +020010093 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10094 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +020010095 } else {
10096 /* unmute internal speaker if necessary */
10097 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +020010098 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10099 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +020010100 }
10101}
10102
10103/* unsolicited event for HP jack sensing */
10104static void alc262_hippo_unsol_event(struct hda_codec *codec,
10105 unsigned int res)
10106{
10107 if ((res >> 26) != ALC880_HP_EVENT)
10108 return;
Takashi Iwai5b319542007-07-26 11:49:22 +020010109 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +020010110}
10111
Takashi Iwai5b319542007-07-26 11:49:22 +020010112static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +020010113{
Kailang Yangccc656c2006-10-17 12:32:26 +020010114 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +020010115 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +020010116
Takashi Iwai5b319542007-07-26 11:49:22 +020010117 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10118 present = snd_hda_codec_read(codec, 0x1b, 0,
10119 AC_VERB_GET_PIN_SENSE, 0);
10120 present = (present & 0x80000000) != 0;
10121 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +020010122 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +020010123 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10124 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +020010125 } else {
10126 /* unmute internal speaker if necessary */
10127 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +020010128 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10129 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +020010130 }
10131}
10132
10133/* unsolicited event for HP jack sensing */
10134static void alc262_hippo1_unsol_event(struct hda_codec *codec,
10135 unsigned int res)
10136{
10137 if ((res >> 26) != ALC880_HP_EVENT)
10138 return;
Takashi Iwai5b319542007-07-26 11:49:22 +020010139 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +020010140}
10141
Takashi Iwai834be882006-03-01 14:16:17 +010010142/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010143 * nec model
10144 * 0x15 = headphone
10145 * 0x16 = internal speaker
10146 * 0x18 = external mic
10147 */
10148
10149static struct snd_kcontrol_new alc262_nec_mixer[] = {
10150 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10151 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10152
10153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10155 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10156
10157 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10158 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10159 { } /* end */
10160};
10161
10162static struct hda_verb alc262_nec_verbs[] = {
10163 /* Unmute Speaker */
10164 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10165
10166 /* Headphone */
10167 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10168 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10169
10170 /* External mic to headphone */
10171 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10172 /* External mic to speaker */
10173 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10174 {}
10175};
10176
10177/*
Takashi Iwai834be882006-03-01 14:16:17 +010010178 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010179 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10180 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010181 */
10182
10183#define ALC_HP_EVENT 0x37
10184
10185static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10186 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10187 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010188 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10189 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010190 {}
10191};
10192
Jiang zhe0e31daf2008-03-20 12:12:39 +010010193static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10194 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10195 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10196 {}
10197};
10198
Takashi Iwai834be882006-03-01 14:16:17 +010010199static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010200 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010201 .items = {
10202 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010203 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010204 { "CD", 0x4 },
10205 },
10206};
10207
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010208static struct hda_input_mux alc262_HP_capture_source = {
10209 .num_items = 5,
10210 .items = {
10211 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010212 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010213 { "Line", 0x2 },
10214 { "CD", 0x4 },
10215 { "AUX IN", 0x6 },
10216 },
10217};
10218
zhejiangaccbe492007-08-31 12:36:05 +020010219static struct hda_input_mux alc262_HP_D7000_capture_source = {
10220 .num_items = 4,
10221 .items = {
10222 { "Mic", 0x0 },
10223 { "Front Mic", 0x2 },
10224 { "Line", 0x1 },
10225 { "CD", 0x4 },
10226 },
10227};
10228
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010229/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010230static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10231{
10232 struct alc_spec *spec = codec->spec;
10233 unsigned int mute;
10234
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010235 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010236 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010237 /* need to execute and sync at first */
10238 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010239 /* check laptop HP jack */
10240 present = snd_hda_codec_read(codec, 0x14, 0,
10241 AC_VERB_GET_PIN_SENSE, 0);
10242 /* need to execute and sync at first */
10243 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10244 /* check docking HP jack */
10245 present |= snd_hda_codec_read(codec, 0x1b, 0,
10246 AC_VERB_GET_PIN_SENSE, 0);
10247 if (present & AC_PINSENSE_PRESENCE)
10248 spec->jack_present = 1;
10249 else
10250 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010251 spec->sense_updated = 1;
10252 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010253 /* unmute internal speaker only if both HPs are unplugged and
10254 * master switch is on
10255 */
10256 if (spec->jack_present)
10257 mute = HDA_AMP_MUTE;
10258 else
Takashi Iwai834be882006-03-01 14:16:17 +010010259 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010260 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10261 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010262}
10263
10264/* unsolicited event for HP jack sensing */
10265static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10266 unsigned int res)
10267{
10268 if ((res >> 26) != ALC_HP_EVENT)
10269 return;
10270 alc262_fujitsu_automute(codec, 1);
10271}
10272
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010273static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10274{
10275 alc262_fujitsu_automute(codec, 1);
10276}
10277
Takashi Iwai834be882006-03-01 14:16:17 +010010278/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010279static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10280 .ops = &snd_hda_bind_vol,
10281 .values = {
10282 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10283 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10284 0
10285 },
10286};
Takashi Iwai834be882006-03-01 14:16:17 +010010287
Jiang zhe0e31daf2008-03-20 12:12:39 +010010288/* mute/unmute internal speaker according to the hp jack and mute state */
10289static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10290{
10291 struct alc_spec *spec = codec->spec;
10292 unsigned int mute;
10293
10294 if (force || !spec->sense_updated) {
10295 unsigned int present_int_hp;
10296 /* need to execute and sync at first */
10297 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10298 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10299 AC_VERB_GET_PIN_SENSE, 0);
10300 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10301 spec->sense_updated = 1;
10302 }
10303 if (spec->jack_present) {
10304 /* mute internal speaker */
10305 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10306 HDA_AMP_MUTE, HDA_AMP_MUTE);
10307 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10308 HDA_AMP_MUTE, HDA_AMP_MUTE);
10309 } else {
10310 /* unmute internal speaker if necessary */
10311 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10312 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10313 HDA_AMP_MUTE, mute);
10314 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10315 HDA_AMP_MUTE, mute);
10316 }
10317}
10318
10319/* unsolicited event for HP jack sensing */
10320static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10321 unsigned int res)
10322{
10323 if ((res >> 26) != ALC_HP_EVENT)
10324 return;
10325 alc262_lenovo_3000_automute(codec, 1);
10326}
10327
Takashi Iwai834be882006-03-01 14:16:17 +010010328/* bind hp and internal speaker mute (with plug check) */
10329static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10330 struct snd_ctl_elem_value *ucontrol)
10331{
10332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10333 long *valp = ucontrol->value.integer.value;
10334 int change;
10335
Tony Vroon5d9fab22008-03-14 17:09:18 +010010336 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10337 HDA_AMP_MUTE,
10338 valp ? 0 : HDA_AMP_MUTE);
10339 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10340 HDA_AMP_MUTE,
10341 valp ? 0 : HDA_AMP_MUTE);
10342
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010343 if (change)
10344 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010345 return change;
10346}
10347
10348static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010349 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010350 {
10351 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10352 .name = "Master Playback Switch",
10353 .info = snd_hda_mixer_amp_switch_info,
10354 .get = snd_hda_mixer_amp_switch_get,
10355 .put = alc262_fujitsu_master_sw_put,
10356 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10357 },
10358 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10359 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10360 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10361 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10362 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010363 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10364 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10365 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010366 { } /* end */
10367};
10368
Jiang zhe0e31daf2008-03-20 12:12:39 +010010369/* bind hp and internal speaker mute (with plug check) */
10370static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10371 struct snd_ctl_elem_value *ucontrol)
10372{
10373 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10374 long *valp = ucontrol->value.integer.value;
10375 int change;
10376
10377 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10378 HDA_AMP_MUTE,
10379 valp ? 0 : HDA_AMP_MUTE);
10380
10381 if (change)
10382 alc262_lenovo_3000_automute(codec, 0);
10383 return change;
10384}
10385
10386static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10387 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10388 {
10389 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10390 .name = "Master Playback Switch",
10391 .info = snd_hda_mixer_amp_switch_info,
10392 .get = snd_hda_mixer_amp_switch_get,
10393 .put = alc262_lenovo_3000_master_sw_put,
10394 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10395 },
10396 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10397 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10398 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10400 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10401 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10402 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10403 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10404 { } /* end */
10405};
10406
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010407static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10408 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10409 {
10410 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10411 .name = "Master Playback Switch",
10412 .info = snd_hda_mixer_amp_switch_info,
10413 .get = snd_hda_mixer_amp_switch_get,
10414 .put = alc262_sony_master_sw_put,
10415 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10416 },
10417 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10418 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10419 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10420 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10421 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10422 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10423 { } /* end */
10424};
10425
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010426/* additional init verbs for Benq laptops */
10427static struct hda_verb alc262_EAPD_verbs[] = {
10428 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10429 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10430 {}
10431};
10432
Kailang Yang83c34212007-07-05 11:43:05 +020010433static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10434 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10435 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10436
10437 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10438 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10439 {}
10440};
10441
Tobin Davisf651b502007-10-26 12:40:47 +020010442/* Samsung Q1 Ultra Vista model setup */
10443static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010444 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10445 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010446 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10447 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10448 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010449 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010450 { } /* end */
10451};
10452
10453static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010454 /* output mixer */
10455 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10456 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10458 /* speaker */
10459 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10460 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10461 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10462 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10463 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10467 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10468 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10469 /* internal mic */
10470 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10472 /* ADC, choose mic */
10473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10474 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10475 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10476 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10477 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10478 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10479 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10480 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10481 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010483 {}
10484};
10485
Tobin Davisf651b502007-10-26 12:40:47 +020010486/* mute/unmute internal speaker according to the hp jack and mute state */
10487static void alc262_ultra_automute(struct hda_codec *codec)
10488{
10489 struct alc_spec *spec = codec->spec;
10490 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010491
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010492 mute = 0;
10493 /* auto-mute only when HP is used as HP */
10494 if (!spec->cur_mux[0]) {
10495 unsigned int present;
10496 /* need to execute and sync at first */
10497 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10498 present = snd_hda_codec_read(codec, 0x15, 0,
10499 AC_VERB_GET_PIN_SENSE, 0);
10500 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10501 if (spec->jack_present)
10502 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010503 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010504 /* mute/unmute internal speaker */
10505 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10506 HDA_AMP_MUTE, mute);
10507 /* mute/unmute HP */
10508 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10509 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010510}
10511
10512/* unsolicited event for HP jack sensing */
10513static void alc262_ultra_unsol_event(struct hda_codec *codec,
10514 unsigned int res)
10515{
10516 if ((res >> 26) != ALC880_HP_EVENT)
10517 return;
10518 alc262_ultra_automute(codec);
10519}
10520
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010521static struct hda_input_mux alc262_ultra_capture_source = {
10522 .num_items = 2,
10523 .items = {
10524 { "Mic", 0x1 },
10525 { "Headphone", 0x7 },
10526 },
10527};
10528
10529static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10530 struct snd_ctl_elem_value *ucontrol)
10531{
10532 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10533 struct alc_spec *spec = codec->spec;
10534 int ret;
10535
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010536 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010537 if (!ret)
10538 return 0;
10539 /* reprogram the HP pin as mic or HP according to the input source */
10540 snd_hda_codec_write_cache(codec, 0x15, 0,
10541 AC_VERB_SET_PIN_WIDGET_CONTROL,
10542 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10543 alc262_ultra_automute(codec); /* mute/unmute HP */
10544 return ret;
10545}
10546
10547static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10548 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10549 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10550 {
10551 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10552 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010553 .info = alc_mux_enum_info,
10554 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010555 .put = alc262_ultra_mux_enum_put,
10556 },
10557 { } /* end */
10558};
10559
Kailang Yangdf694da2005-12-05 19:42:22 +010010560/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010561static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10562 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010563{
10564 hda_nid_t nid;
10565 int err;
10566
10567 spec->multiout.num_dacs = 1; /* only use one dac */
10568 spec->multiout.dac_nids = spec->private_dac_nids;
10569 spec->multiout.dac_nids[0] = 2;
10570
10571 nid = cfg->line_out_pins[0];
10572 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010573 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10574 "Front Playback Volume",
10575 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10576 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010577 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010578 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10579 "Front Playback Switch",
10580 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10581 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010582 return err;
10583 }
10584
Takashi Iwai82bc9552006-03-21 11:24:42 +010010585 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010586 if (nid) {
10587 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010588 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10589 "Speaker Playback Volume",
10590 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10591 HDA_OUTPUT));
10592 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010593 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010594 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10595 "Speaker Playback Switch",
10596 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10597 HDA_OUTPUT));
10598 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010599 return err;
10600 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010601 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10602 "Speaker Playback Switch",
10603 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10604 HDA_OUTPUT));
10605 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010606 return err;
10607 }
10608 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010609 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010610 if (nid) {
10611 /* spec->multiout.hp_nid = 2; */
10612 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010613 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10614 "Headphone Playback Volume",
10615 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10616 HDA_OUTPUT));
10617 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010618 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010619 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10620 "Headphone Playback Switch",
10621 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10622 HDA_OUTPUT));
10623 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010624 return err;
10625 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010626 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10627 "Headphone Playback Switch",
10628 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10629 HDA_OUTPUT));
10630 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010631 return err;
10632 }
10633 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010634 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010635}
10636
10637/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010638#define alc262_auto_create_analog_input_ctls \
10639 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010640
10641/*
10642 * generic initialization of ADC, input mixers and output mixers
10643 */
10644static struct hda_verb alc262_volume_init_verbs[] = {
10645 /*
10646 * Unmute ADC0-2 and set the default input to mic-in
10647 */
10648 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10650 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10651 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10652 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10653 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10654
Takashi Iwaicb53c622007-08-10 17:21:45 +020010655 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010656 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010657 * Note: PASD motherboards uses the Line In 2 as the input for
10658 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010659 */
10660 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010666
10667 /*
10668 * Set up output mixers (0x0c - 0x0f)
10669 */
10670 /* set vol=0 to output mixers */
10671 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10672 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10673 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010674
Kailang Yangdf694da2005-12-05 19:42:22 +010010675 /* set up input amps for analog loopback */
10676 /* Amp Indices: DAC = 0, mixer = 1 */
10677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10679 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10680 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10681 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10682 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10683
10684 /* FIXME: use matrix-type input source selection */
10685 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10686 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10687 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10688 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10689 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10691 /* Input mixer2 */
10692 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10693 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10694 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10695 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10696 /* Input mixer3 */
10697 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10698 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10699 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10700 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10701
10702 { }
10703};
10704
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010705static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10706 /*
10707 * Unmute ADC0-2 and set the default input to mic-in
10708 */
10709 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10711 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10712 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10713 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10714 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10715
Takashi Iwaicb53c622007-08-10 17:21:45 +020010716 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010717 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010718 * Note: PASD motherboards uses the Line In 2 as the input for
10719 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010720 */
10721 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10727 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010729
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010730 /*
10731 * Set up output mixers (0x0c - 0x0e)
10732 */
10733 /* set vol=0 to output mixers */
10734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10736 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10737
10738 /* set up input amps for analog loopback */
10739 /* Amp Indices: DAC = 0, mixer = 1 */
10740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10743 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10745 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10746
Takashi Iwaice875f02008-01-28 18:17:43 +010010747 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10750
10751 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10753
10754 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10755 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10756
10757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10758 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10760 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10761 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10762
10763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10764 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10766 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10767 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10768 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10769
10770
10771 /* FIXME: use matrix-type input source selection */
10772 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10773 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10774 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10775 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10776 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10777 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10778 /* Input mixer2 */
10779 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10780 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10781 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10782 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10783 /* Input mixer3 */
10784 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10785 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10786 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10787 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10788
Takashi Iwaice875f02008-01-28 18:17:43 +010010789 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10790
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010791 { }
10792};
10793
Kailang Yangcd7509a2007-01-26 18:33:17 +010010794static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10795 /*
10796 * Unmute ADC0-2 and set the default input to mic-in
10797 */
10798 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10800 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10801 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10802 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10803 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10804
Takashi Iwaicb53c622007-08-10 17:21:45 +020010805 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010806 * mixer widget
10807 * Note: PASD motherboards uses the Line In 2 as the input for front
10808 * panel mic (mic 2)
10809 */
10810 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010811 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10812 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10813 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10814 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10815 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10817 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10818 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010819 /*
10820 * Set up output mixers (0x0c - 0x0e)
10821 */
10822 /* set vol=0 to output mixers */
10823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10824 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10825 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10826
10827 /* set up input amps for analog loopback */
10828 /* Amp Indices: DAC = 0, mixer = 1 */
10829 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10830 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10831 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10832 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10833 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10834 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10835
10836
10837 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10838 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10839 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10840 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10841 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10842 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10843 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10844
10845 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10846 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10847
10848 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10849 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10850
10851 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10853 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10854 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10855 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10856 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10857
10858 /* FIXME: use matrix-type input source selection */
10859 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10860 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10866 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10867 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10868 /* Input mixer2 */
10869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10871 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10872 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10873 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10874 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10876 /* Input mixer3 */
10877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10880 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10882 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10884
Takashi Iwaice875f02008-01-28 18:17:43 +010010885 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10886
Kailang Yangcd7509a2007-01-26 18:33:17 +010010887 { }
10888};
10889
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010890static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10891
10892 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10894 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10895
10896 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10897 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10898 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10899 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10900
10901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10902 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10903 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10904 {}
10905};
10906
10907
Takashi Iwaicb53c622007-08-10 17:21:45 +020010908#ifdef CONFIG_SND_HDA_POWER_SAVE
10909#define alc262_loopbacks alc880_loopbacks
10910#endif
10911
Kailang Yangdf694da2005-12-05 19:42:22 +010010912/* pcm configuration: identiacal with ALC880 */
10913#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10914#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10915#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10916#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10917
10918/*
10919 * BIOS auto configuration
10920 */
10921static int alc262_parse_auto_config(struct hda_codec *codec)
10922{
10923 struct alc_spec *spec = codec->spec;
10924 int err;
10925 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10926
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010927 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10928 alc262_ignore);
10929 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010930 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010931 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010932 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010933 spec->multiout.max_channels = 2;
10934 spec->no_analog = 1;
10935 goto dig_only;
10936 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010937 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010938 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010939 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10940 if (err < 0)
10941 return err;
10942 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10943 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010944 return err;
10945
10946 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10947
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010948 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010949 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010950 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010951 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010952 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010953 if (spec->autocfg.dig_in_pin)
10954 spec->dig_in_nid = ALC262_DIGIN_NID;
10955
Takashi Iwai603c4012008-07-30 15:01:44 +020010956 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010957 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010958
Takashi Iwaid88897e2008-10-31 15:01:37 +010010959 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010960 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010961 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010962
Takashi Iwai776e1842007-08-29 15:07:11 +020010963 err = alc_auto_add_mic_boost(codec);
10964 if (err < 0)
10965 return err;
10966
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010967 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
10968
Kailang Yangdf694da2005-12-05 19:42:22 +010010969 return 1;
10970}
10971
10972#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10973#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10974#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010975#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010976
10977
10978/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010979static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010980{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010981 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010982 alc262_auto_init_multi_out(codec);
10983 alc262_auto_init_hp_out(codec);
10984 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010985 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010986 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010987 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010988}
10989
10990/*
10991 * configuration and preset
10992 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010993static const char *alc262_models[ALC262_MODEL_LAST] = {
10994 [ALC262_BASIC] = "basic",
10995 [ALC262_HIPPO] = "hippo",
10996 [ALC262_HIPPO_1] = "hippo_1",
10997 [ALC262_FUJITSU] = "fujitsu",
10998 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010999 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011000 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011001 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011002 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011003 [ALC262_BENQ_T31] = "benq-t31",
11004 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011005 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011006 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011007 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011008 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011009 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011010 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011011 [ALC262_AUTO] = "auto",
11012};
11013
11014static struct snd_pci_quirk alc262_cfg_tbl[] = {
11015 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011016 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011017 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11018 ALC262_HP_BPC),
11019 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11020 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011021 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11022 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011023 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011024 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011025 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011026 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011027 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011028 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011029 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011030 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011031 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11032 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11033 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011034 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11035 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011036 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011037 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011038 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011039 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011040 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010011041 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11042 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011043 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011044 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011045 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011046 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011047 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011048 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011049 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11050 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011051 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011052 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011053 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011054 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011055 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011056 {}
11057};
11058
11059static struct alc_config_preset alc262_presets[] = {
11060 [ALC262_BASIC] = {
11061 .mixers = { alc262_base_mixer },
11062 .init_verbs = { alc262_init_verbs },
11063 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11064 .dac_nids = alc262_dac_nids,
11065 .hp_nid = 0x03,
11066 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11067 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011068 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011069 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011070 [ALC262_HIPPO] = {
11071 .mixers = { alc262_base_mixer },
11072 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11073 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11074 .dac_nids = alc262_dac_nids,
11075 .hp_nid = 0x03,
11076 .dig_out_nid = ALC262_DIGOUT_NID,
11077 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11078 .channel_mode = alc262_modes,
11079 .input_mux = &alc262_capture_source,
11080 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011081 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011082 },
11083 [ALC262_HIPPO_1] = {
11084 .mixers = { alc262_hippo1_mixer },
11085 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11086 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11087 .dac_nids = alc262_dac_nids,
11088 .hp_nid = 0x02,
11089 .dig_out_nid = ALC262_DIGOUT_NID,
11090 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11091 .channel_mode = alc262_modes,
11092 .input_mux = &alc262_capture_source,
11093 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011094 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011095 },
Takashi Iwai834be882006-03-01 14:16:17 +010011096 [ALC262_FUJITSU] = {
11097 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011098 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11099 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011100 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11101 .dac_nids = alc262_dac_nids,
11102 .hp_nid = 0x03,
11103 .dig_out_nid = ALC262_DIGOUT_NID,
11104 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11105 .channel_mode = alc262_modes,
11106 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011107 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011108 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011109 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011110 [ALC262_HP_BPC] = {
11111 .mixers = { alc262_HP_BPC_mixer },
11112 .init_verbs = { alc262_HP_BPC_init_verbs },
11113 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11114 .dac_nids = alc262_dac_nids,
11115 .hp_nid = 0x03,
11116 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11117 .channel_mode = alc262_modes,
11118 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011119 .unsol_event = alc262_hp_bpc_unsol_event,
11120 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011121 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011122 [ALC262_HP_BPC_D7000_WF] = {
11123 .mixers = { alc262_HP_BPC_WildWest_mixer },
11124 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11125 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11126 .dac_nids = alc262_dac_nids,
11127 .hp_nid = 0x03,
11128 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11129 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011130 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011131 .unsol_event = alc262_hp_wildwest_unsol_event,
11132 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011133 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011134 [ALC262_HP_BPC_D7000_WL] = {
11135 .mixers = { alc262_HP_BPC_WildWest_mixer,
11136 alc262_HP_BPC_WildWest_option_mixer },
11137 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11138 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11139 .dac_nids = alc262_dac_nids,
11140 .hp_nid = 0x03,
11141 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11142 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011143 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011144 .unsol_event = alc262_hp_wildwest_unsol_event,
11145 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011146 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011147 [ALC262_HP_TC_T5735] = {
11148 .mixers = { alc262_hp_t5735_mixer },
11149 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11150 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11151 .dac_nids = alc262_dac_nids,
11152 .hp_nid = 0x03,
11153 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11154 .channel_mode = alc262_modes,
11155 .input_mux = &alc262_capture_source,
11156 .unsol_event = alc262_hp_t5735_unsol_event,
11157 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011158 },
11159 [ALC262_HP_RP5700] = {
11160 .mixers = { alc262_hp_rp5700_mixer },
11161 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11162 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11163 .dac_nids = alc262_dac_nids,
11164 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11165 .channel_mode = alc262_modes,
11166 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011167 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011168 [ALC262_BENQ_ED8] = {
11169 .mixers = { alc262_base_mixer },
11170 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11171 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11172 .dac_nids = alc262_dac_nids,
11173 .hp_nid = 0x03,
11174 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11175 .channel_mode = alc262_modes,
11176 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011177 },
Kailang Yang272a5272007-05-14 11:00:38 +020011178 [ALC262_SONY_ASSAMD] = {
11179 .mixers = { alc262_sony_mixer },
11180 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11181 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11182 .dac_nids = alc262_dac_nids,
11183 .hp_nid = 0x02,
11184 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11185 .channel_mode = alc262_modes,
11186 .input_mux = &alc262_capture_source,
11187 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011188 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011189 },
11190 [ALC262_BENQ_T31] = {
11191 .mixers = { alc262_benq_t31_mixer },
11192 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11193 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11194 .dac_nids = alc262_dac_nids,
11195 .hp_nid = 0x03,
11196 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11197 .channel_mode = alc262_modes,
11198 .input_mux = &alc262_capture_source,
11199 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011200 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011201 },
Tobin Davisf651b502007-10-26 12:40:47 +020011202 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011203 .mixers = { alc262_ultra_mixer },
11204 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011205 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011206 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11207 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011208 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11209 .channel_mode = alc262_modes,
11210 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011211 .adc_nids = alc262_adc_nids, /* ADC0 */
11212 .capsrc_nids = alc262_capsrc_nids,
11213 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011214 .unsol_event = alc262_ultra_unsol_event,
11215 .init_hook = alc262_ultra_automute,
11216 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011217 [ALC262_LENOVO_3000] = {
11218 .mixers = { alc262_lenovo_3000_mixer },
11219 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11220 alc262_lenovo_3000_unsol_verbs },
11221 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11222 .dac_nids = alc262_dac_nids,
11223 .hp_nid = 0x03,
11224 .dig_out_nid = ALC262_DIGOUT_NID,
11225 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11226 .channel_mode = alc262_modes,
11227 .input_mux = &alc262_fujitsu_capture_source,
11228 .unsol_event = alc262_lenovo_3000_unsol_event,
11229 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011230 [ALC262_NEC] = {
11231 .mixers = { alc262_nec_mixer },
11232 .init_verbs = { alc262_nec_verbs },
11233 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11234 .dac_nids = alc262_dac_nids,
11235 .hp_nid = 0x03,
11236 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11237 .channel_mode = alc262_modes,
11238 .input_mux = &alc262_capture_source,
11239 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011240 [ALC262_TOSHIBA_S06] = {
11241 .mixers = { alc262_toshiba_s06_mixer },
11242 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11243 alc262_eapd_verbs },
11244 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11245 .capsrc_nids = alc262_dmic_capsrc_nids,
11246 .dac_nids = alc262_dac_nids,
11247 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11248 .dig_out_nid = ALC262_DIGOUT_NID,
11249 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11250 .channel_mode = alc262_modes,
11251 .input_mux = &alc262_dmic_capture_source,
11252 .unsol_event = alc262_toshiba_s06_unsol_event,
11253 .init_hook = alc262_toshiba_s06_init_hook,
11254 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011255 [ALC262_TOSHIBA_RX1] = {
11256 .mixers = { alc262_toshiba_rx1_mixer },
11257 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11258 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11259 .dac_nids = alc262_dac_nids,
11260 .hp_nid = 0x03,
11261 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11262 .channel_mode = alc262_modes,
11263 .input_mux = &alc262_capture_source,
11264 .unsol_event = alc262_hippo_unsol_event,
11265 .init_hook = alc262_hippo_automute,
11266 },
Tony Vroonba340e82009-02-02 19:01:30 +000011267 [ALC262_TYAN] = {
11268 .mixers = { alc262_tyan_mixer },
11269 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11270 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11271 .dac_nids = alc262_dac_nids,
11272 .hp_nid = 0x02,
11273 .dig_out_nid = ALC262_DIGOUT_NID,
11274 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11275 .channel_mode = alc262_modes,
11276 .input_mux = &alc262_capture_source,
11277 .unsol_event = alc262_tyan_unsol_event,
11278 .init_hook = alc262_tyan_automute,
11279 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011280};
11281
11282static int patch_alc262(struct hda_codec *codec)
11283{
11284 struct alc_spec *spec;
11285 int board_config;
11286 int err;
11287
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011288 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011289 if (spec == NULL)
11290 return -ENOMEM;
11291
11292 codec->spec = spec;
11293#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011294 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11295 * under-run
11296 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011297 {
11298 int tmp;
11299 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11300 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11301 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11302 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11303 }
11304#endif
11305
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011306 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11307
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011308 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11309 alc262_models,
11310 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011311
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011312 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011313 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11314 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011315 board_config = ALC262_AUTO;
11316 }
11317
11318 if (board_config == ALC262_AUTO) {
11319 /* automatic parse from the BIOS config */
11320 err = alc262_parse_auto_config(codec);
11321 if (err < 0) {
11322 alc_free(codec);
11323 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011324 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011325 printk(KERN_INFO
11326 "hda_codec: Cannot set up configuration "
11327 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011328 board_config = ALC262_BASIC;
11329 }
11330 }
11331
Takashi Iwai07eba612009-02-19 08:06:35 +010011332 if (!spec->no_analog) {
11333 err = snd_hda_attach_beep_device(codec, 0x1);
11334 if (err < 0) {
11335 alc_free(codec);
11336 return err;
11337 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011338 }
11339
Kailang Yangdf694da2005-12-05 19:42:22 +010011340 if (board_config != ALC262_AUTO)
11341 setup_preset(spec, &alc262_presets[board_config]);
11342
11343 spec->stream_name_analog = "ALC262 Analog";
11344 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11345 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011346
Kailang Yangdf694da2005-12-05 19:42:22 +010011347 spec->stream_name_digital = "ALC262 Digital";
11348 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11349 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11350
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011351 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011352 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011353 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011354 unsigned int wcap = get_wcaps(codec, 0x07);
11355
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011356 /* get type */
11357 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011358 if (wcap != AC_WID_AUD_IN) {
11359 spec->adc_nids = alc262_adc_nids_alt;
11360 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011361 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011362 } else {
11363 spec->adc_nids = alc262_adc_nids;
11364 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011365 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011366 }
11367 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011368 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011369 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011370 if (!spec->no_analog)
11371 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011372
Takashi Iwai2134ea42008-01-10 16:53:55 +010011373 spec->vmaster_nid = 0x0c;
11374
Kailang Yangdf694da2005-12-05 19:42:22 +010011375 codec->patch_ops = alc_patch_ops;
11376 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011377 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011378#ifdef CONFIG_SND_HDA_POWER_SAVE
11379 if (!spec->loopback.amplist)
11380 spec->loopback.amplist = alc262_loopbacks;
11381#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011382 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011383
Kailang Yangdf694da2005-12-05 19:42:22 +010011384 return 0;
11385}
11386
Kailang Yangdf694da2005-12-05 19:42:22 +010011387/*
Kailang Yanga361d842007-06-05 12:30:55 +020011388 * ALC268 channel source setting (2 channel)
11389 */
11390#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11391#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011392
Kailang Yanga361d842007-06-05 12:30:55 +020011393static hda_nid_t alc268_dac_nids[2] = {
11394 /* front, hp */
11395 0x02, 0x03
11396};
11397
11398static hda_nid_t alc268_adc_nids[2] = {
11399 /* ADC0-1 */
11400 0x08, 0x07
11401};
11402
11403static hda_nid_t alc268_adc_nids_alt[1] = {
11404 /* ADC0 */
11405 0x08
11406};
11407
Takashi Iwaie1406342008-02-11 18:32:32 +010011408static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11409
Kailang Yanga361d842007-06-05 12:30:55 +020011410static struct snd_kcontrol_new alc268_base_mixer[] = {
11411 /* output mixer control */
11412 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11413 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11414 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11415 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011416 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11417 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11418 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011419 { }
11420};
11421
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011422/* bind Beep switches of both NID 0x0f and 0x10 */
11423static struct hda_bind_ctls alc268_bind_beep_sw = {
11424 .ops = &snd_hda_bind_sw,
11425 .values = {
11426 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11427 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11428 0
11429 },
11430};
11431
11432static struct snd_kcontrol_new alc268_beep_mixer[] = {
11433 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11434 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11435 { }
11436};
11437
Kailang Yangd1a991a2007-08-15 16:21:59 +020011438static struct hda_verb alc268_eapd_verbs[] = {
11439 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11440 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11441 { }
11442};
11443
Takashi Iwaid2738092007-08-16 14:59:45 +020011444/* Toshiba specific */
11445#define alc268_toshiba_automute alc262_hippo_automute
11446
11447static struct hda_verb alc268_toshiba_verbs[] = {
11448 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11449 { } /* end */
11450};
11451
Kailang Yang8ef355d2008-08-26 13:10:22 +020011452static struct hda_input_mux alc268_acer_lc_capture_source = {
11453 .num_items = 2,
11454 .items = {
11455 { "i-Mic", 0x6 },
11456 { "E-Mic", 0x0 },
11457 },
11458};
11459
Takashi Iwaid2738092007-08-16 14:59:45 +020011460/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011461/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011462static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11463 .ops = &snd_hda_bind_vol,
11464 .values = {
11465 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11466 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11467 0
11468 },
11469};
11470
Takashi Iwai889c4392007-08-23 18:56:52 +020011471/* mute/unmute internal speaker according to the hp jack and mute state */
11472static void alc268_acer_automute(struct hda_codec *codec, int force)
11473{
11474 struct alc_spec *spec = codec->spec;
11475 unsigned int mute;
11476
11477 if (force || !spec->sense_updated) {
11478 unsigned int present;
11479 present = snd_hda_codec_read(codec, 0x14, 0,
11480 AC_VERB_GET_PIN_SENSE, 0);
11481 spec->jack_present = (present & 0x80000000) != 0;
11482 spec->sense_updated = 1;
11483 }
11484 if (spec->jack_present)
11485 mute = HDA_AMP_MUTE; /* mute internal speaker */
11486 else /* unmute internal speaker if necessary */
11487 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11488 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11489 HDA_AMP_MUTE, mute);
11490}
11491
11492
11493/* bind hp and internal speaker mute (with plug check) */
11494static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11495 struct snd_ctl_elem_value *ucontrol)
11496{
11497 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11498 long *valp = ucontrol->value.integer.value;
11499 int change;
11500
11501 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11502 HDA_AMP_MUTE,
11503 valp[0] ? 0 : HDA_AMP_MUTE);
11504 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11505 HDA_AMP_MUTE,
11506 valp[1] ? 0 : HDA_AMP_MUTE);
11507 if (change)
11508 alc268_acer_automute(codec, 0);
11509 return change;
11510}
Takashi Iwaid2738092007-08-16 14:59:45 +020011511
Kailang Yang8ef355d2008-08-26 13:10:22 +020011512static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11513 /* output mixer control */
11514 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11515 {
11516 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11517 .name = "Master Playback Switch",
11518 .info = snd_hda_mixer_amp_switch_info,
11519 .get = snd_hda_mixer_amp_switch_get,
11520 .put = alc268_acer_master_sw_put,
11521 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11522 },
11523 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11524 { }
11525};
11526
Takashi Iwaid2738092007-08-16 14:59:45 +020011527static struct snd_kcontrol_new alc268_acer_mixer[] = {
11528 /* output mixer control */
11529 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11530 {
11531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11532 .name = "Master Playback Switch",
11533 .info = snd_hda_mixer_amp_switch_info,
11534 .get = snd_hda_mixer_amp_switch_get,
11535 .put = alc268_acer_master_sw_put,
11536 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11537 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011538 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11539 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11540 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011541 { }
11542};
11543
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011544static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11545 /* output mixer control */
11546 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11547 {
11548 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11549 .name = "Master Playback Switch",
11550 .info = snd_hda_mixer_amp_switch_info,
11551 .get = snd_hda_mixer_amp_switch_get,
11552 .put = alc268_acer_master_sw_put,
11553 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11554 },
11555 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11556 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11557 { }
11558};
11559
Kailang Yang8ef355d2008-08-26 13:10:22 +020011560static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11561 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11562 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11563 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11564 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11565 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11566 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11567 { }
11568};
11569
Takashi Iwaid2738092007-08-16 14:59:45 +020011570static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011571 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11572 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011573 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11574 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011575 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11576 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011577 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11578 { }
11579};
11580
11581/* unsolicited event for HP jack sensing */
11582static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11583 unsigned int res)
11584{
Takashi Iwai889c4392007-08-23 18:56:52 +020011585 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011586 return;
11587 alc268_toshiba_automute(codec);
11588}
11589
11590static void alc268_acer_unsol_event(struct hda_codec *codec,
11591 unsigned int res)
11592{
Takashi Iwai889c4392007-08-23 18:56:52 +020011593 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011594 return;
11595 alc268_acer_automute(codec, 1);
11596}
11597
Takashi Iwai889c4392007-08-23 18:56:52 +020011598static void alc268_acer_init_hook(struct hda_codec *codec)
11599{
11600 alc268_acer_automute(codec, 1);
11601}
11602
Kailang Yang8ef355d2008-08-26 13:10:22 +020011603/* toggle speaker-output according to the hp-jack state */
11604static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11605{
11606 unsigned int present;
11607 unsigned char bits;
11608
11609 present = snd_hda_codec_read(codec, 0x15, 0,
11610 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11611 bits = present ? AMP_IN_MUTE(0) : 0;
11612 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11613 AMP_IN_MUTE(0), bits);
11614 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11615 AMP_IN_MUTE(0), bits);
11616}
11617
11618
11619static void alc268_acer_mic_automute(struct hda_codec *codec)
11620{
11621 unsigned int present;
11622
11623 present = snd_hda_codec_read(codec, 0x18, 0,
11624 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11625 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11626 present ? 0x0 : 0x6);
11627}
11628
11629static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11630 unsigned int res)
11631{
11632 if ((res >> 26) == ALC880_HP_EVENT)
11633 alc268_aspire_one_speaker_automute(codec);
11634 if ((res >> 26) == ALC880_MIC_EVENT)
11635 alc268_acer_mic_automute(codec);
11636}
11637
11638static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11639{
11640 alc268_aspire_one_speaker_automute(codec);
11641 alc268_acer_mic_automute(codec);
11642}
11643
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011644static struct snd_kcontrol_new alc268_dell_mixer[] = {
11645 /* output mixer control */
11646 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11647 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11648 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11649 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11650 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11651 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11652 { }
11653};
11654
11655static struct hda_verb alc268_dell_verbs[] = {
11656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11657 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11658 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11659 { }
11660};
11661
11662/* mute/unmute internal speaker according to the hp jack and mute state */
11663static void alc268_dell_automute(struct hda_codec *codec)
11664{
11665 unsigned int present;
11666 unsigned int mute;
11667
11668 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11669 if (present & 0x80000000)
11670 mute = HDA_AMP_MUTE;
11671 else
11672 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11673 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11674 HDA_AMP_MUTE, mute);
11675}
11676
11677static void alc268_dell_unsol_event(struct hda_codec *codec,
11678 unsigned int res)
11679{
11680 if ((res >> 26) != ALC880_HP_EVENT)
11681 return;
11682 alc268_dell_automute(codec);
11683}
11684
11685#define alc268_dell_init_hook alc268_dell_automute
11686
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011687static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11688 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11689 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11690 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11691 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11692 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11693 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11694 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11695 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11696 { }
11697};
11698
11699static struct hda_verb alc267_quanta_il1_verbs[] = {
11700 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11701 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11702 { }
11703};
11704
11705static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11706{
11707 unsigned int present;
11708
11709 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11710 & AC_PINSENSE_PRESENCE;
11711 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11712 present ? 0 : PIN_OUT);
11713}
11714
11715static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11716{
11717 unsigned int present;
11718
11719 present = snd_hda_codec_read(codec, 0x18, 0,
11720 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11721 snd_hda_codec_write(codec, 0x23, 0,
11722 AC_VERB_SET_CONNECT_SEL,
11723 present ? 0x00 : 0x01);
11724}
11725
11726static void alc267_quanta_il1_automute(struct hda_codec *codec)
11727{
11728 alc267_quanta_il1_hp_automute(codec);
11729 alc267_quanta_il1_mic_automute(codec);
11730}
11731
11732static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11733 unsigned int res)
11734{
11735 switch (res >> 26) {
11736 case ALC880_HP_EVENT:
11737 alc267_quanta_il1_hp_automute(codec);
11738 break;
11739 case ALC880_MIC_EVENT:
11740 alc267_quanta_il1_mic_automute(codec);
11741 break;
11742 }
11743}
11744
Kailang Yanga361d842007-06-05 12:30:55 +020011745/*
11746 * generic initialization of ADC, input mixers and output mixers
11747 */
11748static struct hda_verb alc268_base_init_verbs[] = {
11749 /* Unmute DAC0-1 and set vol = 0 */
11750 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011751 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011752
11753 /*
11754 * Set up output mixers (0x0c - 0x0e)
11755 */
11756 /* set vol=0 to output mixers */
11757 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011758 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11759
11760 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11761 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11762
11763 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11764 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11765 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11766 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11767 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11768 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11769 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11770 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11771
11772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11773 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11774 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011776 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011777
11778 /* set PCBEEP vol = 0, mute connections */
11779 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11780 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11781 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011782
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011783 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011784
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011785 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11786 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11787 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011789
Kailang Yanga361d842007-06-05 12:30:55 +020011790 { }
11791};
11792
11793/*
11794 * generic initialization of ADC, input mixers and output mixers
11795 */
11796static struct hda_verb alc268_volume_init_verbs[] = {
11797 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011798 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11799 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011800
11801 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11802 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11803 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11804 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11805 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11806
Kailang Yanga361d842007-06-05 12:30:55 +020011807 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011808 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11809 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11810
11811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011812 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011813
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011814 /* set PCBEEP vol = 0, mute connections */
11815 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11816 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11817 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011818
11819 { }
11820};
11821
Kailang Yanga361d842007-06-05 12:30:55 +020011822static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11823 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11824 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11825 {
11826 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11827 /* The multiple "Capture Source" controls confuse alsamixer
11828 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011829 */
11830 /* .name = "Capture Source", */
11831 .name = "Input Source",
11832 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011833 .info = alc_mux_enum_info,
11834 .get = alc_mux_enum_get,
11835 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011836 },
11837 { } /* end */
11838};
11839
11840static struct snd_kcontrol_new alc268_capture_mixer[] = {
11841 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11842 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11843 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11844 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11845 {
11846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11847 /* The multiple "Capture Source" controls confuse alsamixer
11848 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011849 */
11850 /* .name = "Capture Source", */
11851 .name = "Input Source",
11852 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011853 .info = alc_mux_enum_info,
11854 .get = alc_mux_enum_get,
11855 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011856 },
11857 { } /* end */
11858};
11859
11860static struct hda_input_mux alc268_capture_source = {
11861 .num_items = 4,
11862 .items = {
11863 { "Mic", 0x0 },
11864 { "Front Mic", 0x1 },
11865 { "Line", 0x2 },
11866 { "CD", 0x3 },
11867 },
11868};
11869
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011870static struct hda_input_mux alc268_acer_capture_source = {
11871 .num_items = 3,
11872 .items = {
11873 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011874 { "Internal Mic", 0x1 },
11875 { "Line", 0x2 },
11876 },
11877};
11878
11879static struct hda_input_mux alc268_acer_dmic_capture_source = {
11880 .num_items = 3,
11881 .items = {
11882 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011883 { "Internal Mic", 0x6 },
11884 { "Line", 0x2 },
11885 },
11886};
11887
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011888#ifdef CONFIG_SND_DEBUG
11889static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011890 /* Volume widgets */
11891 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11892 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11893 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11894 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11895 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11896 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11897 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11898 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11899 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11900 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11901 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11902 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11903 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011904 /* The below appears problematic on some hardwares */
11905 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011906 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11907 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11908 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11909 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11910
11911 /* Modes for retasking pin widgets */
11912 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11913 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11914 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11915 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11916
11917 /* Controls for GPIO pins, assuming they are configured as outputs */
11918 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11919 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11920 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11921 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11922
11923 /* Switches to allow the digital SPDIF output pin to be enabled.
11924 * The ALC268 does not have an SPDIF input.
11925 */
11926 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11927
11928 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11929 * this output to turn on an external amplifier.
11930 */
11931 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11932 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11933
11934 { } /* end */
11935};
11936#endif
11937
Kailang Yanga361d842007-06-05 12:30:55 +020011938/* create input playback/capture controls for the given pin */
11939static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11940 const char *ctlname, int idx)
11941{
11942 char name[32];
11943 int err;
11944
11945 sprintf(name, "%s Playback Volume", ctlname);
11946 if (nid == 0x14) {
11947 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11948 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11949 HDA_OUTPUT));
11950 if (err < 0)
11951 return err;
11952 } else if (nid == 0x15) {
11953 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11954 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11955 HDA_OUTPUT));
11956 if (err < 0)
11957 return err;
11958 } else
11959 return -1;
11960 sprintf(name, "%s Playback Switch", ctlname);
11961 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11962 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11963 if (err < 0)
11964 return err;
11965 return 0;
11966}
11967
11968/* add playback controls from the parsed DAC table */
11969static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11970 const struct auto_pin_cfg *cfg)
11971{
11972 hda_nid_t nid;
11973 int err;
11974
11975 spec->multiout.num_dacs = 2; /* only use one dac */
11976 spec->multiout.dac_nids = spec->private_dac_nids;
11977 spec->multiout.dac_nids[0] = 2;
11978 spec->multiout.dac_nids[1] = 3;
11979
11980 nid = cfg->line_out_pins[0];
11981 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011982 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011983
11984 nid = cfg->speaker_pins[0];
11985 if (nid == 0x1d) {
11986 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11987 "Speaker Playback Volume",
11988 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11989 if (err < 0)
11990 return err;
11991 }
11992 nid = cfg->hp_pins[0];
11993 if (nid)
11994 alc268_new_analog_output(spec, nid, "Headphone", 0);
11995
11996 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11997 if (nid == 0x16) {
11998 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11999 "Mono Playback Switch",
12000 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
12001 if (err < 0)
12002 return err;
12003 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012004 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012005}
12006
12007/* create playback/capture controls for input pins */
12008static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12009 const struct auto_pin_cfg *cfg)
12010{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012011 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012012 int i, idx1;
12013
12014 for (i = 0; i < AUTO_PIN_LAST; i++) {
12015 switch(cfg->input_pins[i]) {
12016 case 0x18:
12017 idx1 = 0; /* Mic 1 */
12018 break;
12019 case 0x19:
12020 idx1 = 1; /* Mic 2 */
12021 break;
12022 case 0x1a:
12023 idx1 = 2; /* Line In */
12024 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012025 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012026 idx1 = 3; /* CD */
12027 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012028 case 0x12:
12029 case 0x13:
12030 idx1 = 6; /* digital mics */
12031 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012032 default:
12033 continue;
12034 }
12035 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12036 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012037 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012038 }
12039 return 0;
12040}
12041
12042static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12043{
12044 struct alc_spec *spec = codec->spec;
12045 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12046 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12047 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12048 unsigned int dac_vol1, dac_vol2;
12049
12050 if (speaker_nid) {
12051 snd_hda_codec_write(codec, speaker_nid, 0,
12052 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12053 snd_hda_codec_write(codec, 0x0f, 0,
12054 AC_VERB_SET_AMP_GAIN_MUTE,
12055 AMP_IN_UNMUTE(1));
12056 snd_hda_codec_write(codec, 0x10, 0,
12057 AC_VERB_SET_AMP_GAIN_MUTE,
12058 AMP_IN_UNMUTE(1));
12059 } else {
12060 snd_hda_codec_write(codec, 0x0f, 0,
12061 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12062 snd_hda_codec_write(codec, 0x10, 0,
12063 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12064 }
12065
12066 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012067 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012068 dac_vol2 = AMP_OUT_ZERO;
12069 else if (line_nid == 0x15)
12070 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012071 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012072 dac_vol2 = AMP_OUT_ZERO;
12073 else if (hp_nid == 0x15)
12074 dac_vol1 = AMP_OUT_ZERO;
12075 if (line_nid != 0x16 || hp_nid != 0x16 ||
12076 spec->autocfg.line_out_pins[1] != 0x16 ||
12077 spec->autocfg.line_out_pins[2] != 0x16)
12078 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12079
12080 snd_hda_codec_write(codec, 0x02, 0,
12081 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12082 snd_hda_codec_write(codec, 0x03, 0,
12083 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12084}
12085
12086/* pcm configuration: identiacal with ALC880 */
12087#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12088#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012089#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012090#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12091
12092/*
12093 * BIOS auto configuration
12094 */
12095static int alc268_parse_auto_config(struct hda_codec *codec)
12096{
12097 struct alc_spec *spec = codec->spec;
12098 int err;
12099 static hda_nid_t alc268_ignore[] = { 0 };
12100
12101 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12102 alc268_ignore);
12103 if (err < 0)
12104 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012105 if (!spec->autocfg.line_outs) {
12106 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12107 spec->multiout.max_channels = 2;
12108 spec->no_analog = 1;
12109 goto dig_only;
12110 }
Kailang Yanga361d842007-06-05 12:30:55 +020012111 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012112 }
Kailang Yanga361d842007-06-05 12:30:55 +020012113 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12114 if (err < 0)
12115 return err;
12116 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12117 if (err < 0)
12118 return err;
12119
12120 spec->multiout.max_channels = 2;
12121
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012122 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012123 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012124 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012125 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012126 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12127 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012128 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012129 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012130
Takashi Iwai892981f2009-03-02 08:04:35 +010012131 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012132 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012133
Takashi Iwaid88897e2008-10-31 15:01:37 +010012134 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012135 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012136 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012137
Takashi Iwai776e1842007-08-29 15:07:11 +020012138 err = alc_auto_add_mic_boost(codec);
12139 if (err < 0)
12140 return err;
12141
Kailang Yanga361d842007-06-05 12:30:55 +020012142 return 1;
12143}
12144
12145#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12146#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12147#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12148
12149/* init callback for auto-configuration model -- overriding the default init */
12150static void alc268_auto_init(struct hda_codec *codec)
12151{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012152 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012153 alc268_auto_init_multi_out(codec);
12154 alc268_auto_init_hp_out(codec);
12155 alc268_auto_init_mono_speaker_out(codec);
12156 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012157 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012158 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012159}
12160
12161/*
12162 * configuration and preset
12163 */
12164static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012165 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012166 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012167 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012168 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012169 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012170 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012171 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012172 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012173#ifdef CONFIG_SND_DEBUG
12174 [ALC268_TEST] = "test",
12175#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012176 [ALC268_AUTO] = "auto",
12177};
12178
12179static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012180 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012181 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012182 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012183 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012184 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012185 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12186 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012187 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012188 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012189 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012190 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020012191 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020012192 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020012193 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012194 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012195 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012196 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012197 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012198 {}
12199};
12200
12201static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012202 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012203 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012204 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12205 alc267_quanta_il1_verbs },
12206 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12207 .dac_nids = alc268_dac_nids,
12208 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12209 .adc_nids = alc268_adc_nids_alt,
12210 .hp_nid = 0x03,
12211 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12212 .channel_mode = alc268_modes,
12213 .input_mux = &alc268_capture_source,
12214 .unsol_event = alc267_quanta_il1_unsol_event,
12215 .init_hook = alc267_quanta_il1_automute,
12216 },
Kailang Yanga361d842007-06-05 12:30:55 +020012217 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012218 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12219 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012220 .init_verbs = { alc268_base_init_verbs },
12221 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12222 .dac_nids = alc268_dac_nids,
12223 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12224 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012225 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012226 .hp_nid = 0x03,
12227 .dig_out_nid = ALC268_DIGOUT_NID,
12228 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12229 .channel_mode = alc268_modes,
12230 .input_mux = &alc268_capture_source,
12231 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012232 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012233 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12234 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012235 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12236 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012237 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12238 .dac_nids = alc268_dac_nids,
12239 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12240 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012241 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012242 .hp_nid = 0x03,
12243 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12244 .channel_mode = alc268_modes,
12245 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012246 .unsol_event = alc268_toshiba_unsol_event,
12247 .init_hook = alc268_toshiba_automute,
12248 },
12249 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012250 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12251 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012252 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12253 alc268_acer_verbs },
12254 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12255 .dac_nids = alc268_dac_nids,
12256 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12257 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012258 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012259 .hp_nid = 0x02,
12260 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12261 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012262 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012263 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012264 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012265 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012266 [ALC268_ACER_DMIC] = {
12267 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12268 alc268_beep_mixer },
12269 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12270 alc268_acer_verbs },
12271 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12272 .dac_nids = alc268_dac_nids,
12273 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12274 .adc_nids = alc268_adc_nids_alt,
12275 .capsrc_nids = alc268_capsrc_nids,
12276 .hp_nid = 0x02,
12277 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12278 .channel_mode = alc268_modes,
12279 .input_mux = &alc268_acer_dmic_capture_source,
12280 .unsol_event = alc268_acer_unsol_event,
12281 .init_hook = alc268_acer_init_hook,
12282 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012283 [ALC268_ACER_ASPIRE_ONE] = {
12284 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012285 alc268_beep_mixer,
12286 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012287 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12288 alc268_acer_aspire_one_verbs },
12289 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12290 .dac_nids = alc268_dac_nids,
12291 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12292 .adc_nids = alc268_adc_nids_alt,
12293 .capsrc_nids = alc268_capsrc_nids,
12294 .hp_nid = 0x03,
12295 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12296 .channel_mode = alc268_modes,
12297 .input_mux = &alc268_acer_lc_capture_source,
12298 .unsol_event = alc268_acer_lc_unsol_event,
12299 .init_hook = alc268_acer_lc_init_hook,
12300 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012301 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012302 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012303 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12304 alc268_dell_verbs },
12305 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12306 .dac_nids = alc268_dac_nids,
12307 .hp_nid = 0x02,
12308 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12309 .channel_mode = alc268_modes,
12310 .unsol_event = alc268_dell_unsol_event,
12311 .init_hook = alc268_dell_init_hook,
12312 .input_mux = &alc268_capture_source,
12313 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012314 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012315 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12316 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012317 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12318 alc268_toshiba_verbs },
12319 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12320 .dac_nids = alc268_dac_nids,
12321 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12322 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012323 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012324 .hp_nid = 0x03,
12325 .dig_out_nid = ALC268_DIGOUT_NID,
12326 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12327 .channel_mode = alc268_modes,
12328 .input_mux = &alc268_capture_source,
12329 .unsol_event = alc268_toshiba_unsol_event,
12330 .init_hook = alc268_toshiba_automute
12331 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012332#ifdef CONFIG_SND_DEBUG
12333 [ALC268_TEST] = {
12334 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12335 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12336 alc268_volume_init_verbs },
12337 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12338 .dac_nids = alc268_dac_nids,
12339 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12340 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012341 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012342 .hp_nid = 0x03,
12343 .dig_out_nid = ALC268_DIGOUT_NID,
12344 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12345 .channel_mode = alc268_modes,
12346 .input_mux = &alc268_capture_source,
12347 },
12348#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012349};
12350
12351static int patch_alc268(struct hda_codec *codec)
12352{
12353 struct alc_spec *spec;
12354 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012355 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012356
12357 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12358 if (spec == NULL)
12359 return -ENOMEM;
12360
12361 codec->spec = spec;
12362
12363 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12364 alc268_models,
12365 alc268_cfg_tbl);
12366
12367 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12368 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12369 "trying auto-probe from BIOS...\n");
12370 board_config = ALC268_AUTO;
12371 }
12372
12373 if (board_config == ALC268_AUTO) {
12374 /* automatic parse from the BIOS config */
12375 err = alc268_parse_auto_config(codec);
12376 if (err < 0) {
12377 alc_free(codec);
12378 return err;
12379 } else if (!err) {
12380 printk(KERN_INFO
12381 "hda_codec: Cannot set up configuration "
12382 "from BIOS. Using base mode...\n");
12383 board_config = ALC268_3ST;
12384 }
12385 }
12386
12387 if (board_config != ALC268_AUTO)
12388 setup_preset(spec, &alc268_presets[board_config]);
12389
Kailang Yang2f893282008-05-27 12:14:47 +020012390 if (codec->vendor_id == 0x10ec0267) {
12391 spec->stream_name_analog = "ALC267 Analog";
12392 spec->stream_name_digital = "ALC267 Digital";
12393 } else {
12394 spec->stream_name_analog = "ALC268 Analog";
12395 spec->stream_name_digital = "ALC268 Digital";
12396 }
12397
Kailang Yanga361d842007-06-05 12:30:55 +020012398 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12399 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012400 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012401
Kailang Yanga361d842007-06-05 12:30:55 +020012402 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12403
Takashi Iwai22971e32009-02-10 11:56:44 +010012404 has_beep = 0;
12405 for (i = 0; i < spec->num_mixers; i++) {
12406 if (spec->mixers[i] == alc268_beep_mixer) {
12407 has_beep = 1;
12408 break;
12409 }
12410 }
12411
12412 if (has_beep) {
12413 err = snd_hda_attach_beep_device(codec, 0x1);
12414 if (err < 0) {
12415 alc_free(codec);
12416 return err;
12417 }
12418 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12419 /* override the amp caps for beep generator */
12420 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012421 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12422 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12423 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12424 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012425 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012426
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012427 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012428 /* check whether NID 0x07 is valid */
12429 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012430 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012431
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012432 /* get type */
12433 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012434 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012435 spec->adc_nids = alc268_adc_nids_alt;
12436 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012437 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012438 } else {
12439 spec->adc_nids = alc268_adc_nids;
12440 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012441 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012442 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012443 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012444 /* set default input source */
12445 for (i = 0; i < spec->num_adc_nids; i++)
12446 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12447 0, AC_VERB_SET_CONNECT_SEL,
12448 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012449 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012450
12451 spec->vmaster_nid = 0x02;
12452
Kailang Yanga361d842007-06-05 12:30:55 +020012453 codec->patch_ops = alc_patch_ops;
12454 if (board_config == ALC268_AUTO)
12455 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012456
Takashi Iwaidaead532008-11-28 12:55:36 +010012457 codec->proc_widget_hook = print_realtek_coef;
12458
Kailang Yanga361d842007-06-05 12:30:55 +020012459 return 0;
12460}
12461
12462/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012463 * ALC269 channel source setting (2 channel)
12464 */
12465#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12466
12467#define alc269_dac_nids alc260_dac_nids
12468
12469static hda_nid_t alc269_adc_nids[1] = {
12470 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012471 0x08,
12472};
12473
Takashi Iwaie01bf502008-08-21 16:25:07 +020012474static hda_nid_t alc269_capsrc_nids[1] = {
12475 0x23,
12476};
12477
12478/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12479 * not a mux!
12480 */
12481
Kailang Yangf53281e2008-07-18 12:36:43 +020012482static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12483 .num_items = 2,
12484 .items = {
12485 { "i-Mic", 0x5 },
12486 { "e-Mic", 0x0 },
12487 },
12488};
12489
12490static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12491 .num_items = 2,
12492 .items = {
12493 { "i-Mic", 0x1 },
12494 { "e-Mic", 0x0 },
12495 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012496};
12497
12498#define alc269_modes alc260_modes
12499#define alc269_capture_source alc880_lg_lw_capture_source
12500
12501static struct snd_kcontrol_new alc269_base_mixer[] = {
12502 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12503 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12505 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12508 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12509 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12510 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12511 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12512 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12513 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12514 { } /* end */
12515};
12516
Kailang Yang60db6b52008-08-26 13:13:00 +020012517static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12518 /* output mixer control */
12519 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12520 {
12521 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12522 .name = "Master Playback Switch",
12523 .info = snd_hda_mixer_amp_switch_info,
12524 .get = snd_hda_mixer_amp_switch_get,
12525 .put = alc268_acer_master_sw_put,
12526 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12527 },
12528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12530 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12531 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12532 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12533 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012534 { }
12535};
12536
Tony Vroon64154832008-11-06 15:08:49 +000012537static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12538 /* output mixer control */
12539 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12540 {
12541 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12542 .name = "Master Playback Switch",
12543 .info = snd_hda_mixer_amp_switch_info,
12544 .get = snd_hda_mixer_amp_switch_get,
12545 .put = alc268_acer_master_sw_put,
12546 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12547 },
12548 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12549 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12550 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12551 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12552 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12553 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12554 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12555 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12556 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012557 { }
12558};
12559
Kailang Yangf53281e2008-07-18 12:36:43 +020012560/* bind volumes of both NID 0x0c and 0x0d */
12561static struct hda_bind_ctls alc269_epc_bind_vol = {
12562 .ops = &snd_hda_bind_vol,
12563 .values = {
12564 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12565 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12566 0
12567 },
12568};
12569
12570static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12571 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12572 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12573 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12574 { } /* end */
12575};
12576
Kailang Yangf6a92242007-12-13 16:52:54 +010012577/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012578static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12579 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12580 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012581 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12582 { } /* end */
12583};
12584
12585/* FSC amilo */
12586static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12587 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12589 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012590 { } /* end */
12591};
12592
Kailang Yang60db6b52008-08-26 13:13:00 +020012593static struct hda_verb alc269_quanta_fl1_verbs[] = {
12594 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12595 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12596 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12597 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12598 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12599 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12600 { }
12601};
12602
Tony Vroon64154832008-11-06 15:08:49 +000012603static struct hda_verb alc269_lifebook_verbs[] = {
12604 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12605 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12606 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12607 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12608 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12609 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12610 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12611 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12612 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12613 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12614 { }
12615};
12616
Kailang Yang60db6b52008-08-26 13:13:00 +020012617/* toggle speaker-output according to the hp-jack state */
12618static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12619{
12620 unsigned int present;
12621 unsigned char bits;
12622
12623 present = snd_hda_codec_read(codec, 0x15, 0,
12624 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12625 bits = present ? AMP_IN_MUTE(0) : 0;
12626 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12627 AMP_IN_MUTE(0), bits);
12628 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12629 AMP_IN_MUTE(0), bits);
12630
12631 snd_hda_codec_write(codec, 0x20, 0,
12632 AC_VERB_SET_COEF_INDEX, 0x0c);
12633 snd_hda_codec_write(codec, 0x20, 0,
12634 AC_VERB_SET_PROC_COEF, 0x680);
12635
12636 snd_hda_codec_write(codec, 0x20, 0,
12637 AC_VERB_SET_COEF_INDEX, 0x0c);
12638 snd_hda_codec_write(codec, 0x20, 0,
12639 AC_VERB_SET_PROC_COEF, 0x480);
12640}
12641
Tony Vroon64154832008-11-06 15:08:49 +000012642/* toggle speaker-output according to the hp-jacks state */
12643static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12644{
12645 unsigned int present;
12646 unsigned char bits;
12647
12648 /* Check laptop headphone socket */
12649 present = snd_hda_codec_read(codec, 0x15, 0,
12650 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12651
12652 /* Check port replicator headphone socket */
12653 present |= snd_hda_codec_read(codec, 0x1a, 0,
12654 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12655
12656 bits = present ? AMP_IN_MUTE(0) : 0;
12657 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12658 AMP_IN_MUTE(0), bits);
12659 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12660 AMP_IN_MUTE(0), bits);
12661
12662 snd_hda_codec_write(codec, 0x20, 0,
12663 AC_VERB_SET_COEF_INDEX, 0x0c);
12664 snd_hda_codec_write(codec, 0x20, 0,
12665 AC_VERB_SET_PROC_COEF, 0x680);
12666
12667 snd_hda_codec_write(codec, 0x20, 0,
12668 AC_VERB_SET_COEF_INDEX, 0x0c);
12669 snd_hda_codec_write(codec, 0x20, 0,
12670 AC_VERB_SET_PROC_COEF, 0x480);
12671}
12672
Kailang Yang60db6b52008-08-26 13:13:00 +020012673static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12674{
12675 unsigned int present;
12676
12677 present = snd_hda_codec_read(codec, 0x18, 0,
12678 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12679 snd_hda_codec_write(codec, 0x23, 0,
12680 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12681}
12682
Tony Vroon64154832008-11-06 15:08:49 +000012683static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12684{
12685 unsigned int present_laptop;
12686 unsigned int present_dock;
12687
12688 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12689 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12690
12691 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12692 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12693
12694 /* Laptop mic port overrides dock mic port, design decision */
12695 if (present_dock)
12696 snd_hda_codec_write(codec, 0x23, 0,
12697 AC_VERB_SET_CONNECT_SEL, 0x3);
12698 if (present_laptop)
12699 snd_hda_codec_write(codec, 0x23, 0,
12700 AC_VERB_SET_CONNECT_SEL, 0x0);
12701 if (!present_dock && !present_laptop)
12702 snd_hda_codec_write(codec, 0x23, 0,
12703 AC_VERB_SET_CONNECT_SEL, 0x1);
12704}
12705
Kailang Yang60db6b52008-08-26 13:13:00 +020012706static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12707 unsigned int res)
12708{
12709 if ((res >> 26) == ALC880_HP_EVENT)
12710 alc269_quanta_fl1_speaker_automute(codec);
12711 if ((res >> 26) == ALC880_MIC_EVENT)
12712 alc269_quanta_fl1_mic_automute(codec);
12713}
12714
Tony Vroon64154832008-11-06 15:08:49 +000012715static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12716 unsigned int res)
12717{
12718 if ((res >> 26) == ALC880_HP_EVENT)
12719 alc269_lifebook_speaker_automute(codec);
12720 if ((res >> 26) == ALC880_MIC_EVENT)
12721 alc269_lifebook_mic_autoswitch(codec);
12722}
12723
Kailang Yang60db6b52008-08-26 13:13:00 +020012724static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12725{
12726 alc269_quanta_fl1_speaker_automute(codec);
12727 alc269_quanta_fl1_mic_automute(codec);
12728}
12729
Tony Vroon64154832008-11-06 15:08:49 +000012730static void alc269_lifebook_init_hook(struct hda_codec *codec)
12731{
12732 alc269_lifebook_speaker_automute(codec);
12733 alc269_lifebook_mic_autoswitch(codec);
12734}
12735
Kailang Yang60db6b52008-08-26 13:13:00 +020012736static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12738 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12739 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12740 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12741 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12742 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12743 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12744 {}
12745};
12746
12747static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12748 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12749 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12750 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12751 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12752 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12753 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12754 {}
12755};
12756
12757/* toggle speaker-output according to the hp-jack state */
12758static void alc269_speaker_automute(struct hda_codec *codec)
12759{
12760 unsigned int present;
12761 unsigned char bits;
12762
12763 present = snd_hda_codec_read(codec, 0x15, 0,
12764 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12765 bits = present ? AMP_IN_MUTE(0) : 0;
12766 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12767 AMP_IN_MUTE(0), bits);
12768 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12769 AMP_IN_MUTE(0), bits);
12770}
12771
12772static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12773{
12774 unsigned int present;
12775
12776 present = snd_hda_codec_read(codec, 0x18, 0,
12777 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12778 snd_hda_codec_write(codec, 0x23, 0,
12779 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12780}
12781
12782static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12783{
12784 unsigned int present;
12785
12786 present = snd_hda_codec_read(codec, 0x18, 0,
12787 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12788 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12789 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12790 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12791 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12792}
12793
12794/* unsolicited event for HP jack sensing */
12795static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12796 unsigned int res)
12797{
12798 if ((res >> 26) == ALC880_HP_EVENT)
12799 alc269_speaker_automute(codec);
12800
12801 if ((res >> 26) == ALC880_MIC_EVENT)
12802 alc269_eeepc_dmic_automute(codec);
12803}
12804
12805static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12806{
12807 alc269_speaker_automute(codec);
12808 alc269_eeepc_dmic_automute(codec);
12809}
12810
12811/* unsolicited event for HP jack sensing */
12812static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12813 unsigned int res)
12814{
12815 if ((res >> 26) == ALC880_HP_EVENT)
12816 alc269_speaker_automute(codec);
12817
12818 if ((res >> 26) == ALC880_MIC_EVENT)
12819 alc269_eeepc_amic_automute(codec);
12820}
12821
12822static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12823{
12824 alc269_speaker_automute(codec);
12825 alc269_eeepc_amic_automute(codec);
12826}
12827
Kailang Yangf6a92242007-12-13 16:52:54 +010012828/*
12829 * generic initialization of ADC, input mixers and output mixers
12830 */
12831static struct hda_verb alc269_init_verbs[] = {
12832 /*
12833 * Unmute ADC0 and set the default input to mic-in
12834 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012835 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012836
12837 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12838 * analog-loopback mixer widget
12839 * Note: PASD motherboards uses the Line In 2 as the input for
12840 * front panel mic (mic 2)
12841 */
12842 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12848
12849 /*
12850 * Set up output mixers (0x0c - 0x0e)
12851 */
12852 /* set vol=0 to output mixers */
12853 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12854 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12855
12856 /* set up input amps for analog loopback */
12857 /* Amp Indices: DAC = 0, mixer = 1 */
12858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12859 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12860 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12861 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12862 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12863 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12864
12865 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12867 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12868 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12869 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12870 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12871 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12872
12873 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12875 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12876 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12877 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12878 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12879 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12880
12881 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12882 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12883
12884 /* FIXME: use matrix-type input source selection */
12885 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12886 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012887 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12888 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012889 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12890 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12891
12892 /* set EAPD */
12893 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12894 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12895 { }
12896};
12897
12898/* add playback controls from the parsed DAC table */
12899static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12900 const struct auto_pin_cfg *cfg)
12901{
12902 hda_nid_t nid;
12903 int err;
12904
12905 spec->multiout.num_dacs = 1; /* only use one dac */
12906 spec->multiout.dac_nids = spec->private_dac_nids;
12907 spec->multiout.dac_nids[0] = 2;
12908
12909 nid = cfg->line_out_pins[0];
12910 if (nid) {
12911 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12912 "Front Playback Volume",
12913 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12914 if (err < 0)
12915 return err;
12916 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12917 "Front Playback Switch",
12918 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12919 if (err < 0)
12920 return err;
12921 }
12922
12923 nid = cfg->speaker_pins[0];
12924 if (nid) {
12925 if (!cfg->line_out_pins[0]) {
12926 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12927 "Speaker Playback Volume",
12928 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12929 HDA_OUTPUT));
12930 if (err < 0)
12931 return err;
12932 }
12933 if (nid == 0x16) {
12934 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12935 "Speaker Playback Switch",
12936 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12937 HDA_OUTPUT));
12938 if (err < 0)
12939 return err;
12940 } else {
12941 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12942 "Speaker Playback Switch",
12943 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12944 HDA_OUTPUT));
12945 if (err < 0)
12946 return err;
12947 }
12948 }
12949 nid = cfg->hp_pins[0];
12950 if (nid) {
12951 /* spec->multiout.hp_nid = 2; */
12952 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12953 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12954 "Headphone Playback Volume",
12955 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12956 HDA_OUTPUT));
12957 if (err < 0)
12958 return err;
12959 }
12960 if (nid == 0x16) {
12961 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12962 "Headphone Playback Switch",
12963 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12964 HDA_OUTPUT));
12965 if (err < 0)
12966 return err;
12967 } else {
12968 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12969 "Headphone Playback Switch",
12970 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12971 HDA_OUTPUT));
12972 if (err < 0)
12973 return err;
12974 }
12975 }
12976 return 0;
12977}
12978
Takashi Iwaiee956e02008-10-31 17:16:31 +010012979static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12980 const struct auto_pin_cfg *cfg)
12981{
12982 int err;
12983
12984 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12985 if (err < 0)
12986 return err;
12987 /* digital-mic input pin is excluded in alc880_auto_create..()
12988 * because it's under 0x18
12989 */
12990 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12991 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012992 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012993 imux->items[imux->num_items].label = "Int Mic";
12994 imux->items[imux->num_items].index = 0x05;
12995 imux->num_items++;
12996 }
12997 return 0;
12998}
Kailang Yangf6a92242007-12-13 16:52:54 +010012999
13000#ifdef CONFIG_SND_HDA_POWER_SAVE
13001#define alc269_loopbacks alc880_loopbacks
13002#endif
13003
13004/* pcm configuration: identiacal with ALC880 */
13005#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13006#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13007#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13008#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13009
Takashi Iwaif03d3112009-03-05 14:18:16 +010013010static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13011 .substreams = 1,
13012 .channels_min = 2,
13013 .channels_max = 8,
13014 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13015 /* NID is set in alc_build_pcms */
13016 .ops = {
13017 .open = alc880_playback_pcm_open,
13018 .prepare = alc880_playback_pcm_prepare,
13019 .cleanup = alc880_playback_pcm_cleanup
13020 },
13021};
13022
13023static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13024 .substreams = 1,
13025 .channels_min = 2,
13026 .channels_max = 2,
13027 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13028 /* NID is set in alc_build_pcms */
13029};
13030
Kailang Yangf6a92242007-12-13 16:52:54 +010013031/*
13032 * BIOS auto configuration
13033 */
13034static int alc269_parse_auto_config(struct hda_codec *codec)
13035{
13036 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013037 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013038 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13039
13040 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13041 alc269_ignore);
13042 if (err < 0)
13043 return err;
13044
13045 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13046 if (err < 0)
13047 return err;
13048 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13049 if (err < 0)
13050 return err;
13051
13052 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13053
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013054 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013055 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13056
Takashi Iwai603c4012008-07-30 15:01:44 +020013057 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013058 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013059
Takashi Iwaid88897e2008-10-31 15:01:37 +010013060 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013061 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013062 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013063 /* set default input source */
13064 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13065 0, AC_VERB_SET_CONNECT_SEL,
13066 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013067
13068 err = alc_auto_add_mic_boost(codec);
13069 if (err < 0)
13070 return err;
13071
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013072 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013073 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013074
Kailang Yangf6a92242007-12-13 16:52:54 +010013075 return 1;
13076}
13077
13078#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13079#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13080#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13081
13082
13083/* init callback for auto-configuration model -- overriding the default init */
13084static void alc269_auto_init(struct hda_codec *codec)
13085{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013086 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013087 alc269_auto_init_multi_out(codec);
13088 alc269_auto_init_hp_out(codec);
13089 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013090 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013091 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013092}
13093
13094/*
13095 * configuration and preset
13096 */
13097static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013098 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013099 [ALC269_QUANTA_FL1] = "quanta",
13100 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013101 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013102 [ALC269_FUJITSU] = "fujitsu",
13103 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013104};
13105
13106static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013107 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013108 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13109 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013110 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13111 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13112 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13113 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13114 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13115 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013116 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13117 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013118 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13119 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013120 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013121 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013122 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013123 {}
13124};
13125
13126static struct alc_config_preset alc269_presets[] = {
13127 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013128 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013129 .init_verbs = { alc269_init_verbs },
13130 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13131 .dac_nids = alc269_dac_nids,
13132 .hp_nid = 0x03,
13133 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13134 .channel_mode = alc269_modes,
13135 .input_mux = &alc269_capture_source,
13136 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013137 [ALC269_QUANTA_FL1] = {
13138 .mixers = { alc269_quanta_fl1_mixer },
13139 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13140 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13141 .dac_nids = alc269_dac_nids,
13142 .hp_nid = 0x03,
13143 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13144 .channel_mode = alc269_modes,
13145 .input_mux = &alc269_capture_source,
13146 .unsol_event = alc269_quanta_fl1_unsol_event,
13147 .init_hook = alc269_quanta_fl1_init_hook,
13148 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013149 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013150 .mixers = { alc269_eeepc_mixer },
13151 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013152 .init_verbs = { alc269_init_verbs,
13153 alc269_eeepc_amic_init_verbs },
13154 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13155 .dac_nids = alc269_dac_nids,
13156 .hp_nid = 0x03,
13157 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13158 .channel_mode = alc269_modes,
13159 .input_mux = &alc269_eeepc_amic_capture_source,
13160 .unsol_event = alc269_eeepc_amic_unsol_event,
13161 .init_hook = alc269_eeepc_amic_inithook,
13162 },
13163 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013164 .mixers = { alc269_eeepc_mixer },
13165 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013166 .init_verbs = { alc269_init_verbs,
13167 alc269_eeepc_dmic_init_verbs },
13168 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13169 .dac_nids = alc269_dac_nids,
13170 .hp_nid = 0x03,
13171 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13172 .channel_mode = alc269_modes,
13173 .input_mux = &alc269_eeepc_dmic_capture_source,
13174 .unsol_event = alc269_eeepc_dmic_unsol_event,
13175 .init_hook = alc269_eeepc_dmic_inithook,
13176 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013177 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013178 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013179 .cap_mixer = alc269_epc_capture_mixer,
13180 .init_verbs = { alc269_init_verbs,
13181 alc269_eeepc_dmic_init_verbs },
13182 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13183 .dac_nids = alc269_dac_nids,
13184 .hp_nid = 0x03,
13185 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13186 .channel_mode = alc269_modes,
13187 .input_mux = &alc269_eeepc_dmic_capture_source,
13188 .unsol_event = alc269_eeepc_dmic_unsol_event,
13189 .init_hook = alc269_eeepc_dmic_inithook,
13190 },
Tony Vroon64154832008-11-06 15:08:49 +000013191 [ALC269_LIFEBOOK] = {
13192 .mixers = { alc269_lifebook_mixer },
13193 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13194 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13195 .dac_nids = alc269_dac_nids,
13196 .hp_nid = 0x03,
13197 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13198 .channel_mode = alc269_modes,
13199 .input_mux = &alc269_capture_source,
13200 .unsol_event = alc269_lifebook_unsol_event,
13201 .init_hook = alc269_lifebook_init_hook,
13202 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013203};
13204
13205static int patch_alc269(struct hda_codec *codec)
13206{
13207 struct alc_spec *spec;
13208 int board_config;
13209 int err;
13210
13211 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13212 if (spec == NULL)
13213 return -ENOMEM;
13214
13215 codec->spec = spec;
13216
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013217 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13218
Kailang Yangf6a92242007-12-13 16:52:54 +010013219 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13220 alc269_models,
13221 alc269_cfg_tbl);
13222
13223 if (board_config < 0) {
13224 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
13225 "trying auto-probe from BIOS...\n");
13226 board_config = ALC269_AUTO;
13227 }
13228
13229 if (board_config == ALC269_AUTO) {
13230 /* automatic parse from the BIOS config */
13231 err = alc269_parse_auto_config(codec);
13232 if (err < 0) {
13233 alc_free(codec);
13234 return err;
13235 } else if (!err) {
13236 printk(KERN_INFO
13237 "hda_codec: Cannot set up configuration "
13238 "from BIOS. Using base mode...\n");
13239 board_config = ALC269_BASIC;
13240 }
13241 }
13242
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013243 err = snd_hda_attach_beep_device(codec, 0x1);
13244 if (err < 0) {
13245 alc_free(codec);
13246 return err;
13247 }
13248
Kailang Yangf6a92242007-12-13 16:52:54 +010013249 if (board_config != ALC269_AUTO)
13250 setup_preset(spec, &alc269_presets[board_config]);
13251
13252 spec->stream_name_analog = "ALC269 Analog";
Takashi Iwaif03d3112009-03-05 14:18:16 +010013253 if (codec->subsystem_id == 0x17aa3bf8) {
13254 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13255 * fix the sample rate of analog I/O to 44.1kHz
13256 */
13257 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13258 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13259 } else {
13260 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13261 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13262 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013263 spec->stream_name_digital = "ALC269 Digital";
13264 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13265 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13266
13267 spec->adc_nids = alc269_adc_nids;
13268 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013269 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013270 if (!spec->cap_mixer)
13271 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013272 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013273
13274 codec->patch_ops = alc_patch_ops;
13275 if (board_config == ALC269_AUTO)
13276 spec->init_hook = alc269_auto_init;
13277#ifdef CONFIG_SND_HDA_POWER_SAVE
13278 if (!spec->loopback.amplist)
13279 spec->loopback.amplist = alc269_loopbacks;
13280#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013281 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013282
13283 return 0;
13284}
13285
13286/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013287 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13288 */
13289
13290/*
13291 * set the path ways for 2 channel output
13292 * need to set the codec line out and mic 1 pin widgets to inputs
13293 */
13294static struct hda_verb alc861_threestack_ch2_init[] = {
13295 /* set pin widget 1Ah (line in) for input */
13296 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013297 /* set pin widget 18h (mic1/2) for input, for mic also enable
13298 * the vref
13299 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013300 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13301
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013302 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13303#if 0
13304 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13305 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13306#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013307 { } /* end */
13308};
13309/*
13310 * 6ch mode
13311 * need to set the codec line out and mic 1 pin widgets to outputs
13312 */
13313static struct hda_verb alc861_threestack_ch6_init[] = {
13314 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13315 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13316 /* set pin widget 18h (mic1) for output (CLFE)*/
13317 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13318
13319 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013320 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013321
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013322 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13323#if 0
13324 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13325 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13326#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013327 { } /* end */
13328};
13329
13330static struct hda_channel_mode alc861_threestack_modes[2] = {
13331 { 2, alc861_threestack_ch2_init },
13332 { 6, alc861_threestack_ch6_init },
13333};
Takashi Iwai22309c32006-08-09 16:57:28 +020013334/* Set mic1 as input and unmute the mixer */
13335static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13336 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13337 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13338 { } /* end */
13339};
13340/* Set mic1 as output and mute mixer */
13341static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13342 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13343 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13344 { } /* end */
13345};
13346
13347static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13348 { 2, alc861_uniwill_m31_ch2_init },
13349 { 4, alc861_uniwill_m31_ch4_init },
13350};
Kailang Yangdf694da2005-12-05 19:42:22 +010013351
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013352/* Set mic1 and line-in as input and unmute the mixer */
13353static struct hda_verb alc861_asus_ch2_init[] = {
13354 /* set pin widget 1Ah (line in) for input */
13355 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013356 /* set pin widget 18h (mic1/2) for input, for mic also enable
13357 * the vref
13358 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013359 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13360
13361 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13362#if 0
13363 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13364 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13365#endif
13366 { } /* end */
13367};
13368/* Set mic1 nad line-in as output and mute mixer */
13369static struct hda_verb alc861_asus_ch6_init[] = {
13370 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13371 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13372 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13373 /* set pin widget 18h (mic1) for output (CLFE)*/
13374 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13375 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13376 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13377 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13378
13379 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13380#if 0
13381 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13382 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13383#endif
13384 { } /* end */
13385};
13386
13387static struct hda_channel_mode alc861_asus_modes[2] = {
13388 { 2, alc861_asus_ch2_init },
13389 { 6, alc861_asus_ch6_init },
13390};
13391
Kailang Yangdf694da2005-12-05 19:42:22 +010013392/* patch-ALC861 */
13393
13394static struct snd_kcontrol_new alc861_base_mixer[] = {
13395 /* output mixer control */
13396 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13397 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13398 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13399 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13400 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13401
13402 /*Input mixer control */
13403 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13404 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13405 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13406 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13407 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13408 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13409 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13410 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13411 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13412 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013413
Kailang Yangdf694da2005-12-05 19:42:22 +010013414 { } /* end */
13415};
13416
13417static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13418 /* output mixer control */
13419 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13420 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13421 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13422 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13423 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13424
13425 /* Input mixer control */
13426 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13427 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13428 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13429 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13430 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13431 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13433 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13434 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13435 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013436
Kailang Yangdf694da2005-12-05 19:42:22 +010013437 {
13438 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13439 .name = "Channel Mode",
13440 .info = alc_ch_mode_info,
13441 .get = alc_ch_mode_get,
13442 .put = alc_ch_mode_put,
13443 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13444 },
13445 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013446};
13447
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013448static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013449 /* output mixer control */
13450 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13451 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13452 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013453
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013454 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013455};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013456
Takashi Iwai22309c32006-08-09 16:57:28 +020013457static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13458 /* output mixer control */
13459 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13460 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13461 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13462 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13463 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13464
13465 /* Input mixer control */
13466 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13467 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13468 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13469 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13470 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13471 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13473 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13474 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13475 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013476
Takashi Iwai22309c32006-08-09 16:57:28 +020013477 {
13478 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13479 .name = "Channel Mode",
13480 .info = alc_ch_mode_info,
13481 .get = alc_ch_mode_get,
13482 .put = alc_ch_mode_put,
13483 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13484 },
13485 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013486};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013487
13488static struct snd_kcontrol_new alc861_asus_mixer[] = {
13489 /* output mixer control */
13490 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13491 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13492 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13493 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13494 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13495
13496 /* Input mixer control */
13497 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13498 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13499 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13500 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13501 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13502 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13504 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13505 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013506 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13507
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013508 {
13509 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13510 .name = "Channel Mode",
13511 .info = alc_ch_mode_info,
13512 .get = alc_ch_mode_get,
13513 .put = alc_ch_mode_put,
13514 .private_value = ARRAY_SIZE(alc861_asus_modes),
13515 },
13516 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013517};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013518
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013519/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013520static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013521 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13522 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013523 { }
13524};
13525
Kailang Yangdf694da2005-12-05 19:42:22 +010013526/*
13527 * generic initialization of ADC, input mixers and output mixers
13528 */
13529static struct hda_verb alc861_base_init_verbs[] = {
13530 /*
13531 * Unmute ADC0 and set the default input to mic-in
13532 */
13533 /* port-A for surround (rear panel) */
13534 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13535 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13536 /* port-B for mic-in (rear panel) with vref */
13537 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13538 /* port-C for line-in (rear panel) */
13539 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13540 /* port-D for Front */
13541 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13542 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13543 /* port-E for HP out (front panel) */
13544 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13545 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013546 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013547 /* port-F for mic-in (front panel) with vref */
13548 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13549 /* port-G for CLFE (rear panel) */
13550 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13551 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13552 /* port-H for side (rear panel) */
13553 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13554 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13555 /* CD-in */
13556 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13557 /* route front mic to ADC1*/
13558 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13559 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013560
Kailang Yangdf694da2005-12-05 19:42:22 +010013561 /* Unmute DAC0~3 & spdif out*/
13562 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13563 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13564 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13565 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13566 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013567
Kailang Yangdf694da2005-12-05 19:42:22 +010013568 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13569 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13570 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13571 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13572 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013573
Kailang Yangdf694da2005-12-05 19:42:22 +010013574 /* Unmute Stereo Mixer 15 */
13575 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013579
13580 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13581 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13582 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13583 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13584 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13585 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13586 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13587 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013588 /* hp used DAC 3 (Front) */
13589 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013590 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13591
13592 { }
13593};
13594
13595static struct hda_verb alc861_threestack_init_verbs[] = {
13596 /*
13597 * Unmute ADC0 and set the default input to mic-in
13598 */
13599 /* port-A for surround (rear panel) */
13600 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13601 /* port-B for mic-in (rear panel) with vref */
13602 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13603 /* port-C for line-in (rear panel) */
13604 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13605 /* port-D for Front */
13606 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13607 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13608 /* port-E for HP out (front panel) */
13609 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13610 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013611 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013612 /* port-F for mic-in (front panel) with vref */
13613 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13614 /* port-G for CLFE (rear panel) */
13615 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13616 /* port-H for side (rear panel) */
13617 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13618 /* CD-in */
13619 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13620 /* route front mic to ADC1*/
13621 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13622 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13623 /* Unmute DAC0~3 & spdif out*/
13624 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13625 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13626 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13627 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013629
Kailang Yangdf694da2005-12-05 19:42:22 +010013630 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13631 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13632 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13633 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13634 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013635
Kailang Yangdf694da2005-12-05 19:42:22 +010013636 /* Unmute Stereo Mixer 15 */
13637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013641
13642 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13643 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13644 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13645 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13646 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13647 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13648 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13649 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013650 /* hp used DAC 3 (Front) */
13651 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013652 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13653 { }
13654};
Takashi Iwai22309c32006-08-09 16:57:28 +020013655
13656static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13657 /*
13658 * Unmute ADC0 and set the default input to mic-in
13659 */
13660 /* port-A for surround (rear panel) */
13661 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13662 /* port-B for mic-in (rear panel) with vref */
13663 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13664 /* port-C for line-in (rear panel) */
13665 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13666 /* port-D for Front */
13667 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13668 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13669 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013670 /* this has to be set to VREF80 */
13671 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013672 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013673 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013674 /* port-F for mic-in (front panel) with vref */
13675 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13676 /* port-G for CLFE (rear panel) */
13677 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13678 /* port-H for side (rear panel) */
13679 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13680 /* CD-in */
13681 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13682 /* route front mic to ADC1*/
13683 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13684 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13685 /* Unmute DAC0~3 & spdif out*/
13686 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13687 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13688 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13689 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13690 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013691
Takashi Iwai22309c32006-08-09 16:57:28 +020013692 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13693 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13694 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13695 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13696 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013697
Takashi Iwai22309c32006-08-09 16:57:28 +020013698 /* Unmute Stereo Mixer 15 */
13699 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13701 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013702 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013703
13704 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13705 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13706 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13707 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13709 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13710 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13711 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013712 /* hp used DAC 3 (Front) */
13713 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013714 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13715 { }
13716};
13717
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013718static struct hda_verb alc861_asus_init_verbs[] = {
13719 /*
13720 * Unmute ADC0 and set the default input to mic-in
13721 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013722 /* port-A for surround (rear panel)
13723 * according to codec#0 this is the HP jack
13724 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013725 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13726 /* route front PCM to HP */
13727 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13728 /* port-B for mic-in (rear panel) with vref */
13729 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13730 /* port-C for line-in (rear panel) */
13731 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13732 /* port-D for Front */
13733 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13734 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13735 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013736 /* this has to be set to VREF80 */
13737 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013738 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013739 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013740 /* port-F for mic-in (front panel) with vref */
13741 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13742 /* port-G for CLFE (rear panel) */
13743 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13744 /* port-H for side (rear panel) */
13745 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13746 /* CD-in */
13747 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13748 /* route front mic to ADC1*/
13749 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13751 /* Unmute DAC0~3 & spdif out*/
13752 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13753 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13754 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13755 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13757 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13758 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13759 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13760 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13761 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013762
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013763 /* Unmute Stereo Mixer 15 */
13764 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13766 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013768
13769 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13770 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13771 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13772 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13773 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13774 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13775 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13776 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013777 /* hp used DAC 3 (Front) */
13778 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13780 { }
13781};
13782
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013783/* additional init verbs for ASUS laptops */
13784static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13785 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13786 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13787 { }
13788};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013789
Kailang Yangdf694da2005-12-05 19:42:22 +010013790/*
13791 * generic initialization of ADC, input mixers and output mixers
13792 */
13793static struct hda_verb alc861_auto_init_verbs[] = {
13794 /*
13795 * Unmute ADC0 and set the default input to mic-in
13796 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013797 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013798 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013799
Kailang Yangdf694da2005-12-05 19:42:22 +010013800 /* Unmute DAC0~3 & spdif out*/
13801 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13802 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13803 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13804 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13805 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013806
Kailang Yangdf694da2005-12-05 19:42:22 +010013807 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13808 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13809 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13810 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13811 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013812
Kailang Yangdf694da2005-12-05 19:42:22 +010013813 /* Unmute Stereo Mixer 15 */
13814 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13815 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13818
13819 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13820 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13821 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13822 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13823 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13824 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13825 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13826 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13827
13828 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13829 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013830 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13831 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013832 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13833 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013834 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13835 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013836
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013837 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013838
13839 { }
13840};
13841
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013842static struct hda_verb alc861_toshiba_init_verbs[] = {
13843 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013844
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013845 { }
13846};
13847
13848/* toggle speaker-output according to the hp-jack state */
13849static void alc861_toshiba_automute(struct hda_codec *codec)
13850{
13851 unsigned int present;
13852
13853 present = snd_hda_codec_read(codec, 0x0f, 0,
13854 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013855 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13856 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13857 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13858 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013859}
13860
13861static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13862 unsigned int res)
13863{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013864 if ((res >> 26) == ALC880_HP_EVENT)
13865 alc861_toshiba_automute(codec);
13866}
13867
Kailang Yangdf694da2005-12-05 19:42:22 +010013868/* pcm configuration: identiacal with ALC880 */
13869#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13870#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13871#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13872#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13873
13874
13875#define ALC861_DIGOUT_NID 0x07
13876
13877static struct hda_channel_mode alc861_8ch_modes[1] = {
13878 { 8, NULL }
13879};
13880
13881static hda_nid_t alc861_dac_nids[4] = {
13882 /* front, surround, clfe, side */
13883 0x03, 0x06, 0x05, 0x04
13884};
13885
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013886static hda_nid_t alc660_dac_nids[3] = {
13887 /* front, clfe, surround */
13888 0x03, 0x05, 0x06
13889};
13890
Kailang Yangdf694da2005-12-05 19:42:22 +010013891static hda_nid_t alc861_adc_nids[1] = {
13892 /* ADC0-2 */
13893 0x08,
13894};
13895
13896static struct hda_input_mux alc861_capture_source = {
13897 .num_items = 5,
13898 .items = {
13899 { "Mic", 0x0 },
13900 { "Front Mic", 0x3 },
13901 { "Line", 0x1 },
13902 { "CD", 0x4 },
13903 { "Mixer", 0x5 },
13904 },
13905};
13906
13907/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013908static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13909 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013910{
13911 int i;
13912 hda_nid_t nid;
13913
13914 spec->multiout.dac_nids = spec->private_dac_nids;
13915 for (i = 0; i < cfg->line_outs; i++) {
13916 nid = cfg->line_out_pins[i];
13917 if (nid) {
13918 if (i >= ARRAY_SIZE(alc861_dac_nids))
13919 continue;
13920 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13921 }
13922 }
13923 spec->multiout.num_dacs = cfg->line_outs;
13924 return 0;
13925}
13926
13927/* add playback controls from the parsed DAC table */
13928static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13929 const struct auto_pin_cfg *cfg)
13930{
13931 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013932 static const char *chname[4] = {
13933 "Front", "Surround", NULL /*CLFE*/, "Side"
13934 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013935 hda_nid_t nid;
13936 int i, idx, err;
13937
13938 for (i = 0; i < cfg->line_outs; i++) {
13939 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013940 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013941 continue;
13942 if (nid == 0x05) {
13943 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013944 err = add_control(spec, ALC_CTL_BIND_MUTE,
13945 "Center Playback Switch",
13946 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13947 HDA_OUTPUT));
13948 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013949 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013950 err = add_control(spec, ALC_CTL_BIND_MUTE,
13951 "LFE Playback Switch",
13952 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13953 HDA_OUTPUT));
13954 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013955 return err;
13956 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013957 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13958 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013959 if (nid == alc861_dac_nids[idx])
13960 break;
13961 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013962 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13963 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13964 HDA_OUTPUT));
13965 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013966 return err;
13967 }
13968 }
13969 return 0;
13970}
13971
13972static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13973{
13974 int err;
13975 hda_nid_t nid;
13976
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013977 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013978 return 0;
13979
13980 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13981 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013982 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13983 "Headphone Playback Switch",
13984 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13985 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013986 return err;
13987 spec->multiout.hp_nid = nid;
13988 }
13989 return 0;
13990}
13991
13992/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013993static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13994 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013995{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013996 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013997 int i, err, idx, idx1;
13998
13999 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014000 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014001 case 0x0c:
14002 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014003 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014004 break;
14005 case 0x0f:
14006 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014007 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014008 break;
14009 case 0x0d:
14010 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014011 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014012 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014013 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014014 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014015 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014016 break;
14017 case 0x11:
14018 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014019 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014020 break;
14021 default:
14022 continue;
14023 }
14024
Takashi Iwai4a471b72005-12-07 13:56:29 +010014025 err = new_analog_input(spec, cfg->input_pins[i],
14026 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014027 if (err < 0)
14028 return err;
14029
Takashi Iwai4a471b72005-12-07 13:56:29 +010014030 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014031 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014032 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014033 }
14034 return 0;
14035}
14036
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014037static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14038 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010014039 int pin_type, int dac_idx)
14040{
Jacek Luczak564c5be2008-05-03 18:41:23 +020014041 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14042 pin_type);
14043 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14044 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010014045}
14046
14047static void alc861_auto_init_multi_out(struct hda_codec *codec)
14048{
14049 struct alc_spec *spec = codec->spec;
14050 int i;
14051
14052 for (i = 0; i < spec->autocfg.line_outs; i++) {
14053 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014054 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014055 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014056 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014057 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014058 }
14059}
14060
14061static void alc861_auto_init_hp_out(struct hda_codec *codec)
14062{
14063 struct alc_spec *spec = codec->spec;
14064 hda_nid_t pin;
14065
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014066 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014067 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014068 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14069 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014070 pin = spec->autocfg.speaker_pins[0];
14071 if (pin)
14072 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014073}
14074
14075static void alc861_auto_init_analog_input(struct hda_codec *codec)
14076{
14077 struct alc_spec *spec = codec->spec;
14078 int i;
14079
14080 for (i = 0; i < AUTO_PIN_LAST; i++) {
14081 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014082 if (nid >= 0x0c && nid <= 0x11)
14083 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014084 }
14085}
14086
14087/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014088/* return 1 if successful, 0 if the proper config is not found,
14089 * or a negative error code
14090 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014091static int alc861_parse_auto_config(struct hda_codec *codec)
14092{
14093 struct alc_spec *spec = codec->spec;
14094 int err;
14095 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14096
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014097 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14098 alc861_ignore);
14099 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014100 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014101 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014102 return 0; /* can't find valid BIOS pin config */
14103
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014104 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14105 if (err < 0)
14106 return err;
14107 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14108 if (err < 0)
14109 return err;
14110 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14111 if (err < 0)
14112 return err;
14113 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14114 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014115 return err;
14116
14117 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14118
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014119 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014120 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14121
Takashi Iwai603c4012008-07-30 15:01:44 +020014122 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014123 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014124
Takashi Iwaid88897e2008-10-31 15:01:37 +010014125 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014126
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014127 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014128 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014129
14130 spec->adc_nids = alc861_adc_nids;
14131 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014132 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014133
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014134 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14135
Kailang Yangdf694da2005-12-05 19:42:22 +010014136 return 1;
14137}
14138
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014139/* additional initialization for auto-configuration model */
14140static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014141{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014142 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014143 alc861_auto_init_multi_out(codec);
14144 alc861_auto_init_hp_out(codec);
14145 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014146 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014147 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014148}
14149
Takashi Iwaicb53c622007-08-10 17:21:45 +020014150#ifdef CONFIG_SND_HDA_POWER_SAVE
14151static struct hda_amp_list alc861_loopbacks[] = {
14152 { 0x15, HDA_INPUT, 0 },
14153 { 0x15, HDA_INPUT, 1 },
14154 { 0x15, HDA_INPUT, 2 },
14155 { 0x15, HDA_INPUT, 3 },
14156 { } /* end */
14157};
14158#endif
14159
Kailang Yangdf694da2005-12-05 19:42:22 +010014160
14161/*
14162 * configuration and preset
14163 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014164static const char *alc861_models[ALC861_MODEL_LAST] = {
14165 [ALC861_3ST] = "3stack",
14166 [ALC660_3ST] = "3stack-660",
14167 [ALC861_3ST_DIG] = "3stack-dig",
14168 [ALC861_6ST_DIG] = "6stack-dig",
14169 [ALC861_UNIWILL_M31] = "uniwill-m31",
14170 [ALC861_TOSHIBA] = "toshiba",
14171 [ALC861_ASUS] = "asus",
14172 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14173 [ALC861_AUTO] = "auto",
14174};
14175
14176static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014177 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014178 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14179 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14180 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014181 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014182 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014183 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014184 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14185 * Any other models that need this preset?
14186 */
14187 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014188 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14189 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014190 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14191 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14192 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14193 /* FIXME: the below seems conflict */
14194 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14195 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14196 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014197 {}
14198};
14199
14200static struct alc_config_preset alc861_presets[] = {
14201 [ALC861_3ST] = {
14202 .mixers = { alc861_3ST_mixer },
14203 .init_verbs = { alc861_threestack_init_verbs },
14204 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14205 .dac_nids = alc861_dac_nids,
14206 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14207 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014208 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014209 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14210 .adc_nids = alc861_adc_nids,
14211 .input_mux = &alc861_capture_source,
14212 },
14213 [ALC861_3ST_DIG] = {
14214 .mixers = { alc861_base_mixer },
14215 .init_verbs = { alc861_threestack_init_verbs },
14216 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14217 .dac_nids = alc861_dac_nids,
14218 .dig_out_nid = ALC861_DIGOUT_NID,
14219 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14220 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014221 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014222 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14223 .adc_nids = alc861_adc_nids,
14224 .input_mux = &alc861_capture_source,
14225 },
14226 [ALC861_6ST_DIG] = {
14227 .mixers = { alc861_base_mixer },
14228 .init_verbs = { alc861_base_init_verbs },
14229 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14230 .dac_nids = alc861_dac_nids,
14231 .dig_out_nid = ALC861_DIGOUT_NID,
14232 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14233 .channel_mode = alc861_8ch_modes,
14234 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14235 .adc_nids = alc861_adc_nids,
14236 .input_mux = &alc861_capture_source,
14237 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014238 [ALC660_3ST] = {
14239 .mixers = { alc861_3ST_mixer },
14240 .init_verbs = { alc861_threestack_init_verbs },
14241 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14242 .dac_nids = alc660_dac_nids,
14243 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14244 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014245 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014246 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14247 .adc_nids = alc861_adc_nids,
14248 .input_mux = &alc861_capture_source,
14249 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014250 [ALC861_UNIWILL_M31] = {
14251 .mixers = { alc861_uniwill_m31_mixer },
14252 .init_verbs = { alc861_uniwill_m31_init_verbs },
14253 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14254 .dac_nids = alc861_dac_nids,
14255 .dig_out_nid = ALC861_DIGOUT_NID,
14256 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14257 .channel_mode = alc861_uniwill_m31_modes,
14258 .need_dac_fix = 1,
14259 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14260 .adc_nids = alc861_adc_nids,
14261 .input_mux = &alc861_capture_source,
14262 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014263 [ALC861_TOSHIBA] = {
14264 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014265 .init_verbs = { alc861_base_init_verbs,
14266 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014267 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14268 .dac_nids = alc861_dac_nids,
14269 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14270 .channel_mode = alc883_3ST_2ch_modes,
14271 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14272 .adc_nids = alc861_adc_nids,
14273 .input_mux = &alc861_capture_source,
14274 .unsol_event = alc861_toshiba_unsol_event,
14275 .init_hook = alc861_toshiba_automute,
14276 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014277 [ALC861_ASUS] = {
14278 .mixers = { alc861_asus_mixer },
14279 .init_verbs = { alc861_asus_init_verbs },
14280 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14281 .dac_nids = alc861_dac_nids,
14282 .dig_out_nid = ALC861_DIGOUT_NID,
14283 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14284 .channel_mode = alc861_asus_modes,
14285 .need_dac_fix = 1,
14286 .hp_nid = 0x06,
14287 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14288 .adc_nids = alc861_adc_nids,
14289 .input_mux = &alc861_capture_source,
14290 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014291 [ALC861_ASUS_LAPTOP] = {
14292 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14293 .init_verbs = { alc861_asus_init_verbs,
14294 alc861_asus_laptop_init_verbs },
14295 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14296 .dac_nids = alc861_dac_nids,
14297 .dig_out_nid = ALC861_DIGOUT_NID,
14298 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14299 .channel_mode = alc883_3ST_2ch_modes,
14300 .need_dac_fix = 1,
14301 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14302 .adc_nids = alc861_adc_nids,
14303 .input_mux = &alc861_capture_source,
14304 },
14305};
Kailang Yangdf694da2005-12-05 19:42:22 +010014306
14307
14308static int patch_alc861(struct hda_codec *codec)
14309{
14310 struct alc_spec *spec;
14311 int board_config;
14312 int err;
14313
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014314 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014315 if (spec == NULL)
14316 return -ENOMEM;
14317
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014318 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014319
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014320 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14321 alc861_models,
14322 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014323
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014324 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014325 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14326 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014327 board_config = ALC861_AUTO;
14328 }
14329
14330 if (board_config == ALC861_AUTO) {
14331 /* automatic parse from the BIOS config */
14332 err = alc861_parse_auto_config(codec);
14333 if (err < 0) {
14334 alc_free(codec);
14335 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014336 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014337 printk(KERN_INFO
14338 "hda_codec: Cannot set up configuration "
14339 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014340 board_config = ALC861_3ST_DIG;
14341 }
14342 }
14343
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014344 err = snd_hda_attach_beep_device(codec, 0x23);
14345 if (err < 0) {
14346 alc_free(codec);
14347 return err;
14348 }
14349
Kailang Yangdf694da2005-12-05 19:42:22 +010014350 if (board_config != ALC861_AUTO)
14351 setup_preset(spec, &alc861_presets[board_config]);
14352
14353 spec->stream_name_analog = "ALC861 Analog";
14354 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14355 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14356
14357 spec->stream_name_digital = "ALC861 Digital";
14358 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14359 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14360
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014361 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14362
Takashi Iwai2134ea42008-01-10 16:53:55 +010014363 spec->vmaster_nid = 0x03;
14364
Kailang Yangdf694da2005-12-05 19:42:22 +010014365 codec->patch_ops = alc_patch_ops;
14366 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014367 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014368#ifdef CONFIG_SND_HDA_POWER_SAVE
14369 if (!spec->loopback.amplist)
14370 spec->loopback.amplist = alc861_loopbacks;
14371#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014372 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014373
Kailang Yangdf694da2005-12-05 19:42:22 +010014374 return 0;
14375}
14376
14377/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014378 * ALC861-VD support
14379 *
14380 * Based on ALC882
14381 *
14382 * In addition, an independent DAC
14383 */
14384#define ALC861VD_DIGOUT_NID 0x06
14385
14386static hda_nid_t alc861vd_dac_nids[4] = {
14387 /* front, surr, clfe, side surr */
14388 0x02, 0x03, 0x04, 0x05
14389};
14390
14391/* dac_nids for ALC660vd are in a different order - according to
14392 * Realtek's driver.
14393 * This should probably tesult in a different mixer for 6stack models
14394 * of ALC660vd codecs, but for now there is only 3stack mixer
14395 * - and it is the same as in 861vd.
14396 * adc_nids in ALC660vd are (is) the same as in 861vd
14397 */
14398static hda_nid_t alc660vd_dac_nids[3] = {
14399 /* front, rear, clfe, rear_surr */
14400 0x02, 0x04, 0x03
14401};
14402
14403static hda_nid_t alc861vd_adc_nids[1] = {
14404 /* ADC0 */
14405 0x09,
14406};
14407
Takashi Iwaie1406342008-02-11 18:32:32 +010014408static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14409
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014410/* input MUX */
14411/* FIXME: should be a matrix-type input source selection */
14412static struct hda_input_mux alc861vd_capture_source = {
14413 .num_items = 4,
14414 .items = {
14415 { "Mic", 0x0 },
14416 { "Front Mic", 0x1 },
14417 { "Line", 0x2 },
14418 { "CD", 0x4 },
14419 },
14420};
14421
Kailang Yang272a5272007-05-14 11:00:38 +020014422static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014423 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014424 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014425 { "Ext Mic", 0x0 },
14426 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014427 },
14428};
14429
Kailang Yangd1a991a2007-08-15 16:21:59 +020014430static struct hda_input_mux alc861vd_hp_capture_source = {
14431 .num_items = 2,
14432 .items = {
14433 { "Front Mic", 0x0 },
14434 { "ATAPI Mic", 0x1 },
14435 },
14436};
14437
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014438/*
14439 * 2ch mode
14440 */
14441static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14442 { 2, NULL }
14443};
14444
14445/*
14446 * 6ch mode
14447 */
14448static struct hda_verb alc861vd_6stack_ch6_init[] = {
14449 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14450 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14451 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14452 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14453 { } /* end */
14454};
14455
14456/*
14457 * 8ch mode
14458 */
14459static struct hda_verb alc861vd_6stack_ch8_init[] = {
14460 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14461 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14462 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14463 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14464 { } /* end */
14465};
14466
14467static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14468 { 6, alc861vd_6stack_ch6_init },
14469 { 8, alc861vd_6stack_ch8_init },
14470};
14471
14472static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14473 {
14474 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14475 .name = "Channel Mode",
14476 .info = alc_ch_mode_info,
14477 .get = alc_ch_mode_get,
14478 .put = alc_ch_mode_put,
14479 },
14480 { } /* end */
14481};
14482
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014483/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14484 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14485 */
14486static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14487 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14488 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14489
14490 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14491 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14492
14493 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14494 HDA_OUTPUT),
14495 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14496 HDA_OUTPUT),
14497 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14498 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14499
14500 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14501 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14502
14503 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14504
14505 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14508
14509 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14510 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14511 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14512
14513 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14514 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14515
14516 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14517 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14518
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014519 { } /* end */
14520};
14521
14522static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14523 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14524 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14525
14526 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14527
14528 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14529 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14530 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14531
14532 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14533 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14534 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14535
14536 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14537 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14538
14539 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14540 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14541
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014542 { } /* end */
14543};
14544
Kailang Yangbdd148a2007-05-08 15:19:08 +020014545static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14546 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14547 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14548 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14549
14550 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14551
14552 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14553 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14554 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14555
14556 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14557 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14558 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14559
14560 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14561 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14562
14563 { } /* end */
14564};
14565
Tobin Davisb419f342008-03-07 11:57:51 +010014566/* Pin assignment: Speaker=0x14, HP = 0x15,
14567 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014568 */
14569static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014570 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14571 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014572 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14573 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014574 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14575 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14576 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14577 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14578 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14579 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014580 { } /* end */
14581};
14582
Kailang Yangd1a991a2007-08-15 16:21:59 +020014583/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14584 * Front Mic=0x18, ATAPI Mic = 0x19,
14585 */
14586static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14587 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14588 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14589 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14590 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14591 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14592 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14593 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14594 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014595
Kailang Yangd1a991a2007-08-15 16:21:59 +020014596 { } /* end */
14597};
14598
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014599/*
14600 * generic initialization of ADC, input mixers and output mixers
14601 */
14602static struct hda_verb alc861vd_volume_init_verbs[] = {
14603 /*
14604 * Unmute ADC0 and set the default input to mic-in
14605 */
14606 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14608
14609 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14610 * the analog-loopback mixer widget
14611 */
14612 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014613 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14614 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014618
14619 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014624
14625 /*
14626 * Set up output mixers (0x02 - 0x05)
14627 */
14628 /* set vol=0 to output mixers */
14629 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14630 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14631 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14632 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14633
14634 /* set up input amps for analog loopback */
14635 /* Amp Indices: DAC = 0, mixer = 1 */
14636 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14638 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14639 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14640 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14641 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14642 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14643 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14644
14645 { }
14646};
14647
14648/*
14649 * 3-stack pin configuration:
14650 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14651 */
14652static struct hda_verb alc861vd_3stack_init_verbs[] = {
14653 /*
14654 * Set pin mode and muting
14655 */
14656 /* set front pin widgets 0x14 for output */
14657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14658 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14659 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14660
14661 /* Mic (rear) pin: input vref at 80% */
14662 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14663 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14664 /* Front Mic pin: input vref at 80% */
14665 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14666 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14667 /* Line In pin: input */
14668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14669 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14670 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14672 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14673 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14674 /* CD pin widget for input */
14675 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14676
14677 { }
14678};
14679
14680/*
14681 * 6-stack pin configuration:
14682 */
14683static struct hda_verb alc861vd_6stack_init_verbs[] = {
14684 /*
14685 * Set pin mode and muting
14686 */
14687 /* set front pin widgets 0x14 for output */
14688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14690 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14691
14692 /* Rear Pin: output 1 (0x0d) */
14693 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14694 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14695 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14696 /* CLFE Pin: output 2 (0x0e) */
14697 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14698 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14699 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14700 /* Side Pin: output 3 (0x0f) */
14701 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14702 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14703 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14704
14705 /* Mic (rear) pin: input vref at 80% */
14706 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14707 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14708 /* Front Mic pin: input vref at 80% */
14709 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14710 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14711 /* Line In pin: input */
14712 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14713 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14714 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14716 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14717 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14718 /* CD pin widget for input */
14719 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14720
14721 { }
14722};
14723
Kailang Yangbdd148a2007-05-08 15:19:08 +020014724static struct hda_verb alc861vd_eapd_verbs[] = {
14725 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14726 { }
14727};
14728
Kailang Yangf9423e72008-05-27 12:32:25 +020014729static struct hda_verb alc660vd_eapd_verbs[] = {
14730 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14731 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14732 { }
14733};
14734
Kailang Yangbdd148a2007-05-08 15:19:08 +020014735static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14739 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014740 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014741 {}
14742};
14743
14744/* toggle speaker-output according to the hp-jack state */
14745static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14746{
14747 unsigned int present;
14748 unsigned char bits;
14749
14750 present = snd_hda_codec_read(codec, 0x1b, 0,
14751 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014752 bits = present ? HDA_AMP_MUTE : 0;
14753 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14754 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014755}
14756
14757static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14758{
14759 unsigned int present;
14760 unsigned char bits;
14761
14762 present = snd_hda_codec_read(codec, 0x18, 0,
14763 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014764 bits = present ? HDA_AMP_MUTE : 0;
14765 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14766 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014767}
14768
14769static void alc861vd_lenovo_automute(struct hda_codec *codec)
14770{
14771 alc861vd_lenovo_hp_automute(codec);
14772 alc861vd_lenovo_mic_automute(codec);
14773}
14774
14775static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14776 unsigned int res)
14777{
14778 switch (res >> 26) {
14779 case ALC880_HP_EVENT:
14780 alc861vd_lenovo_hp_automute(codec);
14781 break;
14782 case ALC880_MIC_EVENT:
14783 alc861vd_lenovo_mic_automute(codec);
14784 break;
14785 }
14786}
14787
Kailang Yang272a5272007-05-14 11:00:38 +020014788static struct hda_verb alc861vd_dallas_verbs[] = {
14789 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14790 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14791 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14792 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14793
14794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14795 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14796 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14797 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14798 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14799 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14800 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14801 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014802
Kailang Yang272a5272007-05-14 11:00:38 +020014803 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14804 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14806 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14807 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14808 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14809 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14810 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14811
14812 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14813 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14814 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14815 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14816 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14817 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14818 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14819 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14820
14821 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14822 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14823 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14824 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14825
14826 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014827 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014828 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14829
14830 { } /* end */
14831};
14832
14833/* toggle speaker-output according to the hp-jack state */
14834static void alc861vd_dallas_automute(struct hda_codec *codec)
14835{
14836 unsigned int present;
14837
14838 present = snd_hda_codec_read(codec, 0x15, 0,
14839 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014840 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14841 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014842}
14843
14844static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14845{
14846 if ((res >> 26) == ALC880_HP_EVENT)
14847 alc861vd_dallas_automute(codec);
14848}
14849
Takashi Iwaicb53c622007-08-10 17:21:45 +020014850#ifdef CONFIG_SND_HDA_POWER_SAVE
14851#define alc861vd_loopbacks alc880_loopbacks
14852#endif
14853
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014854/* pcm configuration: identiacal with ALC880 */
14855#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14856#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14857#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14858#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14859
14860/*
14861 * configuration and preset
14862 */
14863static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14864 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014865 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014866 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014867 [ALC861VD_3ST] = "3stack",
14868 [ALC861VD_3ST_DIG] = "3stack-digout",
14869 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014870 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014871 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014872 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014873 [ALC861VD_AUTO] = "auto",
14874};
14875
14876static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014877 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14878 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014879 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014880 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014881 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014882 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014883 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014884 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014885 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014886 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014887 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014888 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014889 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014890 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014891 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014892 {}
14893};
14894
14895static struct alc_config_preset alc861vd_presets[] = {
14896 [ALC660VD_3ST] = {
14897 .mixers = { alc861vd_3st_mixer },
14898 .init_verbs = { alc861vd_volume_init_verbs,
14899 alc861vd_3stack_init_verbs },
14900 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14901 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014902 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14903 .channel_mode = alc861vd_3stack_2ch_modes,
14904 .input_mux = &alc861vd_capture_source,
14905 },
Mike Crash6963f842007-06-25 12:12:51 +020014906 [ALC660VD_3ST_DIG] = {
14907 .mixers = { alc861vd_3st_mixer },
14908 .init_verbs = { alc861vd_volume_init_verbs,
14909 alc861vd_3stack_init_verbs },
14910 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14911 .dac_nids = alc660vd_dac_nids,
14912 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014913 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14914 .channel_mode = alc861vd_3stack_2ch_modes,
14915 .input_mux = &alc861vd_capture_source,
14916 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014917 [ALC861VD_3ST] = {
14918 .mixers = { alc861vd_3st_mixer },
14919 .init_verbs = { alc861vd_volume_init_verbs,
14920 alc861vd_3stack_init_verbs },
14921 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14922 .dac_nids = alc861vd_dac_nids,
14923 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14924 .channel_mode = alc861vd_3stack_2ch_modes,
14925 .input_mux = &alc861vd_capture_source,
14926 },
14927 [ALC861VD_3ST_DIG] = {
14928 .mixers = { alc861vd_3st_mixer },
14929 .init_verbs = { alc861vd_volume_init_verbs,
14930 alc861vd_3stack_init_verbs },
14931 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14932 .dac_nids = alc861vd_dac_nids,
14933 .dig_out_nid = ALC861VD_DIGOUT_NID,
14934 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14935 .channel_mode = alc861vd_3stack_2ch_modes,
14936 .input_mux = &alc861vd_capture_source,
14937 },
14938 [ALC861VD_6ST_DIG] = {
14939 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14940 .init_verbs = { alc861vd_volume_init_verbs,
14941 alc861vd_6stack_init_verbs },
14942 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14943 .dac_nids = alc861vd_dac_nids,
14944 .dig_out_nid = ALC861VD_DIGOUT_NID,
14945 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14946 .channel_mode = alc861vd_6stack_modes,
14947 .input_mux = &alc861vd_capture_source,
14948 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014949 [ALC861VD_LENOVO] = {
14950 .mixers = { alc861vd_lenovo_mixer },
14951 .init_verbs = { alc861vd_volume_init_verbs,
14952 alc861vd_3stack_init_verbs,
14953 alc861vd_eapd_verbs,
14954 alc861vd_lenovo_unsol_verbs },
14955 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14956 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014957 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14958 .channel_mode = alc861vd_3stack_2ch_modes,
14959 .input_mux = &alc861vd_capture_source,
14960 .unsol_event = alc861vd_lenovo_unsol_event,
14961 .init_hook = alc861vd_lenovo_automute,
14962 },
Kailang Yang272a5272007-05-14 11:00:38 +020014963 [ALC861VD_DALLAS] = {
14964 .mixers = { alc861vd_dallas_mixer },
14965 .init_verbs = { alc861vd_dallas_verbs },
14966 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14967 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014968 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14969 .channel_mode = alc861vd_3stack_2ch_modes,
14970 .input_mux = &alc861vd_dallas_capture_source,
14971 .unsol_event = alc861vd_dallas_unsol_event,
14972 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014973 },
14974 [ALC861VD_HP] = {
14975 .mixers = { alc861vd_hp_mixer },
14976 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14977 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14978 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014979 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014980 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14981 .channel_mode = alc861vd_3stack_2ch_modes,
14982 .input_mux = &alc861vd_hp_capture_source,
14983 .unsol_event = alc861vd_dallas_unsol_event,
14984 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014985 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014986 [ALC660VD_ASUS_V1S] = {
14987 .mixers = { alc861vd_lenovo_mixer },
14988 .init_verbs = { alc861vd_volume_init_verbs,
14989 alc861vd_3stack_init_verbs,
14990 alc861vd_eapd_verbs,
14991 alc861vd_lenovo_unsol_verbs },
14992 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14993 .dac_nids = alc660vd_dac_nids,
14994 .dig_out_nid = ALC861VD_DIGOUT_NID,
14995 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14996 .channel_mode = alc861vd_3stack_2ch_modes,
14997 .input_mux = &alc861vd_capture_source,
14998 .unsol_event = alc861vd_lenovo_unsol_event,
14999 .init_hook = alc861vd_lenovo_automute,
15000 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015001};
15002
15003/*
15004 * BIOS auto configuration
15005 */
15006static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15007 hda_nid_t nid, int pin_type, int dac_idx)
15008{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015009 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015010}
15011
15012static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15013{
15014 struct alc_spec *spec = codec->spec;
15015 int i;
15016
15017 for (i = 0; i <= HDA_SIDE; i++) {
15018 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015019 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015020 if (nid)
15021 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015022 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015023 }
15024}
15025
15026
15027static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15028{
15029 struct alc_spec *spec = codec->spec;
15030 hda_nid_t pin;
15031
15032 pin = spec->autocfg.hp_pins[0];
15033 if (pin) /* connect to front and use dac 0 */
15034 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015035 pin = spec->autocfg.speaker_pins[0];
15036 if (pin)
15037 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015038}
15039
15040#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15041#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15042
15043static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15044{
15045 struct alc_spec *spec = codec->spec;
15046 int i;
15047
15048 for (i = 0; i < AUTO_PIN_LAST; i++) {
15049 hda_nid_t nid = spec->autocfg.input_pins[i];
15050 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015051 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015052 if (nid != ALC861VD_PIN_CD_NID &&
15053 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015054 snd_hda_codec_write(codec, nid, 0,
15055 AC_VERB_SET_AMP_GAIN_MUTE,
15056 AMP_OUT_MUTE);
15057 }
15058 }
15059}
15060
Takashi Iwaif511b012008-08-15 16:46:42 +020015061#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15062
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015063#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15064#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15065
15066/* add playback controls from the parsed DAC table */
15067/* Based on ALC880 version. But ALC861VD has separate,
15068 * different NIDs for mute/unmute switch and volume control */
15069static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15070 const struct auto_pin_cfg *cfg)
15071{
15072 char name[32];
15073 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15074 hda_nid_t nid_v, nid_s;
15075 int i, err;
15076
15077 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015078 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015079 continue;
15080 nid_v = alc861vd_idx_to_mixer_vol(
15081 alc880_dac_to_idx(
15082 spec->multiout.dac_nids[i]));
15083 nid_s = alc861vd_idx_to_mixer_switch(
15084 alc880_dac_to_idx(
15085 spec->multiout.dac_nids[i]));
15086
15087 if (i == 2) {
15088 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015089 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15090 "Center Playback Volume",
15091 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15092 HDA_OUTPUT));
15093 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015094 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015095 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15096 "LFE Playback Volume",
15097 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15098 HDA_OUTPUT));
15099 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015100 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015101 err = add_control(spec, ALC_CTL_BIND_MUTE,
15102 "Center Playback Switch",
15103 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15104 HDA_INPUT));
15105 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015106 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015107 err = add_control(spec, ALC_CTL_BIND_MUTE,
15108 "LFE Playback Switch",
15109 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15110 HDA_INPUT));
15111 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015112 return err;
15113 } else {
15114 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015115 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15116 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15117 HDA_OUTPUT));
15118 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015119 return err;
15120 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015121 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015122 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015123 HDA_INPUT));
15124 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015125 return err;
15126 }
15127 }
15128 return 0;
15129}
15130
15131/* add playback controls for speaker and HP outputs */
15132/* Based on ALC880 version. But ALC861VD has separate,
15133 * different NIDs for mute/unmute switch and volume control */
15134static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15135 hda_nid_t pin, const char *pfx)
15136{
15137 hda_nid_t nid_v, nid_s;
15138 int err;
15139 char name[32];
15140
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015141 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015142 return 0;
15143
15144 if (alc880_is_fixed_pin(pin)) {
15145 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15146 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015147 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015148 spec->multiout.hp_nid = nid_v;
15149 else
15150 spec->multiout.extra_out_nid[0] = nid_v;
15151 /* control HP volume/switch on the output mixer amp */
15152 nid_v = alc861vd_idx_to_mixer_vol(
15153 alc880_fixed_pin_idx(pin));
15154 nid_s = alc861vd_idx_to_mixer_switch(
15155 alc880_fixed_pin_idx(pin));
15156
15157 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015158 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15159 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15160 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015161 return err;
15162 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015163 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15164 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15165 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015166 return err;
15167 } else if (alc880_is_multi_pin(pin)) {
15168 /* set manual connection */
15169 /* we have only a switch on HP-out PIN */
15170 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015171 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15172 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15173 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015174 return err;
15175 }
15176 return 0;
15177}
15178
15179/* parse the BIOS configuration and set up the alc_spec
15180 * return 1 if successful, 0 if the proper config is not found,
15181 * or a negative error code
15182 * Based on ALC880 version - had to change it to override
15183 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15184static int alc861vd_parse_auto_config(struct hda_codec *codec)
15185{
15186 struct alc_spec *spec = codec->spec;
15187 int err;
15188 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15189
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015190 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15191 alc861vd_ignore);
15192 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015193 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015194 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015195 return 0; /* can't find valid BIOS pin config */
15196
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015197 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15198 if (err < 0)
15199 return err;
15200 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15201 if (err < 0)
15202 return err;
15203 err = alc861vd_auto_create_extra_out(spec,
15204 spec->autocfg.speaker_pins[0],
15205 "Speaker");
15206 if (err < 0)
15207 return err;
15208 err = alc861vd_auto_create_extra_out(spec,
15209 spec->autocfg.hp_pins[0],
15210 "Headphone");
15211 if (err < 0)
15212 return err;
15213 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15214 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015215 return err;
15216
15217 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15218
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015219 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015220 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15221
Takashi Iwai603c4012008-07-30 15:01:44 +020015222 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015223 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015224
Takashi Iwaid88897e2008-10-31 15:01:37 +010015225 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015226
15227 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015228 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015229
Takashi Iwai776e1842007-08-29 15:07:11 +020015230 err = alc_auto_add_mic_boost(codec);
15231 if (err < 0)
15232 return err;
15233
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015234 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15235
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015236 return 1;
15237}
15238
15239/* additional initialization for auto-configuration model */
15240static void alc861vd_auto_init(struct hda_codec *codec)
15241{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015242 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015243 alc861vd_auto_init_multi_out(codec);
15244 alc861vd_auto_init_hp_out(codec);
15245 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015246 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015247 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015248 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015249}
15250
15251static int patch_alc861vd(struct hda_codec *codec)
15252{
15253 struct alc_spec *spec;
15254 int err, board_config;
15255
15256 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15257 if (spec == NULL)
15258 return -ENOMEM;
15259
15260 codec->spec = spec;
15261
15262 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15263 alc861vd_models,
15264 alc861vd_cfg_tbl);
15265
15266 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15267 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
15268 "ALC861VD, trying auto-probe from BIOS...\n");
15269 board_config = ALC861VD_AUTO;
15270 }
15271
15272 if (board_config == ALC861VD_AUTO) {
15273 /* automatic parse from the BIOS config */
15274 err = alc861vd_parse_auto_config(codec);
15275 if (err < 0) {
15276 alc_free(codec);
15277 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015278 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015279 printk(KERN_INFO
15280 "hda_codec: Cannot set up configuration "
15281 "from BIOS. Using base mode...\n");
15282 board_config = ALC861VD_3ST;
15283 }
15284 }
15285
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015286 err = snd_hda_attach_beep_device(codec, 0x23);
15287 if (err < 0) {
15288 alc_free(codec);
15289 return err;
15290 }
15291
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015292 if (board_config != ALC861VD_AUTO)
15293 setup_preset(spec, &alc861vd_presets[board_config]);
15294
Kailang Yang2f893282008-05-27 12:14:47 +020015295 if (codec->vendor_id == 0x10ec0660) {
15296 spec->stream_name_analog = "ALC660-VD Analog";
15297 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020015298 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015299 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015300 } else {
15301 spec->stream_name_analog = "ALC861VD Analog";
15302 spec->stream_name_digital = "ALC861VD Digital";
15303 }
15304
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015305 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15306 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15307
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015308 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15309 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15310
15311 spec->adc_nids = alc861vd_adc_nids;
15312 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015313 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015314 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015315
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015316 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015317 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015318
Takashi Iwai2134ea42008-01-10 16:53:55 +010015319 spec->vmaster_nid = 0x02;
15320
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015321 codec->patch_ops = alc_patch_ops;
15322
15323 if (board_config == ALC861VD_AUTO)
15324 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015325#ifdef CONFIG_SND_HDA_POWER_SAVE
15326 if (!spec->loopback.amplist)
15327 spec->loopback.amplist = alc861vd_loopbacks;
15328#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015329 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015330
15331 return 0;
15332}
15333
15334/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015335 * ALC662 support
15336 *
15337 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15338 * configuration. Each pin widget can choose any input DACs and a mixer.
15339 * Each ADC is connected from a mixer of all inputs. This makes possible
15340 * 6-channel independent captures.
15341 *
15342 * In addition, an independent DAC for the multi-playback (not used in this
15343 * driver yet).
15344 */
15345#define ALC662_DIGOUT_NID 0x06
15346#define ALC662_DIGIN_NID 0x0a
15347
15348static hda_nid_t alc662_dac_nids[4] = {
15349 /* front, rear, clfe, rear_surr */
15350 0x02, 0x03, 0x04
15351};
15352
Kailang Yang622e84c2009-04-21 07:39:04 +020015353static hda_nid_t alc272_dac_nids[2] = {
15354 0x02, 0x03
15355};
15356
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015357static hda_nid_t alc662_adc_nids[1] = {
15358 /* ADC1-2 */
15359 0x09,
15360};
Takashi Iwaie1406342008-02-11 18:32:32 +010015361
Kailang Yang622e84c2009-04-21 07:39:04 +020015362static hda_nid_t alc272_adc_nids[1] = {
15363 /* ADC1-2 */
15364 0x08,
15365};
15366
Kailang Yang77a261b2008-02-19 11:38:05 +010015367static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015368static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15369
Takashi Iwaie1406342008-02-11 18:32:32 +010015370
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015371/* input MUX */
15372/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015373static struct hda_input_mux alc662_capture_source = {
15374 .num_items = 4,
15375 .items = {
15376 { "Mic", 0x0 },
15377 { "Front Mic", 0x1 },
15378 { "Line", 0x2 },
15379 { "CD", 0x4 },
15380 },
15381};
15382
15383static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15384 .num_items = 2,
15385 .items = {
15386 { "Mic", 0x1 },
15387 { "Line", 0x2 },
15388 },
15389};
Kailang Yang291702f2007-10-16 14:28:03 +020015390
15391static struct hda_input_mux alc662_eeepc_capture_source = {
15392 .num_items = 2,
15393 .items = {
15394 { "i-Mic", 0x1 },
15395 { "e-Mic", 0x0 },
15396 },
15397};
15398
Kailang Yang6dda9f42008-05-27 12:05:31 +020015399static struct hda_input_mux alc663_capture_source = {
15400 .num_items = 3,
15401 .items = {
15402 { "Mic", 0x0 },
15403 { "Front Mic", 0x1 },
15404 { "Line", 0x2 },
15405 },
15406};
15407
15408static struct hda_input_mux alc663_m51va_capture_source = {
15409 .num_items = 2,
15410 .items = {
15411 { "Ext-Mic", 0x0 },
15412 { "D-Mic", 0x9 },
15413 },
15414};
15415
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015416/*
15417 * 2ch mode
15418 */
15419static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15420 { 2, NULL }
15421};
15422
15423/*
15424 * 2ch mode
15425 */
15426static struct hda_verb alc662_3ST_ch2_init[] = {
15427 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15428 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15429 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15430 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15431 { } /* end */
15432};
15433
15434/*
15435 * 6ch mode
15436 */
15437static struct hda_verb alc662_3ST_ch6_init[] = {
15438 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15439 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15440 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15441 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15442 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15443 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15444 { } /* end */
15445};
15446
15447static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15448 { 2, alc662_3ST_ch2_init },
15449 { 6, alc662_3ST_ch6_init },
15450};
15451
15452/*
15453 * 2ch mode
15454 */
15455static struct hda_verb alc662_sixstack_ch6_init[] = {
15456 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15457 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15458 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15459 { } /* end */
15460};
15461
15462/*
15463 * 6ch mode
15464 */
15465static struct hda_verb alc662_sixstack_ch8_init[] = {
15466 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15467 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15468 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15469 { } /* end */
15470};
15471
15472static struct hda_channel_mode alc662_5stack_modes[2] = {
15473 { 2, alc662_sixstack_ch6_init },
15474 { 6, alc662_sixstack_ch8_init },
15475};
15476
15477/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15478 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15479 */
15480
15481static struct snd_kcontrol_new alc662_base_mixer[] = {
15482 /* output mixer control */
15483 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015484 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015485 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015486 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015487 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15488 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015489 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15490 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015491 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15492
15493 /*Input mixer control */
15494 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15495 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15496 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15497 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15498 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15499 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15500 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15501 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015502 { } /* end */
15503};
15504
15505static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15506 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015507 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015508 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15509 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15510 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15511 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15512 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15513 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15514 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15515 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15516 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015517 { } /* end */
15518};
15519
15520static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15521 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015522 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015523 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015524 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015525 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15526 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015527 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15528 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015529 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15530 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15531 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15532 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15533 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15534 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15535 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15536 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15537 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015538 { } /* end */
15539};
15540
15541static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15542 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15543 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015544 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15545 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015546 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15547 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15548 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015551 { } /* end */
15552};
15553
Kailang Yang291702f2007-10-16 14:28:03 +020015554static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015555 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015556
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015557 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15558 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015559
15560 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15561 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15562 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15563
15564 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15565 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15566 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15567 { } /* end */
15568};
15569
Kailang Yang8c427222008-01-10 13:03:59 +010015570static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015571 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15572 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015573 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15574 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15575 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15576 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15577 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15578 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015579 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015580 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15581 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15582 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15583 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15584 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15585 { } /* end */
15586};
15587
Kailang Yangf1d4e282008-08-26 14:03:29 +020015588static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15589 .ops = &snd_hda_bind_vol,
15590 .values = {
15591 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15592 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15593 0
15594 },
15595};
15596
15597static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15598 .ops = &snd_hda_bind_sw,
15599 .values = {
15600 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15601 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15602 0
15603 },
15604};
15605
Kailang Yang6dda9f42008-05-27 12:05:31 +020015606static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015607 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15608 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15609 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15610 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15611 { } /* end */
15612};
15613
15614static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15615 .ops = &snd_hda_bind_sw,
15616 .values = {
15617 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15618 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15619 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15620 0
15621 },
15622};
15623
15624static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15625 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15626 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15628 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15629 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15630 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15631
15632 { } /* end */
15633};
15634
15635static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15636 .ops = &snd_hda_bind_sw,
15637 .values = {
15638 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15639 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15640 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15641 0
15642 },
15643};
15644
15645static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15646 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15647 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15649 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15650 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15651 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15652 { } /* end */
15653};
15654
15655static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015656 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15657 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015658 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15660 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15661 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15662 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15663 { } /* end */
15664};
15665
15666static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15667 .ops = &snd_hda_bind_vol,
15668 .values = {
15669 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15670 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15671 0
15672 },
15673};
15674
15675static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15676 .ops = &snd_hda_bind_sw,
15677 .values = {
15678 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15679 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15680 0
15681 },
15682};
15683
15684static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15685 HDA_BIND_VOL("Master Playback Volume",
15686 &alc663_asus_two_bind_master_vol),
15687 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15688 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015689 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15690 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15691 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015692 { } /* end */
15693};
15694
15695static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15696 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15697 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15698 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15699 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15700 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15701 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015702 { } /* end */
15703};
15704
15705static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15706 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15707 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15708 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15709 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15710 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15711
15712 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15713 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15714 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15715 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15716 { } /* end */
15717};
15718
15719static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15720 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15721 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15722 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15723
15724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15725 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15726 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15727 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15728 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15729 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15730 { } /* end */
15731};
15732
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015733static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15734 {
15735 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15736 .name = "Channel Mode",
15737 .info = alc_ch_mode_info,
15738 .get = alc_ch_mode_get,
15739 .put = alc_ch_mode_put,
15740 },
15741 { } /* end */
15742};
15743
15744static struct hda_verb alc662_init_verbs[] = {
15745 /* ADC: mute amp left and right */
15746 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15747 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15748 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15749
Takashi Iwaicb53c622007-08-10 17:21:45 +020015750 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15751 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15752 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15753 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015755
Kailang Yangb60dd392007-09-20 12:50:29 +020015756 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15757 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15758 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15759 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15760 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15761 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015762
15763 /* Front Pin: output 0 (0x0c) */
15764 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15765 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15766
15767 /* Rear Pin: output 1 (0x0d) */
15768 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15770
15771 /* CLFE Pin: output 2 (0x0e) */
15772 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15773 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15774
15775 /* Mic (rear) pin: input vref at 80% */
15776 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15777 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15778 /* Front Mic pin: input vref at 80% */
15779 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15780 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15781 /* Line In pin: input */
15782 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15783 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15784 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15785 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15786 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15787 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15788 /* CD pin widget for input */
15789 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15790
15791 /* FIXME: use matrix-type input source selection */
15792 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15793 /* Input mixer */
15794 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015795 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015796
15797 /* always trun on EAPD */
15798 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15799 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15800
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015801 { }
15802};
15803
15804static struct hda_verb alc662_sue_init_verbs[] = {
15805 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15806 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015807 {}
15808};
15809
15810static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15811 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15812 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15813 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015814};
15815
Kailang Yang8c427222008-01-10 13:03:59 +010015816/* Set Unsolicited Event*/
15817static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15818 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15819 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15820 {}
15821};
15822
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015823/*
15824 * generic initialization of ADC, input mixers and output mixers
15825 */
15826static struct hda_verb alc662_auto_init_verbs[] = {
15827 /*
15828 * Unmute ADC and set the default input to mic-in
15829 */
15830 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15831 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15832
15833 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15834 * mixer widget
15835 * Note: PASD motherboards uses the Line In 2 as the input for front
15836 * panel mic (mic 2)
15837 */
15838 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015844
15845 /*
15846 * Set up output mixers (0x0c - 0x0f)
15847 */
15848 /* set vol=0 to output mixers */
15849 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15850 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15851 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15852
15853 /* set up input amps for analog loopback */
15854 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15856 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15857 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15858 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15859 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15860 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015861
15862
15863 /* FIXME: use matrix-type input source selection */
15864 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15865 /* Input mixer */
15866 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015868 { }
15869};
15870
Takashi Iwai24fb9172008-09-02 14:48:20 +020015871/* additional verbs for ALC663 */
15872static struct hda_verb alc663_auto_init_verbs[] = {
15873 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15874 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15875 { }
15876};
15877
Kailang Yang6dda9f42008-05-27 12:05:31 +020015878static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015879 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15880 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015881 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15882 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015883 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15884 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015886 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15887 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15888 {}
15889};
15890
Kailang Yangf1d4e282008-08-26 14:03:29 +020015891static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15892 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15893 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15894 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15895 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15897 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15898 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15899 {}
15900};
15901
15902static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15903 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15904 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15905 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15906 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15909 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15910 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15911 {}
15912};
15913
15914static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15915 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15916 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15917 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15918 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15919 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15920 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15921 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15922 {}
15923};
15924
15925static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15926 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15927 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15928 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15929 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15930 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15931 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15932 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15933 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15935 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15936 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15937 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15938 {}
15939};
15940
15941static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15942 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15944 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15945 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15946 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15948 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15951 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15952 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15953 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15954 {}
15955};
15956
Kailang Yang6dda9f42008-05-27 12:05:31 +020015957static struct hda_verb alc663_g71v_init_verbs[] = {
15958 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15959 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15960 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15961
15962 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15963 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15964 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15965
15966 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15967 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15968 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15969 {}
15970};
15971
15972static struct hda_verb alc663_g50v_init_verbs[] = {
15973 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15974 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15975 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15976
15977 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15978 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15979 {}
15980};
15981
Kailang Yangf1d4e282008-08-26 14:03:29 +020015982static struct hda_verb alc662_ecs_init_verbs[] = {
15983 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15984 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15985 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15986 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15987 {}
15988};
15989
Kailang Yang622e84c2009-04-21 07:39:04 +020015990static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15991 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15992 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15993 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15994 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15995 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15996 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15997 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16000 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16001 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16002 {}
16003};
16004
16005static struct hda_verb alc272_dell_init_verbs[] = {
16006 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16007 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16008 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16009 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16010 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16011 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16012 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16013 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16014 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16015 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16016 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16017 {}
16018};
16019
Kailang Yangf1d4e282008-08-26 14:03:29 +020016020static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16021 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16022 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16023 { } /* end */
16024};
16025
Kailang Yang622e84c2009-04-21 07:39:04 +020016026static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16027 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16028 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16029 { } /* end */
16030};
16031
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016032static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16033{
16034 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016035 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016036
16037 present = snd_hda_codec_read(codec, 0x14, 0,
16038 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016039 bits = present ? HDA_AMP_MUTE : 0;
16040 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16041 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016042}
16043
16044static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16045{
16046 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016047 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016048
16049 present = snd_hda_codec_read(codec, 0x1b, 0,
16050 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016051 bits = present ? HDA_AMP_MUTE : 0;
16052 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16053 HDA_AMP_MUTE, bits);
16054 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16055 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016056}
16057
16058static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16059 unsigned int res)
16060{
16061 if ((res >> 26) == ALC880_HP_EVENT)
16062 alc662_lenovo_101e_all_automute(codec);
16063 if ((res >> 26) == ALC880_FRONT_EVENT)
16064 alc662_lenovo_101e_ispeaker_automute(codec);
16065}
16066
Kailang Yang291702f2007-10-16 14:28:03 +020016067static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16068{
16069 unsigned int present;
16070
16071 present = snd_hda_codec_read(codec, 0x18, 0,
16072 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16073 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16074 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16075 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16076 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16077 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16078 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16079 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16080 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16081}
16082
16083/* unsolicited event for HP jack sensing */
16084static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16085 unsigned int res)
16086{
16087 if ((res >> 26) == ALC880_HP_EVENT)
16088 alc262_hippo1_automute( codec );
16089
16090 if ((res >> 26) == ALC880_MIC_EVENT)
16091 alc662_eeepc_mic_automute(codec);
16092}
16093
16094static void alc662_eeepc_inithook(struct hda_codec *codec)
16095{
16096 alc262_hippo1_automute( codec );
16097 alc662_eeepc_mic_automute(codec);
16098}
16099
Kailang Yang8c427222008-01-10 13:03:59 +010016100static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
16101{
16102 unsigned int mute;
16103 unsigned int present;
16104
16105 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
16106 present = snd_hda_codec_read(codec, 0x14, 0,
16107 AC_VERB_GET_PIN_SENSE, 0);
16108 present = (present & 0x80000000) != 0;
16109 if (present) {
16110 /* mute internal speaker */
16111 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016112 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010016113 } else {
16114 /* unmute internal speaker if necessary */
16115 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
16116 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016117 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010016118 }
16119}
16120
16121/* unsolicited event for HP jack sensing */
16122static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
16123 unsigned int res)
16124{
16125 if ((res >> 26) == ALC880_HP_EVENT)
16126 alc662_eeepc_ep20_automute(codec);
16127}
16128
16129static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16130{
16131 alc662_eeepc_ep20_automute(codec);
16132}
16133
Kailang Yang6dda9f42008-05-27 12:05:31 +020016134static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16135{
16136 unsigned int present;
16137 unsigned char bits;
16138
16139 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016140 AC_VERB_GET_PIN_SENSE, 0)
16141 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016142 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016143 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16144 AMP_IN_MUTE(0), bits);
16145 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16146 AMP_IN_MUTE(0), bits);
16147}
16148
16149static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16150{
16151 unsigned int present;
16152 unsigned char bits;
16153
16154 present = snd_hda_codec_read(codec, 0x21, 0,
16155 AC_VERB_GET_PIN_SENSE, 0)
16156 & AC_PINSENSE_PRESENCE;
16157 bits = present ? HDA_AMP_MUTE : 0;
16158 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16159 AMP_IN_MUTE(0), bits);
16160 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16161 AMP_IN_MUTE(0), bits);
16162 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16163 AMP_IN_MUTE(0), bits);
16164 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16165 AMP_IN_MUTE(0), bits);
16166}
16167
16168static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16169{
16170 unsigned int present;
16171 unsigned char bits;
16172
16173 present = snd_hda_codec_read(codec, 0x15, 0,
16174 AC_VERB_GET_PIN_SENSE, 0)
16175 & AC_PINSENSE_PRESENCE;
16176 bits = present ? HDA_AMP_MUTE : 0;
16177 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16178 AMP_IN_MUTE(0), bits);
16179 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16180 AMP_IN_MUTE(0), bits);
16181 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16182 AMP_IN_MUTE(0), bits);
16183 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16184 AMP_IN_MUTE(0), bits);
16185}
16186
16187static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16188{
16189 unsigned int present;
16190 unsigned char bits;
16191
16192 present = snd_hda_codec_read(codec, 0x1b, 0,
16193 AC_VERB_GET_PIN_SENSE, 0)
16194 & AC_PINSENSE_PRESENCE;
16195 bits = present ? 0 : PIN_OUT;
16196 snd_hda_codec_write(codec, 0x14, 0,
16197 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16198}
16199
16200static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16201{
16202 unsigned int present1, present2;
16203
16204 present1 = snd_hda_codec_read(codec, 0x21, 0,
16205 AC_VERB_GET_PIN_SENSE, 0)
16206 & AC_PINSENSE_PRESENCE;
16207 present2 = snd_hda_codec_read(codec, 0x15, 0,
16208 AC_VERB_GET_PIN_SENSE, 0)
16209 & AC_PINSENSE_PRESENCE;
16210
16211 if (present1 || present2) {
16212 snd_hda_codec_write_cache(codec, 0x14, 0,
16213 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16214 } else {
16215 snd_hda_codec_write_cache(codec, 0x14, 0,
16216 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16217 }
16218}
16219
16220static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16221{
16222 unsigned int present1, present2;
16223
16224 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16225 AC_VERB_GET_PIN_SENSE, 0)
16226 & AC_PINSENSE_PRESENCE;
16227 present2 = snd_hda_codec_read(codec, 0x15, 0,
16228 AC_VERB_GET_PIN_SENSE, 0)
16229 & AC_PINSENSE_PRESENCE;
16230
16231 if (present1 || present2) {
16232 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16233 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16234 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16235 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16236 } else {
16237 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16238 AMP_IN_MUTE(0), 0);
16239 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16240 AMP_IN_MUTE(0), 0);
16241 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016242}
16243
16244static void alc663_m51va_mic_automute(struct hda_codec *codec)
16245{
16246 unsigned int present;
16247
16248 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016249 AC_VERB_GET_PIN_SENSE, 0)
16250 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016251 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016252 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016253 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016254 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016255 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016256 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016257 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016258 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016259}
16260
16261static void alc663_m51va_unsol_event(struct hda_codec *codec,
16262 unsigned int res)
16263{
16264 switch (res >> 26) {
16265 case ALC880_HP_EVENT:
16266 alc663_m51va_speaker_automute(codec);
16267 break;
16268 case ALC880_MIC_EVENT:
16269 alc663_m51va_mic_automute(codec);
16270 break;
16271 }
16272}
16273
16274static void alc663_m51va_inithook(struct hda_codec *codec)
16275{
16276 alc663_m51va_speaker_automute(codec);
16277 alc663_m51va_mic_automute(codec);
16278}
16279
Kailang Yangf1d4e282008-08-26 14:03:29 +020016280/* ***************** Mode1 ******************************/
16281static void alc663_mode1_unsol_event(struct hda_codec *codec,
16282 unsigned int res)
16283{
16284 switch (res >> 26) {
16285 case ALC880_HP_EVENT:
16286 alc663_m51va_speaker_automute(codec);
16287 break;
16288 case ALC880_MIC_EVENT:
16289 alc662_eeepc_mic_automute(codec);
16290 break;
16291 }
16292}
16293
16294static void alc663_mode1_inithook(struct hda_codec *codec)
16295{
16296 alc663_m51va_speaker_automute(codec);
16297 alc662_eeepc_mic_automute(codec);
16298}
16299/* ***************** Mode2 ******************************/
16300static void alc662_mode2_unsol_event(struct hda_codec *codec,
16301 unsigned int res)
16302{
16303 switch (res >> 26) {
16304 case ALC880_HP_EVENT:
16305 alc662_f5z_speaker_automute(codec);
16306 break;
16307 case ALC880_MIC_EVENT:
16308 alc662_eeepc_mic_automute(codec);
16309 break;
16310 }
16311}
16312
16313static void alc662_mode2_inithook(struct hda_codec *codec)
16314{
16315 alc662_f5z_speaker_automute(codec);
16316 alc662_eeepc_mic_automute(codec);
16317}
16318/* ***************** Mode3 ******************************/
16319static void alc663_mode3_unsol_event(struct hda_codec *codec,
16320 unsigned int res)
16321{
16322 switch (res >> 26) {
16323 case ALC880_HP_EVENT:
16324 alc663_two_hp_m1_speaker_automute(codec);
16325 break;
16326 case ALC880_MIC_EVENT:
16327 alc662_eeepc_mic_automute(codec);
16328 break;
16329 }
16330}
16331
16332static void alc663_mode3_inithook(struct hda_codec *codec)
16333{
16334 alc663_two_hp_m1_speaker_automute(codec);
16335 alc662_eeepc_mic_automute(codec);
16336}
16337/* ***************** Mode4 ******************************/
16338static void alc663_mode4_unsol_event(struct hda_codec *codec,
16339 unsigned int res)
16340{
16341 switch (res >> 26) {
16342 case ALC880_HP_EVENT:
16343 alc663_21jd_two_speaker_automute(codec);
16344 break;
16345 case ALC880_MIC_EVENT:
16346 alc662_eeepc_mic_automute(codec);
16347 break;
16348 }
16349}
16350
16351static void alc663_mode4_inithook(struct hda_codec *codec)
16352{
16353 alc663_21jd_two_speaker_automute(codec);
16354 alc662_eeepc_mic_automute(codec);
16355}
16356/* ***************** Mode5 ******************************/
16357static void alc663_mode5_unsol_event(struct hda_codec *codec,
16358 unsigned int res)
16359{
16360 switch (res >> 26) {
16361 case ALC880_HP_EVENT:
16362 alc663_15jd_two_speaker_automute(codec);
16363 break;
16364 case ALC880_MIC_EVENT:
16365 alc662_eeepc_mic_automute(codec);
16366 break;
16367 }
16368}
16369
16370static void alc663_mode5_inithook(struct hda_codec *codec)
16371{
16372 alc663_15jd_two_speaker_automute(codec);
16373 alc662_eeepc_mic_automute(codec);
16374}
16375/* ***************** Mode6 ******************************/
16376static void alc663_mode6_unsol_event(struct hda_codec *codec,
16377 unsigned int res)
16378{
16379 switch (res >> 26) {
16380 case ALC880_HP_EVENT:
16381 alc663_two_hp_m2_speaker_automute(codec);
16382 break;
16383 case ALC880_MIC_EVENT:
16384 alc662_eeepc_mic_automute(codec);
16385 break;
16386 }
16387}
16388
16389static void alc663_mode6_inithook(struct hda_codec *codec)
16390{
16391 alc663_two_hp_m2_speaker_automute(codec);
16392 alc662_eeepc_mic_automute(codec);
16393}
16394
Kailang Yang6dda9f42008-05-27 12:05:31 +020016395static void alc663_g71v_hp_automute(struct hda_codec *codec)
16396{
16397 unsigned int present;
16398 unsigned char bits;
16399
16400 present = snd_hda_codec_read(codec, 0x21, 0,
16401 AC_VERB_GET_PIN_SENSE, 0)
16402 & AC_PINSENSE_PRESENCE;
16403 bits = present ? HDA_AMP_MUTE : 0;
16404 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16405 HDA_AMP_MUTE, bits);
16406 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16407 HDA_AMP_MUTE, bits);
16408}
16409
16410static void alc663_g71v_front_automute(struct hda_codec *codec)
16411{
16412 unsigned int present;
16413 unsigned char bits;
16414
16415 present = snd_hda_codec_read(codec, 0x15, 0,
16416 AC_VERB_GET_PIN_SENSE, 0)
16417 & AC_PINSENSE_PRESENCE;
16418 bits = present ? HDA_AMP_MUTE : 0;
16419 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16420 HDA_AMP_MUTE, bits);
16421}
16422
16423static void alc663_g71v_unsol_event(struct hda_codec *codec,
16424 unsigned int res)
16425{
16426 switch (res >> 26) {
16427 case ALC880_HP_EVENT:
16428 alc663_g71v_hp_automute(codec);
16429 break;
16430 case ALC880_FRONT_EVENT:
16431 alc663_g71v_front_automute(codec);
16432 break;
16433 case ALC880_MIC_EVENT:
16434 alc662_eeepc_mic_automute(codec);
16435 break;
16436 }
16437}
16438
16439static void alc663_g71v_inithook(struct hda_codec *codec)
16440{
16441 alc663_g71v_front_automute(codec);
16442 alc663_g71v_hp_automute(codec);
16443 alc662_eeepc_mic_automute(codec);
16444}
16445
16446static void alc663_g50v_unsol_event(struct hda_codec *codec,
16447 unsigned int res)
16448{
16449 switch (res >> 26) {
16450 case ALC880_HP_EVENT:
16451 alc663_m51va_speaker_automute(codec);
16452 break;
16453 case ALC880_MIC_EVENT:
16454 alc662_eeepc_mic_automute(codec);
16455 break;
16456 }
16457}
16458
16459static void alc663_g50v_inithook(struct hda_codec *codec)
16460{
16461 alc663_m51va_speaker_automute(codec);
16462 alc662_eeepc_mic_automute(codec);
16463}
16464
Kailang Yangf1d4e282008-08-26 14:03:29 +020016465/* bind hp and internal speaker mute (with plug check) */
16466static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16467 struct snd_ctl_elem_value *ucontrol)
16468{
16469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16470 long *valp = ucontrol->value.integer.value;
16471 int change;
16472
16473 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16474 HDA_AMP_MUTE,
16475 valp[0] ? 0 : HDA_AMP_MUTE);
16476 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16477 HDA_AMP_MUTE,
16478 valp[1] ? 0 : HDA_AMP_MUTE);
16479 if (change)
16480 alc262_hippo1_automute(codec);
16481 return change;
16482}
16483
16484static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16485 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16486 {
16487 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16488 .name = "Master Playback Switch",
16489 .info = snd_hda_mixer_amp_switch_info,
16490 .get = snd_hda_mixer_amp_switch_get,
16491 .put = alc662_ecs_master_sw_put,
16492 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16493 },
16494
16495 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16496 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16497 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16498
16499 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16500 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16501 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16502 { } /* end */
16503};
16504
Takashi Iwaicb53c622007-08-10 17:21:45 +020016505#ifdef CONFIG_SND_HDA_POWER_SAVE
16506#define alc662_loopbacks alc880_loopbacks
16507#endif
16508
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016509
16510/* pcm configuration: identiacal with ALC880 */
16511#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16512#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16513#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16514#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16515
16516/*
16517 * configuration and preset
16518 */
16519static const char *alc662_models[ALC662_MODEL_LAST] = {
16520 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16521 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16522 [ALC662_3ST_6ch] = "3stack-6ch",
16523 [ALC662_5ST_DIG] = "6stack-dig",
16524 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016525 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016526 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016527 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016528 [ALC663_ASUS_M51VA] = "m51va",
16529 [ALC663_ASUS_G71V] = "g71v",
16530 [ALC663_ASUS_H13] = "h13",
16531 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016532 [ALC663_ASUS_MODE1] = "asus-mode1",
16533 [ALC662_ASUS_MODE2] = "asus-mode2",
16534 [ALC663_ASUS_MODE3] = "asus-mode3",
16535 [ALC663_ASUS_MODE4] = "asus-mode4",
16536 [ALC663_ASUS_MODE5] = "asus-mode5",
16537 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016538 [ALC662_AUTO] = "auto",
16539};
16540
16541static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016542 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016543 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16544 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016545 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16546 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16547 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16548 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16549 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16550 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16551 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16552 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16553 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16554 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16555 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16556 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016557 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16558 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16559 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016560 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16561 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16562 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16563 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016564 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016565 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16566 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016567 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016568 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16569 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16570 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016571 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16572 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16573 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016574 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16575 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16576 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016577 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016578 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16579 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016580 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016581 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016582 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016583 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16584 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16585 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016586 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016587 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16588 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016589 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016590 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016591 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016592 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016593 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16594 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016595 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16596 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016597 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016598 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016599 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016600 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016601 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016602 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16603 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016604 {}
16605};
16606
16607static struct alc_config_preset alc662_presets[] = {
16608 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016609 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016610 .init_verbs = { alc662_init_verbs },
16611 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16612 .dac_nids = alc662_dac_nids,
16613 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016614 .dig_in_nid = ALC662_DIGIN_NID,
16615 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16616 .channel_mode = alc662_3ST_2ch_modes,
16617 .input_mux = &alc662_capture_source,
16618 },
16619 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016620 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016621 .init_verbs = { alc662_init_verbs },
16622 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16623 .dac_nids = alc662_dac_nids,
16624 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016625 .dig_in_nid = ALC662_DIGIN_NID,
16626 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16627 .channel_mode = alc662_3ST_6ch_modes,
16628 .need_dac_fix = 1,
16629 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016630 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016631 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016632 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016633 .init_verbs = { alc662_init_verbs },
16634 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16635 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016636 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16637 .channel_mode = alc662_3ST_6ch_modes,
16638 .need_dac_fix = 1,
16639 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016640 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016641 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016642 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016643 .init_verbs = { alc662_init_verbs },
16644 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16645 .dac_nids = alc662_dac_nids,
16646 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016647 .dig_in_nid = ALC662_DIGIN_NID,
16648 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16649 .channel_mode = alc662_5stack_modes,
16650 .input_mux = &alc662_capture_source,
16651 },
16652 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016653 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016654 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16655 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16656 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016657 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16658 .channel_mode = alc662_3ST_2ch_modes,
16659 .input_mux = &alc662_lenovo_101e_capture_source,
16660 .unsol_event = alc662_lenovo_101e_unsol_event,
16661 .init_hook = alc662_lenovo_101e_all_automute,
16662 },
Kailang Yang291702f2007-10-16 14:28:03 +020016663 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016664 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016665 .init_verbs = { alc662_init_verbs,
16666 alc662_eeepc_sue_init_verbs },
16667 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16668 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016669 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16670 .channel_mode = alc662_3ST_2ch_modes,
16671 .input_mux = &alc662_eeepc_capture_source,
16672 .unsol_event = alc662_eeepc_unsol_event,
16673 .init_hook = alc662_eeepc_inithook,
16674 },
Kailang Yang8c427222008-01-10 13:03:59 +010016675 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016676 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016677 alc662_chmode_mixer },
16678 .init_verbs = { alc662_init_verbs,
16679 alc662_eeepc_ep20_sue_init_verbs },
16680 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16681 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016682 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16683 .channel_mode = alc662_3ST_6ch_modes,
16684 .input_mux = &alc662_lenovo_101e_capture_source,
16685 .unsol_event = alc662_eeepc_ep20_unsol_event,
16686 .init_hook = alc662_eeepc_ep20_inithook,
16687 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016688 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016689 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016690 .init_verbs = { alc662_init_verbs,
16691 alc662_ecs_init_verbs },
16692 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16693 .dac_nids = alc662_dac_nids,
16694 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16695 .channel_mode = alc662_3ST_2ch_modes,
16696 .input_mux = &alc662_eeepc_capture_source,
16697 .unsol_event = alc662_eeepc_unsol_event,
16698 .init_hook = alc662_eeepc_inithook,
16699 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016700 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016701 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016702 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16703 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16704 .dac_nids = alc662_dac_nids,
16705 .dig_out_nid = ALC662_DIGOUT_NID,
16706 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16707 .channel_mode = alc662_3ST_2ch_modes,
16708 .input_mux = &alc663_m51va_capture_source,
16709 .unsol_event = alc663_m51va_unsol_event,
16710 .init_hook = alc663_m51va_inithook,
16711 },
16712 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016713 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016714 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16715 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16716 .dac_nids = alc662_dac_nids,
16717 .dig_out_nid = ALC662_DIGOUT_NID,
16718 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16719 .channel_mode = alc662_3ST_2ch_modes,
16720 .input_mux = &alc662_eeepc_capture_source,
16721 .unsol_event = alc663_g71v_unsol_event,
16722 .init_hook = alc663_g71v_inithook,
16723 },
16724 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016725 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016726 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16727 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16728 .dac_nids = alc662_dac_nids,
16729 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16730 .channel_mode = alc662_3ST_2ch_modes,
16731 .input_mux = &alc663_m51va_capture_source,
16732 .unsol_event = alc663_m51va_unsol_event,
16733 .init_hook = alc663_m51va_inithook,
16734 },
16735 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016736 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016737 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16738 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16739 .dac_nids = alc662_dac_nids,
16740 .dig_out_nid = ALC662_DIGOUT_NID,
16741 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16742 .channel_mode = alc662_3ST_6ch_modes,
16743 .input_mux = &alc663_capture_source,
16744 .unsol_event = alc663_g50v_unsol_event,
16745 .init_hook = alc663_g50v_inithook,
16746 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016747 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016748 .mixers = { alc663_m51va_mixer },
16749 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016750 .init_verbs = { alc662_init_verbs,
16751 alc663_21jd_amic_init_verbs },
16752 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16753 .hp_nid = 0x03,
16754 .dac_nids = alc662_dac_nids,
16755 .dig_out_nid = ALC662_DIGOUT_NID,
16756 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16757 .channel_mode = alc662_3ST_2ch_modes,
16758 .input_mux = &alc662_eeepc_capture_source,
16759 .unsol_event = alc663_mode1_unsol_event,
16760 .init_hook = alc663_mode1_inithook,
16761 },
16762 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016763 .mixers = { alc662_1bjd_mixer },
16764 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016765 .init_verbs = { alc662_init_verbs,
16766 alc662_1bjd_amic_init_verbs },
16767 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16768 .dac_nids = alc662_dac_nids,
16769 .dig_out_nid = ALC662_DIGOUT_NID,
16770 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16771 .channel_mode = alc662_3ST_2ch_modes,
16772 .input_mux = &alc662_eeepc_capture_source,
16773 .unsol_event = alc662_mode2_unsol_event,
16774 .init_hook = alc662_mode2_inithook,
16775 },
16776 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016777 .mixers = { alc663_two_hp_m1_mixer },
16778 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016779 .init_verbs = { alc662_init_verbs,
16780 alc663_two_hp_amic_m1_init_verbs },
16781 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16782 .hp_nid = 0x03,
16783 .dac_nids = alc662_dac_nids,
16784 .dig_out_nid = ALC662_DIGOUT_NID,
16785 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16786 .channel_mode = alc662_3ST_2ch_modes,
16787 .input_mux = &alc662_eeepc_capture_source,
16788 .unsol_event = alc663_mode3_unsol_event,
16789 .init_hook = alc663_mode3_inithook,
16790 },
16791 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016792 .mixers = { alc663_asus_21jd_clfe_mixer },
16793 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016794 .init_verbs = { alc662_init_verbs,
16795 alc663_21jd_amic_init_verbs},
16796 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16797 .hp_nid = 0x03,
16798 .dac_nids = alc662_dac_nids,
16799 .dig_out_nid = ALC662_DIGOUT_NID,
16800 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16801 .channel_mode = alc662_3ST_2ch_modes,
16802 .input_mux = &alc662_eeepc_capture_source,
16803 .unsol_event = alc663_mode4_unsol_event,
16804 .init_hook = alc663_mode4_inithook,
16805 },
16806 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016807 .mixers = { alc663_asus_15jd_clfe_mixer },
16808 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016809 .init_verbs = { alc662_init_verbs,
16810 alc663_15jd_amic_init_verbs },
16811 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16812 .hp_nid = 0x03,
16813 .dac_nids = alc662_dac_nids,
16814 .dig_out_nid = ALC662_DIGOUT_NID,
16815 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16816 .channel_mode = alc662_3ST_2ch_modes,
16817 .input_mux = &alc662_eeepc_capture_source,
16818 .unsol_event = alc663_mode5_unsol_event,
16819 .init_hook = alc663_mode5_inithook,
16820 },
16821 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016822 .mixers = { alc663_two_hp_m2_mixer },
16823 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016824 .init_verbs = { alc662_init_verbs,
16825 alc663_two_hp_amic_m2_init_verbs },
16826 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16827 .hp_nid = 0x03,
16828 .dac_nids = alc662_dac_nids,
16829 .dig_out_nid = ALC662_DIGOUT_NID,
16830 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16831 .channel_mode = alc662_3ST_2ch_modes,
16832 .input_mux = &alc662_eeepc_capture_source,
16833 .unsol_event = alc663_mode6_unsol_event,
16834 .init_hook = alc663_mode6_inithook,
16835 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016836 [ALC272_DELL] = {
16837 .mixers = { alc663_m51va_mixer },
16838 .cap_mixer = alc272_auto_capture_mixer,
16839 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16840 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16841 .dac_nids = alc662_dac_nids,
16842 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16843 .adc_nids = alc272_adc_nids,
16844 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16845 .capsrc_nids = alc272_capsrc_nids,
16846 .channel_mode = alc662_3ST_2ch_modes,
16847 .input_mux = &alc663_m51va_capture_source,
16848 .unsol_event = alc663_m51va_unsol_event,
16849 .init_hook = alc663_m51va_inithook,
16850 },
16851 [ALC272_DELL_ZM1] = {
16852 .mixers = { alc663_m51va_mixer },
16853 .cap_mixer = alc662_auto_capture_mixer,
16854 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16855 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16856 .dac_nids = alc662_dac_nids,
16857 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16858 .adc_nids = alc662_adc_nids,
16859 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16860 .capsrc_nids = alc662_capsrc_nids,
16861 .channel_mode = alc662_3ST_2ch_modes,
16862 .input_mux = &alc663_m51va_capture_source,
16863 .unsol_event = alc663_m51va_unsol_event,
16864 .init_hook = alc663_m51va_inithook,
16865 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016866};
16867
16868
16869/*
16870 * BIOS auto configuration
16871 */
16872
16873/* add playback controls from the parsed DAC table */
16874static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16875 const struct auto_pin_cfg *cfg)
16876{
16877 char name[32];
16878 static const char *chname[4] = {
16879 "Front", "Surround", NULL /*CLFE*/, "Side"
16880 };
16881 hda_nid_t nid;
16882 int i, err;
16883
16884 for (i = 0; i < cfg->line_outs; i++) {
16885 if (!spec->multiout.dac_nids[i])
16886 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016887 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016888 if (i == 2) {
16889 /* Center/LFE */
16890 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16891 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016892 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16893 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016894 if (err < 0)
16895 return err;
16896 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16897 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016898 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16899 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016900 if (err < 0)
16901 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016902 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016903 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016904 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016905 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016906 if (err < 0)
16907 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016908 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016909 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016910 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016911 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016912 if (err < 0)
16913 return err;
16914 } else {
16915 sprintf(name, "%s Playback Volume", chname[i]);
16916 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016917 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16918 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016919 if (err < 0)
16920 return err;
16921 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016922 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16923 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16924 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016925 if (err < 0)
16926 return err;
16927 }
16928 }
16929 return 0;
16930}
16931
16932/* add playback controls for speaker and HP outputs */
16933static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16934 const char *pfx)
16935{
16936 hda_nid_t nid;
16937 int err;
16938 char name[32];
16939
16940 if (!pin)
16941 return 0;
16942
Takashi Iwai24fb9172008-09-02 14:48:20 +020016943 if (pin == 0x17) {
16944 /* ALC663 has a mono output pin on 0x17 */
16945 sprintf(name, "%s Playback Switch", pfx);
16946 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16947 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16948 return err;
16949 }
16950
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016951 if (alc880_is_fixed_pin(pin)) {
16952 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016953 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016954 /* specify the DAC as the extra output */
16955 if (!spec->multiout.hp_nid)
16956 spec->multiout.hp_nid = nid;
16957 else
16958 spec->multiout.extra_out_nid[0] = nid;
16959 /* control HP volume/switch on the output mixer amp */
16960 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16961 sprintf(name, "%s Playback Volume", pfx);
16962 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16963 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16964 if (err < 0)
16965 return err;
16966 sprintf(name, "%s Playback Switch", pfx);
16967 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16968 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16969 if (err < 0)
16970 return err;
16971 } else if (alc880_is_multi_pin(pin)) {
16972 /* set manual connection */
16973 /* we have only a switch on HP-out PIN */
16974 sprintf(name, "%s Playback Switch", pfx);
16975 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16976 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16977 if (err < 0)
16978 return err;
16979 }
16980 return 0;
16981}
16982
Takashi Iwai2d864c42009-03-20 12:52:47 +010016983/* return the index of the src widget from the connection list of the nid.
16984 * return -1 if not found
16985 */
16986static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16987 hda_nid_t src)
16988{
16989 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16990 int i, conns;
16991
16992 conns = snd_hda_get_connections(codec, nid, conn_list,
16993 ARRAY_SIZE(conn_list));
16994 if (conns < 0)
16995 return -1;
16996 for (i = 0; i < conns; i++)
16997 if (conn_list[i] == src)
16998 return i;
16999 return -1;
17000}
17001
17002static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17003{
Takashi Iwai1327a322009-03-23 13:07:47 +010017004 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017005 return (pincap & AC_PINCAP_IN) != 0;
17006}
17007
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017008/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017009static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017010 const struct auto_pin_cfg *cfg)
17011{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017012 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017013 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017014 int i, err, idx;
17015
17016 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017017 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17018 idx = alc662_input_pin_idx(codec, 0x0b,
17019 cfg->input_pins[i]);
17020 if (idx >= 0) {
17021 err = new_analog_input(spec, cfg->input_pins[i],
17022 auto_pin_cfg_labels[i],
17023 idx, 0x0b);
17024 if (err < 0)
17025 return err;
17026 }
17027 idx = alc662_input_pin_idx(codec, 0x22,
17028 cfg->input_pins[i]);
17029 if (idx >= 0) {
17030 imux->items[imux->num_items].label =
17031 auto_pin_cfg_labels[i];
17032 imux->items[imux->num_items].index = idx;
17033 imux->num_items++;
17034 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017035 }
17036 }
17037 return 0;
17038}
17039
17040static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17041 hda_nid_t nid, int pin_type,
17042 int dac_idx)
17043{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017044 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017045 /* need the manual connection? */
17046 if (alc880_is_multi_pin(nid)) {
17047 struct alc_spec *spec = codec->spec;
17048 int idx = alc880_multi_pin_idx(nid);
17049 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17050 AC_VERB_SET_CONNECT_SEL,
17051 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17052 }
17053}
17054
17055static void alc662_auto_init_multi_out(struct hda_codec *codec)
17056{
17057 struct alc_spec *spec = codec->spec;
17058 int i;
17059
17060 for (i = 0; i <= HDA_SIDE; i++) {
17061 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017062 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017063 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017064 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017065 i);
17066 }
17067}
17068
17069static void alc662_auto_init_hp_out(struct hda_codec *codec)
17070{
17071 struct alc_spec *spec = codec->spec;
17072 hda_nid_t pin;
17073
17074 pin = spec->autocfg.hp_pins[0];
17075 if (pin) /* connect to front */
17076 /* use dac 0 */
17077 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017078 pin = spec->autocfg.speaker_pins[0];
17079 if (pin)
17080 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017081}
17082
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017083#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17084
17085static void alc662_auto_init_analog_input(struct hda_codec *codec)
17086{
17087 struct alc_spec *spec = codec->spec;
17088 int i;
17089
17090 for (i = 0; i < AUTO_PIN_LAST; i++) {
17091 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017092 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017093 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017094 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017095 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017096 snd_hda_codec_write(codec, nid, 0,
17097 AC_VERB_SET_AMP_GAIN_MUTE,
17098 AMP_OUT_MUTE);
17099 }
17100 }
17101}
17102
Takashi Iwaif511b012008-08-15 16:46:42 +020017103#define alc662_auto_init_input_src alc882_auto_init_input_src
17104
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017105static int alc662_parse_auto_config(struct hda_codec *codec)
17106{
17107 struct alc_spec *spec = codec->spec;
17108 int err;
17109 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17110
17111 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17112 alc662_ignore);
17113 if (err < 0)
17114 return err;
17115 if (!spec->autocfg.line_outs)
17116 return 0; /* can't find valid BIOS pin config */
17117
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017118 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17119 if (err < 0)
17120 return err;
17121 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17122 if (err < 0)
17123 return err;
17124 err = alc662_auto_create_extra_out(spec,
17125 spec->autocfg.speaker_pins[0],
17126 "Speaker");
17127 if (err < 0)
17128 return err;
17129 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17130 "Headphone");
17131 if (err < 0)
17132 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017133 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017134 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017135 return err;
17136
17137 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17138
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017139 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017140 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17141
Takashi Iwai603c4012008-07-30 15:01:44 +020017142 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017143 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017144
17145 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017146 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017147
Takashi Iwaid88897e2008-10-31 15:01:37 +010017148 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017149 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017150 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017151
17152 err = alc_auto_add_mic_boost(codec);
17153 if (err < 0)
17154 return err;
17155
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017156 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17157
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017158 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017159}
17160
17161/* additional initialization for auto-configuration model */
17162static void alc662_auto_init(struct hda_codec *codec)
17163{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017164 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017165 alc662_auto_init_multi_out(codec);
17166 alc662_auto_init_hp_out(codec);
17167 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017168 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017169 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017170 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017171}
17172
17173static int patch_alc662(struct hda_codec *codec)
17174{
17175 struct alc_spec *spec;
17176 int err, board_config;
17177
17178 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17179 if (!spec)
17180 return -ENOMEM;
17181
17182 codec->spec = spec;
17183
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017184 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17185
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017186 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17187 alc662_models,
17188 alc662_cfg_tbl);
17189 if (board_config < 0) {
17190 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
17191 "trying auto-probe from BIOS...\n");
17192 board_config = ALC662_AUTO;
17193 }
17194
17195 if (board_config == ALC662_AUTO) {
17196 /* automatic parse from the BIOS config */
17197 err = alc662_parse_auto_config(codec);
17198 if (err < 0) {
17199 alc_free(codec);
17200 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017201 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017202 printk(KERN_INFO
17203 "hda_codec: Cannot set up configuration "
17204 "from BIOS. Using base mode...\n");
17205 board_config = ALC662_3ST_2ch_DIG;
17206 }
17207 }
17208
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017209 err = snd_hda_attach_beep_device(codec, 0x1);
17210 if (err < 0) {
17211 alc_free(codec);
17212 return err;
17213 }
17214
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017215 if (board_config != ALC662_AUTO)
17216 setup_preset(spec, &alc662_presets[board_config]);
17217
Kailang Yang6dda9f42008-05-27 12:05:31 +020017218 if (codec->vendor_id == 0x10ec0663) {
17219 spec->stream_name_analog = "ALC663 Analog";
17220 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020017221 } else if (codec->vendor_id == 0x10ec0272) {
17222 spec->stream_name_analog = "ALC272 Analog";
17223 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020017224 } else {
17225 spec->stream_name_analog = "ALC662 Analog";
17226 spec->stream_name_digital = "ALC662 Digital";
17227 }
17228
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017229 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17230 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17231
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017232 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17233 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17234
Takashi Iwaie1406342008-02-11 18:32:32 +010017235 spec->adc_nids = alc662_adc_nids;
17236 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17237 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017238 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017239
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017240 if (!spec->cap_mixer)
17241 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017242 if (codec->vendor_id == 0x10ec0662)
17243 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17244 else
17245 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017246
Takashi Iwai2134ea42008-01-10 16:53:55 +010017247 spec->vmaster_nid = 0x02;
17248
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017249 codec->patch_ops = alc_patch_ops;
17250 if (board_config == ALC662_AUTO)
17251 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017252#ifdef CONFIG_SND_HDA_POWER_SAVE
17253 if (!spec->loopback.amplist)
17254 spec->loopback.amplist = alc662_loopbacks;
17255#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017256 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017257
17258 return 0;
17259}
17260
17261/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017262 * patch entries
17263 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017264static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017265 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017266 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017267 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017268 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017269 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017270 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017271 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017272 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017273 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17274 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17275 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017276 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17277 .patch = patch_alc883 },
17278 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17279 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017280 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017281 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017282 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017283 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017284 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17285 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017286 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017287 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017288 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017289 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017290 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17291 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017292 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017293 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017294 {} /* terminator */
17295};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017296
17297MODULE_ALIAS("snd-hda-codec-id:10ec*");
17298
17299MODULE_LICENSE("GPL");
17300MODULE_DESCRIPTION("Realtek HD-audio codec");
17301
17302static struct hda_codec_preset_list realtek_list = {
17303 .preset = snd_hda_preset_realtek,
17304 .owner = THIS_MODULE,
17305};
17306
17307static int __init patch_realtek_init(void)
17308{
17309 return snd_hda_add_codec_preset(&realtek_list);
17310}
17311
17312static void __exit patch_realtek_exit(void)
17313{
17314 snd_hda_delete_codec_preset(&realtek_list);
17315}
17316
17317module_init(patch_realtek_init)
17318module_exit(patch_realtek_exit)