blob: 8b242c9da4ddb4e93941485805929d98d4c136e2 [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
Takashi Iwaice875f02008-01-28 18:17:43 +01009537/* update HP, line and mono-out pins according to the master switch */
9538static void alc262_hp_master_update(struct hda_codec *codec)
9539{
9540 struct alc_spec *spec = codec->spec;
9541 int val = spec->master_sw;
9542
9543 /* HP & line-out */
9544 snd_hda_codec_write_cache(codec, 0x1b, 0,
9545 AC_VERB_SET_PIN_WIDGET_CONTROL,
9546 val ? PIN_HP : 0);
9547 snd_hda_codec_write_cache(codec, 0x15, 0,
9548 AC_VERB_SET_PIN_WIDGET_CONTROL,
9549 val ? PIN_HP : 0);
9550 /* mono (speaker) depending on the HP jack sense */
9551 val = val && !spec->jack_present;
9552 snd_hda_codec_write_cache(codec, 0x16, 0,
9553 AC_VERB_SET_PIN_WIDGET_CONTROL,
9554 val ? PIN_OUT : 0);
9555}
9556
9557static void alc262_hp_bpc_automute(struct hda_codec *codec)
9558{
9559 struct alc_spec *spec = codec->spec;
9560 unsigned int presence;
9561 presence = snd_hda_codec_read(codec, 0x1b, 0,
9562 AC_VERB_GET_PIN_SENSE, 0);
9563 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9564 alc262_hp_master_update(codec);
9565}
9566
9567static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9568{
9569 if ((res >> 26) != ALC880_HP_EVENT)
9570 return;
9571 alc262_hp_bpc_automute(codec);
9572}
9573
9574static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9575{
9576 struct alc_spec *spec = codec->spec;
9577 unsigned int presence;
9578 presence = snd_hda_codec_read(codec, 0x15, 0,
9579 AC_VERB_GET_PIN_SENSE, 0);
9580 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9581 alc262_hp_master_update(codec);
9582}
9583
9584static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9585 unsigned int res)
9586{
9587 if ((res >> 26) != ALC880_HP_EVENT)
9588 return;
9589 alc262_hp_wildwest_automute(codec);
9590}
9591
9592static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9593 struct snd_ctl_elem_value *ucontrol)
9594{
9595 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9596 struct alc_spec *spec = codec->spec;
9597 *ucontrol->value.integer.value = spec->master_sw;
9598 return 0;
9599}
9600
9601static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9602 struct snd_ctl_elem_value *ucontrol)
9603{
9604 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9605 struct alc_spec *spec = codec->spec;
9606 int val = !!*ucontrol->value.integer.value;
9607
9608 if (val == spec->master_sw)
9609 return 0;
9610 spec->master_sw = val;
9611 alc262_hp_master_update(codec);
9612 return 1;
9613}
9614
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009615static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009616 {
9617 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9618 .name = "Master Playback Switch",
9619 .info = snd_ctl_boolean_mono_info,
9620 .get = alc262_hp_master_sw_get,
9621 .put = alc262_hp_master_sw_put,
9622 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009623 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9624 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9625 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009626 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9627 HDA_OUTPUT),
9628 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9629 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9631 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009632 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009633 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9634 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009635 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009636 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9637 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9638 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9639 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009640 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9641 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9642 { } /* end */
9643};
9644
Kailang Yangcd7509a2007-01-26 18:33:17 +01009645static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009646 {
9647 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9648 .name = "Master Playback Switch",
9649 .info = snd_ctl_boolean_mono_info,
9650 .get = alc262_hp_master_sw_get,
9651 .put = alc262_hp_master_sw_put,
9652 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009653 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9654 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9655 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009657 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9658 HDA_OUTPUT),
9659 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9660 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009661 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9662 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009663 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009664 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9665 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9666 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9667 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009668 { } /* end */
9669};
9670
9671static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9672 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9673 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009674 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009675 { } /* end */
9676};
9677
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009678/* mute/unmute internal speaker according to the hp jack and mute state */
9679static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9680{
9681 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009682
9683 if (force || !spec->sense_updated) {
9684 unsigned int present;
9685 present = snd_hda_codec_read(codec, 0x15, 0,
9686 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009687 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009688 spec->sense_updated = 1;
9689 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009690 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9691 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009692}
9693
9694static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9695 unsigned int res)
9696{
9697 if ((res >> 26) != ALC880_HP_EVENT)
9698 return;
9699 alc262_hp_t5735_automute(codec, 1);
9700}
9701
9702static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9703{
9704 alc262_hp_t5735_automute(codec, 1);
9705}
9706
9707static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009708 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9709 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009710 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9711 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9712 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9713 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9714 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9715 { } /* end */
9716};
9717
9718static struct hda_verb alc262_hp_t5735_verbs[] = {
9719 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9720 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9721
9722 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9723 { }
9724};
9725
Kailang Yang8c427222008-01-10 13:03:59 +01009726static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009727 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9728 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009729 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9730 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009731 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9732 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9733 { } /* end */
9734};
9735
9736static struct hda_verb alc262_hp_rp5700_verbs[] = {
9737 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9738 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9739 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9740 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9742 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9743 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9744 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9745 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9746 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9747 {}
9748};
9749
9750static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9751 .num_items = 1,
9752 .items = {
9753 { "Line", 0x1 },
9754 },
9755};
9756
Takashi Iwai42171c12009-05-08 14:11:43 +02009757/* bind hp and internal speaker mute (with plug check) as master switch */
9758static void alc262_hippo_master_update(struct hda_codec *codec)
9759{
9760 struct alc_spec *spec = codec->spec;
9761 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9762 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9763 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9764 unsigned int mute;
9765
9766 /* HP */
9767 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9768 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9769 HDA_AMP_MUTE, mute);
9770 /* mute internal speaker per jack sense */
9771 if (spec->jack_present)
9772 mute = HDA_AMP_MUTE;
9773 if (line_nid)
9774 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9775 HDA_AMP_MUTE, mute);
9776 if (speaker_nid && speaker_nid != line_nid)
9777 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
9778 HDA_AMP_MUTE, mute);
9779}
9780
9781#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
9782
9783static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
9784 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +02009785{
9786 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +02009787 struct alc_spec *spec = codec->spec;
9788 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009789
Takashi Iwai42171c12009-05-08 14:11:43 +02009790 if (val == spec->master_sw)
9791 return 0;
9792 spec->master_sw = val;
9793 alc262_hippo_master_update(codec);
9794 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009795}
Takashi Iwai5b319542007-07-26 11:49:22 +02009796
Takashi Iwai42171c12009-05-08 14:11:43 +02009797#define ALC262_HIPPO_MASTER_SWITCH \
9798 { \
9799 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9800 .name = "Master Playback Switch", \
9801 .info = snd_ctl_boolean_mono_info, \
9802 .get = alc262_hippo_master_sw_get, \
9803 .put = alc262_hippo_master_sw_put, \
9804 }
9805
9806static struct snd_kcontrol_new alc262_hippo_mixer[] = {
9807 ALC262_HIPPO_MASTER_SWITCH,
9808 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9809 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9810 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9811 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9812 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9813 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9815 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9816 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9817 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9818 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9819 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9820 { } /* end */
9821};
9822
9823static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9824 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9825 ALC262_HIPPO_MASTER_SWITCH,
9826 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9827 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9828 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9829 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9830 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9831 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9832 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9833 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9834 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9835 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9836 { } /* end */
9837};
9838
9839/* mute/unmute internal speaker according to the hp jack and mute state */
9840static void alc262_hippo_automute(struct hda_codec *codec)
9841{
9842 struct alc_spec *spec = codec->spec;
9843 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9844 unsigned int present;
9845
9846 /* need to execute and sync at first */
9847 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
9848 present = snd_hda_codec_read(codec, hp_nid, 0,
9849 AC_VERB_GET_PIN_SENSE, 0);
9850 spec->jack_present = (present & 0x80000000) != 0;
9851 alc262_hippo_master_update(codec);
9852}
9853
9854static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
9855{
9856 if ((res >> 26) != ALC880_HP_EVENT)
9857 return;
9858 alc262_hippo_automute(codec);
9859}
9860
9861static void alc262_hippo_init_hook(struct hda_codec *codec)
9862{
9863 struct alc_spec *spec = codec->spec;
9864
9865 spec->autocfg.hp_pins[0] = 0x15;
9866 spec->autocfg.speaker_pins[0] = 0x14;
9867 alc262_hippo_automute(codec);
9868}
9869
9870static void alc262_hippo1_init_hook(struct hda_codec *codec)
9871{
9872 struct alc_spec *spec = codec->spec;
9873
9874 spec->autocfg.hp_pins[0] = 0x1b;
9875 spec->autocfg.speaker_pins[0] = 0x14;
9876 alc262_hippo_automute(codec);
9877}
9878
9879
Kailang Yang272a5272007-05-14 11:00:38 +02009880static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009881 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +02009882 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +02009883 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9884 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9885 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9886 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9887 { } /* end */
9888};
9889
Kailang Yang83c34212007-07-05 11:43:05 +02009890static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +02009891 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9892 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +02009893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9894 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9895 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9896 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9897 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9898 { } /* end */
9899};
Kailang Yang272a5272007-05-14 11:00:38 +02009900
Tony Vroonba340e82009-02-02 19:01:30 +00009901static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9902 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9903 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9904 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9905 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9906 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9907 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9908 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9909 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9910 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9911 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9912 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9913 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9914 { } /* end */
9915};
9916
9917static struct hda_verb alc262_tyan_verbs[] = {
9918 /* Headphone automute */
9919 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9920 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9921 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9922
9923 /* P11 AUX_IN, white 4-pin connector */
9924 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9925 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9926 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9927 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9928
9929 {}
9930};
9931
9932/* unsolicited event for HP jack sensing */
9933static void alc262_tyan_automute(struct hda_codec *codec)
9934{
9935 unsigned int mute;
9936 unsigned int present;
9937
9938 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9939 present = snd_hda_codec_read(codec, 0x1b, 0,
9940 AC_VERB_GET_PIN_SENSE, 0);
9941 present = (present & 0x80000000) != 0;
9942 if (present) {
9943 /* mute line output on ATX panel */
9944 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9945 HDA_AMP_MUTE, HDA_AMP_MUTE);
9946 } else {
9947 /* unmute line output if necessary */
9948 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9949 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9950 HDA_AMP_MUTE, mute);
9951 }
9952}
9953
9954static void alc262_tyan_unsol_event(struct hda_codec *codec,
9955 unsigned int res)
9956{
9957 if ((res >> 26) != ALC880_HP_EVENT)
9958 return;
9959 alc262_tyan_automute(codec);
9960}
9961
Kailang Yangdf694da2005-12-05 19:42:22 +01009962#define alc262_capture_mixer alc882_capture_mixer
9963#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9964
9965/*
9966 * generic initialization of ADC, input mixers and output mixers
9967 */
9968static struct hda_verb alc262_init_verbs[] = {
9969 /*
9970 * Unmute ADC0-2 and set the default input to mic-in
9971 */
9972 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9974 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9975 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9976 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9977 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9978
Takashi Iwaicb53c622007-08-10 17:21:45 +02009979 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009980 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009981 * Note: PASD motherboards uses the Line In 2 as the input for
9982 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009983 */
9984 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9986 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9987 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9988 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9989 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009990
9991 /*
9992 * Set up output mixers (0x0c - 0x0e)
9993 */
9994 /* set vol=0 to output mixers */
9995 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9996 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9997 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9998 /* set up input amps for analog loopback */
9999 /* Amp Indices: DAC = 0, mixer = 1 */
10000 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10001 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10002 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10003 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10004 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10005 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10006
10007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10008 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10009 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10010 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10011 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10012 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10013
10014 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10015 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10016 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10017 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10018 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010019
Kailang Yangdf694da2005-12-05 19:42:22 +010010020 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10021 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010022
Kailang Yangdf694da2005-12-05 19:42:22 +010010023 /* FIXME: use matrix-type input source selection */
10024 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10025 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10027 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10029 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10030 /* Input mixer2 */
10031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10032 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10034 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10035 /* Input mixer3 */
10036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10037 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010040
10041 { }
10042};
10043
Kailang Yang4e555fe2008-08-26 13:05:55 +020010044static struct hda_verb alc262_eapd_verbs[] = {
10045 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10046 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10047 { }
10048};
10049
Kailang Yangccc656c2006-10-17 12:32:26 +020010050static struct hda_verb alc262_hippo_unsol_verbs[] = {
10051 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10052 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10053 {}
10054};
10055
10056static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10057 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10058 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10059 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10060
10061 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10062 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10063 {}
10064};
10065
Kailang Yang272a5272007-05-14 11:00:38 +020010066static struct hda_verb alc262_sony_unsol_verbs[] = {
10067 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10068 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10069 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10070
10071 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10072 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010073 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010074};
10075
Kailang Yang4e555fe2008-08-26 13:05:55 +020010076static struct hda_input_mux alc262_dmic_capture_source = {
10077 .num_items = 2,
10078 .items = {
10079 { "Int DMic", 0x9 },
10080 { "Mic", 0x0 },
10081 },
10082};
10083
10084static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10085 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10086 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10087 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10088 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10089 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010090 { } /* end */
10091};
10092
10093static struct hda_verb alc262_toshiba_s06_verbs[] = {
10094 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10095 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10096 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10097 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10098 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10099 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10100 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10101 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10102 {}
10103};
10104
10105static void alc262_dmic_automute(struct hda_codec *codec)
10106{
10107 unsigned int present;
10108
10109 present = snd_hda_codec_read(codec, 0x18, 0,
10110 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10111 snd_hda_codec_write(codec, 0x22, 0,
10112 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10113}
10114
10115/* toggle speaker-output according to the hp-jack state */
10116static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
10117{
10118 unsigned int present;
10119 unsigned char bits;
10120
10121 present = snd_hda_codec_read(codec, 0x15, 0,
10122 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10123 bits = present ? 0 : PIN_OUT;
10124 snd_hda_codec_write(codec, 0x14, 0,
10125 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
10126}
10127
10128
10129
10130/* unsolicited event for HP jack sensing */
10131static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10132 unsigned int res)
10133{
10134 if ((res >> 26) == ALC880_HP_EVENT)
10135 alc262_toshiba_s06_speaker_automute(codec);
10136 if ((res >> 26) == ALC880_MIC_EVENT)
10137 alc262_dmic_automute(codec);
10138
10139}
10140
10141static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10142{
10143 alc262_toshiba_s06_speaker_automute(codec);
10144 alc262_dmic_automute(codec);
10145}
10146
Takashi Iwai834be882006-03-01 14:16:17 +010010147/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010148 * nec model
10149 * 0x15 = headphone
10150 * 0x16 = internal speaker
10151 * 0x18 = external mic
10152 */
10153
10154static struct snd_kcontrol_new alc262_nec_mixer[] = {
10155 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10156 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10157
10158 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10159 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10160 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10161
10162 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10163 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10164 { } /* end */
10165};
10166
10167static struct hda_verb alc262_nec_verbs[] = {
10168 /* Unmute Speaker */
10169 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10170
10171 /* Headphone */
10172 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10173 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10174
10175 /* External mic to headphone */
10176 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10177 /* External mic to speaker */
10178 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10179 {}
10180};
10181
10182/*
Takashi Iwai834be882006-03-01 14:16:17 +010010183 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010184 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10185 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010186 */
10187
10188#define ALC_HP_EVENT 0x37
10189
10190static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10191 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010193 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10194 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010195 {}
10196};
10197
Jiang zhe0e31daf2008-03-20 12:12:39 +010010198static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10199 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10200 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10201 {}
10202};
10203
Takashi Iwai834be882006-03-01 14:16:17 +010010204static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010205 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010206 .items = {
10207 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010208 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010209 { "CD", 0x4 },
10210 },
10211};
10212
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010213static struct hda_input_mux alc262_HP_capture_source = {
10214 .num_items = 5,
10215 .items = {
10216 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010217 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010218 { "Line", 0x2 },
10219 { "CD", 0x4 },
10220 { "AUX IN", 0x6 },
10221 },
10222};
10223
zhejiangaccbe492007-08-31 12:36:05 +020010224static struct hda_input_mux alc262_HP_D7000_capture_source = {
10225 .num_items = 4,
10226 .items = {
10227 { "Mic", 0x0 },
10228 { "Front Mic", 0x2 },
10229 { "Line", 0x1 },
10230 { "CD", 0x4 },
10231 },
10232};
10233
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010234/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010235static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10236{
10237 struct alc_spec *spec = codec->spec;
10238 unsigned int mute;
10239
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010240 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010241 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010242 /* need to execute and sync at first */
10243 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010244 /* check laptop HP jack */
10245 present = snd_hda_codec_read(codec, 0x14, 0,
10246 AC_VERB_GET_PIN_SENSE, 0);
10247 /* need to execute and sync at first */
10248 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10249 /* check docking HP jack */
10250 present |= snd_hda_codec_read(codec, 0x1b, 0,
10251 AC_VERB_GET_PIN_SENSE, 0);
10252 if (present & AC_PINSENSE_PRESENCE)
10253 spec->jack_present = 1;
10254 else
10255 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010256 spec->sense_updated = 1;
10257 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010258 /* unmute internal speaker only if both HPs are unplugged and
10259 * master switch is on
10260 */
10261 if (spec->jack_present)
10262 mute = HDA_AMP_MUTE;
10263 else
Takashi Iwai834be882006-03-01 14:16:17 +010010264 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010265 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10266 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010267}
10268
10269/* unsolicited event for HP jack sensing */
10270static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10271 unsigned int res)
10272{
10273 if ((res >> 26) != ALC_HP_EVENT)
10274 return;
10275 alc262_fujitsu_automute(codec, 1);
10276}
10277
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010278static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10279{
10280 alc262_fujitsu_automute(codec, 1);
10281}
10282
Takashi Iwai834be882006-03-01 14:16:17 +010010283/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010284static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10285 .ops = &snd_hda_bind_vol,
10286 .values = {
10287 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10288 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10289 0
10290 },
10291};
Takashi Iwai834be882006-03-01 14:16:17 +010010292
Jiang zhe0e31daf2008-03-20 12:12:39 +010010293/* mute/unmute internal speaker according to the hp jack and mute state */
10294static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10295{
10296 struct alc_spec *spec = codec->spec;
10297 unsigned int mute;
10298
10299 if (force || !spec->sense_updated) {
10300 unsigned int present_int_hp;
10301 /* need to execute and sync at first */
10302 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10303 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10304 AC_VERB_GET_PIN_SENSE, 0);
10305 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10306 spec->sense_updated = 1;
10307 }
10308 if (spec->jack_present) {
10309 /* mute internal speaker */
10310 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10311 HDA_AMP_MUTE, HDA_AMP_MUTE);
10312 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10313 HDA_AMP_MUTE, HDA_AMP_MUTE);
10314 } else {
10315 /* unmute internal speaker if necessary */
10316 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10317 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10318 HDA_AMP_MUTE, mute);
10319 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10320 HDA_AMP_MUTE, mute);
10321 }
10322}
10323
10324/* unsolicited event for HP jack sensing */
10325static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10326 unsigned int res)
10327{
10328 if ((res >> 26) != ALC_HP_EVENT)
10329 return;
10330 alc262_lenovo_3000_automute(codec, 1);
10331}
10332
Takashi Iwai834be882006-03-01 14:16:17 +010010333/* bind hp and internal speaker mute (with plug check) */
10334static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10335 struct snd_ctl_elem_value *ucontrol)
10336{
10337 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10338 long *valp = ucontrol->value.integer.value;
10339 int change;
10340
Tony Vroon5d9fab22008-03-14 17:09:18 +010010341 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10342 HDA_AMP_MUTE,
10343 valp ? 0 : HDA_AMP_MUTE);
10344 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10345 HDA_AMP_MUTE,
10346 valp ? 0 : HDA_AMP_MUTE);
10347
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010348 if (change)
10349 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010350 return change;
10351}
10352
10353static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010354 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010355 {
10356 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10357 .name = "Master Playback Switch",
10358 .info = snd_hda_mixer_amp_switch_info,
10359 .get = snd_hda_mixer_amp_switch_get,
10360 .put = alc262_fujitsu_master_sw_put,
10361 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10362 },
10363 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10364 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10365 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010368 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10369 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10370 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010371 { } /* end */
10372};
10373
Jiang zhe0e31daf2008-03-20 12:12:39 +010010374/* bind hp and internal speaker mute (with plug check) */
10375static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10376 struct snd_ctl_elem_value *ucontrol)
10377{
10378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10379 long *valp = ucontrol->value.integer.value;
10380 int change;
10381
10382 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10383 HDA_AMP_MUTE,
10384 valp ? 0 : HDA_AMP_MUTE);
10385
10386 if (change)
10387 alc262_lenovo_3000_automute(codec, 0);
10388 return change;
10389}
10390
10391static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10392 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10393 {
10394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10395 .name = "Master Playback Switch",
10396 .info = snd_hda_mixer_amp_switch_info,
10397 .get = snd_hda_mixer_amp_switch_get,
10398 .put = alc262_lenovo_3000_master_sw_put,
10399 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10400 },
10401 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10402 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10403 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10404 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10405 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10406 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10407 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10408 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10409 { } /* end */
10410};
10411
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010412static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10413 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010414 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010415 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10416 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10417 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10418 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10419 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10420 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10421 { } /* end */
10422};
10423
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010424/* additional init verbs for Benq laptops */
10425static struct hda_verb alc262_EAPD_verbs[] = {
10426 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10427 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10428 {}
10429};
10430
Kailang Yang83c34212007-07-05 11:43:05 +020010431static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10432 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10433 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10434
10435 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10436 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10437 {}
10438};
10439
Tobin Davisf651b502007-10-26 12:40:47 +020010440/* Samsung Q1 Ultra Vista model setup */
10441static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010442 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10443 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10445 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10446 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010447 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010448 { } /* end */
10449};
10450
10451static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010452 /* output mixer */
10453 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10454 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10455 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10456 /* speaker */
10457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10458 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10460 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10461 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010463 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10464 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10465 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10466 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10467 /* internal mic */
10468 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10469 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10470 /* ADC, choose mic */
10471 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10472 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10473 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10474 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10475 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10476 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10477 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10478 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10479 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10480 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010481 {}
10482};
10483
Tobin Davisf651b502007-10-26 12:40:47 +020010484/* mute/unmute internal speaker according to the hp jack and mute state */
10485static void alc262_ultra_automute(struct hda_codec *codec)
10486{
10487 struct alc_spec *spec = codec->spec;
10488 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010489
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010490 mute = 0;
10491 /* auto-mute only when HP is used as HP */
10492 if (!spec->cur_mux[0]) {
10493 unsigned int present;
10494 /* need to execute and sync at first */
10495 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10496 present = snd_hda_codec_read(codec, 0x15, 0,
10497 AC_VERB_GET_PIN_SENSE, 0);
10498 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10499 if (spec->jack_present)
10500 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010501 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010502 /* mute/unmute internal speaker */
10503 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10504 HDA_AMP_MUTE, mute);
10505 /* mute/unmute HP */
10506 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10507 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010508}
10509
10510/* unsolicited event for HP jack sensing */
10511static void alc262_ultra_unsol_event(struct hda_codec *codec,
10512 unsigned int res)
10513{
10514 if ((res >> 26) != ALC880_HP_EVENT)
10515 return;
10516 alc262_ultra_automute(codec);
10517}
10518
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010519static struct hda_input_mux alc262_ultra_capture_source = {
10520 .num_items = 2,
10521 .items = {
10522 { "Mic", 0x1 },
10523 { "Headphone", 0x7 },
10524 },
10525};
10526
10527static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10528 struct snd_ctl_elem_value *ucontrol)
10529{
10530 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10531 struct alc_spec *spec = codec->spec;
10532 int ret;
10533
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010534 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010535 if (!ret)
10536 return 0;
10537 /* reprogram the HP pin as mic or HP according to the input source */
10538 snd_hda_codec_write_cache(codec, 0x15, 0,
10539 AC_VERB_SET_PIN_WIDGET_CONTROL,
10540 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10541 alc262_ultra_automute(codec); /* mute/unmute HP */
10542 return ret;
10543}
10544
10545static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10546 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10547 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10548 {
10549 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10550 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010551 .info = alc_mux_enum_info,
10552 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010553 .put = alc262_ultra_mux_enum_put,
10554 },
10555 { } /* end */
10556};
10557
Kailang Yangdf694da2005-12-05 19:42:22 +010010558/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010559static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10560 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010561{
10562 hda_nid_t nid;
10563 int err;
10564
10565 spec->multiout.num_dacs = 1; /* only use one dac */
10566 spec->multiout.dac_nids = spec->private_dac_nids;
10567 spec->multiout.dac_nids[0] = 2;
10568
10569 nid = cfg->line_out_pins[0];
10570 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010571 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10572 "Front Playback Volume",
10573 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10574 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010575 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010576 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10577 "Front Playback Switch",
10578 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10579 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010580 return err;
10581 }
10582
Takashi Iwai82bc9552006-03-21 11:24:42 +010010583 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010584 if (nid) {
10585 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010586 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10587 "Speaker Playback Volume",
10588 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10589 HDA_OUTPUT));
10590 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010591 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010592 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10593 "Speaker Playback Switch",
10594 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10595 HDA_OUTPUT));
10596 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010597 return err;
10598 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010599 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10600 "Speaker Playback Switch",
10601 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10602 HDA_OUTPUT));
10603 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010604 return err;
10605 }
10606 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010607 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010608 if (nid) {
10609 /* spec->multiout.hp_nid = 2; */
10610 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010611 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10612 "Headphone Playback Volume",
10613 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10614 HDA_OUTPUT));
10615 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010616 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010617 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10618 "Headphone Playback Switch",
10619 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10620 HDA_OUTPUT));
10621 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010622 return err;
10623 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010624 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10625 "Headphone Playback Switch",
10626 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10627 HDA_OUTPUT));
10628 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010629 return err;
10630 }
10631 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010632 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010633}
10634
10635/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010636#define alc262_auto_create_analog_input_ctls \
10637 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010638
10639/*
10640 * generic initialization of ADC, input mixers and output mixers
10641 */
10642static struct hda_verb alc262_volume_init_verbs[] = {
10643 /*
10644 * Unmute ADC0-2 and set the default input to mic-in
10645 */
10646 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10648 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10649 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10650 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10651 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10652
Takashi Iwaicb53c622007-08-10 17:21:45 +020010653 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010654 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010655 * Note: PASD motherboards uses the Line In 2 as the input for
10656 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010657 */
10658 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010659 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10660 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010664
10665 /*
10666 * Set up output mixers (0x0c - 0x0f)
10667 */
10668 /* set vol=0 to output mixers */
10669 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10670 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10671 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010672
Kailang Yangdf694da2005-12-05 19:42:22 +010010673 /* set up input amps for analog loopback */
10674 /* Amp Indices: DAC = 0, mixer = 1 */
10675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10676 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10677 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10678 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10679 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10680 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10681
10682 /* FIXME: use matrix-type input source selection */
10683 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10684 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10685 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10686 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10687 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10688 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10689 /* Input mixer2 */
10690 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10691 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10692 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10693 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10694 /* Input mixer3 */
10695 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10696 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10697 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10698 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10699
10700 { }
10701};
10702
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010703static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10704 /*
10705 * Unmute ADC0-2 and set the default input to mic-in
10706 */
10707 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10708 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10709 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10710 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10711 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10712 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10713
Takashi Iwaicb53c622007-08-10 17:21:45 +020010714 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010715 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010716 * Note: PASD motherboards uses the Line In 2 as the input for
10717 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010718 */
10719 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010727
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010728 /*
10729 * Set up output mixers (0x0c - 0x0e)
10730 */
10731 /* set vol=0 to output mixers */
10732 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10733 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10734 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10735
10736 /* set up input amps for analog loopback */
10737 /* Amp Indices: DAC = 0, mixer = 1 */
10738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10743 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10744
Takashi Iwaice875f02008-01-28 18:17:43 +010010745 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010746 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10747 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10748
10749 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10750 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10751
10752 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10753 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10754
10755 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10756 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10757 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10758 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10759 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10760
10761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10762 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10763 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10764 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10765 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10766 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10767
10768
10769 /* FIXME: use matrix-type input source selection */
10770 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10771 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10772 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10773 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10774 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10775 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10776 /* Input mixer2 */
10777 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10778 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10779 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10780 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10781 /* Input mixer3 */
10782 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10783 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10784 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10785 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10786
Takashi Iwaice875f02008-01-28 18:17:43 +010010787 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10788
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010789 { }
10790};
10791
Kailang Yangcd7509a2007-01-26 18:33:17 +010010792static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10793 /*
10794 * Unmute ADC0-2 and set the default input to mic-in
10795 */
10796 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10798 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10799 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10800 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10801 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10802
Takashi Iwaicb53c622007-08-10 17:21:45 +020010803 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010804 * mixer widget
10805 * Note: PASD motherboards uses the Line In 2 as the input for front
10806 * panel mic (mic 2)
10807 */
10808 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010809 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10810 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10811 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10812 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10813 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10814 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10815 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010817 /*
10818 * Set up output mixers (0x0c - 0x0e)
10819 */
10820 /* set vol=0 to output mixers */
10821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10822 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10823 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10824
10825 /* set up input amps for analog loopback */
10826 /* Amp Indices: DAC = 0, mixer = 1 */
10827 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10828 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10829 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10830 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10831 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10832 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10833
10834
10835 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10836 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10837 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10838 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10839 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10840 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10841 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10842
10843 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10845
10846 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10847 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10848
10849 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10850 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10851 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10852 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10853 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10854 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10855
10856 /* FIXME: use matrix-type input source selection */
10857 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10858 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10864 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10866 /* Input mixer2 */
10867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10871 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10872 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10873 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10874 /* Input mixer3 */
10875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10880 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10882
Takashi Iwaice875f02008-01-28 18:17:43 +010010883 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10884
Kailang Yangcd7509a2007-01-26 18:33:17 +010010885 { }
10886};
10887
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010888static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10889
10890 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10891 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10892 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10893
10894 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10895 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10896 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10897 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10898
10899 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10900 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10901 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10902 {}
10903};
10904
10905
Takashi Iwaicb53c622007-08-10 17:21:45 +020010906#ifdef CONFIG_SND_HDA_POWER_SAVE
10907#define alc262_loopbacks alc880_loopbacks
10908#endif
10909
Kailang Yangdf694da2005-12-05 19:42:22 +010010910/* pcm configuration: identiacal with ALC880 */
10911#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10912#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10913#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10914#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10915
10916/*
10917 * BIOS auto configuration
10918 */
10919static int alc262_parse_auto_config(struct hda_codec *codec)
10920{
10921 struct alc_spec *spec = codec->spec;
10922 int err;
10923 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10924
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010925 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10926 alc262_ignore);
10927 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010928 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010929 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010930 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010931 spec->multiout.max_channels = 2;
10932 spec->no_analog = 1;
10933 goto dig_only;
10934 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010935 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010936 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010937 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10938 if (err < 0)
10939 return err;
10940 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10941 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010942 return err;
10943
10944 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10945
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010946 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010947 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010948 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010949 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010950 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010951 if (spec->autocfg.dig_in_pin)
10952 spec->dig_in_nid = ALC262_DIGIN_NID;
10953
Takashi Iwai603c4012008-07-30 15:01:44 +020010954 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010955 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010956
Takashi Iwaid88897e2008-10-31 15:01:37 +010010957 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010958 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010959 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010960
Takashi Iwai776e1842007-08-29 15:07:11 +020010961 err = alc_auto_add_mic_boost(codec);
10962 if (err < 0)
10963 return err;
10964
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010965 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
10966
Kailang Yangdf694da2005-12-05 19:42:22 +010010967 return 1;
10968}
10969
10970#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10971#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10972#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010973#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010974
10975
10976/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010977static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010978{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010979 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010980 alc262_auto_init_multi_out(codec);
10981 alc262_auto_init_hp_out(codec);
10982 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010983 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010984 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010985 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010986}
10987
10988/*
10989 * configuration and preset
10990 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010991static const char *alc262_models[ALC262_MODEL_LAST] = {
10992 [ALC262_BASIC] = "basic",
10993 [ALC262_HIPPO] = "hippo",
10994 [ALC262_HIPPO_1] = "hippo_1",
10995 [ALC262_FUJITSU] = "fujitsu",
10996 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010997 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010998 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010999 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011000 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011001 [ALC262_BENQ_T31] = "benq-t31",
11002 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011003 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011004 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011005 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011006 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011007 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011008 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011009 [ALC262_AUTO] = "auto",
11010};
11011
11012static struct snd_pci_quirk alc262_cfg_tbl[] = {
11013 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011014 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011015 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11016 ALC262_HP_BPC),
11017 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11018 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011019 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11020 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011021 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011022 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011023 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011024 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011025 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011026 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011027 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011028 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011029 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11030 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11031 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011032 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11033 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011034 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011035 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011036 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011037 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011038 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010011039 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11040 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011041 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011042 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011043 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011044 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011045 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011046 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011047 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11048 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011049 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011050 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011051 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011052 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011053 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011054 {}
11055};
11056
11057static struct alc_config_preset alc262_presets[] = {
11058 [ALC262_BASIC] = {
11059 .mixers = { alc262_base_mixer },
11060 .init_verbs = { alc262_init_verbs },
11061 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11062 .dac_nids = alc262_dac_nids,
11063 .hp_nid = 0x03,
11064 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11065 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011066 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011067 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011068 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011069 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020011070 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11071 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11072 .dac_nids = alc262_dac_nids,
11073 .hp_nid = 0x03,
11074 .dig_out_nid = ALC262_DIGOUT_NID,
11075 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11076 .channel_mode = alc262_modes,
11077 .input_mux = &alc262_capture_source,
11078 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011079 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011080 },
11081 [ALC262_HIPPO_1] = {
11082 .mixers = { alc262_hippo1_mixer },
11083 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11084 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11085 .dac_nids = alc262_dac_nids,
11086 .hp_nid = 0x02,
11087 .dig_out_nid = ALC262_DIGOUT_NID,
11088 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11089 .channel_mode = alc262_modes,
11090 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011091 .unsol_event = alc262_hippo_unsol_event,
11092 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011093 },
Takashi Iwai834be882006-03-01 14:16:17 +010011094 [ALC262_FUJITSU] = {
11095 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011096 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11097 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011098 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11099 .dac_nids = alc262_dac_nids,
11100 .hp_nid = 0x03,
11101 .dig_out_nid = ALC262_DIGOUT_NID,
11102 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11103 .channel_mode = alc262_modes,
11104 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011105 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011106 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011107 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011108 [ALC262_HP_BPC] = {
11109 .mixers = { alc262_HP_BPC_mixer },
11110 .init_verbs = { alc262_HP_BPC_init_verbs },
11111 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11112 .dac_nids = alc262_dac_nids,
11113 .hp_nid = 0x03,
11114 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11115 .channel_mode = alc262_modes,
11116 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011117 .unsol_event = alc262_hp_bpc_unsol_event,
11118 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011119 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011120 [ALC262_HP_BPC_D7000_WF] = {
11121 .mixers = { alc262_HP_BPC_WildWest_mixer },
11122 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11123 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11124 .dac_nids = alc262_dac_nids,
11125 .hp_nid = 0x03,
11126 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11127 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011128 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011129 .unsol_event = alc262_hp_wildwest_unsol_event,
11130 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011131 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011132 [ALC262_HP_BPC_D7000_WL] = {
11133 .mixers = { alc262_HP_BPC_WildWest_mixer,
11134 alc262_HP_BPC_WildWest_option_mixer },
11135 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11136 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11137 .dac_nids = alc262_dac_nids,
11138 .hp_nid = 0x03,
11139 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11140 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011141 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011142 .unsol_event = alc262_hp_wildwest_unsol_event,
11143 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011144 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011145 [ALC262_HP_TC_T5735] = {
11146 .mixers = { alc262_hp_t5735_mixer },
11147 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11148 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11149 .dac_nids = alc262_dac_nids,
11150 .hp_nid = 0x03,
11151 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11152 .channel_mode = alc262_modes,
11153 .input_mux = &alc262_capture_source,
11154 .unsol_event = alc262_hp_t5735_unsol_event,
11155 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011156 },
11157 [ALC262_HP_RP5700] = {
11158 .mixers = { alc262_hp_rp5700_mixer },
11159 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11160 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11161 .dac_nids = alc262_dac_nids,
11162 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11163 .channel_mode = alc262_modes,
11164 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011165 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011166 [ALC262_BENQ_ED8] = {
11167 .mixers = { alc262_base_mixer },
11168 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11169 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11170 .dac_nids = alc262_dac_nids,
11171 .hp_nid = 0x03,
11172 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11173 .channel_mode = alc262_modes,
11174 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011175 },
Kailang Yang272a5272007-05-14 11:00:38 +020011176 [ALC262_SONY_ASSAMD] = {
11177 .mixers = { alc262_sony_mixer },
11178 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11179 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11180 .dac_nids = alc262_dac_nids,
11181 .hp_nid = 0x02,
11182 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11183 .channel_mode = alc262_modes,
11184 .input_mux = &alc262_capture_source,
11185 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011186 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011187 },
11188 [ALC262_BENQ_T31] = {
11189 .mixers = { alc262_benq_t31_mixer },
11190 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11191 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11192 .dac_nids = alc262_dac_nids,
11193 .hp_nid = 0x03,
11194 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11195 .channel_mode = alc262_modes,
11196 .input_mux = &alc262_capture_source,
11197 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011198 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011199 },
Tobin Davisf651b502007-10-26 12:40:47 +020011200 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011201 .mixers = { alc262_ultra_mixer },
11202 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011203 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011204 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11205 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011206 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11207 .channel_mode = alc262_modes,
11208 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011209 .adc_nids = alc262_adc_nids, /* ADC0 */
11210 .capsrc_nids = alc262_capsrc_nids,
11211 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011212 .unsol_event = alc262_ultra_unsol_event,
11213 .init_hook = alc262_ultra_automute,
11214 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011215 [ALC262_LENOVO_3000] = {
11216 .mixers = { alc262_lenovo_3000_mixer },
11217 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11218 alc262_lenovo_3000_unsol_verbs },
11219 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11220 .dac_nids = alc262_dac_nids,
11221 .hp_nid = 0x03,
11222 .dig_out_nid = ALC262_DIGOUT_NID,
11223 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11224 .channel_mode = alc262_modes,
11225 .input_mux = &alc262_fujitsu_capture_source,
11226 .unsol_event = alc262_lenovo_3000_unsol_event,
11227 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011228 [ALC262_NEC] = {
11229 .mixers = { alc262_nec_mixer },
11230 .init_verbs = { alc262_nec_verbs },
11231 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11232 .dac_nids = alc262_dac_nids,
11233 .hp_nid = 0x03,
11234 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11235 .channel_mode = alc262_modes,
11236 .input_mux = &alc262_capture_source,
11237 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011238 [ALC262_TOSHIBA_S06] = {
11239 .mixers = { alc262_toshiba_s06_mixer },
11240 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11241 alc262_eapd_verbs },
11242 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11243 .capsrc_nids = alc262_dmic_capsrc_nids,
11244 .dac_nids = alc262_dac_nids,
11245 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11246 .dig_out_nid = ALC262_DIGOUT_NID,
11247 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11248 .channel_mode = alc262_modes,
11249 .input_mux = &alc262_dmic_capture_source,
11250 .unsol_event = alc262_toshiba_s06_unsol_event,
11251 .init_hook = alc262_toshiba_s06_init_hook,
11252 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011253 [ALC262_TOSHIBA_RX1] = {
11254 .mixers = { alc262_toshiba_rx1_mixer },
11255 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11256 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11257 .dac_nids = alc262_dac_nids,
11258 .hp_nid = 0x03,
11259 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11260 .channel_mode = alc262_modes,
11261 .input_mux = &alc262_capture_source,
11262 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011263 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011264 },
Tony Vroonba340e82009-02-02 19:01:30 +000011265 [ALC262_TYAN] = {
11266 .mixers = { alc262_tyan_mixer },
11267 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11268 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11269 .dac_nids = alc262_dac_nids,
11270 .hp_nid = 0x02,
11271 .dig_out_nid = ALC262_DIGOUT_NID,
11272 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11273 .channel_mode = alc262_modes,
11274 .input_mux = &alc262_capture_source,
11275 .unsol_event = alc262_tyan_unsol_event,
11276 .init_hook = alc262_tyan_automute,
11277 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011278};
11279
11280static int patch_alc262(struct hda_codec *codec)
11281{
11282 struct alc_spec *spec;
11283 int board_config;
11284 int err;
11285
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011286 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011287 if (spec == NULL)
11288 return -ENOMEM;
11289
11290 codec->spec = spec;
11291#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011292 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11293 * under-run
11294 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011295 {
11296 int tmp;
11297 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11298 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11299 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11300 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11301 }
11302#endif
11303
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011304 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11305
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011306 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11307 alc262_models,
11308 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011309
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011310 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011311 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11312 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011313 board_config = ALC262_AUTO;
11314 }
11315
11316 if (board_config == ALC262_AUTO) {
11317 /* automatic parse from the BIOS config */
11318 err = alc262_parse_auto_config(codec);
11319 if (err < 0) {
11320 alc_free(codec);
11321 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011322 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011323 printk(KERN_INFO
11324 "hda_codec: Cannot set up configuration "
11325 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011326 board_config = ALC262_BASIC;
11327 }
11328 }
11329
Takashi Iwai07eba612009-02-19 08:06:35 +010011330 if (!spec->no_analog) {
11331 err = snd_hda_attach_beep_device(codec, 0x1);
11332 if (err < 0) {
11333 alc_free(codec);
11334 return err;
11335 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011336 }
11337
Kailang Yangdf694da2005-12-05 19:42:22 +010011338 if (board_config != ALC262_AUTO)
11339 setup_preset(spec, &alc262_presets[board_config]);
11340
11341 spec->stream_name_analog = "ALC262 Analog";
11342 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11343 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011344
Kailang Yangdf694da2005-12-05 19:42:22 +010011345 spec->stream_name_digital = "ALC262 Digital";
11346 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11347 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11348
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011349 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011350 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011351 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011352 unsigned int wcap = get_wcaps(codec, 0x07);
11353
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011354 /* get type */
11355 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011356 if (wcap != AC_WID_AUD_IN) {
11357 spec->adc_nids = alc262_adc_nids_alt;
11358 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011359 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011360 } else {
11361 spec->adc_nids = alc262_adc_nids;
11362 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011363 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011364 }
11365 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011366 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011367 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011368 if (!spec->no_analog)
11369 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011370
Takashi Iwai2134ea42008-01-10 16:53:55 +010011371 spec->vmaster_nid = 0x0c;
11372
Kailang Yangdf694da2005-12-05 19:42:22 +010011373 codec->patch_ops = alc_patch_ops;
11374 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011375 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011376#ifdef CONFIG_SND_HDA_POWER_SAVE
11377 if (!spec->loopback.amplist)
11378 spec->loopback.amplist = alc262_loopbacks;
11379#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011380 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011381
Kailang Yangdf694da2005-12-05 19:42:22 +010011382 return 0;
11383}
11384
Kailang Yangdf694da2005-12-05 19:42:22 +010011385/*
Kailang Yanga361d842007-06-05 12:30:55 +020011386 * ALC268 channel source setting (2 channel)
11387 */
11388#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11389#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011390
Kailang Yanga361d842007-06-05 12:30:55 +020011391static hda_nid_t alc268_dac_nids[2] = {
11392 /* front, hp */
11393 0x02, 0x03
11394};
11395
11396static hda_nid_t alc268_adc_nids[2] = {
11397 /* ADC0-1 */
11398 0x08, 0x07
11399};
11400
11401static hda_nid_t alc268_adc_nids_alt[1] = {
11402 /* ADC0 */
11403 0x08
11404};
11405
Takashi Iwaie1406342008-02-11 18:32:32 +010011406static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11407
Kailang Yanga361d842007-06-05 12:30:55 +020011408static struct snd_kcontrol_new alc268_base_mixer[] = {
11409 /* output mixer control */
11410 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11411 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11412 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11413 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011414 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11415 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11416 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011417 { }
11418};
11419
Takashi Iwai42171c12009-05-08 14:11:43 +020011420static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11421 /* output mixer control */
11422 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11423 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11424 ALC262_HIPPO_MASTER_SWITCH,
11425 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11426 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11427 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11428 { }
11429};
11430
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011431/* bind Beep switches of both NID 0x0f and 0x10 */
11432static struct hda_bind_ctls alc268_bind_beep_sw = {
11433 .ops = &snd_hda_bind_sw,
11434 .values = {
11435 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11436 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11437 0
11438 },
11439};
11440
11441static struct snd_kcontrol_new alc268_beep_mixer[] = {
11442 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11443 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11444 { }
11445};
11446
Kailang Yangd1a991a2007-08-15 16:21:59 +020011447static struct hda_verb alc268_eapd_verbs[] = {
11448 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11449 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11450 { }
11451};
11452
Takashi Iwaid2738092007-08-16 14:59:45 +020011453/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011454static struct hda_verb alc268_toshiba_verbs[] = {
11455 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11456 { } /* end */
11457};
11458
Kailang Yang8ef355d2008-08-26 13:10:22 +020011459static struct hda_input_mux alc268_acer_lc_capture_source = {
11460 .num_items = 2,
11461 .items = {
11462 { "i-Mic", 0x6 },
11463 { "E-Mic", 0x0 },
11464 },
11465};
11466
Takashi Iwaid2738092007-08-16 14:59:45 +020011467/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011468/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011469static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11470 .ops = &snd_hda_bind_vol,
11471 .values = {
11472 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11473 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11474 0
11475 },
11476};
11477
Takashi Iwai889c4392007-08-23 18:56:52 +020011478/* mute/unmute internal speaker according to the hp jack and mute state */
11479static void alc268_acer_automute(struct hda_codec *codec, int force)
11480{
11481 struct alc_spec *spec = codec->spec;
11482 unsigned int mute;
11483
11484 if (force || !spec->sense_updated) {
11485 unsigned int present;
11486 present = snd_hda_codec_read(codec, 0x14, 0,
11487 AC_VERB_GET_PIN_SENSE, 0);
11488 spec->jack_present = (present & 0x80000000) != 0;
11489 spec->sense_updated = 1;
11490 }
11491 if (spec->jack_present)
11492 mute = HDA_AMP_MUTE; /* mute internal speaker */
11493 else /* unmute internal speaker if necessary */
11494 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11495 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11496 HDA_AMP_MUTE, mute);
11497}
11498
11499
11500/* bind hp and internal speaker mute (with plug check) */
11501static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11502 struct snd_ctl_elem_value *ucontrol)
11503{
11504 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11505 long *valp = ucontrol->value.integer.value;
11506 int change;
11507
11508 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11509 HDA_AMP_MUTE,
11510 valp[0] ? 0 : HDA_AMP_MUTE);
11511 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11512 HDA_AMP_MUTE,
11513 valp[1] ? 0 : HDA_AMP_MUTE);
11514 if (change)
11515 alc268_acer_automute(codec, 0);
11516 return change;
11517}
Takashi Iwaid2738092007-08-16 14:59:45 +020011518
Kailang Yang8ef355d2008-08-26 13:10:22 +020011519static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11520 /* output mixer control */
11521 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11522 {
11523 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11524 .name = "Master Playback Switch",
11525 .info = snd_hda_mixer_amp_switch_info,
11526 .get = snd_hda_mixer_amp_switch_get,
11527 .put = alc268_acer_master_sw_put,
11528 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11529 },
11530 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11531 { }
11532};
11533
Takashi Iwaid2738092007-08-16 14:59:45 +020011534static struct snd_kcontrol_new alc268_acer_mixer[] = {
11535 /* output mixer control */
11536 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11537 {
11538 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11539 .name = "Master Playback Switch",
11540 .info = snd_hda_mixer_amp_switch_info,
11541 .get = snd_hda_mixer_amp_switch_get,
11542 .put = alc268_acer_master_sw_put,
11543 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11544 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011545 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11546 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11547 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011548 { }
11549};
11550
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011551static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11552 /* output mixer control */
11553 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11554 {
11555 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11556 .name = "Master Playback Switch",
11557 .info = snd_hda_mixer_amp_switch_info,
11558 .get = snd_hda_mixer_amp_switch_get,
11559 .put = alc268_acer_master_sw_put,
11560 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11561 },
11562 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11563 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11564 { }
11565};
11566
Kailang Yang8ef355d2008-08-26 13:10:22 +020011567static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11568 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11569 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11570 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11571 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11572 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11574 { }
11575};
11576
Takashi Iwaid2738092007-08-16 14:59:45 +020011577static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011578 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11579 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011580 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11581 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011582 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11583 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011584 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11585 { }
11586};
11587
11588/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011589#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11590#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011591
11592static void alc268_acer_unsol_event(struct hda_codec *codec,
11593 unsigned int res)
11594{
Takashi Iwai889c4392007-08-23 18:56:52 +020011595 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011596 return;
11597 alc268_acer_automute(codec, 1);
11598}
11599
Takashi Iwai889c4392007-08-23 18:56:52 +020011600static void alc268_acer_init_hook(struct hda_codec *codec)
11601{
11602 alc268_acer_automute(codec, 1);
11603}
11604
Kailang Yang8ef355d2008-08-26 13:10:22 +020011605/* toggle speaker-output according to the hp-jack state */
11606static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11607{
11608 unsigned int present;
11609 unsigned char bits;
11610
11611 present = snd_hda_codec_read(codec, 0x15, 0,
11612 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11613 bits = present ? AMP_IN_MUTE(0) : 0;
11614 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11615 AMP_IN_MUTE(0), bits);
11616 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11617 AMP_IN_MUTE(0), bits);
11618}
11619
11620
11621static void alc268_acer_mic_automute(struct hda_codec *codec)
11622{
11623 unsigned int present;
11624
11625 present = snd_hda_codec_read(codec, 0x18, 0,
11626 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11627 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11628 present ? 0x0 : 0x6);
11629}
11630
11631static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11632 unsigned int res)
11633{
11634 if ((res >> 26) == ALC880_HP_EVENT)
11635 alc268_aspire_one_speaker_automute(codec);
11636 if ((res >> 26) == ALC880_MIC_EVENT)
11637 alc268_acer_mic_automute(codec);
11638}
11639
11640static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11641{
11642 alc268_aspire_one_speaker_automute(codec);
11643 alc268_acer_mic_automute(codec);
11644}
11645
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011646static struct snd_kcontrol_new alc268_dell_mixer[] = {
11647 /* output mixer control */
11648 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11649 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11650 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11651 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11652 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11653 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11654 { }
11655};
11656
11657static struct hda_verb alc268_dell_verbs[] = {
11658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11660 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11661 { }
11662};
11663
11664/* mute/unmute internal speaker according to the hp jack and mute state */
11665static void alc268_dell_automute(struct hda_codec *codec)
11666{
11667 unsigned int present;
11668 unsigned int mute;
11669
11670 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11671 if (present & 0x80000000)
11672 mute = HDA_AMP_MUTE;
11673 else
11674 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11675 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11676 HDA_AMP_MUTE, mute);
11677}
11678
11679static void alc268_dell_unsol_event(struct hda_codec *codec,
11680 unsigned int res)
11681{
11682 if ((res >> 26) != ALC880_HP_EVENT)
11683 return;
11684 alc268_dell_automute(codec);
11685}
11686
11687#define alc268_dell_init_hook alc268_dell_automute
11688
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011689static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11690 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11691 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11692 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11693 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11694 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11695 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11696 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11697 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11698 { }
11699};
11700
11701static struct hda_verb alc267_quanta_il1_verbs[] = {
11702 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11703 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11704 { }
11705};
11706
11707static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11708{
11709 unsigned int present;
11710
11711 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11712 & AC_PINSENSE_PRESENCE;
11713 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11714 present ? 0 : PIN_OUT);
11715}
11716
11717static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11718{
11719 unsigned int present;
11720
11721 present = snd_hda_codec_read(codec, 0x18, 0,
11722 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11723 snd_hda_codec_write(codec, 0x23, 0,
11724 AC_VERB_SET_CONNECT_SEL,
11725 present ? 0x00 : 0x01);
11726}
11727
11728static void alc267_quanta_il1_automute(struct hda_codec *codec)
11729{
11730 alc267_quanta_il1_hp_automute(codec);
11731 alc267_quanta_il1_mic_automute(codec);
11732}
11733
11734static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11735 unsigned int res)
11736{
11737 switch (res >> 26) {
11738 case ALC880_HP_EVENT:
11739 alc267_quanta_il1_hp_automute(codec);
11740 break;
11741 case ALC880_MIC_EVENT:
11742 alc267_quanta_il1_mic_automute(codec);
11743 break;
11744 }
11745}
11746
Kailang Yanga361d842007-06-05 12:30:55 +020011747/*
11748 * generic initialization of ADC, input mixers and output mixers
11749 */
11750static struct hda_verb alc268_base_init_verbs[] = {
11751 /* Unmute DAC0-1 and set vol = 0 */
11752 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011753 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011754
11755 /*
11756 * Set up output mixers (0x0c - 0x0e)
11757 */
11758 /* set vol=0 to output mixers */
11759 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011760 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11761
11762 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11763 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11764
11765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11766 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11767 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11768 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11769 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11770 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11771 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11772 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11773
11774 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11776 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11777 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011778 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011779
11780 /* set PCBEEP vol = 0, mute connections */
11781 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11782 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11783 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011784
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011785 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011786
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011787 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11788 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11789 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011791
Kailang Yanga361d842007-06-05 12:30:55 +020011792 { }
11793};
11794
11795/*
11796 * generic initialization of ADC, input mixers and output mixers
11797 */
11798static struct hda_verb alc268_volume_init_verbs[] = {
11799 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011800 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11801 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011802
11803 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11804 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11805 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11806 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11807 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11808
Kailang Yanga361d842007-06-05 12:30:55 +020011809 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011810 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11811 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11812
11813 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011814 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011815
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011816 /* set PCBEEP vol = 0, mute connections */
11817 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11818 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11819 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011820
11821 { }
11822};
11823
Kailang Yanga361d842007-06-05 12:30:55 +020011824static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11825 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11826 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11827 {
11828 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11829 /* The multiple "Capture Source" controls confuse alsamixer
11830 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011831 */
11832 /* .name = "Capture Source", */
11833 .name = "Input Source",
11834 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011835 .info = alc_mux_enum_info,
11836 .get = alc_mux_enum_get,
11837 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011838 },
11839 { } /* end */
11840};
11841
11842static struct snd_kcontrol_new alc268_capture_mixer[] = {
11843 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11844 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11845 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11846 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11847 {
11848 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11849 /* The multiple "Capture Source" controls confuse alsamixer
11850 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011851 */
11852 /* .name = "Capture Source", */
11853 .name = "Input Source",
11854 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011855 .info = alc_mux_enum_info,
11856 .get = alc_mux_enum_get,
11857 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011858 },
11859 { } /* end */
11860};
11861
11862static struct hda_input_mux alc268_capture_source = {
11863 .num_items = 4,
11864 .items = {
11865 { "Mic", 0x0 },
11866 { "Front Mic", 0x1 },
11867 { "Line", 0x2 },
11868 { "CD", 0x3 },
11869 },
11870};
11871
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011872static struct hda_input_mux alc268_acer_capture_source = {
11873 .num_items = 3,
11874 .items = {
11875 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011876 { "Internal Mic", 0x1 },
11877 { "Line", 0x2 },
11878 },
11879};
11880
11881static struct hda_input_mux alc268_acer_dmic_capture_source = {
11882 .num_items = 3,
11883 .items = {
11884 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011885 { "Internal Mic", 0x6 },
11886 { "Line", 0x2 },
11887 },
11888};
11889
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011890#ifdef CONFIG_SND_DEBUG
11891static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011892 /* Volume widgets */
11893 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11894 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11895 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11896 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11897 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11898 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11899 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11900 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11901 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11902 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11903 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11904 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11905 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011906 /* The below appears problematic on some hardwares */
11907 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011908 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11909 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11910 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11911 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11912
11913 /* Modes for retasking pin widgets */
11914 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11915 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11916 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11917 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11918
11919 /* Controls for GPIO pins, assuming they are configured as outputs */
11920 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11921 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11922 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11923 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11924
11925 /* Switches to allow the digital SPDIF output pin to be enabled.
11926 * The ALC268 does not have an SPDIF input.
11927 */
11928 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11929
11930 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11931 * this output to turn on an external amplifier.
11932 */
11933 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11934 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11935
11936 { } /* end */
11937};
11938#endif
11939
Kailang Yanga361d842007-06-05 12:30:55 +020011940/* create input playback/capture controls for the given pin */
11941static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11942 const char *ctlname, int idx)
11943{
11944 char name[32];
11945 int err;
11946
11947 sprintf(name, "%s Playback Volume", ctlname);
11948 if (nid == 0x14) {
11949 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11950 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11951 HDA_OUTPUT));
11952 if (err < 0)
11953 return err;
11954 } else if (nid == 0x15) {
11955 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11956 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11957 HDA_OUTPUT));
11958 if (err < 0)
11959 return err;
11960 } else
11961 return -1;
11962 sprintf(name, "%s Playback Switch", ctlname);
11963 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11964 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11965 if (err < 0)
11966 return err;
11967 return 0;
11968}
11969
11970/* add playback controls from the parsed DAC table */
11971static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11972 const struct auto_pin_cfg *cfg)
11973{
11974 hda_nid_t nid;
11975 int err;
11976
11977 spec->multiout.num_dacs = 2; /* only use one dac */
11978 spec->multiout.dac_nids = spec->private_dac_nids;
11979 spec->multiout.dac_nids[0] = 2;
11980 spec->multiout.dac_nids[1] = 3;
11981
11982 nid = cfg->line_out_pins[0];
11983 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011984 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011985
11986 nid = cfg->speaker_pins[0];
11987 if (nid == 0x1d) {
11988 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11989 "Speaker Playback Volume",
11990 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11991 if (err < 0)
11992 return err;
11993 }
11994 nid = cfg->hp_pins[0];
11995 if (nid)
11996 alc268_new_analog_output(spec, nid, "Headphone", 0);
11997
11998 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11999 if (nid == 0x16) {
12000 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12001 "Mono Playback Switch",
12002 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
12003 if (err < 0)
12004 return err;
12005 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012006 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012007}
12008
12009/* create playback/capture controls for input pins */
12010static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12011 const struct auto_pin_cfg *cfg)
12012{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012013 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012014 int i, idx1;
12015
12016 for (i = 0; i < AUTO_PIN_LAST; i++) {
12017 switch(cfg->input_pins[i]) {
12018 case 0x18:
12019 idx1 = 0; /* Mic 1 */
12020 break;
12021 case 0x19:
12022 idx1 = 1; /* Mic 2 */
12023 break;
12024 case 0x1a:
12025 idx1 = 2; /* Line In */
12026 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012027 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012028 idx1 = 3; /* CD */
12029 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012030 case 0x12:
12031 case 0x13:
12032 idx1 = 6; /* digital mics */
12033 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012034 default:
12035 continue;
12036 }
12037 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12038 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012039 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012040 }
12041 return 0;
12042}
12043
12044static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12045{
12046 struct alc_spec *spec = codec->spec;
12047 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12048 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12049 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12050 unsigned int dac_vol1, dac_vol2;
12051
12052 if (speaker_nid) {
12053 snd_hda_codec_write(codec, speaker_nid, 0,
12054 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12055 snd_hda_codec_write(codec, 0x0f, 0,
12056 AC_VERB_SET_AMP_GAIN_MUTE,
12057 AMP_IN_UNMUTE(1));
12058 snd_hda_codec_write(codec, 0x10, 0,
12059 AC_VERB_SET_AMP_GAIN_MUTE,
12060 AMP_IN_UNMUTE(1));
12061 } else {
12062 snd_hda_codec_write(codec, 0x0f, 0,
12063 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12064 snd_hda_codec_write(codec, 0x10, 0,
12065 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12066 }
12067
12068 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012069 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012070 dac_vol2 = AMP_OUT_ZERO;
12071 else if (line_nid == 0x15)
12072 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012073 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012074 dac_vol2 = AMP_OUT_ZERO;
12075 else if (hp_nid == 0x15)
12076 dac_vol1 = AMP_OUT_ZERO;
12077 if (line_nid != 0x16 || hp_nid != 0x16 ||
12078 spec->autocfg.line_out_pins[1] != 0x16 ||
12079 spec->autocfg.line_out_pins[2] != 0x16)
12080 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12081
12082 snd_hda_codec_write(codec, 0x02, 0,
12083 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12084 snd_hda_codec_write(codec, 0x03, 0,
12085 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12086}
12087
12088/* pcm configuration: identiacal with ALC880 */
12089#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12090#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012091#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012092#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12093
12094/*
12095 * BIOS auto configuration
12096 */
12097static int alc268_parse_auto_config(struct hda_codec *codec)
12098{
12099 struct alc_spec *spec = codec->spec;
12100 int err;
12101 static hda_nid_t alc268_ignore[] = { 0 };
12102
12103 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12104 alc268_ignore);
12105 if (err < 0)
12106 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012107 if (!spec->autocfg.line_outs) {
12108 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12109 spec->multiout.max_channels = 2;
12110 spec->no_analog = 1;
12111 goto dig_only;
12112 }
Kailang Yanga361d842007-06-05 12:30:55 +020012113 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012114 }
Kailang Yanga361d842007-06-05 12:30:55 +020012115 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12116 if (err < 0)
12117 return err;
12118 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12119 if (err < 0)
12120 return err;
12121
12122 spec->multiout.max_channels = 2;
12123
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012124 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012125 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012126 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012127 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012128 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12129 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012130 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012131 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012132
Takashi Iwai892981f2009-03-02 08:04:35 +010012133 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012134 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012135
Takashi Iwaid88897e2008-10-31 15:01:37 +010012136 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012137 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012138 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012139
Takashi Iwai776e1842007-08-29 15:07:11 +020012140 err = alc_auto_add_mic_boost(codec);
12141 if (err < 0)
12142 return err;
12143
Kailang Yanga361d842007-06-05 12:30:55 +020012144 return 1;
12145}
12146
12147#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12148#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12149#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12150
12151/* init callback for auto-configuration model -- overriding the default init */
12152static void alc268_auto_init(struct hda_codec *codec)
12153{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012154 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012155 alc268_auto_init_multi_out(codec);
12156 alc268_auto_init_hp_out(codec);
12157 alc268_auto_init_mono_speaker_out(codec);
12158 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012159 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012160 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012161}
12162
12163/*
12164 * configuration and preset
12165 */
12166static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012167 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012168 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012169 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012170 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012171 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012172 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012173 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012174 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012175#ifdef CONFIG_SND_DEBUG
12176 [ALC268_TEST] = "test",
12177#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012178 [ALC268_AUTO] = "auto",
12179};
12180
12181static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012182 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012183 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012184 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012185 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012186 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012187 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12188 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012189 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012190 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012191 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012192 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020012193 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020012194 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020012195 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012196 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012197 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012198 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012199 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012200 {}
12201};
12202
12203static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012204 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012205 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012206 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12207 alc267_quanta_il1_verbs },
12208 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12209 .dac_nids = alc268_dac_nids,
12210 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12211 .adc_nids = alc268_adc_nids_alt,
12212 .hp_nid = 0x03,
12213 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12214 .channel_mode = alc268_modes,
12215 .input_mux = &alc268_capture_source,
12216 .unsol_event = alc267_quanta_il1_unsol_event,
12217 .init_hook = alc267_quanta_il1_automute,
12218 },
Kailang Yanga361d842007-06-05 12:30:55 +020012219 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012220 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12221 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012222 .init_verbs = { alc268_base_init_verbs },
12223 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12224 .dac_nids = alc268_dac_nids,
12225 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12226 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012227 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012228 .hp_nid = 0x03,
12229 .dig_out_nid = ALC268_DIGOUT_NID,
12230 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12231 .channel_mode = alc268_modes,
12232 .input_mux = &alc268_capture_source,
12233 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012234 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012235 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012236 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012237 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12238 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012239 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12240 .dac_nids = alc268_dac_nids,
12241 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12242 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012243 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012244 .hp_nid = 0x03,
12245 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12246 .channel_mode = alc268_modes,
12247 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012248 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012249 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012250 },
12251 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012252 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12253 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012254 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12255 alc268_acer_verbs },
12256 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12257 .dac_nids = alc268_dac_nids,
12258 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12259 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012260 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012261 .hp_nid = 0x02,
12262 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12263 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012264 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012265 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012266 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012267 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012268 [ALC268_ACER_DMIC] = {
12269 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12270 alc268_beep_mixer },
12271 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12272 alc268_acer_verbs },
12273 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12274 .dac_nids = alc268_dac_nids,
12275 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12276 .adc_nids = alc268_adc_nids_alt,
12277 .capsrc_nids = alc268_capsrc_nids,
12278 .hp_nid = 0x02,
12279 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12280 .channel_mode = alc268_modes,
12281 .input_mux = &alc268_acer_dmic_capture_source,
12282 .unsol_event = alc268_acer_unsol_event,
12283 .init_hook = alc268_acer_init_hook,
12284 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012285 [ALC268_ACER_ASPIRE_ONE] = {
12286 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012287 alc268_beep_mixer,
12288 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012289 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12290 alc268_acer_aspire_one_verbs },
12291 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12292 .dac_nids = alc268_dac_nids,
12293 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12294 .adc_nids = alc268_adc_nids_alt,
12295 .capsrc_nids = alc268_capsrc_nids,
12296 .hp_nid = 0x03,
12297 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12298 .channel_mode = alc268_modes,
12299 .input_mux = &alc268_acer_lc_capture_source,
12300 .unsol_event = alc268_acer_lc_unsol_event,
12301 .init_hook = alc268_acer_lc_init_hook,
12302 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012303 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012304 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012305 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12306 alc268_dell_verbs },
12307 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12308 .dac_nids = alc268_dac_nids,
12309 .hp_nid = 0x02,
12310 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12311 .channel_mode = alc268_modes,
12312 .unsol_event = alc268_dell_unsol_event,
12313 .init_hook = alc268_dell_init_hook,
12314 .input_mux = &alc268_capture_source,
12315 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012316 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012317 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12318 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012319 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12320 alc268_toshiba_verbs },
12321 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12322 .dac_nids = alc268_dac_nids,
12323 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12324 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012325 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012326 .hp_nid = 0x03,
12327 .dig_out_nid = ALC268_DIGOUT_NID,
12328 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12329 .channel_mode = alc268_modes,
12330 .input_mux = &alc268_capture_source,
12331 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012332 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012333 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012334#ifdef CONFIG_SND_DEBUG
12335 [ALC268_TEST] = {
12336 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12337 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12338 alc268_volume_init_verbs },
12339 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12340 .dac_nids = alc268_dac_nids,
12341 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12342 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012343 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012344 .hp_nid = 0x03,
12345 .dig_out_nid = ALC268_DIGOUT_NID,
12346 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12347 .channel_mode = alc268_modes,
12348 .input_mux = &alc268_capture_source,
12349 },
12350#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012351};
12352
12353static int patch_alc268(struct hda_codec *codec)
12354{
12355 struct alc_spec *spec;
12356 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012357 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012358
12359 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12360 if (spec == NULL)
12361 return -ENOMEM;
12362
12363 codec->spec = spec;
12364
12365 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12366 alc268_models,
12367 alc268_cfg_tbl);
12368
12369 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12370 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12371 "trying auto-probe from BIOS...\n");
12372 board_config = ALC268_AUTO;
12373 }
12374
12375 if (board_config == ALC268_AUTO) {
12376 /* automatic parse from the BIOS config */
12377 err = alc268_parse_auto_config(codec);
12378 if (err < 0) {
12379 alc_free(codec);
12380 return err;
12381 } else if (!err) {
12382 printk(KERN_INFO
12383 "hda_codec: Cannot set up configuration "
12384 "from BIOS. Using base mode...\n");
12385 board_config = ALC268_3ST;
12386 }
12387 }
12388
12389 if (board_config != ALC268_AUTO)
12390 setup_preset(spec, &alc268_presets[board_config]);
12391
Kailang Yang2f893282008-05-27 12:14:47 +020012392 if (codec->vendor_id == 0x10ec0267) {
12393 spec->stream_name_analog = "ALC267 Analog";
12394 spec->stream_name_digital = "ALC267 Digital";
12395 } else {
12396 spec->stream_name_analog = "ALC268 Analog";
12397 spec->stream_name_digital = "ALC268 Digital";
12398 }
12399
Kailang Yanga361d842007-06-05 12:30:55 +020012400 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12401 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012402 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012403
Kailang Yanga361d842007-06-05 12:30:55 +020012404 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12405
Takashi Iwai22971e32009-02-10 11:56:44 +010012406 has_beep = 0;
12407 for (i = 0; i < spec->num_mixers; i++) {
12408 if (spec->mixers[i] == alc268_beep_mixer) {
12409 has_beep = 1;
12410 break;
12411 }
12412 }
12413
12414 if (has_beep) {
12415 err = snd_hda_attach_beep_device(codec, 0x1);
12416 if (err < 0) {
12417 alc_free(codec);
12418 return err;
12419 }
12420 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12421 /* override the amp caps for beep generator */
12422 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012423 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12424 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12425 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12426 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012427 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012428
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012429 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012430 /* check whether NID 0x07 is valid */
12431 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012432 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012433
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012434 /* get type */
12435 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012436 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012437 spec->adc_nids = alc268_adc_nids_alt;
12438 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012439 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012440 } else {
12441 spec->adc_nids = alc268_adc_nids;
12442 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012443 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012444 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012445 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012446 /* set default input source */
12447 for (i = 0; i < spec->num_adc_nids; i++)
12448 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12449 0, AC_VERB_SET_CONNECT_SEL,
12450 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012451 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012452
12453 spec->vmaster_nid = 0x02;
12454
Kailang Yanga361d842007-06-05 12:30:55 +020012455 codec->patch_ops = alc_patch_ops;
12456 if (board_config == ALC268_AUTO)
12457 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012458
Takashi Iwaidaead532008-11-28 12:55:36 +010012459 codec->proc_widget_hook = print_realtek_coef;
12460
Kailang Yanga361d842007-06-05 12:30:55 +020012461 return 0;
12462}
12463
12464/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012465 * ALC269 channel source setting (2 channel)
12466 */
12467#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12468
12469#define alc269_dac_nids alc260_dac_nids
12470
12471static hda_nid_t alc269_adc_nids[1] = {
12472 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012473 0x08,
12474};
12475
Takashi Iwaie01bf502008-08-21 16:25:07 +020012476static hda_nid_t alc269_capsrc_nids[1] = {
12477 0x23,
12478};
12479
12480/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12481 * not a mux!
12482 */
12483
Kailang Yangf53281e2008-07-18 12:36:43 +020012484static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12485 .num_items = 2,
12486 .items = {
12487 { "i-Mic", 0x5 },
12488 { "e-Mic", 0x0 },
12489 },
12490};
12491
12492static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12493 .num_items = 2,
12494 .items = {
12495 { "i-Mic", 0x1 },
12496 { "e-Mic", 0x0 },
12497 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012498};
12499
12500#define alc269_modes alc260_modes
12501#define alc269_capture_source alc880_lg_lw_capture_source
12502
12503static struct snd_kcontrol_new alc269_base_mixer[] = {
12504 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12505 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12506 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12507 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12509 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12510 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12511 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12512 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12513 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12514 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12515 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12516 { } /* end */
12517};
12518
Kailang Yang60db6b52008-08-26 13:13:00 +020012519static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12520 /* output mixer control */
12521 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12522 {
12523 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12524 .name = "Master Playback Switch",
12525 .info = snd_hda_mixer_amp_switch_info,
12526 .get = snd_hda_mixer_amp_switch_get,
12527 .put = alc268_acer_master_sw_put,
12528 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12529 },
12530 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12531 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12532 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12533 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12534 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12535 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012536 { }
12537};
12538
Tony Vroon64154832008-11-06 15:08:49 +000012539static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12540 /* output mixer control */
12541 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12542 {
12543 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12544 .name = "Master Playback Switch",
12545 .info = snd_hda_mixer_amp_switch_info,
12546 .get = snd_hda_mixer_amp_switch_get,
12547 .put = alc268_acer_master_sw_put,
12548 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12549 },
12550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12552 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12553 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12554 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12555 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12556 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12557 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12558 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012559 { }
12560};
12561
Kailang Yangf53281e2008-07-18 12:36:43 +020012562/* bind volumes of both NID 0x0c and 0x0d */
12563static struct hda_bind_ctls alc269_epc_bind_vol = {
12564 .ops = &snd_hda_bind_vol,
12565 .values = {
12566 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12567 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12568 0
12569 },
12570};
12571
12572static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12573 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12574 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12575 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12576 { } /* end */
12577};
12578
Kailang Yangf6a92242007-12-13 16:52:54 +010012579/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012580static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12581 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12582 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012583 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12584 { } /* end */
12585};
12586
12587/* FSC amilo */
12588static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12589 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12591 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012592 { } /* end */
12593};
12594
Kailang Yang60db6b52008-08-26 13:13:00 +020012595static struct hda_verb alc269_quanta_fl1_verbs[] = {
12596 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12597 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12598 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12599 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12600 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12601 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12602 { }
12603};
12604
Tony Vroon64154832008-11-06 15:08:49 +000012605static struct hda_verb alc269_lifebook_verbs[] = {
12606 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12607 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12608 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12610 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12611 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12612 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12613 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12614 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12615 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12616 { }
12617};
12618
Kailang Yang60db6b52008-08-26 13:13:00 +020012619/* toggle speaker-output according to the hp-jack state */
12620static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12621{
12622 unsigned int present;
12623 unsigned char bits;
12624
12625 present = snd_hda_codec_read(codec, 0x15, 0,
12626 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12627 bits = present ? AMP_IN_MUTE(0) : 0;
12628 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12629 AMP_IN_MUTE(0), bits);
12630 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12631 AMP_IN_MUTE(0), bits);
12632
12633 snd_hda_codec_write(codec, 0x20, 0,
12634 AC_VERB_SET_COEF_INDEX, 0x0c);
12635 snd_hda_codec_write(codec, 0x20, 0,
12636 AC_VERB_SET_PROC_COEF, 0x680);
12637
12638 snd_hda_codec_write(codec, 0x20, 0,
12639 AC_VERB_SET_COEF_INDEX, 0x0c);
12640 snd_hda_codec_write(codec, 0x20, 0,
12641 AC_VERB_SET_PROC_COEF, 0x480);
12642}
12643
Tony Vroon64154832008-11-06 15:08:49 +000012644/* toggle speaker-output according to the hp-jacks state */
12645static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12646{
12647 unsigned int present;
12648 unsigned char bits;
12649
12650 /* Check laptop headphone socket */
12651 present = snd_hda_codec_read(codec, 0x15, 0,
12652 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12653
12654 /* Check port replicator headphone socket */
12655 present |= snd_hda_codec_read(codec, 0x1a, 0,
12656 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12657
12658 bits = present ? AMP_IN_MUTE(0) : 0;
12659 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12660 AMP_IN_MUTE(0), bits);
12661 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12662 AMP_IN_MUTE(0), bits);
12663
12664 snd_hda_codec_write(codec, 0x20, 0,
12665 AC_VERB_SET_COEF_INDEX, 0x0c);
12666 snd_hda_codec_write(codec, 0x20, 0,
12667 AC_VERB_SET_PROC_COEF, 0x680);
12668
12669 snd_hda_codec_write(codec, 0x20, 0,
12670 AC_VERB_SET_COEF_INDEX, 0x0c);
12671 snd_hda_codec_write(codec, 0x20, 0,
12672 AC_VERB_SET_PROC_COEF, 0x480);
12673}
12674
Kailang Yang60db6b52008-08-26 13:13:00 +020012675static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12676{
12677 unsigned int present;
12678
12679 present = snd_hda_codec_read(codec, 0x18, 0,
12680 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12681 snd_hda_codec_write(codec, 0x23, 0,
12682 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12683}
12684
Tony Vroon64154832008-11-06 15:08:49 +000012685static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12686{
12687 unsigned int present_laptop;
12688 unsigned int present_dock;
12689
12690 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12691 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12692
12693 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12694 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12695
12696 /* Laptop mic port overrides dock mic port, design decision */
12697 if (present_dock)
12698 snd_hda_codec_write(codec, 0x23, 0,
12699 AC_VERB_SET_CONNECT_SEL, 0x3);
12700 if (present_laptop)
12701 snd_hda_codec_write(codec, 0x23, 0,
12702 AC_VERB_SET_CONNECT_SEL, 0x0);
12703 if (!present_dock && !present_laptop)
12704 snd_hda_codec_write(codec, 0x23, 0,
12705 AC_VERB_SET_CONNECT_SEL, 0x1);
12706}
12707
Kailang Yang60db6b52008-08-26 13:13:00 +020012708static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12709 unsigned int res)
12710{
12711 if ((res >> 26) == ALC880_HP_EVENT)
12712 alc269_quanta_fl1_speaker_automute(codec);
12713 if ((res >> 26) == ALC880_MIC_EVENT)
12714 alc269_quanta_fl1_mic_automute(codec);
12715}
12716
Tony Vroon64154832008-11-06 15:08:49 +000012717static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12718 unsigned int res)
12719{
12720 if ((res >> 26) == ALC880_HP_EVENT)
12721 alc269_lifebook_speaker_automute(codec);
12722 if ((res >> 26) == ALC880_MIC_EVENT)
12723 alc269_lifebook_mic_autoswitch(codec);
12724}
12725
Kailang Yang60db6b52008-08-26 13:13:00 +020012726static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12727{
12728 alc269_quanta_fl1_speaker_automute(codec);
12729 alc269_quanta_fl1_mic_automute(codec);
12730}
12731
Tony Vroon64154832008-11-06 15:08:49 +000012732static void alc269_lifebook_init_hook(struct hda_codec *codec)
12733{
12734 alc269_lifebook_speaker_automute(codec);
12735 alc269_lifebook_mic_autoswitch(codec);
12736}
12737
Kailang Yang60db6b52008-08-26 13:13:00 +020012738static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12739 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12740 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12741 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12742 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12743 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12744 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12745 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12746 {}
12747};
12748
12749static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12750 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12751 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12752 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12753 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12754 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12755 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12756 {}
12757};
12758
12759/* toggle speaker-output according to the hp-jack state */
12760static void alc269_speaker_automute(struct hda_codec *codec)
12761{
12762 unsigned int present;
12763 unsigned char bits;
12764
12765 present = snd_hda_codec_read(codec, 0x15, 0,
12766 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12767 bits = present ? AMP_IN_MUTE(0) : 0;
12768 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12769 AMP_IN_MUTE(0), bits);
12770 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12771 AMP_IN_MUTE(0), bits);
12772}
12773
12774static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12775{
12776 unsigned int present;
12777
12778 present = snd_hda_codec_read(codec, 0x18, 0,
12779 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12780 snd_hda_codec_write(codec, 0x23, 0,
12781 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12782}
12783
12784static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12785{
12786 unsigned int present;
12787
12788 present = snd_hda_codec_read(codec, 0x18, 0,
12789 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12790 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12791 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12792 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12793 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12794}
12795
12796/* unsolicited event for HP jack sensing */
12797static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12798 unsigned int res)
12799{
12800 if ((res >> 26) == ALC880_HP_EVENT)
12801 alc269_speaker_automute(codec);
12802
12803 if ((res >> 26) == ALC880_MIC_EVENT)
12804 alc269_eeepc_dmic_automute(codec);
12805}
12806
12807static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12808{
12809 alc269_speaker_automute(codec);
12810 alc269_eeepc_dmic_automute(codec);
12811}
12812
12813/* unsolicited event for HP jack sensing */
12814static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12815 unsigned int res)
12816{
12817 if ((res >> 26) == ALC880_HP_EVENT)
12818 alc269_speaker_automute(codec);
12819
12820 if ((res >> 26) == ALC880_MIC_EVENT)
12821 alc269_eeepc_amic_automute(codec);
12822}
12823
12824static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12825{
12826 alc269_speaker_automute(codec);
12827 alc269_eeepc_amic_automute(codec);
12828}
12829
Kailang Yangf6a92242007-12-13 16:52:54 +010012830/*
12831 * generic initialization of ADC, input mixers and output mixers
12832 */
12833static struct hda_verb alc269_init_verbs[] = {
12834 /*
12835 * Unmute ADC0 and set the default input to mic-in
12836 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012837 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012838
12839 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12840 * analog-loopback mixer widget
12841 * Note: PASD motherboards uses the Line In 2 as the input for
12842 * front panel mic (mic 2)
12843 */
12844 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12848 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12850
12851 /*
12852 * Set up output mixers (0x0c - 0x0e)
12853 */
12854 /* set vol=0 to output mixers */
12855 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12856 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12857
12858 /* set up input amps for analog loopback */
12859 /* Amp Indices: DAC = 0, mixer = 1 */
12860 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12861 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12862 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12863 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12864 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12865 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12866
12867 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12869 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12870 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12871 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12872 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12873 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12874
12875 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12876 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12877 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12878 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12879 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12880 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12881 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12882
12883 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12884 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12885
12886 /* FIXME: use matrix-type input source selection */
12887 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12888 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012889 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12890 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012891 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12892 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12893
12894 /* set EAPD */
12895 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12896 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12897 { }
12898};
12899
12900/* add playback controls from the parsed DAC table */
12901static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12902 const struct auto_pin_cfg *cfg)
12903{
12904 hda_nid_t nid;
12905 int err;
12906
12907 spec->multiout.num_dacs = 1; /* only use one dac */
12908 spec->multiout.dac_nids = spec->private_dac_nids;
12909 spec->multiout.dac_nids[0] = 2;
12910
12911 nid = cfg->line_out_pins[0];
12912 if (nid) {
12913 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12914 "Front Playback Volume",
12915 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12916 if (err < 0)
12917 return err;
12918 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12919 "Front Playback Switch",
12920 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12921 if (err < 0)
12922 return err;
12923 }
12924
12925 nid = cfg->speaker_pins[0];
12926 if (nid) {
12927 if (!cfg->line_out_pins[0]) {
12928 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12929 "Speaker Playback Volume",
12930 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12931 HDA_OUTPUT));
12932 if (err < 0)
12933 return err;
12934 }
12935 if (nid == 0x16) {
12936 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12937 "Speaker Playback Switch",
12938 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12939 HDA_OUTPUT));
12940 if (err < 0)
12941 return err;
12942 } else {
12943 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12944 "Speaker Playback Switch",
12945 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12946 HDA_OUTPUT));
12947 if (err < 0)
12948 return err;
12949 }
12950 }
12951 nid = cfg->hp_pins[0];
12952 if (nid) {
12953 /* spec->multiout.hp_nid = 2; */
12954 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12955 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12956 "Headphone Playback Volume",
12957 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12958 HDA_OUTPUT));
12959 if (err < 0)
12960 return err;
12961 }
12962 if (nid == 0x16) {
12963 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12964 "Headphone Playback Switch",
12965 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12966 HDA_OUTPUT));
12967 if (err < 0)
12968 return err;
12969 } else {
12970 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12971 "Headphone Playback Switch",
12972 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12973 HDA_OUTPUT));
12974 if (err < 0)
12975 return err;
12976 }
12977 }
12978 return 0;
12979}
12980
Takashi Iwaiee956e02008-10-31 17:16:31 +010012981static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12982 const struct auto_pin_cfg *cfg)
12983{
12984 int err;
12985
12986 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12987 if (err < 0)
12988 return err;
12989 /* digital-mic input pin is excluded in alc880_auto_create..()
12990 * because it's under 0x18
12991 */
12992 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12993 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012994 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012995 imux->items[imux->num_items].label = "Int Mic";
12996 imux->items[imux->num_items].index = 0x05;
12997 imux->num_items++;
12998 }
12999 return 0;
13000}
Kailang Yangf6a92242007-12-13 16:52:54 +010013001
13002#ifdef CONFIG_SND_HDA_POWER_SAVE
13003#define alc269_loopbacks alc880_loopbacks
13004#endif
13005
13006/* pcm configuration: identiacal with ALC880 */
13007#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13008#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13009#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13010#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13011
Takashi Iwaif03d3112009-03-05 14:18:16 +010013012static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13013 .substreams = 1,
13014 .channels_min = 2,
13015 .channels_max = 8,
13016 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13017 /* NID is set in alc_build_pcms */
13018 .ops = {
13019 .open = alc880_playback_pcm_open,
13020 .prepare = alc880_playback_pcm_prepare,
13021 .cleanup = alc880_playback_pcm_cleanup
13022 },
13023};
13024
13025static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13026 .substreams = 1,
13027 .channels_min = 2,
13028 .channels_max = 2,
13029 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13030 /* NID is set in alc_build_pcms */
13031};
13032
Kailang Yangf6a92242007-12-13 16:52:54 +010013033/*
13034 * BIOS auto configuration
13035 */
13036static int alc269_parse_auto_config(struct hda_codec *codec)
13037{
13038 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013039 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013040 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13041
13042 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13043 alc269_ignore);
13044 if (err < 0)
13045 return err;
13046
13047 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13048 if (err < 0)
13049 return err;
13050 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13051 if (err < 0)
13052 return err;
13053
13054 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13055
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013056 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013057 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13058
Takashi Iwai603c4012008-07-30 15:01:44 +020013059 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013060 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013061
Takashi Iwaid88897e2008-10-31 15:01:37 +010013062 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013063 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013064 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013065 /* set default input source */
13066 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13067 0, AC_VERB_SET_CONNECT_SEL,
13068 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013069
13070 err = alc_auto_add_mic_boost(codec);
13071 if (err < 0)
13072 return err;
13073
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013074 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013075 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013076
Kailang Yangf6a92242007-12-13 16:52:54 +010013077 return 1;
13078}
13079
13080#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13081#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13082#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13083
13084
13085/* init callback for auto-configuration model -- overriding the default init */
13086static void alc269_auto_init(struct hda_codec *codec)
13087{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013088 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013089 alc269_auto_init_multi_out(codec);
13090 alc269_auto_init_hp_out(codec);
13091 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013092 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013093 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013094}
13095
13096/*
13097 * configuration and preset
13098 */
13099static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013100 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013101 [ALC269_QUANTA_FL1] = "quanta",
13102 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013103 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013104 [ALC269_FUJITSU] = "fujitsu",
13105 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013106};
13107
13108static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013109 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013110 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13111 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013112 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13113 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13114 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13115 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13116 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13117 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013118 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13119 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013120 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13121 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013122 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013123 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013124 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013125 {}
13126};
13127
13128static struct alc_config_preset alc269_presets[] = {
13129 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013130 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013131 .init_verbs = { alc269_init_verbs },
13132 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13133 .dac_nids = alc269_dac_nids,
13134 .hp_nid = 0x03,
13135 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13136 .channel_mode = alc269_modes,
13137 .input_mux = &alc269_capture_source,
13138 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013139 [ALC269_QUANTA_FL1] = {
13140 .mixers = { alc269_quanta_fl1_mixer },
13141 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13142 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13143 .dac_nids = alc269_dac_nids,
13144 .hp_nid = 0x03,
13145 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13146 .channel_mode = alc269_modes,
13147 .input_mux = &alc269_capture_source,
13148 .unsol_event = alc269_quanta_fl1_unsol_event,
13149 .init_hook = alc269_quanta_fl1_init_hook,
13150 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013151 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013152 .mixers = { alc269_eeepc_mixer },
13153 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013154 .init_verbs = { alc269_init_verbs,
13155 alc269_eeepc_amic_init_verbs },
13156 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13157 .dac_nids = alc269_dac_nids,
13158 .hp_nid = 0x03,
13159 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13160 .channel_mode = alc269_modes,
13161 .input_mux = &alc269_eeepc_amic_capture_source,
13162 .unsol_event = alc269_eeepc_amic_unsol_event,
13163 .init_hook = alc269_eeepc_amic_inithook,
13164 },
13165 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013166 .mixers = { alc269_eeepc_mixer },
13167 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013168 .init_verbs = { alc269_init_verbs,
13169 alc269_eeepc_dmic_init_verbs },
13170 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13171 .dac_nids = alc269_dac_nids,
13172 .hp_nid = 0x03,
13173 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13174 .channel_mode = alc269_modes,
13175 .input_mux = &alc269_eeepc_dmic_capture_source,
13176 .unsol_event = alc269_eeepc_dmic_unsol_event,
13177 .init_hook = alc269_eeepc_dmic_inithook,
13178 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013179 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013180 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013181 .cap_mixer = alc269_epc_capture_mixer,
13182 .init_verbs = { alc269_init_verbs,
13183 alc269_eeepc_dmic_init_verbs },
13184 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13185 .dac_nids = alc269_dac_nids,
13186 .hp_nid = 0x03,
13187 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13188 .channel_mode = alc269_modes,
13189 .input_mux = &alc269_eeepc_dmic_capture_source,
13190 .unsol_event = alc269_eeepc_dmic_unsol_event,
13191 .init_hook = alc269_eeepc_dmic_inithook,
13192 },
Tony Vroon64154832008-11-06 15:08:49 +000013193 [ALC269_LIFEBOOK] = {
13194 .mixers = { alc269_lifebook_mixer },
13195 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13196 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13197 .dac_nids = alc269_dac_nids,
13198 .hp_nid = 0x03,
13199 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13200 .channel_mode = alc269_modes,
13201 .input_mux = &alc269_capture_source,
13202 .unsol_event = alc269_lifebook_unsol_event,
13203 .init_hook = alc269_lifebook_init_hook,
13204 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013205};
13206
13207static int patch_alc269(struct hda_codec *codec)
13208{
13209 struct alc_spec *spec;
13210 int board_config;
13211 int err;
13212
13213 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13214 if (spec == NULL)
13215 return -ENOMEM;
13216
13217 codec->spec = spec;
13218
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013219 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13220
Kailang Yangf6a92242007-12-13 16:52:54 +010013221 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13222 alc269_models,
13223 alc269_cfg_tbl);
13224
13225 if (board_config < 0) {
13226 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
13227 "trying auto-probe from BIOS...\n");
13228 board_config = ALC269_AUTO;
13229 }
13230
13231 if (board_config == ALC269_AUTO) {
13232 /* automatic parse from the BIOS config */
13233 err = alc269_parse_auto_config(codec);
13234 if (err < 0) {
13235 alc_free(codec);
13236 return err;
13237 } else if (!err) {
13238 printk(KERN_INFO
13239 "hda_codec: Cannot set up configuration "
13240 "from BIOS. Using base mode...\n");
13241 board_config = ALC269_BASIC;
13242 }
13243 }
13244
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013245 err = snd_hda_attach_beep_device(codec, 0x1);
13246 if (err < 0) {
13247 alc_free(codec);
13248 return err;
13249 }
13250
Kailang Yangf6a92242007-12-13 16:52:54 +010013251 if (board_config != ALC269_AUTO)
13252 setup_preset(spec, &alc269_presets[board_config]);
13253
13254 spec->stream_name_analog = "ALC269 Analog";
Takashi Iwaif03d3112009-03-05 14:18:16 +010013255 if (codec->subsystem_id == 0x17aa3bf8) {
13256 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13257 * fix the sample rate of analog I/O to 44.1kHz
13258 */
13259 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13260 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13261 } else {
13262 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13263 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13264 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013265 spec->stream_name_digital = "ALC269 Digital";
13266 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13267 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13268
13269 spec->adc_nids = alc269_adc_nids;
13270 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013271 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013272 if (!spec->cap_mixer)
13273 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013274 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013275
13276 codec->patch_ops = alc_patch_ops;
13277 if (board_config == ALC269_AUTO)
13278 spec->init_hook = alc269_auto_init;
13279#ifdef CONFIG_SND_HDA_POWER_SAVE
13280 if (!spec->loopback.amplist)
13281 spec->loopback.amplist = alc269_loopbacks;
13282#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013283 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013284
13285 return 0;
13286}
13287
13288/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013289 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13290 */
13291
13292/*
13293 * set the path ways for 2 channel output
13294 * need to set the codec line out and mic 1 pin widgets to inputs
13295 */
13296static struct hda_verb alc861_threestack_ch2_init[] = {
13297 /* set pin widget 1Ah (line in) for input */
13298 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013299 /* set pin widget 18h (mic1/2) for input, for mic also enable
13300 * the vref
13301 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013302 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13303
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013304 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13305#if 0
13306 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13307 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13308#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013309 { } /* end */
13310};
13311/*
13312 * 6ch mode
13313 * need to set the codec line out and mic 1 pin widgets to outputs
13314 */
13315static struct hda_verb alc861_threestack_ch6_init[] = {
13316 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13317 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13318 /* set pin widget 18h (mic1) for output (CLFE)*/
13319 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13320
13321 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013322 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013323
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013324 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13325#if 0
13326 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13327 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13328#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013329 { } /* end */
13330};
13331
13332static struct hda_channel_mode alc861_threestack_modes[2] = {
13333 { 2, alc861_threestack_ch2_init },
13334 { 6, alc861_threestack_ch6_init },
13335};
Takashi Iwai22309c32006-08-09 16:57:28 +020013336/* Set mic1 as input and unmute the mixer */
13337static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13338 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13339 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13340 { } /* end */
13341};
13342/* Set mic1 as output and mute mixer */
13343static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13344 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13345 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13346 { } /* end */
13347};
13348
13349static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13350 { 2, alc861_uniwill_m31_ch2_init },
13351 { 4, alc861_uniwill_m31_ch4_init },
13352};
Kailang Yangdf694da2005-12-05 19:42:22 +010013353
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013354/* Set mic1 and line-in as input and unmute the mixer */
13355static struct hda_verb alc861_asus_ch2_init[] = {
13356 /* set pin widget 1Ah (line in) for input */
13357 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013358 /* set pin widget 18h (mic1/2) for input, for mic also enable
13359 * the vref
13360 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013361 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13362
13363 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13364#if 0
13365 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13366 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13367#endif
13368 { } /* end */
13369};
13370/* Set mic1 nad line-in as output and mute mixer */
13371static struct hda_verb alc861_asus_ch6_init[] = {
13372 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13373 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13374 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13375 /* set pin widget 18h (mic1) for output (CLFE)*/
13376 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13377 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13378 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13379 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13380
13381 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13382#if 0
13383 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13384 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13385#endif
13386 { } /* end */
13387};
13388
13389static struct hda_channel_mode alc861_asus_modes[2] = {
13390 { 2, alc861_asus_ch2_init },
13391 { 6, alc861_asus_ch6_init },
13392};
13393
Kailang Yangdf694da2005-12-05 19:42:22 +010013394/* patch-ALC861 */
13395
13396static struct snd_kcontrol_new alc861_base_mixer[] = {
13397 /* output mixer control */
13398 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13399 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13400 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13401 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13402 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13403
13404 /*Input mixer control */
13405 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13406 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13407 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13408 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13409 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13410 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13411 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13412 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13413 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13414 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013415
Kailang Yangdf694da2005-12-05 19:42:22 +010013416 { } /* end */
13417};
13418
13419static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13420 /* output mixer control */
13421 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13422 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13423 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13424 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13425 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13426
13427 /* Input mixer control */
13428 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13429 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13430 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13431 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13432 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13433 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13434 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13435 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13436 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13437 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013438
Kailang Yangdf694da2005-12-05 19:42:22 +010013439 {
13440 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13441 .name = "Channel Mode",
13442 .info = alc_ch_mode_info,
13443 .get = alc_ch_mode_get,
13444 .put = alc_ch_mode_put,
13445 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13446 },
13447 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013448};
13449
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013450static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013451 /* output mixer control */
13452 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13454 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013455
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013456 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013457};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013458
Takashi Iwai22309c32006-08-09 16:57:28 +020013459static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13460 /* output mixer control */
13461 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13462 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13463 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13464 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13465 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13466
13467 /* Input mixer control */
13468 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13469 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13470 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13471 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13472 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13473 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13474 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13475 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13476 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13477 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013478
Takashi Iwai22309c32006-08-09 16:57:28 +020013479 {
13480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13481 .name = "Channel Mode",
13482 .info = alc_ch_mode_info,
13483 .get = alc_ch_mode_get,
13484 .put = alc_ch_mode_put,
13485 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13486 },
13487 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013488};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013489
13490static struct snd_kcontrol_new alc861_asus_mixer[] = {
13491 /* output mixer control */
13492 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13493 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13494 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13495 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13496 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13497
13498 /* Input mixer control */
13499 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13500 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13501 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13502 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13503 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13504 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13505 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13506 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13507 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013508 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13509
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013510 {
13511 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13512 .name = "Channel Mode",
13513 .info = alc_ch_mode_info,
13514 .get = alc_ch_mode_get,
13515 .put = alc_ch_mode_put,
13516 .private_value = ARRAY_SIZE(alc861_asus_modes),
13517 },
13518 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013519};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013520
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013521/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013522static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013523 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13524 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013525 { }
13526};
13527
Kailang Yangdf694da2005-12-05 19:42:22 +010013528/*
13529 * generic initialization of ADC, input mixers and output mixers
13530 */
13531static struct hda_verb alc861_base_init_verbs[] = {
13532 /*
13533 * Unmute ADC0 and set the default input to mic-in
13534 */
13535 /* port-A for surround (rear panel) */
13536 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13537 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13538 /* port-B for mic-in (rear panel) with vref */
13539 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13540 /* port-C for line-in (rear panel) */
13541 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13542 /* port-D for Front */
13543 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13544 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13545 /* port-E for HP out (front panel) */
13546 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13547 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013548 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013549 /* port-F for mic-in (front panel) with vref */
13550 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13551 /* port-G for CLFE (rear panel) */
13552 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13553 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13554 /* port-H for side (rear panel) */
13555 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13556 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13557 /* CD-in */
13558 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13559 /* route front mic to ADC1*/
13560 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13561 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013562
Kailang Yangdf694da2005-12-05 19:42:22 +010013563 /* Unmute DAC0~3 & spdif out*/
13564 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13565 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13566 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13567 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13568 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013569
Kailang Yangdf694da2005-12-05 19:42:22 +010013570 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13571 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13572 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13573 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13574 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013575
Kailang Yangdf694da2005-12-05 19:42:22 +010013576 /* Unmute Stereo Mixer 15 */
13577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13579 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013580 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013581
13582 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13583 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13584 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13585 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13586 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13587 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13588 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13589 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013590 /* hp used DAC 3 (Front) */
13591 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013592 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13593
13594 { }
13595};
13596
13597static struct hda_verb alc861_threestack_init_verbs[] = {
13598 /*
13599 * Unmute ADC0 and set the default input to mic-in
13600 */
13601 /* port-A for surround (rear panel) */
13602 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13603 /* port-B for mic-in (rear panel) with vref */
13604 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13605 /* port-C for line-in (rear panel) */
13606 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13607 /* port-D for Front */
13608 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13609 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13610 /* port-E for HP out (front panel) */
13611 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13612 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013613 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013614 /* port-F for mic-in (front panel) with vref */
13615 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13616 /* port-G for CLFE (rear panel) */
13617 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13618 /* port-H for side (rear panel) */
13619 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13620 /* CD-in */
13621 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13622 /* route front mic to ADC1*/
13623 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13624 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13625 /* Unmute DAC0~3 & spdif out*/
13626 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13627 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13628 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13629 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13630 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013631
Kailang Yangdf694da2005-12-05 19:42:22 +010013632 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13633 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13634 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13635 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13636 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013637
Kailang Yangdf694da2005-12-05 19:42:22 +010013638 /* Unmute Stereo Mixer 15 */
13639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013642 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013643
13644 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13645 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13646 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13647 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13648 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13649 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13650 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13651 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013652 /* hp used DAC 3 (Front) */
13653 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013654 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13655 { }
13656};
Takashi Iwai22309c32006-08-09 16:57:28 +020013657
13658static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13659 /*
13660 * Unmute ADC0 and set the default input to mic-in
13661 */
13662 /* port-A for surround (rear panel) */
13663 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13664 /* port-B for mic-in (rear panel) with vref */
13665 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13666 /* port-C for line-in (rear panel) */
13667 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13668 /* port-D for Front */
13669 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13670 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13671 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013672 /* this has to be set to VREF80 */
13673 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013674 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013675 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013676 /* port-F for mic-in (front panel) with vref */
13677 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13678 /* port-G for CLFE (rear panel) */
13679 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13680 /* port-H for side (rear panel) */
13681 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13682 /* CD-in */
13683 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13684 /* route front mic to ADC1*/
13685 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13686 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13687 /* Unmute DAC0~3 & spdif out*/
13688 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13689 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13690 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13691 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13692 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013693
Takashi Iwai22309c32006-08-09 16:57:28 +020013694 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13695 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13696 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13697 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13698 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013699
Takashi Iwai22309c32006-08-09 16:57:28 +020013700 /* Unmute Stereo Mixer 15 */
13701 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13702 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13703 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013704 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013705
13706 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13707 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13708 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13709 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13710 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13711 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13712 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13713 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013714 /* hp used DAC 3 (Front) */
13715 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013716 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13717 { }
13718};
13719
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013720static struct hda_verb alc861_asus_init_verbs[] = {
13721 /*
13722 * Unmute ADC0 and set the default input to mic-in
13723 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013724 /* port-A for surround (rear panel)
13725 * according to codec#0 this is the HP jack
13726 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013727 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13728 /* route front PCM to HP */
13729 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13730 /* port-B for mic-in (rear panel) with vref */
13731 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13732 /* port-C for line-in (rear panel) */
13733 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13734 /* port-D for Front */
13735 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13736 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13737 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013738 /* this has to be set to VREF80 */
13739 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013740 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013741 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013742 /* port-F for mic-in (front panel) with vref */
13743 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13744 /* port-G for CLFE (rear panel) */
13745 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13746 /* port-H for side (rear panel) */
13747 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13748 /* CD-in */
13749 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13750 /* route front mic to ADC1*/
13751 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13752 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13753 /* Unmute DAC0~3 & spdif out*/
13754 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13755 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13756 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13757 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13759 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13760 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13761 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13762 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13763 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013764
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013765 /* Unmute Stereo Mixer 15 */
13766 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013770
13771 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13772 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13773 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13774 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13776 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13778 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013779 /* hp used DAC 3 (Front) */
13780 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013781 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13782 { }
13783};
13784
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013785/* additional init verbs for ASUS laptops */
13786static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13787 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13788 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13789 { }
13790};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013791
Kailang Yangdf694da2005-12-05 19:42:22 +010013792/*
13793 * generic initialization of ADC, input mixers and output mixers
13794 */
13795static struct hda_verb alc861_auto_init_verbs[] = {
13796 /*
13797 * Unmute ADC0 and set the default input to mic-in
13798 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013799 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013800 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013801
Kailang Yangdf694da2005-12-05 19:42:22 +010013802 /* Unmute DAC0~3 & spdif out*/
13803 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13804 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13805 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13806 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13807 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013808
Kailang Yangdf694da2005-12-05 19:42:22 +010013809 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13810 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13811 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13812 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13813 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013814
Kailang Yangdf694da2005-12-05 19:42:22 +010013815 /* Unmute Stereo Mixer 15 */
13816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13818 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13819 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13820
13821 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13822 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13823 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13824 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13825 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13826 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13827 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13828 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13829
13830 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13831 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013832 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13833 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013834 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13835 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013836 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13837 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013838
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013839 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013840
13841 { }
13842};
13843
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013844static struct hda_verb alc861_toshiba_init_verbs[] = {
13845 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013846
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013847 { }
13848};
13849
13850/* toggle speaker-output according to the hp-jack state */
13851static void alc861_toshiba_automute(struct hda_codec *codec)
13852{
13853 unsigned int present;
13854
13855 present = snd_hda_codec_read(codec, 0x0f, 0,
13856 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013857 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13858 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13859 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13860 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013861}
13862
13863static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13864 unsigned int res)
13865{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013866 if ((res >> 26) == ALC880_HP_EVENT)
13867 alc861_toshiba_automute(codec);
13868}
13869
Kailang Yangdf694da2005-12-05 19:42:22 +010013870/* pcm configuration: identiacal with ALC880 */
13871#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13872#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13873#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13874#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13875
13876
13877#define ALC861_DIGOUT_NID 0x07
13878
13879static struct hda_channel_mode alc861_8ch_modes[1] = {
13880 { 8, NULL }
13881};
13882
13883static hda_nid_t alc861_dac_nids[4] = {
13884 /* front, surround, clfe, side */
13885 0x03, 0x06, 0x05, 0x04
13886};
13887
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013888static hda_nid_t alc660_dac_nids[3] = {
13889 /* front, clfe, surround */
13890 0x03, 0x05, 0x06
13891};
13892
Kailang Yangdf694da2005-12-05 19:42:22 +010013893static hda_nid_t alc861_adc_nids[1] = {
13894 /* ADC0-2 */
13895 0x08,
13896};
13897
13898static struct hda_input_mux alc861_capture_source = {
13899 .num_items = 5,
13900 .items = {
13901 { "Mic", 0x0 },
13902 { "Front Mic", 0x3 },
13903 { "Line", 0x1 },
13904 { "CD", 0x4 },
13905 { "Mixer", 0x5 },
13906 },
13907};
13908
13909/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013910static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13911 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013912{
13913 int i;
13914 hda_nid_t nid;
13915
13916 spec->multiout.dac_nids = spec->private_dac_nids;
13917 for (i = 0; i < cfg->line_outs; i++) {
13918 nid = cfg->line_out_pins[i];
13919 if (nid) {
13920 if (i >= ARRAY_SIZE(alc861_dac_nids))
13921 continue;
13922 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13923 }
13924 }
13925 spec->multiout.num_dacs = cfg->line_outs;
13926 return 0;
13927}
13928
13929/* add playback controls from the parsed DAC table */
13930static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13931 const struct auto_pin_cfg *cfg)
13932{
13933 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013934 static const char *chname[4] = {
13935 "Front", "Surround", NULL /*CLFE*/, "Side"
13936 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013937 hda_nid_t nid;
13938 int i, idx, err;
13939
13940 for (i = 0; i < cfg->line_outs; i++) {
13941 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013942 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013943 continue;
13944 if (nid == 0x05) {
13945 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013946 err = add_control(spec, ALC_CTL_BIND_MUTE,
13947 "Center Playback Switch",
13948 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13949 HDA_OUTPUT));
13950 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013951 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013952 err = add_control(spec, ALC_CTL_BIND_MUTE,
13953 "LFE Playback Switch",
13954 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13955 HDA_OUTPUT));
13956 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013957 return err;
13958 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013959 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13960 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013961 if (nid == alc861_dac_nids[idx])
13962 break;
13963 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013964 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13965 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13966 HDA_OUTPUT));
13967 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013968 return err;
13969 }
13970 }
13971 return 0;
13972}
13973
13974static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13975{
13976 int err;
13977 hda_nid_t nid;
13978
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013979 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013980 return 0;
13981
13982 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13983 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013984 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13985 "Headphone Playback Switch",
13986 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13987 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013988 return err;
13989 spec->multiout.hp_nid = nid;
13990 }
13991 return 0;
13992}
13993
13994/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013995static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13996 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013997{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013998 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013999 int i, err, idx, idx1;
14000
14001 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014002 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014003 case 0x0c:
14004 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014005 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014006 break;
14007 case 0x0f:
14008 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014009 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014010 break;
14011 case 0x0d:
14012 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014013 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014014 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014015 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014016 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014017 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014018 break;
14019 case 0x11:
14020 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014021 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014022 break;
14023 default:
14024 continue;
14025 }
14026
Takashi Iwai4a471b72005-12-07 13:56:29 +010014027 err = new_analog_input(spec, cfg->input_pins[i],
14028 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014029 if (err < 0)
14030 return err;
14031
Takashi Iwai4a471b72005-12-07 13:56:29 +010014032 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014033 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014034 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014035 }
14036 return 0;
14037}
14038
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014039static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14040 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010014041 int pin_type, int dac_idx)
14042{
Jacek Luczak564c5be2008-05-03 18:41:23 +020014043 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14044 pin_type);
14045 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14046 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010014047}
14048
14049static void alc861_auto_init_multi_out(struct hda_codec *codec)
14050{
14051 struct alc_spec *spec = codec->spec;
14052 int i;
14053
14054 for (i = 0; i < spec->autocfg.line_outs; i++) {
14055 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014056 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014057 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014058 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014059 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014060 }
14061}
14062
14063static void alc861_auto_init_hp_out(struct hda_codec *codec)
14064{
14065 struct alc_spec *spec = codec->spec;
14066 hda_nid_t pin;
14067
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014068 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014069 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014070 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14071 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014072 pin = spec->autocfg.speaker_pins[0];
14073 if (pin)
14074 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014075}
14076
14077static void alc861_auto_init_analog_input(struct hda_codec *codec)
14078{
14079 struct alc_spec *spec = codec->spec;
14080 int i;
14081
14082 for (i = 0; i < AUTO_PIN_LAST; i++) {
14083 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014084 if (nid >= 0x0c && nid <= 0x11)
14085 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014086 }
14087}
14088
14089/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014090/* return 1 if successful, 0 if the proper config is not found,
14091 * or a negative error code
14092 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014093static int alc861_parse_auto_config(struct hda_codec *codec)
14094{
14095 struct alc_spec *spec = codec->spec;
14096 int err;
14097 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14098
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014099 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14100 alc861_ignore);
14101 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014102 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014103 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014104 return 0; /* can't find valid BIOS pin config */
14105
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014106 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14107 if (err < 0)
14108 return err;
14109 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14110 if (err < 0)
14111 return err;
14112 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14113 if (err < 0)
14114 return err;
14115 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14116 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014117 return err;
14118
14119 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14120
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014121 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014122 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14123
Takashi Iwai603c4012008-07-30 15:01:44 +020014124 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014125 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014126
Takashi Iwaid88897e2008-10-31 15:01:37 +010014127 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014128
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014129 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014130 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014131
14132 spec->adc_nids = alc861_adc_nids;
14133 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014134 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014135
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014136 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14137
Kailang Yangdf694da2005-12-05 19:42:22 +010014138 return 1;
14139}
14140
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014141/* additional initialization for auto-configuration model */
14142static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014143{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014144 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014145 alc861_auto_init_multi_out(codec);
14146 alc861_auto_init_hp_out(codec);
14147 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014148 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014149 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014150}
14151
Takashi Iwaicb53c622007-08-10 17:21:45 +020014152#ifdef CONFIG_SND_HDA_POWER_SAVE
14153static struct hda_amp_list alc861_loopbacks[] = {
14154 { 0x15, HDA_INPUT, 0 },
14155 { 0x15, HDA_INPUT, 1 },
14156 { 0x15, HDA_INPUT, 2 },
14157 { 0x15, HDA_INPUT, 3 },
14158 { } /* end */
14159};
14160#endif
14161
Kailang Yangdf694da2005-12-05 19:42:22 +010014162
14163/*
14164 * configuration and preset
14165 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014166static const char *alc861_models[ALC861_MODEL_LAST] = {
14167 [ALC861_3ST] = "3stack",
14168 [ALC660_3ST] = "3stack-660",
14169 [ALC861_3ST_DIG] = "3stack-dig",
14170 [ALC861_6ST_DIG] = "6stack-dig",
14171 [ALC861_UNIWILL_M31] = "uniwill-m31",
14172 [ALC861_TOSHIBA] = "toshiba",
14173 [ALC861_ASUS] = "asus",
14174 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14175 [ALC861_AUTO] = "auto",
14176};
14177
14178static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014179 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014180 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14181 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14182 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014183 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014184 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014185 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014186 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14187 * Any other models that need this preset?
14188 */
14189 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014190 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14191 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014192 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14193 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14194 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14195 /* FIXME: the below seems conflict */
14196 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14197 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14198 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014199 {}
14200};
14201
14202static struct alc_config_preset alc861_presets[] = {
14203 [ALC861_3ST] = {
14204 .mixers = { alc861_3ST_mixer },
14205 .init_verbs = { alc861_threestack_init_verbs },
14206 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14207 .dac_nids = alc861_dac_nids,
14208 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14209 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014210 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014211 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14212 .adc_nids = alc861_adc_nids,
14213 .input_mux = &alc861_capture_source,
14214 },
14215 [ALC861_3ST_DIG] = {
14216 .mixers = { alc861_base_mixer },
14217 .init_verbs = { alc861_threestack_init_verbs },
14218 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14219 .dac_nids = alc861_dac_nids,
14220 .dig_out_nid = ALC861_DIGOUT_NID,
14221 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14222 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014223 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014224 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14225 .adc_nids = alc861_adc_nids,
14226 .input_mux = &alc861_capture_source,
14227 },
14228 [ALC861_6ST_DIG] = {
14229 .mixers = { alc861_base_mixer },
14230 .init_verbs = { alc861_base_init_verbs },
14231 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14232 .dac_nids = alc861_dac_nids,
14233 .dig_out_nid = ALC861_DIGOUT_NID,
14234 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14235 .channel_mode = alc861_8ch_modes,
14236 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14237 .adc_nids = alc861_adc_nids,
14238 .input_mux = &alc861_capture_source,
14239 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014240 [ALC660_3ST] = {
14241 .mixers = { alc861_3ST_mixer },
14242 .init_verbs = { alc861_threestack_init_verbs },
14243 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14244 .dac_nids = alc660_dac_nids,
14245 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14246 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014247 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014248 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14249 .adc_nids = alc861_adc_nids,
14250 .input_mux = &alc861_capture_source,
14251 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014252 [ALC861_UNIWILL_M31] = {
14253 .mixers = { alc861_uniwill_m31_mixer },
14254 .init_verbs = { alc861_uniwill_m31_init_verbs },
14255 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14256 .dac_nids = alc861_dac_nids,
14257 .dig_out_nid = ALC861_DIGOUT_NID,
14258 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14259 .channel_mode = alc861_uniwill_m31_modes,
14260 .need_dac_fix = 1,
14261 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14262 .adc_nids = alc861_adc_nids,
14263 .input_mux = &alc861_capture_source,
14264 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014265 [ALC861_TOSHIBA] = {
14266 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014267 .init_verbs = { alc861_base_init_verbs,
14268 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014269 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14270 .dac_nids = alc861_dac_nids,
14271 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14272 .channel_mode = alc883_3ST_2ch_modes,
14273 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14274 .adc_nids = alc861_adc_nids,
14275 .input_mux = &alc861_capture_source,
14276 .unsol_event = alc861_toshiba_unsol_event,
14277 .init_hook = alc861_toshiba_automute,
14278 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014279 [ALC861_ASUS] = {
14280 .mixers = { alc861_asus_mixer },
14281 .init_verbs = { alc861_asus_init_verbs },
14282 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14283 .dac_nids = alc861_dac_nids,
14284 .dig_out_nid = ALC861_DIGOUT_NID,
14285 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14286 .channel_mode = alc861_asus_modes,
14287 .need_dac_fix = 1,
14288 .hp_nid = 0x06,
14289 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14290 .adc_nids = alc861_adc_nids,
14291 .input_mux = &alc861_capture_source,
14292 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014293 [ALC861_ASUS_LAPTOP] = {
14294 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14295 .init_verbs = { alc861_asus_init_verbs,
14296 alc861_asus_laptop_init_verbs },
14297 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14298 .dac_nids = alc861_dac_nids,
14299 .dig_out_nid = ALC861_DIGOUT_NID,
14300 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14301 .channel_mode = alc883_3ST_2ch_modes,
14302 .need_dac_fix = 1,
14303 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14304 .adc_nids = alc861_adc_nids,
14305 .input_mux = &alc861_capture_source,
14306 },
14307};
Kailang Yangdf694da2005-12-05 19:42:22 +010014308
14309
14310static int patch_alc861(struct hda_codec *codec)
14311{
14312 struct alc_spec *spec;
14313 int board_config;
14314 int err;
14315
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014316 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014317 if (spec == NULL)
14318 return -ENOMEM;
14319
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014320 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014321
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014322 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14323 alc861_models,
14324 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014325
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014326 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014327 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14328 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014329 board_config = ALC861_AUTO;
14330 }
14331
14332 if (board_config == ALC861_AUTO) {
14333 /* automatic parse from the BIOS config */
14334 err = alc861_parse_auto_config(codec);
14335 if (err < 0) {
14336 alc_free(codec);
14337 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014338 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014339 printk(KERN_INFO
14340 "hda_codec: Cannot set up configuration "
14341 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014342 board_config = ALC861_3ST_DIG;
14343 }
14344 }
14345
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014346 err = snd_hda_attach_beep_device(codec, 0x23);
14347 if (err < 0) {
14348 alc_free(codec);
14349 return err;
14350 }
14351
Kailang Yangdf694da2005-12-05 19:42:22 +010014352 if (board_config != ALC861_AUTO)
14353 setup_preset(spec, &alc861_presets[board_config]);
14354
14355 spec->stream_name_analog = "ALC861 Analog";
14356 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14357 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14358
14359 spec->stream_name_digital = "ALC861 Digital";
14360 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14361 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14362
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014363 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14364
Takashi Iwai2134ea42008-01-10 16:53:55 +010014365 spec->vmaster_nid = 0x03;
14366
Kailang Yangdf694da2005-12-05 19:42:22 +010014367 codec->patch_ops = alc_patch_ops;
14368 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014369 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014370#ifdef CONFIG_SND_HDA_POWER_SAVE
14371 if (!spec->loopback.amplist)
14372 spec->loopback.amplist = alc861_loopbacks;
14373#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014374 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014375
Kailang Yangdf694da2005-12-05 19:42:22 +010014376 return 0;
14377}
14378
14379/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014380 * ALC861-VD support
14381 *
14382 * Based on ALC882
14383 *
14384 * In addition, an independent DAC
14385 */
14386#define ALC861VD_DIGOUT_NID 0x06
14387
14388static hda_nid_t alc861vd_dac_nids[4] = {
14389 /* front, surr, clfe, side surr */
14390 0x02, 0x03, 0x04, 0x05
14391};
14392
14393/* dac_nids for ALC660vd are in a different order - according to
14394 * Realtek's driver.
14395 * This should probably tesult in a different mixer for 6stack models
14396 * of ALC660vd codecs, but for now there is only 3stack mixer
14397 * - and it is the same as in 861vd.
14398 * adc_nids in ALC660vd are (is) the same as in 861vd
14399 */
14400static hda_nid_t alc660vd_dac_nids[3] = {
14401 /* front, rear, clfe, rear_surr */
14402 0x02, 0x04, 0x03
14403};
14404
14405static hda_nid_t alc861vd_adc_nids[1] = {
14406 /* ADC0 */
14407 0x09,
14408};
14409
Takashi Iwaie1406342008-02-11 18:32:32 +010014410static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14411
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014412/* input MUX */
14413/* FIXME: should be a matrix-type input source selection */
14414static struct hda_input_mux alc861vd_capture_source = {
14415 .num_items = 4,
14416 .items = {
14417 { "Mic", 0x0 },
14418 { "Front Mic", 0x1 },
14419 { "Line", 0x2 },
14420 { "CD", 0x4 },
14421 },
14422};
14423
Kailang Yang272a5272007-05-14 11:00:38 +020014424static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014425 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014426 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014427 { "Ext Mic", 0x0 },
14428 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014429 },
14430};
14431
Kailang Yangd1a991a2007-08-15 16:21:59 +020014432static struct hda_input_mux alc861vd_hp_capture_source = {
14433 .num_items = 2,
14434 .items = {
14435 { "Front Mic", 0x0 },
14436 { "ATAPI Mic", 0x1 },
14437 },
14438};
14439
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014440/*
14441 * 2ch mode
14442 */
14443static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14444 { 2, NULL }
14445};
14446
14447/*
14448 * 6ch mode
14449 */
14450static struct hda_verb alc861vd_6stack_ch6_init[] = {
14451 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14452 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14453 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14454 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14455 { } /* end */
14456};
14457
14458/*
14459 * 8ch mode
14460 */
14461static struct hda_verb alc861vd_6stack_ch8_init[] = {
14462 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14463 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14464 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14465 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14466 { } /* end */
14467};
14468
14469static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14470 { 6, alc861vd_6stack_ch6_init },
14471 { 8, alc861vd_6stack_ch8_init },
14472};
14473
14474static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14475 {
14476 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14477 .name = "Channel Mode",
14478 .info = alc_ch_mode_info,
14479 .get = alc_ch_mode_get,
14480 .put = alc_ch_mode_put,
14481 },
14482 { } /* end */
14483};
14484
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014485/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14486 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14487 */
14488static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14489 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14490 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14491
14492 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14493 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14494
14495 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14496 HDA_OUTPUT),
14497 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14498 HDA_OUTPUT),
14499 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14500 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14501
14502 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14503 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14504
14505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14506
14507 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14509 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14510
14511 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14512 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14513 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14514
14515 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14516 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14517
14518 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14519 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14520
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014521 { } /* end */
14522};
14523
14524static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14525 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14526 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14527
14528 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14529
14530 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14532 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14533
14534 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14535 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14536 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14537
14538 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14539 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14540
14541 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14542 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14543
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014544 { } /* end */
14545};
14546
Kailang Yangbdd148a2007-05-08 15:19:08 +020014547static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14548 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14549 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14550 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14551
14552 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14553
14554 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14555 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14556 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14557
14558 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14559 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14560 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14561
14562 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14563 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14564
14565 { } /* end */
14566};
14567
Tobin Davisb419f342008-03-07 11:57:51 +010014568/* Pin assignment: Speaker=0x14, HP = 0x15,
14569 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014570 */
14571static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014572 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14573 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014574 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14575 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014576 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14577 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14578 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14579 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14580 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14581 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014582 { } /* end */
14583};
14584
Kailang Yangd1a991a2007-08-15 16:21:59 +020014585/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14586 * Front Mic=0x18, ATAPI Mic = 0x19,
14587 */
14588static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14589 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14590 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14591 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14592 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14593 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14594 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14595 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14596 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014597
Kailang Yangd1a991a2007-08-15 16:21:59 +020014598 { } /* end */
14599};
14600
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014601/*
14602 * generic initialization of ADC, input mixers and output mixers
14603 */
14604static struct hda_verb alc861vd_volume_init_verbs[] = {
14605 /*
14606 * Unmute ADC0 and set the default input to mic-in
14607 */
14608 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14609 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14610
14611 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14612 * the analog-loopback mixer widget
14613 */
14614 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14618 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14619 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014620
14621 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014625 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014626
14627 /*
14628 * Set up output mixers (0x02 - 0x05)
14629 */
14630 /* set vol=0 to output mixers */
14631 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14632 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14633 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14634 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14635
14636 /* set up input amps for analog loopback */
14637 /* Amp Indices: DAC = 0, mixer = 1 */
14638 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14639 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14640 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14641 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14642 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14643 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14644 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14645 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14646
14647 { }
14648};
14649
14650/*
14651 * 3-stack pin configuration:
14652 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14653 */
14654static struct hda_verb alc861vd_3stack_init_verbs[] = {
14655 /*
14656 * Set pin mode and muting
14657 */
14658 /* set front pin widgets 0x14 for output */
14659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14661 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14662
14663 /* Mic (rear) pin: input vref at 80% */
14664 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14665 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14666 /* Front Mic pin: input vref at 80% */
14667 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14668 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14669 /* Line In pin: input */
14670 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14671 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14672 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14673 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14674 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14675 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14676 /* CD pin widget for input */
14677 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14678
14679 { }
14680};
14681
14682/*
14683 * 6-stack pin configuration:
14684 */
14685static struct hda_verb alc861vd_6stack_init_verbs[] = {
14686 /*
14687 * Set pin mode and muting
14688 */
14689 /* set front pin widgets 0x14 for output */
14690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14692 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14693
14694 /* Rear Pin: output 1 (0x0d) */
14695 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14696 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14697 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14698 /* CLFE Pin: output 2 (0x0e) */
14699 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14700 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14701 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14702 /* Side Pin: output 3 (0x0f) */
14703 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14704 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14705 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14706
14707 /* Mic (rear) pin: input vref at 80% */
14708 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14709 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14710 /* Front Mic pin: input vref at 80% */
14711 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14712 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14713 /* Line In pin: input */
14714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14715 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14716 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14717 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14718 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14719 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14720 /* CD pin widget for input */
14721 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14722
14723 { }
14724};
14725
Kailang Yangbdd148a2007-05-08 15:19:08 +020014726static struct hda_verb alc861vd_eapd_verbs[] = {
14727 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14728 { }
14729};
14730
Kailang Yangf9423e72008-05-27 12:32:25 +020014731static struct hda_verb alc660vd_eapd_verbs[] = {
14732 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14733 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14734 { }
14735};
14736
Kailang Yangbdd148a2007-05-08 15:19:08 +020014737static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14741 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014742 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014743 {}
14744};
14745
14746/* toggle speaker-output according to the hp-jack state */
14747static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14748{
14749 unsigned int present;
14750 unsigned char bits;
14751
14752 present = snd_hda_codec_read(codec, 0x1b, 0,
14753 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014754 bits = present ? HDA_AMP_MUTE : 0;
14755 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14756 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014757}
14758
14759static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14760{
14761 unsigned int present;
14762 unsigned char bits;
14763
14764 present = snd_hda_codec_read(codec, 0x18, 0,
14765 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014766 bits = present ? HDA_AMP_MUTE : 0;
14767 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14768 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014769}
14770
14771static void alc861vd_lenovo_automute(struct hda_codec *codec)
14772{
14773 alc861vd_lenovo_hp_automute(codec);
14774 alc861vd_lenovo_mic_automute(codec);
14775}
14776
14777static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14778 unsigned int res)
14779{
14780 switch (res >> 26) {
14781 case ALC880_HP_EVENT:
14782 alc861vd_lenovo_hp_automute(codec);
14783 break;
14784 case ALC880_MIC_EVENT:
14785 alc861vd_lenovo_mic_automute(codec);
14786 break;
14787 }
14788}
14789
Kailang Yang272a5272007-05-14 11:00:38 +020014790static struct hda_verb alc861vd_dallas_verbs[] = {
14791 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14792 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14793 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14794 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14795
14796 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14797 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14798 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14799 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14800 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14801 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14802 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14803 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014804
Kailang Yang272a5272007-05-14 11:00:38 +020014805 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14806 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14809 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14810 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14811 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14812 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14813
14814 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14815 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14816 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14817 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14818 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14819 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14820 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14821 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14822
14823 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14824 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14825 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14826 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14827
14828 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014829 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014830 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14831
14832 { } /* end */
14833};
14834
14835/* toggle speaker-output according to the hp-jack state */
14836static void alc861vd_dallas_automute(struct hda_codec *codec)
14837{
14838 unsigned int present;
14839
14840 present = snd_hda_codec_read(codec, 0x15, 0,
14841 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014842 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14843 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014844}
14845
14846static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14847{
14848 if ((res >> 26) == ALC880_HP_EVENT)
14849 alc861vd_dallas_automute(codec);
14850}
14851
Takashi Iwaicb53c622007-08-10 17:21:45 +020014852#ifdef CONFIG_SND_HDA_POWER_SAVE
14853#define alc861vd_loopbacks alc880_loopbacks
14854#endif
14855
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014856/* pcm configuration: identiacal with ALC880 */
14857#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14858#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14859#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14860#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14861
14862/*
14863 * configuration and preset
14864 */
14865static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14866 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014867 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014868 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014869 [ALC861VD_3ST] = "3stack",
14870 [ALC861VD_3ST_DIG] = "3stack-digout",
14871 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014872 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014873 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014874 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014875 [ALC861VD_AUTO] = "auto",
14876};
14877
14878static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014879 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14880 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014881 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014882 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014883 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014884 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014885 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014886 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014887 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014888 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014889 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014890 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014891 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014892 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014893 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014894 {}
14895};
14896
14897static struct alc_config_preset alc861vd_presets[] = {
14898 [ALC660VD_3ST] = {
14899 .mixers = { alc861vd_3st_mixer },
14900 .init_verbs = { alc861vd_volume_init_verbs,
14901 alc861vd_3stack_init_verbs },
14902 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14903 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014904 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14905 .channel_mode = alc861vd_3stack_2ch_modes,
14906 .input_mux = &alc861vd_capture_source,
14907 },
Mike Crash6963f842007-06-25 12:12:51 +020014908 [ALC660VD_3ST_DIG] = {
14909 .mixers = { alc861vd_3st_mixer },
14910 .init_verbs = { alc861vd_volume_init_verbs,
14911 alc861vd_3stack_init_verbs },
14912 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14913 .dac_nids = alc660vd_dac_nids,
14914 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014915 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14916 .channel_mode = alc861vd_3stack_2ch_modes,
14917 .input_mux = &alc861vd_capture_source,
14918 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014919 [ALC861VD_3ST] = {
14920 .mixers = { alc861vd_3st_mixer },
14921 .init_verbs = { alc861vd_volume_init_verbs,
14922 alc861vd_3stack_init_verbs },
14923 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14924 .dac_nids = alc861vd_dac_nids,
14925 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14926 .channel_mode = alc861vd_3stack_2ch_modes,
14927 .input_mux = &alc861vd_capture_source,
14928 },
14929 [ALC861VD_3ST_DIG] = {
14930 .mixers = { alc861vd_3st_mixer },
14931 .init_verbs = { alc861vd_volume_init_verbs,
14932 alc861vd_3stack_init_verbs },
14933 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14934 .dac_nids = alc861vd_dac_nids,
14935 .dig_out_nid = ALC861VD_DIGOUT_NID,
14936 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14937 .channel_mode = alc861vd_3stack_2ch_modes,
14938 .input_mux = &alc861vd_capture_source,
14939 },
14940 [ALC861VD_6ST_DIG] = {
14941 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14942 .init_verbs = { alc861vd_volume_init_verbs,
14943 alc861vd_6stack_init_verbs },
14944 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14945 .dac_nids = alc861vd_dac_nids,
14946 .dig_out_nid = ALC861VD_DIGOUT_NID,
14947 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14948 .channel_mode = alc861vd_6stack_modes,
14949 .input_mux = &alc861vd_capture_source,
14950 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014951 [ALC861VD_LENOVO] = {
14952 .mixers = { alc861vd_lenovo_mixer },
14953 .init_verbs = { alc861vd_volume_init_verbs,
14954 alc861vd_3stack_init_verbs,
14955 alc861vd_eapd_verbs,
14956 alc861vd_lenovo_unsol_verbs },
14957 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14958 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014959 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14960 .channel_mode = alc861vd_3stack_2ch_modes,
14961 .input_mux = &alc861vd_capture_source,
14962 .unsol_event = alc861vd_lenovo_unsol_event,
14963 .init_hook = alc861vd_lenovo_automute,
14964 },
Kailang Yang272a5272007-05-14 11:00:38 +020014965 [ALC861VD_DALLAS] = {
14966 .mixers = { alc861vd_dallas_mixer },
14967 .init_verbs = { alc861vd_dallas_verbs },
14968 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14969 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014970 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14971 .channel_mode = alc861vd_3stack_2ch_modes,
14972 .input_mux = &alc861vd_dallas_capture_source,
14973 .unsol_event = alc861vd_dallas_unsol_event,
14974 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014975 },
14976 [ALC861VD_HP] = {
14977 .mixers = { alc861vd_hp_mixer },
14978 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14979 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14980 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014981 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014982 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14983 .channel_mode = alc861vd_3stack_2ch_modes,
14984 .input_mux = &alc861vd_hp_capture_source,
14985 .unsol_event = alc861vd_dallas_unsol_event,
14986 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014987 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014988 [ALC660VD_ASUS_V1S] = {
14989 .mixers = { alc861vd_lenovo_mixer },
14990 .init_verbs = { alc861vd_volume_init_verbs,
14991 alc861vd_3stack_init_verbs,
14992 alc861vd_eapd_verbs,
14993 alc861vd_lenovo_unsol_verbs },
14994 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14995 .dac_nids = alc660vd_dac_nids,
14996 .dig_out_nid = ALC861VD_DIGOUT_NID,
14997 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14998 .channel_mode = alc861vd_3stack_2ch_modes,
14999 .input_mux = &alc861vd_capture_source,
15000 .unsol_event = alc861vd_lenovo_unsol_event,
15001 .init_hook = alc861vd_lenovo_automute,
15002 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015003};
15004
15005/*
15006 * BIOS auto configuration
15007 */
15008static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15009 hda_nid_t nid, int pin_type, int dac_idx)
15010{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015011 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015012}
15013
15014static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15015{
15016 struct alc_spec *spec = codec->spec;
15017 int i;
15018
15019 for (i = 0; i <= HDA_SIDE; i++) {
15020 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015021 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015022 if (nid)
15023 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015024 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015025 }
15026}
15027
15028
15029static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15030{
15031 struct alc_spec *spec = codec->spec;
15032 hda_nid_t pin;
15033
15034 pin = spec->autocfg.hp_pins[0];
15035 if (pin) /* connect to front and use dac 0 */
15036 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015037 pin = spec->autocfg.speaker_pins[0];
15038 if (pin)
15039 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015040}
15041
15042#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15043#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15044
15045static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15046{
15047 struct alc_spec *spec = codec->spec;
15048 int i;
15049
15050 for (i = 0; i < AUTO_PIN_LAST; i++) {
15051 hda_nid_t nid = spec->autocfg.input_pins[i];
15052 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015053 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015054 if (nid != ALC861VD_PIN_CD_NID &&
15055 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015056 snd_hda_codec_write(codec, nid, 0,
15057 AC_VERB_SET_AMP_GAIN_MUTE,
15058 AMP_OUT_MUTE);
15059 }
15060 }
15061}
15062
Takashi Iwaif511b012008-08-15 16:46:42 +020015063#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15064
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015065#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15066#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15067
15068/* add playback controls from the parsed DAC table */
15069/* Based on ALC880 version. But ALC861VD has separate,
15070 * different NIDs for mute/unmute switch and volume control */
15071static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15072 const struct auto_pin_cfg *cfg)
15073{
15074 char name[32];
15075 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15076 hda_nid_t nid_v, nid_s;
15077 int i, err;
15078
15079 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015080 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015081 continue;
15082 nid_v = alc861vd_idx_to_mixer_vol(
15083 alc880_dac_to_idx(
15084 spec->multiout.dac_nids[i]));
15085 nid_s = alc861vd_idx_to_mixer_switch(
15086 alc880_dac_to_idx(
15087 spec->multiout.dac_nids[i]));
15088
15089 if (i == 2) {
15090 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015091 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15092 "Center Playback Volume",
15093 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15094 HDA_OUTPUT));
15095 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015096 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015097 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15098 "LFE Playback Volume",
15099 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15100 HDA_OUTPUT));
15101 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015102 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015103 err = add_control(spec, ALC_CTL_BIND_MUTE,
15104 "Center Playback Switch",
15105 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15106 HDA_INPUT));
15107 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015108 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015109 err = add_control(spec, ALC_CTL_BIND_MUTE,
15110 "LFE Playback Switch",
15111 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15112 HDA_INPUT));
15113 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015114 return err;
15115 } else {
15116 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015117 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15118 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15119 HDA_OUTPUT));
15120 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015121 return err;
15122 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015123 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015124 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015125 HDA_INPUT));
15126 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015127 return err;
15128 }
15129 }
15130 return 0;
15131}
15132
15133/* add playback controls for speaker and HP outputs */
15134/* Based on ALC880 version. But ALC861VD has separate,
15135 * different NIDs for mute/unmute switch and volume control */
15136static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15137 hda_nid_t pin, const char *pfx)
15138{
15139 hda_nid_t nid_v, nid_s;
15140 int err;
15141 char name[32];
15142
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015143 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015144 return 0;
15145
15146 if (alc880_is_fixed_pin(pin)) {
15147 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15148 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015149 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015150 spec->multiout.hp_nid = nid_v;
15151 else
15152 spec->multiout.extra_out_nid[0] = nid_v;
15153 /* control HP volume/switch on the output mixer amp */
15154 nid_v = alc861vd_idx_to_mixer_vol(
15155 alc880_fixed_pin_idx(pin));
15156 nid_s = alc861vd_idx_to_mixer_switch(
15157 alc880_fixed_pin_idx(pin));
15158
15159 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015160 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15161 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15162 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015163 return err;
15164 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015165 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15166 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15167 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015168 return err;
15169 } else if (alc880_is_multi_pin(pin)) {
15170 /* set manual connection */
15171 /* we have only a switch on HP-out PIN */
15172 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015173 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15174 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15175 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015176 return err;
15177 }
15178 return 0;
15179}
15180
15181/* parse the BIOS configuration and set up the alc_spec
15182 * return 1 if successful, 0 if the proper config is not found,
15183 * or a negative error code
15184 * Based on ALC880 version - had to change it to override
15185 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15186static int alc861vd_parse_auto_config(struct hda_codec *codec)
15187{
15188 struct alc_spec *spec = codec->spec;
15189 int err;
15190 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15191
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015192 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15193 alc861vd_ignore);
15194 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015195 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015196 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015197 return 0; /* can't find valid BIOS pin config */
15198
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015199 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15200 if (err < 0)
15201 return err;
15202 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15203 if (err < 0)
15204 return err;
15205 err = alc861vd_auto_create_extra_out(spec,
15206 spec->autocfg.speaker_pins[0],
15207 "Speaker");
15208 if (err < 0)
15209 return err;
15210 err = alc861vd_auto_create_extra_out(spec,
15211 spec->autocfg.hp_pins[0],
15212 "Headphone");
15213 if (err < 0)
15214 return err;
15215 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15216 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015217 return err;
15218
15219 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15220
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015221 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015222 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15223
Takashi Iwai603c4012008-07-30 15:01:44 +020015224 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015225 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015226
Takashi Iwaid88897e2008-10-31 15:01:37 +010015227 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015228
15229 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015230 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015231
Takashi Iwai776e1842007-08-29 15:07:11 +020015232 err = alc_auto_add_mic_boost(codec);
15233 if (err < 0)
15234 return err;
15235
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015236 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15237
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015238 return 1;
15239}
15240
15241/* additional initialization for auto-configuration model */
15242static void alc861vd_auto_init(struct hda_codec *codec)
15243{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015244 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015245 alc861vd_auto_init_multi_out(codec);
15246 alc861vd_auto_init_hp_out(codec);
15247 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015248 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015249 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015250 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015251}
15252
15253static int patch_alc861vd(struct hda_codec *codec)
15254{
15255 struct alc_spec *spec;
15256 int err, board_config;
15257
15258 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15259 if (spec == NULL)
15260 return -ENOMEM;
15261
15262 codec->spec = spec;
15263
15264 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15265 alc861vd_models,
15266 alc861vd_cfg_tbl);
15267
15268 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15269 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
15270 "ALC861VD, trying auto-probe from BIOS...\n");
15271 board_config = ALC861VD_AUTO;
15272 }
15273
15274 if (board_config == ALC861VD_AUTO) {
15275 /* automatic parse from the BIOS config */
15276 err = alc861vd_parse_auto_config(codec);
15277 if (err < 0) {
15278 alc_free(codec);
15279 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015280 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015281 printk(KERN_INFO
15282 "hda_codec: Cannot set up configuration "
15283 "from BIOS. Using base mode...\n");
15284 board_config = ALC861VD_3ST;
15285 }
15286 }
15287
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015288 err = snd_hda_attach_beep_device(codec, 0x23);
15289 if (err < 0) {
15290 alc_free(codec);
15291 return err;
15292 }
15293
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015294 if (board_config != ALC861VD_AUTO)
15295 setup_preset(spec, &alc861vd_presets[board_config]);
15296
Kailang Yang2f893282008-05-27 12:14:47 +020015297 if (codec->vendor_id == 0x10ec0660) {
15298 spec->stream_name_analog = "ALC660-VD Analog";
15299 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020015300 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015301 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015302 } else {
15303 spec->stream_name_analog = "ALC861VD Analog";
15304 spec->stream_name_digital = "ALC861VD Digital";
15305 }
15306
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015307 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15308 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15309
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015310 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15311 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15312
15313 spec->adc_nids = alc861vd_adc_nids;
15314 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015315 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015316 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015317
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015318 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015319 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015320
Takashi Iwai2134ea42008-01-10 16:53:55 +010015321 spec->vmaster_nid = 0x02;
15322
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015323 codec->patch_ops = alc_patch_ops;
15324
15325 if (board_config == ALC861VD_AUTO)
15326 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015327#ifdef CONFIG_SND_HDA_POWER_SAVE
15328 if (!spec->loopback.amplist)
15329 spec->loopback.amplist = alc861vd_loopbacks;
15330#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015331 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015332
15333 return 0;
15334}
15335
15336/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015337 * ALC662 support
15338 *
15339 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15340 * configuration. Each pin widget can choose any input DACs and a mixer.
15341 * Each ADC is connected from a mixer of all inputs. This makes possible
15342 * 6-channel independent captures.
15343 *
15344 * In addition, an independent DAC for the multi-playback (not used in this
15345 * driver yet).
15346 */
15347#define ALC662_DIGOUT_NID 0x06
15348#define ALC662_DIGIN_NID 0x0a
15349
15350static hda_nid_t alc662_dac_nids[4] = {
15351 /* front, rear, clfe, rear_surr */
15352 0x02, 0x03, 0x04
15353};
15354
Kailang Yang622e84c2009-04-21 07:39:04 +020015355static hda_nid_t alc272_dac_nids[2] = {
15356 0x02, 0x03
15357};
15358
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015359static hda_nid_t alc662_adc_nids[1] = {
15360 /* ADC1-2 */
15361 0x09,
15362};
Takashi Iwaie1406342008-02-11 18:32:32 +010015363
Kailang Yang622e84c2009-04-21 07:39:04 +020015364static hda_nid_t alc272_adc_nids[1] = {
15365 /* ADC1-2 */
15366 0x08,
15367};
15368
Kailang Yang77a261b2008-02-19 11:38:05 +010015369static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015370static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15371
Takashi Iwaie1406342008-02-11 18:32:32 +010015372
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015373/* input MUX */
15374/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015375static struct hda_input_mux alc662_capture_source = {
15376 .num_items = 4,
15377 .items = {
15378 { "Mic", 0x0 },
15379 { "Front Mic", 0x1 },
15380 { "Line", 0x2 },
15381 { "CD", 0x4 },
15382 },
15383};
15384
15385static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15386 .num_items = 2,
15387 .items = {
15388 { "Mic", 0x1 },
15389 { "Line", 0x2 },
15390 },
15391};
Kailang Yang291702f2007-10-16 14:28:03 +020015392
15393static struct hda_input_mux alc662_eeepc_capture_source = {
15394 .num_items = 2,
15395 .items = {
15396 { "i-Mic", 0x1 },
15397 { "e-Mic", 0x0 },
15398 },
15399};
15400
Kailang Yang6dda9f42008-05-27 12:05:31 +020015401static struct hda_input_mux alc663_capture_source = {
15402 .num_items = 3,
15403 .items = {
15404 { "Mic", 0x0 },
15405 { "Front Mic", 0x1 },
15406 { "Line", 0x2 },
15407 },
15408};
15409
15410static struct hda_input_mux alc663_m51va_capture_source = {
15411 .num_items = 2,
15412 .items = {
15413 { "Ext-Mic", 0x0 },
15414 { "D-Mic", 0x9 },
15415 },
15416};
15417
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015418/*
15419 * 2ch mode
15420 */
15421static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15422 { 2, NULL }
15423};
15424
15425/*
15426 * 2ch mode
15427 */
15428static struct hda_verb alc662_3ST_ch2_init[] = {
15429 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15430 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15431 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15432 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15433 { } /* end */
15434};
15435
15436/*
15437 * 6ch mode
15438 */
15439static struct hda_verb alc662_3ST_ch6_init[] = {
15440 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15441 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15442 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15443 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15444 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15445 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15446 { } /* end */
15447};
15448
15449static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15450 { 2, alc662_3ST_ch2_init },
15451 { 6, alc662_3ST_ch6_init },
15452};
15453
15454/*
15455 * 2ch mode
15456 */
15457static struct hda_verb alc662_sixstack_ch6_init[] = {
15458 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15459 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15460 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15461 { } /* end */
15462};
15463
15464/*
15465 * 6ch mode
15466 */
15467static struct hda_verb alc662_sixstack_ch8_init[] = {
15468 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15469 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15470 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15471 { } /* end */
15472};
15473
15474static struct hda_channel_mode alc662_5stack_modes[2] = {
15475 { 2, alc662_sixstack_ch6_init },
15476 { 6, alc662_sixstack_ch8_init },
15477};
15478
15479/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15480 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15481 */
15482
15483static struct snd_kcontrol_new alc662_base_mixer[] = {
15484 /* output mixer control */
15485 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015486 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015487 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015488 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015489 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15490 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015491 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15492 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015493 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15494
15495 /*Input mixer control */
15496 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15497 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15498 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15499 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15500 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15501 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15502 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15503 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015504 { } /* end */
15505};
15506
15507static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15508 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015509 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015510 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15511 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15512 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15513 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15514 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15515 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15516 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15517 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15518 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015519 { } /* end */
15520};
15521
15522static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15523 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015524 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015525 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015526 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015527 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15528 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015529 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15530 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015531 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15532 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15533 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15534 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15535 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15536 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15537 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15538 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15539 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015540 { } /* end */
15541};
15542
15543static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15544 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15545 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015546 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15547 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015548 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15549 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15550 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015553 { } /* end */
15554};
15555
Kailang Yang291702f2007-10-16 14:28:03 +020015556static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015557 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15558 ALC262_HIPPO_MASTER_SWITCH,
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 Iwai42171c12009-05-08 14:11:43 +020015571 ALC262_HIPPO_MASTER_SWITCH,
15572 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015573 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015574 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15575 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015576 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15577 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15578 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15579 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15580 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15581 { } /* end */
15582};
15583
Kailang Yangf1d4e282008-08-26 14:03:29 +020015584static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15585 .ops = &snd_hda_bind_vol,
15586 .values = {
15587 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15588 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15589 0
15590 },
15591};
15592
15593static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15594 .ops = &snd_hda_bind_sw,
15595 .values = {
15596 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15597 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15598 0
15599 },
15600};
15601
Kailang Yang6dda9f42008-05-27 12:05:31 +020015602static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015603 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15604 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15605 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15606 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15607 { } /* end */
15608};
15609
15610static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15611 .ops = &snd_hda_bind_sw,
15612 .values = {
15613 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15614 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15615 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15616 0
15617 },
15618};
15619
15620static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15621 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15622 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15623 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15624 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15625 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15626 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15627
15628 { } /* end */
15629};
15630
15631static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15632 .ops = &snd_hda_bind_sw,
15633 .values = {
15634 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15635 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15636 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15637 0
15638 },
15639};
15640
15641static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15642 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15643 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15644 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15645 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15646 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15647 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15648 { } /* end */
15649};
15650
15651static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015652 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15653 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015654 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15655 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15656 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15657 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15658 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15659 { } /* end */
15660};
15661
15662static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15663 .ops = &snd_hda_bind_vol,
15664 .values = {
15665 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15666 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15667 0
15668 },
15669};
15670
15671static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15672 .ops = &snd_hda_bind_sw,
15673 .values = {
15674 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15675 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15676 0
15677 },
15678};
15679
15680static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15681 HDA_BIND_VOL("Master Playback Volume",
15682 &alc663_asus_two_bind_master_vol),
15683 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15684 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015685 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15686 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15687 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015688 { } /* end */
15689};
15690
15691static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15692 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15693 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15694 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15695 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15696 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15697 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015698 { } /* end */
15699};
15700
15701static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15702 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15703 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15704 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15705 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15707
15708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15709 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15710 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15711 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15712 { } /* end */
15713};
15714
15715static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15716 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15717 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15719
15720 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15721 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15722 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15723 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15724 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15725 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15726 { } /* end */
15727};
15728
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015729static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15730 {
15731 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15732 .name = "Channel Mode",
15733 .info = alc_ch_mode_info,
15734 .get = alc_ch_mode_get,
15735 .put = alc_ch_mode_put,
15736 },
15737 { } /* end */
15738};
15739
15740static struct hda_verb alc662_init_verbs[] = {
15741 /* ADC: mute amp left and right */
15742 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15743 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15744 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15745
Takashi Iwaicb53c622007-08-10 17:21:45 +020015746 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15747 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15748 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15749 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15750 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015751
Kailang Yangb60dd392007-09-20 12:50:29 +020015752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15755 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15757 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015758
15759 /* Front Pin: output 0 (0x0c) */
15760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15762
15763 /* Rear Pin: output 1 (0x0d) */
15764 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15766
15767 /* CLFE Pin: output 2 (0x0e) */
15768 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15769 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15770
15771 /* Mic (rear) pin: input vref at 80% */
15772 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15773 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15774 /* Front Mic pin: input vref at 80% */
15775 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15776 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15777 /* Line In pin: input */
15778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15780 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15781 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15782 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15783 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15784 /* CD pin widget for input */
15785 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15786
15787 /* FIXME: use matrix-type input source selection */
15788 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15789 /* Input mixer */
15790 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015791 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015792
15793 /* always trun on EAPD */
15794 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15795 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15796
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015797 { }
15798};
15799
15800static struct hda_verb alc662_sue_init_verbs[] = {
15801 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15802 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015803 {}
15804};
15805
15806static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15807 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15808 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15809 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015810};
15811
Kailang Yang8c427222008-01-10 13:03:59 +010015812/* Set Unsolicited Event*/
15813static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15814 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15815 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15816 {}
15817};
15818
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015819/*
15820 * generic initialization of ADC, input mixers and output mixers
15821 */
15822static struct hda_verb alc662_auto_init_verbs[] = {
15823 /*
15824 * Unmute ADC and set the default input to mic-in
15825 */
15826 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15827 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15828
15829 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15830 * mixer widget
15831 * Note: PASD motherboards uses the Line In 2 as the input for front
15832 * panel mic (mic 2)
15833 */
15834 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015840
15841 /*
15842 * Set up output mixers (0x0c - 0x0f)
15843 */
15844 /* set vol=0 to output mixers */
15845 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15846 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15847 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15848
15849 /* set up input amps for analog loopback */
15850 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15853 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15854 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15855 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15856 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015857
15858
15859 /* FIXME: use matrix-type input source selection */
15860 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15861 /* Input mixer */
15862 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015863 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015864 { }
15865};
15866
Takashi Iwai24fb9172008-09-02 14:48:20 +020015867/* additional verbs for ALC663 */
15868static struct hda_verb alc663_auto_init_verbs[] = {
15869 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15870 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15871 { }
15872};
15873
Kailang Yang6dda9f42008-05-27 12:05:31 +020015874static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015875 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15876 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015877 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15878 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015879 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15880 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015882 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15883 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15884 {}
15885};
15886
Kailang Yangf1d4e282008-08-26 14:03:29 +020015887static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15888 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15889 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15890 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15891 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15892 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15893 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15894 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15895 {}
15896};
15897
15898static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15899 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15900 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15901 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15902 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15905 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15906 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15907 {}
15908};
15909
15910static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15913 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15915 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15916 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15917 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15918 {}
15919};
15920
15921static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15922 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15923 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15924 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15925 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15926 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15927 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15928 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15929 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15930 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15931 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15932 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15933 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15934 {}
15935};
15936
15937static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15938 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15939 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15940 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15941 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15942 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15944 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15945 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15946 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15947 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15948 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15949 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15950 {}
15951};
15952
Kailang Yang6dda9f42008-05-27 12:05:31 +020015953static struct hda_verb alc663_g71v_init_verbs[] = {
15954 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15955 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15956 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15957
15958 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15959 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15960 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15961
15962 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15963 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15964 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15965 {}
15966};
15967
15968static struct hda_verb alc663_g50v_init_verbs[] = {
15969 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15970 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15971 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15972
15973 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15974 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15975 {}
15976};
15977
Kailang Yangf1d4e282008-08-26 14:03:29 +020015978static struct hda_verb alc662_ecs_init_verbs[] = {
15979 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15981 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15982 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15983 {}
15984};
15985
Kailang Yang622e84c2009-04-21 07:39:04 +020015986static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15987 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15988 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15991 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15992 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15993 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15994 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15995 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15996 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15997 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15998 {}
15999};
16000
16001static struct hda_verb alc272_dell_init_verbs[] = {
16002 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16003 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16005 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16006 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16007 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16008 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16009 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16010 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16011 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16012 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16013 {}
16014};
16015
Kailang Yangf1d4e282008-08-26 14:03:29 +020016016static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16017 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16018 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16019 { } /* end */
16020};
16021
Kailang Yang622e84c2009-04-21 07:39:04 +020016022static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16023 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16024 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16025 { } /* end */
16026};
16027
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016028static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16029{
16030 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016031 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016032
16033 present = snd_hda_codec_read(codec, 0x14, 0,
16034 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016035 bits = present ? HDA_AMP_MUTE : 0;
16036 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16037 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016038}
16039
16040static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16041{
16042 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016043 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016044
16045 present = snd_hda_codec_read(codec, 0x1b, 0,
16046 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016047 bits = present ? HDA_AMP_MUTE : 0;
16048 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16049 HDA_AMP_MUTE, bits);
16050 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16051 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016052}
16053
16054static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16055 unsigned int res)
16056{
16057 if ((res >> 26) == ALC880_HP_EVENT)
16058 alc662_lenovo_101e_all_automute(codec);
16059 if ((res >> 26) == ALC880_FRONT_EVENT)
16060 alc662_lenovo_101e_ispeaker_automute(codec);
16061}
16062
Kailang Yang291702f2007-10-16 14:28:03 +020016063static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16064{
16065 unsigned int present;
16066
16067 present = snd_hda_codec_read(codec, 0x18, 0,
16068 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16069 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16070 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16071 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16072 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16073 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16074 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16075 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16076 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16077}
16078
16079/* unsolicited event for HP jack sensing */
16080static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16081 unsigned int res)
16082{
Kailang Yang291702f2007-10-16 14:28:03 +020016083 if ((res >> 26) == ALC880_MIC_EVENT)
16084 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016085 else
16086 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016087}
16088
16089static void alc662_eeepc_inithook(struct hda_codec *codec)
16090{
Takashi Iwai42171c12009-05-08 14:11:43 +020016091 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016092 alc662_eeepc_mic_automute(codec);
16093}
16094
Kailang Yang8c427222008-01-10 13:03:59 +010016095static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16096{
Takashi Iwai42171c12009-05-08 14:11:43 +020016097 struct alc_spec *spec = codec->spec;
16098
16099 spec->autocfg.hp_pins[0] = 0x14;
16100 spec->autocfg.speaker_pins[0] = 0x1b;
16101 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016102}
16103
Kailang Yang6dda9f42008-05-27 12:05:31 +020016104static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16105{
16106 unsigned int present;
16107 unsigned char bits;
16108
16109 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016110 AC_VERB_GET_PIN_SENSE, 0)
16111 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016112 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016113 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16114 AMP_IN_MUTE(0), bits);
16115 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16116 AMP_IN_MUTE(0), bits);
16117}
16118
16119static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16120{
16121 unsigned int present;
16122 unsigned char bits;
16123
16124 present = snd_hda_codec_read(codec, 0x21, 0,
16125 AC_VERB_GET_PIN_SENSE, 0)
16126 & AC_PINSENSE_PRESENCE;
16127 bits = present ? HDA_AMP_MUTE : 0;
16128 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16129 AMP_IN_MUTE(0), bits);
16130 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16131 AMP_IN_MUTE(0), bits);
16132 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16133 AMP_IN_MUTE(0), bits);
16134 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16135 AMP_IN_MUTE(0), bits);
16136}
16137
16138static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16139{
16140 unsigned int present;
16141 unsigned char bits;
16142
16143 present = snd_hda_codec_read(codec, 0x15, 0,
16144 AC_VERB_GET_PIN_SENSE, 0)
16145 & AC_PINSENSE_PRESENCE;
16146 bits = present ? HDA_AMP_MUTE : 0;
16147 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16148 AMP_IN_MUTE(0), bits);
16149 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16150 AMP_IN_MUTE(0), bits);
16151 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16152 AMP_IN_MUTE(0), bits);
16153 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16154 AMP_IN_MUTE(0), bits);
16155}
16156
16157static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16158{
16159 unsigned int present;
16160 unsigned char bits;
16161
16162 present = snd_hda_codec_read(codec, 0x1b, 0,
16163 AC_VERB_GET_PIN_SENSE, 0)
16164 & AC_PINSENSE_PRESENCE;
16165 bits = present ? 0 : PIN_OUT;
16166 snd_hda_codec_write(codec, 0x14, 0,
16167 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16168}
16169
16170static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16171{
16172 unsigned int present1, present2;
16173
16174 present1 = snd_hda_codec_read(codec, 0x21, 0,
16175 AC_VERB_GET_PIN_SENSE, 0)
16176 & AC_PINSENSE_PRESENCE;
16177 present2 = snd_hda_codec_read(codec, 0x15, 0,
16178 AC_VERB_GET_PIN_SENSE, 0)
16179 & AC_PINSENSE_PRESENCE;
16180
16181 if (present1 || present2) {
16182 snd_hda_codec_write_cache(codec, 0x14, 0,
16183 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16184 } else {
16185 snd_hda_codec_write_cache(codec, 0x14, 0,
16186 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16187 }
16188}
16189
16190static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16191{
16192 unsigned int present1, present2;
16193
16194 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16195 AC_VERB_GET_PIN_SENSE, 0)
16196 & AC_PINSENSE_PRESENCE;
16197 present2 = snd_hda_codec_read(codec, 0x15, 0,
16198 AC_VERB_GET_PIN_SENSE, 0)
16199 & AC_PINSENSE_PRESENCE;
16200
16201 if (present1 || present2) {
16202 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16203 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16204 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16205 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16206 } else {
16207 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16208 AMP_IN_MUTE(0), 0);
16209 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16210 AMP_IN_MUTE(0), 0);
16211 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016212}
16213
16214static void alc663_m51va_mic_automute(struct hda_codec *codec)
16215{
16216 unsigned int present;
16217
16218 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016219 AC_VERB_GET_PIN_SENSE, 0)
16220 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016221 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016222 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016223 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016224 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016225 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016226 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016227 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016228 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016229}
16230
16231static void alc663_m51va_unsol_event(struct hda_codec *codec,
16232 unsigned int res)
16233{
16234 switch (res >> 26) {
16235 case ALC880_HP_EVENT:
16236 alc663_m51va_speaker_automute(codec);
16237 break;
16238 case ALC880_MIC_EVENT:
16239 alc663_m51va_mic_automute(codec);
16240 break;
16241 }
16242}
16243
16244static void alc663_m51va_inithook(struct hda_codec *codec)
16245{
16246 alc663_m51va_speaker_automute(codec);
16247 alc663_m51va_mic_automute(codec);
16248}
16249
Kailang Yangf1d4e282008-08-26 14:03:29 +020016250/* ***************** Mode1 ******************************/
16251static void alc663_mode1_unsol_event(struct hda_codec *codec,
16252 unsigned int res)
16253{
16254 switch (res >> 26) {
16255 case ALC880_HP_EVENT:
16256 alc663_m51va_speaker_automute(codec);
16257 break;
16258 case ALC880_MIC_EVENT:
16259 alc662_eeepc_mic_automute(codec);
16260 break;
16261 }
16262}
16263
16264static void alc663_mode1_inithook(struct hda_codec *codec)
16265{
16266 alc663_m51va_speaker_automute(codec);
16267 alc662_eeepc_mic_automute(codec);
16268}
16269/* ***************** Mode2 ******************************/
16270static void alc662_mode2_unsol_event(struct hda_codec *codec,
16271 unsigned int res)
16272{
16273 switch (res >> 26) {
16274 case ALC880_HP_EVENT:
16275 alc662_f5z_speaker_automute(codec);
16276 break;
16277 case ALC880_MIC_EVENT:
16278 alc662_eeepc_mic_automute(codec);
16279 break;
16280 }
16281}
16282
16283static void alc662_mode2_inithook(struct hda_codec *codec)
16284{
16285 alc662_f5z_speaker_automute(codec);
16286 alc662_eeepc_mic_automute(codec);
16287}
16288/* ***************** Mode3 ******************************/
16289static void alc663_mode3_unsol_event(struct hda_codec *codec,
16290 unsigned int res)
16291{
16292 switch (res >> 26) {
16293 case ALC880_HP_EVENT:
16294 alc663_two_hp_m1_speaker_automute(codec);
16295 break;
16296 case ALC880_MIC_EVENT:
16297 alc662_eeepc_mic_automute(codec);
16298 break;
16299 }
16300}
16301
16302static void alc663_mode3_inithook(struct hda_codec *codec)
16303{
16304 alc663_two_hp_m1_speaker_automute(codec);
16305 alc662_eeepc_mic_automute(codec);
16306}
16307/* ***************** Mode4 ******************************/
16308static void alc663_mode4_unsol_event(struct hda_codec *codec,
16309 unsigned int res)
16310{
16311 switch (res >> 26) {
16312 case ALC880_HP_EVENT:
16313 alc663_21jd_two_speaker_automute(codec);
16314 break;
16315 case ALC880_MIC_EVENT:
16316 alc662_eeepc_mic_automute(codec);
16317 break;
16318 }
16319}
16320
16321static void alc663_mode4_inithook(struct hda_codec *codec)
16322{
16323 alc663_21jd_two_speaker_automute(codec);
16324 alc662_eeepc_mic_automute(codec);
16325}
16326/* ***************** Mode5 ******************************/
16327static void alc663_mode5_unsol_event(struct hda_codec *codec,
16328 unsigned int res)
16329{
16330 switch (res >> 26) {
16331 case ALC880_HP_EVENT:
16332 alc663_15jd_two_speaker_automute(codec);
16333 break;
16334 case ALC880_MIC_EVENT:
16335 alc662_eeepc_mic_automute(codec);
16336 break;
16337 }
16338}
16339
16340static void alc663_mode5_inithook(struct hda_codec *codec)
16341{
16342 alc663_15jd_two_speaker_automute(codec);
16343 alc662_eeepc_mic_automute(codec);
16344}
16345/* ***************** Mode6 ******************************/
16346static void alc663_mode6_unsol_event(struct hda_codec *codec,
16347 unsigned int res)
16348{
16349 switch (res >> 26) {
16350 case ALC880_HP_EVENT:
16351 alc663_two_hp_m2_speaker_automute(codec);
16352 break;
16353 case ALC880_MIC_EVENT:
16354 alc662_eeepc_mic_automute(codec);
16355 break;
16356 }
16357}
16358
16359static void alc663_mode6_inithook(struct hda_codec *codec)
16360{
16361 alc663_two_hp_m2_speaker_automute(codec);
16362 alc662_eeepc_mic_automute(codec);
16363}
16364
Kailang Yang6dda9f42008-05-27 12:05:31 +020016365static void alc663_g71v_hp_automute(struct hda_codec *codec)
16366{
16367 unsigned int present;
16368 unsigned char bits;
16369
16370 present = snd_hda_codec_read(codec, 0x21, 0,
16371 AC_VERB_GET_PIN_SENSE, 0)
16372 & AC_PINSENSE_PRESENCE;
16373 bits = present ? HDA_AMP_MUTE : 0;
16374 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16375 HDA_AMP_MUTE, bits);
16376 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16377 HDA_AMP_MUTE, bits);
16378}
16379
16380static void alc663_g71v_front_automute(struct hda_codec *codec)
16381{
16382 unsigned int present;
16383 unsigned char bits;
16384
16385 present = snd_hda_codec_read(codec, 0x15, 0,
16386 AC_VERB_GET_PIN_SENSE, 0)
16387 & AC_PINSENSE_PRESENCE;
16388 bits = present ? HDA_AMP_MUTE : 0;
16389 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16390 HDA_AMP_MUTE, bits);
16391}
16392
16393static void alc663_g71v_unsol_event(struct hda_codec *codec,
16394 unsigned int res)
16395{
16396 switch (res >> 26) {
16397 case ALC880_HP_EVENT:
16398 alc663_g71v_hp_automute(codec);
16399 break;
16400 case ALC880_FRONT_EVENT:
16401 alc663_g71v_front_automute(codec);
16402 break;
16403 case ALC880_MIC_EVENT:
16404 alc662_eeepc_mic_automute(codec);
16405 break;
16406 }
16407}
16408
16409static void alc663_g71v_inithook(struct hda_codec *codec)
16410{
16411 alc663_g71v_front_automute(codec);
16412 alc663_g71v_hp_automute(codec);
16413 alc662_eeepc_mic_automute(codec);
16414}
16415
16416static void alc663_g50v_unsol_event(struct hda_codec *codec,
16417 unsigned int res)
16418{
16419 switch (res >> 26) {
16420 case ALC880_HP_EVENT:
16421 alc663_m51va_speaker_automute(codec);
16422 break;
16423 case ALC880_MIC_EVENT:
16424 alc662_eeepc_mic_automute(codec);
16425 break;
16426 }
16427}
16428
16429static void alc663_g50v_inithook(struct hda_codec *codec)
16430{
16431 alc663_m51va_speaker_automute(codec);
16432 alc662_eeepc_mic_automute(codec);
16433}
16434
Kailang Yangf1d4e282008-08-26 14:03:29 +020016435static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16436 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016437 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016438
16439 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16440 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16441 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16442
16443 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16444 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16445 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16446 { } /* end */
16447};
16448
Takashi Iwaicb53c622007-08-10 17:21:45 +020016449#ifdef CONFIG_SND_HDA_POWER_SAVE
16450#define alc662_loopbacks alc880_loopbacks
16451#endif
16452
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016453
16454/* pcm configuration: identiacal with ALC880 */
16455#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16456#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16457#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16458#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16459
16460/*
16461 * configuration and preset
16462 */
16463static const char *alc662_models[ALC662_MODEL_LAST] = {
16464 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16465 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16466 [ALC662_3ST_6ch] = "3stack-6ch",
16467 [ALC662_5ST_DIG] = "6stack-dig",
16468 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016469 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016470 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016471 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016472 [ALC663_ASUS_M51VA] = "m51va",
16473 [ALC663_ASUS_G71V] = "g71v",
16474 [ALC663_ASUS_H13] = "h13",
16475 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016476 [ALC663_ASUS_MODE1] = "asus-mode1",
16477 [ALC662_ASUS_MODE2] = "asus-mode2",
16478 [ALC663_ASUS_MODE3] = "asus-mode3",
16479 [ALC663_ASUS_MODE4] = "asus-mode4",
16480 [ALC663_ASUS_MODE5] = "asus-mode5",
16481 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016482 [ALC662_AUTO] = "auto",
16483};
16484
16485static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016486 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016487 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16488 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016489 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16490 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16491 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16492 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16493 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16494 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16495 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16496 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16497 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16498 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16499 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16500 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016501 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16502 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16503 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016504 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16505 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16506 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16507 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016508 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016509 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16510 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016511 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016512 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16513 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16514 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016515 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16516 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16517 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016518 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16519 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16520 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016521 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016522 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16523 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016524 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016525 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016526 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016527 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16528 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16529 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016530 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016531 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16532 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016533 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016534 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016535 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016536 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016537 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16538 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016539 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16540 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016541 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016542 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016543 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016544 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016545 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016546 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16547 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016548 {}
16549};
16550
16551static struct alc_config_preset alc662_presets[] = {
16552 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016553 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016554 .init_verbs = { alc662_init_verbs },
16555 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16556 .dac_nids = alc662_dac_nids,
16557 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016558 .dig_in_nid = ALC662_DIGIN_NID,
16559 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16560 .channel_mode = alc662_3ST_2ch_modes,
16561 .input_mux = &alc662_capture_source,
16562 },
16563 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016564 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016565 .init_verbs = { alc662_init_verbs },
16566 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16567 .dac_nids = alc662_dac_nids,
16568 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016569 .dig_in_nid = ALC662_DIGIN_NID,
16570 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16571 .channel_mode = alc662_3ST_6ch_modes,
16572 .need_dac_fix = 1,
16573 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016574 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016575 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016576 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016577 .init_verbs = { alc662_init_verbs },
16578 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16579 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016580 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16581 .channel_mode = alc662_3ST_6ch_modes,
16582 .need_dac_fix = 1,
16583 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016584 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016585 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016586 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016587 .init_verbs = { alc662_init_verbs },
16588 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16589 .dac_nids = alc662_dac_nids,
16590 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016591 .dig_in_nid = ALC662_DIGIN_NID,
16592 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16593 .channel_mode = alc662_5stack_modes,
16594 .input_mux = &alc662_capture_source,
16595 },
16596 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016597 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016598 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16599 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16600 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016601 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16602 .channel_mode = alc662_3ST_2ch_modes,
16603 .input_mux = &alc662_lenovo_101e_capture_source,
16604 .unsol_event = alc662_lenovo_101e_unsol_event,
16605 .init_hook = alc662_lenovo_101e_all_automute,
16606 },
Kailang Yang291702f2007-10-16 14:28:03 +020016607 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016608 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016609 .init_verbs = { alc662_init_verbs,
16610 alc662_eeepc_sue_init_verbs },
16611 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16612 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016613 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16614 .channel_mode = alc662_3ST_2ch_modes,
16615 .input_mux = &alc662_eeepc_capture_source,
16616 .unsol_event = alc662_eeepc_unsol_event,
16617 .init_hook = alc662_eeepc_inithook,
16618 },
Kailang Yang8c427222008-01-10 13:03:59 +010016619 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016620 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016621 alc662_chmode_mixer },
16622 .init_verbs = { alc662_init_verbs,
16623 alc662_eeepc_ep20_sue_init_verbs },
16624 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16625 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016626 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16627 .channel_mode = alc662_3ST_6ch_modes,
16628 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016629 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016630 .init_hook = alc662_eeepc_ep20_inithook,
16631 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016632 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016633 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016634 .init_verbs = { alc662_init_verbs,
16635 alc662_ecs_init_verbs },
16636 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16637 .dac_nids = alc662_dac_nids,
16638 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16639 .channel_mode = alc662_3ST_2ch_modes,
16640 .input_mux = &alc662_eeepc_capture_source,
16641 .unsol_event = alc662_eeepc_unsol_event,
16642 .init_hook = alc662_eeepc_inithook,
16643 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016644 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016645 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016646 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16647 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16648 .dac_nids = alc662_dac_nids,
16649 .dig_out_nid = ALC662_DIGOUT_NID,
16650 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16651 .channel_mode = alc662_3ST_2ch_modes,
16652 .input_mux = &alc663_m51va_capture_source,
16653 .unsol_event = alc663_m51va_unsol_event,
16654 .init_hook = alc663_m51va_inithook,
16655 },
16656 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016657 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016658 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16659 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16660 .dac_nids = alc662_dac_nids,
16661 .dig_out_nid = ALC662_DIGOUT_NID,
16662 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16663 .channel_mode = alc662_3ST_2ch_modes,
16664 .input_mux = &alc662_eeepc_capture_source,
16665 .unsol_event = alc663_g71v_unsol_event,
16666 .init_hook = alc663_g71v_inithook,
16667 },
16668 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016669 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016670 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16671 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16672 .dac_nids = alc662_dac_nids,
16673 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16674 .channel_mode = alc662_3ST_2ch_modes,
16675 .input_mux = &alc663_m51va_capture_source,
16676 .unsol_event = alc663_m51va_unsol_event,
16677 .init_hook = alc663_m51va_inithook,
16678 },
16679 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016680 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016681 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16682 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16683 .dac_nids = alc662_dac_nids,
16684 .dig_out_nid = ALC662_DIGOUT_NID,
16685 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16686 .channel_mode = alc662_3ST_6ch_modes,
16687 .input_mux = &alc663_capture_source,
16688 .unsol_event = alc663_g50v_unsol_event,
16689 .init_hook = alc663_g50v_inithook,
16690 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016691 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016692 .mixers = { alc663_m51va_mixer },
16693 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016694 .init_verbs = { alc662_init_verbs,
16695 alc663_21jd_amic_init_verbs },
16696 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16697 .hp_nid = 0x03,
16698 .dac_nids = alc662_dac_nids,
16699 .dig_out_nid = ALC662_DIGOUT_NID,
16700 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16701 .channel_mode = alc662_3ST_2ch_modes,
16702 .input_mux = &alc662_eeepc_capture_source,
16703 .unsol_event = alc663_mode1_unsol_event,
16704 .init_hook = alc663_mode1_inithook,
16705 },
16706 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016707 .mixers = { alc662_1bjd_mixer },
16708 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016709 .init_verbs = { alc662_init_verbs,
16710 alc662_1bjd_amic_init_verbs },
16711 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16712 .dac_nids = alc662_dac_nids,
16713 .dig_out_nid = ALC662_DIGOUT_NID,
16714 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16715 .channel_mode = alc662_3ST_2ch_modes,
16716 .input_mux = &alc662_eeepc_capture_source,
16717 .unsol_event = alc662_mode2_unsol_event,
16718 .init_hook = alc662_mode2_inithook,
16719 },
16720 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016721 .mixers = { alc663_two_hp_m1_mixer },
16722 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016723 .init_verbs = { alc662_init_verbs,
16724 alc663_two_hp_amic_m1_init_verbs },
16725 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16726 .hp_nid = 0x03,
16727 .dac_nids = alc662_dac_nids,
16728 .dig_out_nid = ALC662_DIGOUT_NID,
16729 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16730 .channel_mode = alc662_3ST_2ch_modes,
16731 .input_mux = &alc662_eeepc_capture_source,
16732 .unsol_event = alc663_mode3_unsol_event,
16733 .init_hook = alc663_mode3_inithook,
16734 },
16735 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016736 .mixers = { alc663_asus_21jd_clfe_mixer },
16737 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016738 .init_verbs = { alc662_init_verbs,
16739 alc663_21jd_amic_init_verbs},
16740 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16741 .hp_nid = 0x03,
16742 .dac_nids = alc662_dac_nids,
16743 .dig_out_nid = ALC662_DIGOUT_NID,
16744 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16745 .channel_mode = alc662_3ST_2ch_modes,
16746 .input_mux = &alc662_eeepc_capture_source,
16747 .unsol_event = alc663_mode4_unsol_event,
16748 .init_hook = alc663_mode4_inithook,
16749 },
16750 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016751 .mixers = { alc663_asus_15jd_clfe_mixer },
16752 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016753 .init_verbs = { alc662_init_verbs,
16754 alc663_15jd_amic_init_verbs },
16755 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16756 .hp_nid = 0x03,
16757 .dac_nids = alc662_dac_nids,
16758 .dig_out_nid = ALC662_DIGOUT_NID,
16759 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16760 .channel_mode = alc662_3ST_2ch_modes,
16761 .input_mux = &alc662_eeepc_capture_source,
16762 .unsol_event = alc663_mode5_unsol_event,
16763 .init_hook = alc663_mode5_inithook,
16764 },
16765 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016766 .mixers = { alc663_two_hp_m2_mixer },
16767 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016768 .init_verbs = { alc662_init_verbs,
16769 alc663_two_hp_amic_m2_init_verbs },
16770 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16771 .hp_nid = 0x03,
16772 .dac_nids = alc662_dac_nids,
16773 .dig_out_nid = ALC662_DIGOUT_NID,
16774 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16775 .channel_mode = alc662_3ST_2ch_modes,
16776 .input_mux = &alc662_eeepc_capture_source,
16777 .unsol_event = alc663_mode6_unsol_event,
16778 .init_hook = alc663_mode6_inithook,
16779 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016780 [ALC272_DELL] = {
16781 .mixers = { alc663_m51va_mixer },
16782 .cap_mixer = alc272_auto_capture_mixer,
16783 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16784 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16785 .dac_nids = alc662_dac_nids,
16786 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16787 .adc_nids = alc272_adc_nids,
16788 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16789 .capsrc_nids = alc272_capsrc_nids,
16790 .channel_mode = alc662_3ST_2ch_modes,
16791 .input_mux = &alc663_m51va_capture_source,
16792 .unsol_event = alc663_m51va_unsol_event,
16793 .init_hook = alc663_m51va_inithook,
16794 },
16795 [ALC272_DELL_ZM1] = {
16796 .mixers = { alc663_m51va_mixer },
16797 .cap_mixer = alc662_auto_capture_mixer,
16798 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16799 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16800 .dac_nids = alc662_dac_nids,
16801 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16802 .adc_nids = alc662_adc_nids,
16803 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16804 .capsrc_nids = alc662_capsrc_nids,
16805 .channel_mode = alc662_3ST_2ch_modes,
16806 .input_mux = &alc663_m51va_capture_source,
16807 .unsol_event = alc663_m51va_unsol_event,
16808 .init_hook = alc663_m51va_inithook,
16809 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016810};
16811
16812
16813/*
16814 * BIOS auto configuration
16815 */
16816
16817/* add playback controls from the parsed DAC table */
16818static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16819 const struct auto_pin_cfg *cfg)
16820{
16821 char name[32];
16822 static const char *chname[4] = {
16823 "Front", "Surround", NULL /*CLFE*/, "Side"
16824 };
16825 hda_nid_t nid;
16826 int i, err;
16827
16828 for (i = 0; i < cfg->line_outs; i++) {
16829 if (!spec->multiout.dac_nids[i])
16830 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016831 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016832 if (i == 2) {
16833 /* Center/LFE */
16834 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16835 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016836 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16837 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016838 if (err < 0)
16839 return err;
16840 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16841 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016842 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16843 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016844 if (err < 0)
16845 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016846 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016847 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016848 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016849 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016850 if (err < 0)
16851 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016852 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016853 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016854 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016855 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016856 if (err < 0)
16857 return err;
16858 } else {
16859 sprintf(name, "%s Playback Volume", chname[i]);
16860 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016861 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16862 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016863 if (err < 0)
16864 return err;
16865 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016866 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16867 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16868 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016869 if (err < 0)
16870 return err;
16871 }
16872 }
16873 return 0;
16874}
16875
16876/* add playback controls for speaker and HP outputs */
16877static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16878 const char *pfx)
16879{
16880 hda_nid_t nid;
16881 int err;
16882 char name[32];
16883
16884 if (!pin)
16885 return 0;
16886
Takashi Iwai24fb9172008-09-02 14:48:20 +020016887 if (pin == 0x17) {
16888 /* ALC663 has a mono output pin on 0x17 */
16889 sprintf(name, "%s Playback Switch", pfx);
16890 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16891 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16892 return err;
16893 }
16894
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016895 if (alc880_is_fixed_pin(pin)) {
16896 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016897 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016898 /* specify the DAC as the extra output */
16899 if (!spec->multiout.hp_nid)
16900 spec->multiout.hp_nid = nid;
16901 else
16902 spec->multiout.extra_out_nid[0] = nid;
16903 /* control HP volume/switch on the output mixer amp */
16904 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16905 sprintf(name, "%s Playback Volume", pfx);
16906 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16907 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16908 if (err < 0)
16909 return err;
16910 sprintf(name, "%s Playback Switch", pfx);
16911 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16912 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16913 if (err < 0)
16914 return err;
16915 } else if (alc880_is_multi_pin(pin)) {
16916 /* set manual connection */
16917 /* we have only a switch on HP-out PIN */
16918 sprintf(name, "%s Playback Switch", pfx);
16919 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16920 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16921 if (err < 0)
16922 return err;
16923 }
16924 return 0;
16925}
16926
Takashi Iwai2d864c42009-03-20 12:52:47 +010016927/* return the index of the src widget from the connection list of the nid.
16928 * return -1 if not found
16929 */
16930static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16931 hda_nid_t src)
16932{
16933 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16934 int i, conns;
16935
16936 conns = snd_hda_get_connections(codec, nid, conn_list,
16937 ARRAY_SIZE(conn_list));
16938 if (conns < 0)
16939 return -1;
16940 for (i = 0; i < conns; i++)
16941 if (conn_list[i] == src)
16942 return i;
16943 return -1;
16944}
16945
16946static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16947{
Takashi Iwai1327a322009-03-23 13:07:47 +010016948 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010016949 return (pincap & AC_PINCAP_IN) != 0;
16950}
16951
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016952/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010016953static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016954 const struct auto_pin_cfg *cfg)
16955{
Takashi Iwai2d864c42009-03-20 12:52:47 +010016956 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016957 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016958 int i, err, idx;
16959
16960 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010016961 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16962 idx = alc662_input_pin_idx(codec, 0x0b,
16963 cfg->input_pins[i]);
16964 if (idx >= 0) {
16965 err = new_analog_input(spec, cfg->input_pins[i],
16966 auto_pin_cfg_labels[i],
16967 idx, 0x0b);
16968 if (err < 0)
16969 return err;
16970 }
16971 idx = alc662_input_pin_idx(codec, 0x22,
16972 cfg->input_pins[i]);
16973 if (idx >= 0) {
16974 imux->items[imux->num_items].label =
16975 auto_pin_cfg_labels[i];
16976 imux->items[imux->num_items].index = idx;
16977 imux->num_items++;
16978 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016979 }
16980 }
16981 return 0;
16982}
16983
16984static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16985 hda_nid_t nid, int pin_type,
16986 int dac_idx)
16987{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016988 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016989 /* need the manual connection? */
16990 if (alc880_is_multi_pin(nid)) {
16991 struct alc_spec *spec = codec->spec;
16992 int idx = alc880_multi_pin_idx(nid);
16993 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16994 AC_VERB_SET_CONNECT_SEL,
16995 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16996 }
16997}
16998
16999static void alc662_auto_init_multi_out(struct hda_codec *codec)
17000{
17001 struct alc_spec *spec = codec->spec;
17002 int i;
17003
17004 for (i = 0; i <= HDA_SIDE; i++) {
17005 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017006 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017007 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017008 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017009 i);
17010 }
17011}
17012
17013static void alc662_auto_init_hp_out(struct hda_codec *codec)
17014{
17015 struct alc_spec *spec = codec->spec;
17016 hda_nid_t pin;
17017
17018 pin = spec->autocfg.hp_pins[0];
17019 if (pin) /* connect to front */
17020 /* use dac 0 */
17021 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017022 pin = spec->autocfg.speaker_pins[0];
17023 if (pin)
17024 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017025}
17026
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017027#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17028
17029static void alc662_auto_init_analog_input(struct hda_codec *codec)
17030{
17031 struct alc_spec *spec = codec->spec;
17032 int i;
17033
17034 for (i = 0; i < AUTO_PIN_LAST; i++) {
17035 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017036 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017037 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017038 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017039 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017040 snd_hda_codec_write(codec, nid, 0,
17041 AC_VERB_SET_AMP_GAIN_MUTE,
17042 AMP_OUT_MUTE);
17043 }
17044 }
17045}
17046
Takashi Iwaif511b012008-08-15 16:46:42 +020017047#define alc662_auto_init_input_src alc882_auto_init_input_src
17048
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017049static int alc662_parse_auto_config(struct hda_codec *codec)
17050{
17051 struct alc_spec *spec = codec->spec;
17052 int err;
17053 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17054
17055 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17056 alc662_ignore);
17057 if (err < 0)
17058 return err;
17059 if (!spec->autocfg.line_outs)
17060 return 0; /* can't find valid BIOS pin config */
17061
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017062 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17063 if (err < 0)
17064 return err;
17065 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17066 if (err < 0)
17067 return err;
17068 err = alc662_auto_create_extra_out(spec,
17069 spec->autocfg.speaker_pins[0],
17070 "Speaker");
17071 if (err < 0)
17072 return err;
17073 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17074 "Headphone");
17075 if (err < 0)
17076 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017077 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017078 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017079 return err;
17080
17081 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17082
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017083 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017084 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17085
Takashi Iwai603c4012008-07-30 15:01:44 +020017086 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017087 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017088
17089 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017090 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017091
Takashi Iwaid88897e2008-10-31 15:01:37 +010017092 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017093 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017094 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017095
17096 err = alc_auto_add_mic_boost(codec);
17097 if (err < 0)
17098 return err;
17099
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017100 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17101
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017102 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017103}
17104
17105/* additional initialization for auto-configuration model */
17106static void alc662_auto_init(struct hda_codec *codec)
17107{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017108 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017109 alc662_auto_init_multi_out(codec);
17110 alc662_auto_init_hp_out(codec);
17111 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017112 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017113 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017114 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017115}
17116
17117static int patch_alc662(struct hda_codec *codec)
17118{
17119 struct alc_spec *spec;
17120 int err, board_config;
17121
17122 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17123 if (!spec)
17124 return -ENOMEM;
17125
17126 codec->spec = spec;
17127
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017128 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17129
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017130 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17131 alc662_models,
17132 alc662_cfg_tbl);
17133 if (board_config < 0) {
17134 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
17135 "trying auto-probe from BIOS...\n");
17136 board_config = ALC662_AUTO;
17137 }
17138
17139 if (board_config == ALC662_AUTO) {
17140 /* automatic parse from the BIOS config */
17141 err = alc662_parse_auto_config(codec);
17142 if (err < 0) {
17143 alc_free(codec);
17144 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017145 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017146 printk(KERN_INFO
17147 "hda_codec: Cannot set up configuration "
17148 "from BIOS. Using base mode...\n");
17149 board_config = ALC662_3ST_2ch_DIG;
17150 }
17151 }
17152
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017153 err = snd_hda_attach_beep_device(codec, 0x1);
17154 if (err < 0) {
17155 alc_free(codec);
17156 return err;
17157 }
17158
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017159 if (board_config != ALC662_AUTO)
17160 setup_preset(spec, &alc662_presets[board_config]);
17161
Kailang Yang6dda9f42008-05-27 12:05:31 +020017162 if (codec->vendor_id == 0x10ec0663) {
17163 spec->stream_name_analog = "ALC663 Analog";
17164 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020017165 } else if (codec->vendor_id == 0x10ec0272) {
17166 spec->stream_name_analog = "ALC272 Analog";
17167 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020017168 } else {
17169 spec->stream_name_analog = "ALC662 Analog";
17170 spec->stream_name_digital = "ALC662 Digital";
17171 }
17172
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017173 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17174 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17175
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017176 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17177 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17178
Takashi Iwaie1406342008-02-11 18:32:32 +010017179 spec->adc_nids = alc662_adc_nids;
17180 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17181 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017182 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017183
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017184 if (!spec->cap_mixer)
17185 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017186 if (codec->vendor_id == 0x10ec0662)
17187 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17188 else
17189 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017190
Takashi Iwai2134ea42008-01-10 16:53:55 +010017191 spec->vmaster_nid = 0x02;
17192
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017193 codec->patch_ops = alc_patch_ops;
17194 if (board_config == ALC662_AUTO)
17195 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017196#ifdef CONFIG_SND_HDA_POWER_SAVE
17197 if (!spec->loopback.amplist)
17198 spec->loopback.amplist = alc662_loopbacks;
17199#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017200 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017201
17202 return 0;
17203}
17204
17205/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017206 * patch entries
17207 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017208static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017209 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017210 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017211 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017212 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017213 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017214 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017215 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017216 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017217 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17218 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17219 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017220 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17221 .patch = patch_alc883 },
17222 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17223 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017224 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017225 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017226 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017227 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017228 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17229 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017230 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017231 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017232 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017233 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017234 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17235 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017236 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017237 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017238 {} /* terminator */
17239};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017240
17241MODULE_ALIAS("snd-hda-codec-id:10ec*");
17242
17243MODULE_LICENSE("GPL");
17244MODULE_DESCRIPTION("Realtek HD-audio codec");
17245
17246static struct hda_codec_preset_list realtek_list = {
17247 .preset = snd_hda_preset_realtek,
17248 .owner = THIS_MODULE,
17249};
17250
17251static int __init patch_realtek_init(void)
17252{
17253 return snd_hda_add_codec_preset(&realtek_list);
17254}
17255
17256static void __exit patch_realtek_exit(void)
17257{
17258 snd_hda_delete_codec_preset(&realtek_list);
17259}
17260
17261module_init(patch_realtek_init)
17262module_exit(patch_realtek_exit)