blob: 7c043b3b81a5b21a26e5017b5b79f473f99a41b6 [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
Takashi Iwaib72519b2009-05-08 14:31:55 +02009592#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009593
9594static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9595 struct snd_ctl_elem_value *ucontrol)
9596{
9597 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9598 struct alc_spec *spec = codec->spec;
9599 int val = !!*ucontrol->value.integer.value;
9600
9601 if (val == spec->master_sw)
9602 return 0;
9603 spec->master_sw = val;
9604 alc262_hp_master_update(codec);
9605 return 1;
9606}
9607
Takashi Iwaib72519b2009-05-08 14:31:55 +02009608#define ALC262_HP_MASTER_SWITCH \
9609 { \
9610 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9611 .name = "Master Playback Switch", \
9612 .info = snd_ctl_boolean_mono_info, \
9613 .get = alc262_hp_master_sw_get, \
9614 .put = alc262_hp_master_sw_put, \
9615 }
9616
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009617static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009618 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009619 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9620 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9621 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009622 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9623 HDA_OUTPUT),
9624 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9625 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009626 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9627 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009628 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009629 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9630 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009631 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009632 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9633 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9634 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9635 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009636 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9637 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9638 { } /* end */
9639};
9640
Kailang Yangcd7509a2007-01-26 18:33:17 +01009641static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009642 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009643 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9644 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9645 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9646 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009647 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9648 HDA_OUTPUT),
9649 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9650 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009651 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9652 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009653 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009654 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9655 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9656 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9657 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009658 { } /* end */
9659};
9660
9661static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9662 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9663 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009664 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009665 { } /* end */
9666};
9667
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009668/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaib72519b2009-05-08 14:31:55 +02009669static void alc262_hp_t5735_automute(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009670{
9671 struct alc_spec *spec = codec->spec;
Takashi Iwaib72519b2009-05-08 14:31:55 +02009672 unsigned int present;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009673
Takashi Iwaib72519b2009-05-08 14:31:55 +02009674 present = snd_hda_codec_read(codec, 0x15, 0,
9675 AC_VERB_GET_PIN_SENSE, 0);
9676 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai4bb26132008-01-28 18:12:42 +01009677 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9678 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009679}
9680
9681static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9682 unsigned int res)
9683{
9684 if ((res >> 26) != ALC880_HP_EVENT)
9685 return;
Takashi Iwaib72519b2009-05-08 14:31:55 +02009686 alc262_hp_t5735_automute(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009687}
9688
Takashi Iwaib72519b2009-05-08 14:31:55 +02009689#define alc262_hp_t5735_init_hook alc262_hp_t5735_automute
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009690
9691static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009692 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9693 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009694 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9695 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9696 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9697 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9698 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9699 { } /* end */
9700};
9701
9702static struct hda_verb alc262_hp_t5735_verbs[] = {
9703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9704 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9705
9706 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9707 { }
9708};
9709
Kailang Yang8c427222008-01-10 13:03:59 +01009710static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009711 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9712 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009713 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9714 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009715 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9716 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9717 { } /* end */
9718};
9719
9720static struct hda_verb alc262_hp_rp5700_verbs[] = {
9721 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9722 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9723 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9724 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9725 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9726 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9727 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9728 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9729 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9730 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9731 {}
9732};
9733
9734static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9735 .num_items = 1,
9736 .items = {
9737 { "Line", 0x1 },
9738 },
9739};
9740
Takashi Iwai42171c12009-05-08 14:11:43 +02009741/* bind hp and internal speaker mute (with plug check) as master switch */
9742static void alc262_hippo_master_update(struct hda_codec *codec)
9743{
9744 struct alc_spec *spec = codec->spec;
9745 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9746 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9747 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9748 unsigned int mute;
9749
9750 /* HP */
9751 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9752 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9753 HDA_AMP_MUTE, mute);
9754 /* mute internal speaker per jack sense */
9755 if (spec->jack_present)
9756 mute = HDA_AMP_MUTE;
9757 if (line_nid)
9758 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9759 HDA_AMP_MUTE, mute);
9760 if (speaker_nid && speaker_nid != line_nid)
9761 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
9762 HDA_AMP_MUTE, mute);
9763}
9764
9765#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
9766
9767static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
9768 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +02009769{
9770 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +02009771 struct alc_spec *spec = codec->spec;
9772 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009773
Takashi Iwai42171c12009-05-08 14:11:43 +02009774 if (val == spec->master_sw)
9775 return 0;
9776 spec->master_sw = val;
9777 alc262_hippo_master_update(codec);
9778 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009779}
Takashi Iwai5b319542007-07-26 11:49:22 +02009780
Takashi Iwai42171c12009-05-08 14:11:43 +02009781#define ALC262_HIPPO_MASTER_SWITCH \
9782 { \
9783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9784 .name = "Master Playback Switch", \
9785 .info = snd_ctl_boolean_mono_info, \
9786 .get = alc262_hippo_master_sw_get, \
9787 .put = alc262_hippo_master_sw_put, \
9788 }
9789
9790static struct snd_kcontrol_new alc262_hippo_mixer[] = {
9791 ALC262_HIPPO_MASTER_SWITCH,
9792 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9799 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9800 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9801 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9802 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9803 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9804 { } /* end */
9805};
9806
9807static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9808 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9809 ALC262_HIPPO_MASTER_SWITCH,
9810 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9811 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9812 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9813 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9815 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9816 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9817 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9818 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9819 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9820 { } /* end */
9821};
9822
9823/* mute/unmute internal speaker according to the hp jack and mute state */
9824static void alc262_hippo_automute(struct hda_codec *codec)
9825{
9826 struct alc_spec *spec = codec->spec;
9827 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9828 unsigned int present;
9829
9830 /* need to execute and sync at first */
9831 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
9832 present = snd_hda_codec_read(codec, hp_nid, 0,
9833 AC_VERB_GET_PIN_SENSE, 0);
9834 spec->jack_present = (present & 0x80000000) != 0;
9835 alc262_hippo_master_update(codec);
9836}
9837
9838static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
9839{
9840 if ((res >> 26) != ALC880_HP_EVENT)
9841 return;
9842 alc262_hippo_automute(codec);
9843}
9844
9845static void alc262_hippo_init_hook(struct hda_codec *codec)
9846{
9847 struct alc_spec *spec = codec->spec;
9848
9849 spec->autocfg.hp_pins[0] = 0x15;
9850 spec->autocfg.speaker_pins[0] = 0x14;
9851 alc262_hippo_automute(codec);
9852}
9853
9854static void alc262_hippo1_init_hook(struct hda_codec *codec)
9855{
9856 struct alc_spec *spec = codec->spec;
9857
9858 spec->autocfg.hp_pins[0] = 0x1b;
9859 spec->autocfg.speaker_pins[0] = 0x14;
9860 alc262_hippo_automute(codec);
9861}
9862
9863
Kailang Yang272a5272007-05-14 11:00:38 +02009864static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009865 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +02009866 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +02009867 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9868 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9869 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9870 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9871 { } /* end */
9872};
9873
Kailang Yang83c34212007-07-05 11:43:05 +02009874static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +02009875 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9876 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +02009877 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9880 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9881 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9882 { } /* end */
9883};
Kailang Yang272a5272007-05-14 11:00:38 +02009884
Tony Vroonba340e82009-02-02 19:01:30 +00009885static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9886 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9887 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9888 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9889 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9890 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9891 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9894 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9895 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9896 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9897 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9898 { } /* end */
9899};
9900
9901static struct hda_verb alc262_tyan_verbs[] = {
9902 /* Headphone automute */
9903 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9904 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9905 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9906
9907 /* P11 AUX_IN, white 4-pin connector */
9908 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9909 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9910 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9911 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9912
9913 {}
9914};
9915
9916/* unsolicited event for HP jack sensing */
9917static void alc262_tyan_automute(struct hda_codec *codec)
9918{
9919 unsigned int mute;
9920 unsigned int present;
9921
9922 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9923 present = snd_hda_codec_read(codec, 0x1b, 0,
9924 AC_VERB_GET_PIN_SENSE, 0);
9925 present = (present & 0x80000000) != 0;
9926 if (present) {
9927 /* mute line output on ATX panel */
9928 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9929 HDA_AMP_MUTE, HDA_AMP_MUTE);
9930 } else {
9931 /* unmute line output if necessary */
9932 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9933 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9934 HDA_AMP_MUTE, mute);
9935 }
9936}
9937
9938static void alc262_tyan_unsol_event(struct hda_codec *codec,
9939 unsigned int res)
9940{
9941 if ((res >> 26) != ALC880_HP_EVENT)
9942 return;
9943 alc262_tyan_automute(codec);
9944}
9945
Kailang Yangdf694da2005-12-05 19:42:22 +01009946#define alc262_capture_mixer alc882_capture_mixer
9947#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9948
9949/*
9950 * generic initialization of ADC, input mixers and output mixers
9951 */
9952static struct hda_verb alc262_init_verbs[] = {
9953 /*
9954 * Unmute ADC0-2 and set the default input to mic-in
9955 */
9956 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9957 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9958 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9959 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9960 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9961 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9962
Takashi Iwaicb53c622007-08-10 17:21:45 +02009963 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009964 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009965 * Note: PASD motherboards uses the Line In 2 as the input for
9966 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009967 */
9968 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009969 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9970 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9971 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9972 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9973 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009974
9975 /*
9976 * Set up output mixers (0x0c - 0x0e)
9977 */
9978 /* set vol=0 to output mixers */
9979 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9980 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9981 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9982 /* set up input amps for analog loopback */
9983 /* Amp Indices: DAC = 0, mixer = 1 */
9984 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9985 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9986 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9987 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9988 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9989 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9990
9991 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9992 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9993 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9994 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9995 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9996 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9997
9998 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9999 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10000 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10001 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10002 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010003
Kailang Yangdf694da2005-12-05 19:42:22 +010010004 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10005 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010006
Kailang Yangdf694da2005-12-05 19:42:22 +010010007 /* FIXME: use matrix-type input source selection */
10008 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10009 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10010 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10011 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10012 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10013 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10014 /* Input mixer2 */
10015 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10016 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10017 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10018 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10019 /* Input mixer3 */
10020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10022 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010023 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010024
10025 { }
10026};
10027
Kailang Yang4e555fe2008-08-26 13:05:55 +020010028static struct hda_verb alc262_eapd_verbs[] = {
10029 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10030 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10031 { }
10032};
10033
Kailang Yangccc656c2006-10-17 12:32:26 +020010034static struct hda_verb alc262_hippo_unsol_verbs[] = {
10035 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10036 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10037 {}
10038};
10039
10040static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10042 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10043 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10044
10045 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10046 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10047 {}
10048};
10049
Kailang Yang272a5272007-05-14 11:00:38 +020010050static struct hda_verb alc262_sony_unsol_verbs[] = {
10051 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10052 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10053 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10054
10055 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10056 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010057 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010058};
10059
Kailang Yang4e555fe2008-08-26 13:05:55 +020010060static struct hda_input_mux alc262_dmic_capture_source = {
10061 .num_items = 2,
10062 .items = {
10063 { "Int DMic", 0x9 },
10064 { "Mic", 0x0 },
10065 },
10066};
10067
10068static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10069 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10070 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10071 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010074 { } /* end */
10075};
10076
10077static struct hda_verb alc262_toshiba_s06_verbs[] = {
10078 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10079 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10081 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10082 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10083 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10084 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10085 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10086 {}
10087};
10088
10089static void alc262_dmic_automute(struct hda_codec *codec)
10090{
10091 unsigned int present;
10092
10093 present = snd_hda_codec_read(codec, 0x18, 0,
10094 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10095 snd_hda_codec_write(codec, 0x22, 0,
10096 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10097}
10098
10099/* toggle speaker-output according to the hp-jack state */
10100static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
10101{
10102 unsigned int present;
10103 unsigned char bits;
10104
10105 present = snd_hda_codec_read(codec, 0x15, 0,
10106 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10107 bits = present ? 0 : PIN_OUT;
10108 snd_hda_codec_write(codec, 0x14, 0,
10109 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
10110}
10111
10112
10113
10114/* unsolicited event for HP jack sensing */
10115static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10116 unsigned int res)
10117{
10118 if ((res >> 26) == ALC880_HP_EVENT)
10119 alc262_toshiba_s06_speaker_automute(codec);
10120 if ((res >> 26) == ALC880_MIC_EVENT)
10121 alc262_dmic_automute(codec);
10122
10123}
10124
10125static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10126{
10127 alc262_toshiba_s06_speaker_automute(codec);
10128 alc262_dmic_automute(codec);
10129}
10130
Takashi Iwai834be882006-03-01 14:16:17 +010010131/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010132 * nec model
10133 * 0x15 = headphone
10134 * 0x16 = internal speaker
10135 * 0x18 = external mic
10136 */
10137
10138static struct snd_kcontrol_new alc262_nec_mixer[] = {
10139 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10140 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10141
10142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10144 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10145
10146 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10148 { } /* end */
10149};
10150
10151static struct hda_verb alc262_nec_verbs[] = {
10152 /* Unmute Speaker */
10153 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10154
10155 /* Headphone */
10156 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10158
10159 /* External mic to headphone */
10160 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10161 /* External mic to speaker */
10162 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10163 {}
10164};
10165
10166/*
Takashi Iwai834be882006-03-01 14:16:17 +010010167 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010168 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10169 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010170 */
10171
10172#define ALC_HP_EVENT 0x37
10173
10174static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10175 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10176 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010177 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10178 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010179 {}
10180};
10181
Jiang zhe0e31daf2008-03-20 12:12:39 +010010182static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10183 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10185 {}
10186};
10187
Takashi Iwai834be882006-03-01 14:16:17 +010010188static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010189 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010190 .items = {
10191 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010192 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010193 { "CD", 0x4 },
10194 },
10195};
10196
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010197static struct hda_input_mux alc262_HP_capture_source = {
10198 .num_items = 5,
10199 .items = {
10200 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010201 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010202 { "Line", 0x2 },
10203 { "CD", 0x4 },
10204 { "AUX IN", 0x6 },
10205 },
10206};
10207
zhejiangaccbe492007-08-31 12:36:05 +020010208static struct hda_input_mux alc262_HP_D7000_capture_source = {
10209 .num_items = 4,
10210 .items = {
10211 { "Mic", 0x0 },
10212 { "Front Mic", 0x2 },
10213 { "Line", 0x1 },
10214 { "CD", 0x4 },
10215 },
10216};
10217
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010218/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010219static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10220{
10221 struct alc_spec *spec = codec->spec;
10222 unsigned int mute;
10223
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010224 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010225 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010226 /* need to execute and sync at first */
10227 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010228 /* check laptop HP jack */
10229 present = snd_hda_codec_read(codec, 0x14, 0,
10230 AC_VERB_GET_PIN_SENSE, 0);
10231 /* need to execute and sync at first */
10232 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10233 /* check docking HP jack */
10234 present |= snd_hda_codec_read(codec, 0x1b, 0,
10235 AC_VERB_GET_PIN_SENSE, 0);
10236 if (present & AC_PINSENSE_PRESENCE)
10237 spec->jack_present = 1;
10238 else
10239 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010240 spec->sense_updated = 1;
10241 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010242 /* unmute internal speaker only if both HPs are unplugged and
10243 * master switch is on
10244 */
10245 if (spec->jack_present)
10246 mute = HDA_AMP_MUTE;
10247 else
Takashi Iwai834be882006-03-01 14:16:17 +010010248 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010249 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10250 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010251}
10252
10253/* unsolicited event for HP jack sensing */
10254static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10255 unsigned int res)
10256{
10257 if ((res >> 26) != ALC_HP_EVENT)
10258 return;
10259 alc262_fujitsu_automute(codec, 1);
10260}
10261
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010262static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10263{
10264 alc262_fujitsu_automute(codec, 1);
10265}
10266
Takashi Iwai834be882006-03-01 14:16:17 +010010267/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010268static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10269 .ops = &snd_hda_bind_vol,
10270 .values = {
10271 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10272 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10273 0
10274 },
10275};
Takashi Iwai834be882006-03-01 14:16:17 +010010276
Jiang zhe0e31daf2008-03-20 12:12:39 +010010277/* mute/unmute internal speaker according to the hp jack and mute state */
10278static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10279{
10280 struct alc_spec *spec = codec->spec;
10281 unsigned int mute;
10282
10283 if (force || !spec->sense_updated) {
10284 unsigned int present_int_hp;
10285 /* need to execute and sync at first */
10286 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10287 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10288 AC_VERB_GET_PIN_SENSE, 0);
10289 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10290 spec->sense_updated = 1;
10291 }
10292 if (spec->jack_present) {
10293 /* mute internal speaker */
10294 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10295 HDA_AMP_MUTE, HDA_AMP_MUTE);
10296 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10297 HDA_AMP_MUTE, HDA_AMP_MUTE);
10298 } else {
10299 /* unmute internal speaker if necessary */
10300 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10301 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10302 HDA_AMP_MUTE, mute);
10303 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10304 HDA_AMP_MUTE, mute);
10305 }
10306}
10307
10308/* unsolicited event for HP jack sensing */
10309static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10310 unsigned int res)
10311{
10312 if ((res >> 26) != ALC_HP_EVENT)
10313 return;
10314 alc262_lenovo_3000_automute(codec, 1);
10315}
10316
Takashi Iwai834be882006-03-01 14:16:17 +010010317/* bind hp and internal speaker mute (with plug check) */
10318static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10319 struct snd_ctl_elem_value *ucontrol)
10320{
10321 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10322 long *valp = ucontrol->value.integer.value;
10323 int change;
10324
Tony Vroon5d9fab22008-03-14 17:09:18 +010010325 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10326 HDA_AMP_MUTE,
10327 valp ? 0 : HDA_AMP_MUTE);
10328 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10329 HDA_AMP_MUTE,
10330 valp ? 0 : HDA_AMP_MUTE);
10331
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010332 if (change)
10333 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010334 return change;
10335}
10336
10337static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010338 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010339 {
10340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10341 .name = "Master Playback Switch",
10342 .info = snd_hda_mixer_amp_switch_info,
10343 .get = snd_hda_mixer_amp_switch_get,
10344 .put = alc262_fujitsu_master_sw_put,
10345 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10346 },
10347 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10348 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10349 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10351 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010352 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10353 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10354 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010355 { } /* end */
10356};
10357
Jiang zhe0e31daf2008-03-20 12:12:39 +010010358/* bind hp and internal speaker mute (with plug check) */
10359static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10360 struct snd_ctl_elem_value *ucontrol)
10361{
10362 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10363 long *valp = ucontrol->value.integer.value;
10364 int change;
10365
10366 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10367 HDA_AMP_MUTE,
10368 valp ? 0 : HDA_AMP_MUTE);
10369
10370 if (change)
10371 alc262_lenovo_3000_automute(codec, 0);
10372 return change;
10373}
10374
10375static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10376 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10377 {
10378 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10379 .name = "Master Playback Switch",
10380 .info = snd_hda_mixer_amp_switch_info,
10381 .get = snd_hda_mixer_amp_switch_get,
10382 .put = alc262_lenovo_3000_master_sw_put,
10383 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10384 },
10385 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10386 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10387 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10388 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10389 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10390 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10391 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10392 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10393 { } /* end */
10394};
10395
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010396static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10397 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010398 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10400 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10401 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10402 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10403 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10404 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10405 { } /* end */
10406};
10407
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010408/* additional init verbs for Benq laptops */
10409static struct hda_verb alc262_EAPD_verbs[] = {
10410 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10411 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10412 {}
10413};
10414
Kailang Yang83c34212007-07-05 11:43:05 +020010415static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10416 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10417 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10418
10419 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10420 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10421 {}
10422};
10423
Tobin Davisf651b502007-10-26 12:40:47 +020010424/* Samsung Q1 Ultra Vista model setup */
10425static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010426 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10427 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10430 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010431 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010432 { } /* end */
10433};
10434
10435static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010436 /* output mixer */
10437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10438 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10439 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10440 /* speaker */
10441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10442 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10443 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10444 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10445 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010446 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10449 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10450 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10451 /* internal mic */
10452 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10453 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10454 /* ADC, choose mic */
10455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10461 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10462 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10463 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10464 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010465 {}
10466};
10467
Tobin Davisf651b502007-10-26 12:40:47 +020010468/* mute/unmute internal speaker according to the hp jack and mute state */
10469static void alc262_ultra_automute(struct hda_codec *codec)
10470{
10471 struct alc_spec *spec = codec->spec;
10472 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010473
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010474 mute = 0;
10475 /* auto-mute only when HP is used as HP */
10476 if (!spec->cur_mux[0]) {
10477 unsigned int present;
10478 /* need to execute and sync at first */
10479 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10480 present = snd_hda_codec_read(codec, 0x15, 0,
10481 AC_VERB_GET_PIN_SENSE, 0);
10482 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10483 if (spec->jack_present)
10484 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010485 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010486 /* mute/unmute internal speaker */
10487 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10488 HDA_AMP_MUTE, mute);
10489 /* mute/unmute HP */
10490 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10491 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010492}
10493
10494/* unsolicited event for HP jack sensing */
10495static void alc262_ultra_unsol_event(struct hda_codec *codec,
10496 unsigned int res)
10497{
10498 if ((res >> 26) != ALC880_HP_EVENT)
10499 return;
10500 alc262_ultra_automute(codec);
10501}
10502
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010503static struct hda_input_mux alc262_ultra_capture_source = {
10504 .num_items = 2,
10505 .items = {
10506 { "Mic", 0x1 },
10507 { "Headphone", 0x7 },
10508 },
10509};
10510
10511static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10512 struct snd_ctl_elem_value *ucontrol)
10513{
10514 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10515 struct alc_spec *spec = codec->spec;
10516 int ret;
10517
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010518 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010519 if (!ret)
10520 return 0;
10521 /* reprogram the HP pin as mic or HP according to the input source */
10522 snd_hda_codec_write_cache(codec, 0x15, 0,
10523 AC_VERB_SET_PIN_WIDGET_CONTROL,
10524 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10525 alc262_ultra_automute(codec); /* mute/unmute HP */
10526 return ret;
10527}
10528
10529static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10530 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10531 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10532 {
10533 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10534 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010535 .info = alc_mux_enum_info,
10536 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010537 .put = alc262_ultra_mux_enum_put,
10538 },
10539 { } /* end */
10540};
10541
Kailang Yangdf694da2005-12-05 19:42:22 +010010542/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010543static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10544 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010545{
10546 hda_nid_t nid;
10547 int err;
10548
10549 spec->multiout.num_dacs = 1; /* only use one dac */
10550 spec->multiout.dac_nids = spec->private_dac_nids;
10551 spec->multiout.dac_nids[0] = 2;
10552
10553 nid = cfg->line_out_pins[0];
10554 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010555 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10556 "Front Playback Volume",
10557 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10558 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010559 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010560 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10561 "Front Playback Switch",
10562 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10563 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010564 return err;
10565 }
10566
Takashi Iwai82bc9552006-03-21 11:24:42 +010010567 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010568 if (nid) {
10569 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010570 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10571 "Speaker Playback Volume",
10572 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10573 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 "Speaker Playback Switch",
10578 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10579 HDA_OUTPUT));
10580 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010581 return err;
10582 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010583 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10584 "Speaker Playback Switch",
10585 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10586 HDA_OUTPUT));
10587 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010588 return err;
10589 }
10590 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010591 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010592 if (nid) {
10593 /* spec->multiout.hp_nid = 2; */
10594 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010595 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10596 "Headphone Playback Volume",
10597 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10598 HDA_OUTPUT));
10599 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010600 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010601 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10602 "Headphone Playback Switch",
10603 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10604 HDA_OUTPUT));
10605 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010606 return err;
10607 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010608 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10609 "Headphone Playback Switch",
10610 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10611 HDA_OUTPUT));
10612 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010613 return err;
10614 }
10615 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010616 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010617}
10618
10619/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010620#define alc262_auto_create_analog_input_ctls \
10621 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010622
10623/*
10624 * generic initialization of ADC, input mixers and output mixers
10625 */
10626static struct hda_verb alc262_volume_init_verbs[] = {
10627 /*
10628 * Unmute ADC0-2 and set the default input to mic-in
10629 */
10630 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10632 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10634 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10635 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10636
Takashi Iwaicb53c622007-08-10 17:21:45 +020010637 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010638 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010639 * Note: PASD motherboards uses the Line In 2 as the input for
10640 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010641 */
10642 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010648
10649 /*
10650 * Set up output mixers (0x0c - 0x0f)
10651 */
10652 /* set vol=0 to output mixers */
10653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10654 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010656
Kailang Yangdf694da2005-12-05 19:42:22 +010010657 /* set up input amps for analog loopback */
10658 /* Amp Indices: DAC = 0, mixer = 1 */
10659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10662 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10664 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10665
10666 /* FIXME: use matrix-type input source selection */
10667 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10668 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10669 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10670 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10673 /* Input mixer2 */
10674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10675 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10676 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10678 /* Input mixer3 */
10679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10683
10684 { }
10685};
10686
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010687static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10688 /*
10689 * Unmute ADC0-2 and set the default input to mic-in
10690 */
10691 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10692 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10693 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10694 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10695 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10696 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10697
Takashi Iwaicb53c622007-08-10 17:21:45 +020010698 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010699 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010700 * Note: PASD motherboards uses the Line In 2 as the input for
10701 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010702 */
10703 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010711
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010712 /*
10713 * Set up output mixers (0x0c - 0x0e)
10714 */
10715 /* set vol=0 to output mixers */
10716 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10718 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10719
10720 /* set up input amps for analog loopback */
10721 /* Amp Indices: DAC = 0, mixer = 1 */
10722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10724 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10726 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10727 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10728
Takashi Iwaice875f02008-01-28 18:17:43 +010010729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010730 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10732
10733 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10734 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10735
10736 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10738
10739 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10740 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10742 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10743 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10744
10745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10746 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10747 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10748 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10749 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10750 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10751
10752
10753 /* FIXME: use matrix-type input source selection */
10754 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10755 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10756 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10757 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10760 /* Input mixer2 */
10761 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10762 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10765 /* Input mixer3 */
10766 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10767 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10770
Takashi Iwaice875f02008-01-28 18:17:43 +010010771 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10772
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010773 { }
10774};
10775
Kailang Yangcd7509a2007-01-26 18:33:17 +010010776static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10777 /*
10778 * Unmute ADC0-2 and set the default input to mic-in
10779 */
10780 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10781 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10782 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10783 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10784 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10785 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10786
Takashi Iwaicb53c622007-08-10 17:21:45 +020010787 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010788 * mixer widget
10789 * Note: PASD motherboards uses the Line In 2 as the input for front
10790 * panel mic (mic 2)
10791 */
10792 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010793 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10796 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10798 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10800 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010801 /*
10802 * Set up output mixers (0x0c - 0x0e)
10803 */
10804 /* set vol=0 to output mixers */
10805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10807 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10808
10809 /* set up input amps for analog loopback */
10810 /* Amp Indices: DAC = 0, mixer = 1 */
10811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10813 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10814 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10815 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10816 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10817
10818
10819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10820 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10821 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10822 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10823 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10824 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10825 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10826
10827 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10829
10830 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10831 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10832
10833 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10834 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10835 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10836 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10837 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10838 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10839
10840 /* FIXME: use matrix-type input source selection */
10841 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10842 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10843 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10844 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10845 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10846 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10847 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10848 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10849 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10850 /* Input mixer2 */
10851 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10852 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10853 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10854 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10855 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10856 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10857 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10858 /* Input mixer3 */
10859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10860 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10861 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10862 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10863 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10864 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10865 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10866
Takashi Iwaice875f02008-01-28 18:17:43 +010010867 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10868
Kailang Yangcd7509a2007-01-26 18:33:17 +010010869 { }
10870};
10871
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010872static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10873
10874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10875 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10876 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10877
10878 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10879 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10880 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10881 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10882
10883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10884 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10885 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10886 {}
10887};
10888
10889
Takashi Iwaicb53c622007-08-10 17:21:45 +020010890#ifdef CONFIG_SND_HDA_POWER_SAVE
10891#define alc262_loopbacks alc880_loopbacks
10892#endif
10893
Kailang Yangdf694da2005-12-05 19:42:22 +010010894/* pcm configuration: identiacal with ALC880 */
10895#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10896#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10897#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10898#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10899
10900/*
10901 * BIOS auto configuration
10902 */
10903static int alc262_parse_auto_config(struct hda_codec *codec)
10904{
10905 struct alc_spec *spec = codec->spec;
10906 int err;
10907 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10908
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010909 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10910 alc262_ignore);
10911 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010912 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010913 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010914 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010915 spec->multiout.max_channels = 2;
10916 spec->no_analog = 1;
10917 goto dig_only;
10918 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010919 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010920 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010921 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10922 if (err < 0)
10923 return err;
10924 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10925 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010926 return err;
10927
10928 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10929
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010930 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010931 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010932 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010933 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010934 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010935 if (spec->autocfg.dig_in_pin)
10936 spec->dig_in_nid = ALC262_DIGIN_NID;
10937
Takashi Iwai603c4012008-07-30 15:01:44 +020010938 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010939 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010940
Takashi Iwaid88897e2008-10-31 15:01:37 +010010941 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010942 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010943 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010944
Takashi Iwai776e1842007-08-29 15:07:11 +020010945 err = alc_auto_add_mic_boost(codec);
10946 if (err < 0)
10947 return err;
10948
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010949 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
10950
Kailang Yangdf694da2005-12-05 19:42:22 +010010951 return 1;
10952}
10953
10954#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10955#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10956#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010957#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010958
10959
10960/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010961static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010962{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010963 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010964 alc262_auto_init_multi_out(codec);
10965 alc262_auto_init_hp_out(codec);
10966 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010967 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010968 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010969 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010970}
10971
10972/*
10973 * configuration and preset
10974 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010975static const char *alc262_models[ALC262_MODEL_LAST] = {
10976 [ALC262_BASIC] = "basic",
10977 [ALC262_HIPPO] = "hippo",
10978 [ALC262_HIPPO_1] = "hippo_1",
10979 [ALC262_FUJITSU] = "fujitsu",
10980 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010981 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010982 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010983 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010984 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010985 [ALC262_BENQ_T31] = "benq-t31",
10986 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010987 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010988 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010989 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010990 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010991 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010992 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010993 [ALC262_AUTO] = "auto",
10994};
10995
10996static struct snd_pci_quirk alc262_cfg_tbl[] = {
10997 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010998 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010999 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11000 ALC262_HP_BPC),
11001 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11002 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011003 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11004 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011005 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011006 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011007 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011008 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011009 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011010 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011011 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011012 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011013 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11014 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11015 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011016 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11017 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011018 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011019 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011020 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011021 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011022 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010011023 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11024 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011025 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011026 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011027 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011028 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011029 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011030 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011031 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11032 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011033 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011034 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011035 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011036 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011037 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011038 {}
11039};
11040
11041static struct alc_config_preset alc262_presets[] = {
11042 [ALC262_BASIC] = {
11043 .mixers = { alc262_base_mixer },
11044 .init_verbs = { alc262_init_verbs },
11045 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11046 .dac_nids = alc262_dac_nids,
11047 .hp_nid = 0x03,
11048 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11049 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011050 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011051 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011052 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011053 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020011054 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11055 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11056 .dac_nids = alc262_dac_nids,
11057 .hp_nid = 0x03,
11058 .dig_out_nid = ALC262_DIGOUT_NID,
11059 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11060 .channel_mode = alc262_modes,
11061 .input_mux = &alc262_capture_source,
11062 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011063 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011064 },
11065 [ALC262_HIPPO_1] = {
11066 .mixers = { alc262_hippo1_mixer },
11067 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11068 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11069 .dac_nids = alc262_dac_nids,
11070 .hp_nid = 0x02,
11071 .dig_out_nid = ALC262_DIGOUT_NID,
11072 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11073 .channel_mode = alc262_modes,
11074 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011075 .unsol_event = alc262_hippo_unsol_event,
11076 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011077 },
Takashi Iwai834be882006-03-01 14:16:17 +010011078 [ALC262_FUJITSU] = {
11079 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011080 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11081 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011082 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11083 .dac_nids = alc262_dac_nids,
11084 .hp_nid = 0x03,
11085 .dig_out_nid = ALC262_DIGOUT_NID,
11086 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11087 .channel_mode = alc262_modes,
11088 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011089 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011090 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011091 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011092 [ALC262_HP_BPC] = {
11093 .mixers = { alc262_HP_BPC_mixer },
11094 .init_verbs = { alc262_HP_BPC_init_verbs },
11095 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11096 .dac_nids = alc262_dac_nids,
11097 .hp_nid = 0x03,
11098 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11099 .channel_mode = alc262_modes,
11100 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011101 .unsol_event = alc262_hp_bpc_unsol_event,
11102 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011103 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011104 [ALC262_HP_BPC_D7000_WF] = {
11105 .mixers = { alc262_HP_BPC_WildWest_mixer },
11106 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11107 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11108 .dac_nids = alc262_dac_nids,
11109 .hp_nid = 0x03,
11110 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11111 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011112 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011113 .unsol_event = alc262_hp_wildwest_unsol_event,
11114 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011115 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011116 [ALC262_HP_BPC_D7000_WL] = {
11117 .mixers = { alc262_HP_BPC_WildWest_mixer,
11118 alc262_HP_BPC_WildWest_option_mixer },
11119 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11120 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11121 .dac_nids = alc262_dac_nids,
11122 .hp_nid = 0x03,
11123 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11124 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011125 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011126 .unsol_event = alc262_hp_wildwest_unsol_event,
11127 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011128 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011129 [ALC262_HP_TC_T5735] = {
11130 .mixers = { alc262_hp_t5735_mixer },
11131 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11132 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11133 .dac_nids = alc262_dac_nids,
11134 .hp_nid = 0x03,
11135 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11136 .channel_mode = alc262_modes,
11137 .input_mux = &alc262_capture_source,
11138 .unsol_event = alc262_hp_t5735_unsol_event,
11139 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011140 },
11141 [ALC262_HP_RP5700] = {
11142 .mixers = { alc262_hp_rp5700_mixer },
11143 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11144 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11145 .dac_nids = alc262_dac_nids,
11146 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11147 .channel_mode = alc262_modes,
11148 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011149 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011150 [ALC262_BENQ_ED8] = {
11151 .mixers = { alc262_base_mixer },
11152 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11153 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11154 .dac_nids = alc262_dac_nids,
11155 .hp_nid = 0x03,
11156 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11157 .channel_mode = alc262_modes,
11158 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011159 },
Kailang Yang272a5272007-05-14 11:00:38 +020011160 [ALC262_SONY_ASSAMD] = {
11161 .mixers = { alc262_sony_mixer },
11162 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11163 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11164 .dac_nids = alc262_dac_nids,
11165 .hp_nid = 0x02,
11166 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11167 .channel_mode = alc262_modes,
11168 .input_mux = &alc262_capture_source,
11169 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011170 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011171 },
11172 [ALC262_BENQ_T31] = {
11173 .mixers = { alc262_benq_t31_mixer },
11174 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11175 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11176 .dac_nids = alc262_dac_nids,
11177 .hp_nid = 0x03,
11178 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11179 .channel_mode = alc262_modes,
11180 .input_mux = &alc262_capture_source,
11181 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011182 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011183 },
Tobin Davisf651b502007-10-26 12:40:47 +020011184 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011185 .mixers = { alc262_ultra_mixer },
11186 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011187 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011188 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11189 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011190 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11191 .channel_mode = alc262_modes,
11192 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011193 .adc_nids = alc262_adc_nids, /* ADC0 */
11194 .capsrc_nids = alc262_capsrc_nids,
11195 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011196 .unsol_event = alc262_ultra_unsol_event,
11197 .init_hook = alc262_ultra_automute,
11198 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011199 [ALC262_LENOVO_3000] = {
11200 .mixers = { alc262_lenovo_3000_mixer },
11201 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11202 alc262_lenovo_3000_unsol_verbs },
11203 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11204 .dac_nids = alc262_dac_nids,
11205 .hp_nid = 0x03,
11206 .dig_out_nid = ALC262_DIGOUT_NID,
11207 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11208 .channel_mode = alc262_modes,
11209 .input_mux = &alc262_fujitsu_capture_source,
11210 .unsol_event = alc262_lenovo_3000_unsol_event,
11211 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011212 [ALC262_NEC] = {
11213 .mixers = { alc262_nec_mixer },
11214 .init_verbs = { alc262_nec_verbs },
11215 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11216 .dac_nids = alc262_dac_nids,
11217 .hp_nid = 0x03,
11218 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11219 .channel_mode = alc262_modes,
11220 .input_mux = &alc262_capture_source,
11221 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011222 [ALC262_TOSHIBA_S06] = {
11223 .mixers = { alc262_toshiba_s06_mixer },
11224 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11225 alc262_eapd_verbs },
11226 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11227 .capsrc_nids = alc262_dmic_capsrc_nids,
11228 .dac_nids = alc262_dac_nids,
11229 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11230 .dig_out_nid = ALC262_DIGOUT_NID,
11231 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11232 .channel_mode = alc262_modes,
11233 .input_mux = &alc262_dmic_capture_source,
11234 .unsol_event = alc262_toshiba_s06_unsol_event,
11235 .init_hook = alc262_toshiba_s06_init_hook,
11236 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011237 [ALC262_TOSHIBA_RX1] = {
11238 .mixers = { alc262_toshiba_rx1_mixer },
11239 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11240 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11241 .dac_nids = alc262_dac_nids,
11242 .hp_nid = 0x03,
11243 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11244 .channel_mode = alc262_modes,
11245 .input_mux = &alc262_capture_source,
11246 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011247 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011248 },
Tony Vroonba340e82009-02-02 19:01:30 +000011249 [ALC262_TYAN] = {
11250 .mixers = { alc262_tyan_mixer },
11251 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11252 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11253 .dac_nids = alc262_dac_nids,
11254 .hp_nid = 0x02,
11255 .dig_out_nid = ALC262_DIGOUT_NID,
11256 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11257 .channel_mode = alc262_modes,
11258 .input_mux = &alc262_capture_source,
11259 .unsol_event = alc262_tyan_unsol_event,
11260 .init_hook = alc262_tyan_automute,
11261 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011262};
11263
11264static int patch_alc262(struct hda_codec *codec)
11265{
11266 struct alc_spec *spec;
11267 int board_config;
11268 int err;
11269
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011270 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011271 if (spec == NULL)
11272 return -ENOMEM;
11273
11274 codec->spec = spec;
11275#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011276 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11277 * under-run
11278 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011279 {
11280 int tmp;
11281 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11282 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11283 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11284 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11285 }
11286#endif
11287
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011288 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11289
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011290 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11291 alc262_models,
11292 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011293
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011294 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011295 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11296 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011297 board_config = ALC262_AUTO;
11298 }
11299
11300 if (board_config == ALC262_AUTO) {
11301 /* automatic parse from the BIOS config */
11302 err = alc262_parse_auto_config(codec);
11303 if (err < 0) {
11304 alc_free(codec);
11305 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011306 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011307 printk(KERN_INFO
11308 "hda_codec: Cannot set up configuration "
11309 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011310 board_config = ALC262_BASIC;
11311 }
11312 }
11313
Takashi Iwai07eba612009-02-19 08:06:35 +010011314 if (!spec->no_analog) {
11315 err = snd_hda_attach_beep_device(codec, 0x1);
11316 if (err < 0) {
11317 alc_free(codec);
11318 return err;
11319 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011320 }
11321
Kailang Yangdf694da2005-12-05 19:42:22 +010011322 if (board_config != ALC262_AUTO)
11323 setup_preset(spec, &alc262_presets[board_config]);
11324
11325 spec->stream_name_analog = "ALC262 Analog";
11326 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11327 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011328
Kailang Yangdf694da2005-12-05 19:42:22 +010011329 spec->stream_name_digital = "ALC262 Digital";
11330 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11331 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11332
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011333 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011334 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011335 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011336 unsigned int wcap = get_wcaps(codec, 0x07);
11337
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011338 /* get type */
11339 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011340 if (wcap != AC_WID_AUD_IN) {
11341 spec->adc_nids = alc262_adc_nids_alt;
11342 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011343 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011344 } else {
11345 spec->adc_nids = alc262_adc_nids;
11346 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011347 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011348 }
11349 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011350 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011351 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011352 if (!spec->no_analog)
11353 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011354
Takashi Iwai2134ea42008-01-10 16:53:55 +010011355 spec->vmaster_nid = 0x0c;
11356
Kailang Yangdf694da2005-12-05 19:42:22 +010011357 codec->patch_ops = alc_patch_ops;
11358 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011359 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011360#ifdef CONFIG_SND_HDA_POWER_SAVE
11361 if (!spec->loopback.amplist)
11362 spec->loopback.amplist = alc262_loopbacks;
11363#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011364 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011365
Kailang Yangdf694da2005-12-05 19:42:22 +010011366 return 0;
11367}
11368
Kailang Yangdf694da2005-12-05 19:42:22 +010011369/*
Kailang Yanga361d842007-06-05 12:30:55 +020011370 * ALC268 channel source setting (2 channel)
11371 */
11372#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11373#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011374
Kailang Yanga361d842007-06-05 12:30:55 +020011375static hda_nid_t alc268_dac_nids[2] = {
11376 /* front, hp */
11377 0x02, 0x03
11378};
11379
11380static hda_nid_t alc268_adc_nids[2] = {
11381 /* ADC0-1 */
11382 0x08, 0x07
11383};
11384
11385static hda_nid_t alc268_adc_nids_alt[1] = {
11386 /* ADC0 */
11387 0x08
11388};
11389
Takashi Iwaie1406342008-02-11 18:32:32 +010011390static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11391
Kailang Yanga361d842007-06-05 12:30:55 +020011392static struct snd_kcontrol_new alc268_base_mixer[] = {
11393 /* output mixer control */
11394 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11395 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11396 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11397 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011398 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11399 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11400 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011401 { }
11402};
11403
Takashi Iwai42171c12009-05-08 14:11:43 +020011404static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11405 /* output mixer control */
11406 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11407 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11408 ALC262_HIPPO_MASTER_SWITCH,
11409 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11410 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11411 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11412 { }
11413};
11414
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011415/* bind Beep switches of both NID 0x0f and 0x10 */
11416static struct hda_bind_ctls alc268_bind_beep_sw = {
11417 .ops = &snd_hda_bind_sw,
11418 .values = {
11419 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11420 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11421 0
11422 },
11423};
11424
11425static struct snd_kcontrol_new alc268_beep_mixer[] = {
11426 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11427 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11428 { }
11429};
11430
Kailang Yangd1a991a2007-08-15 16:21:59 +020011431static struct hda_verb alc268_eapd_verbs[] = {
11432 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11433 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11434 { }
11435};
11436
Takashi Iwaid2738092007-08-16 14:59:45 +020011437/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011438static struct hda_verb alc268_toshiba_verbs[] = {
11439 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11440 { } /* end */
11441};
11442
Kailang Yang8ef355d2008-08-26 13:10:22 +020011443static struct hda_input_mux alc268_acer_lc_capture_source = {
11444 .num_items = 2,
11445 .items = {
11446 { "i-Mic", 0x6 },
11447 { "E-Mic", 0x0 },
11448 },
11449};
11450
Takashi Iwaid2738092007-08-16 14:59:45 +020011451/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011452/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011453static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11454 .ops = &snd_hda_bind_vol,
11455 .values = {
11456 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11457 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11458 0
11459 },
11460};
11461
Takashi Iwai889c4392007-08-23 18:56:52 +020011462/* mute/unmute internal speaker according to the hp jack and mute state */
11463static void alc268_acer_automute(struct hda_codec *codec, int force)
11464{
11465 struct alc_spec *spec = codec->spec;
11466 unsigned int mute;
11467
11468 if (force || !spec->sense_updated) {
11469 unsigned int present;
11470 present = snd_hda_codec_read(codec, 0x14, 0,
11471 AC_VERB_GET_PIN_SENSE, 0);
11472 spec->jack_present = (present & 0x80000000) != 0;
11473 spec->sense_updated = 1;
11474 }
11475 if (spec->jack_present)
11476 mute = HDA_AMP_MUTE; /* mute internal speaker */
11477 else /* unmute internal speaker if necessary */
11478 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11479 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11480 HDA_AMP_MUTE, mute);
11481}
11482
11483
11484/* bind hp and internal speaker mute (with plug check) */
11485static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11486 struct snd_ctl_elem_value *ucontrol)
11487{
11488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11489 long *valp = ucontrol->value.integer.value;
11490 int change;
11491
11492 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11493 HDA_AMP_MUTE,
11494 valp[0] ? 0 : HDA_AMP_MUTE);
11495 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11496 HDA_AMP_MUTE,
11497 valp[1] ? 0 : HDA_AMP_MUTE);
11498 if (change)
11499 alc268_acer_automute(codec, 0);
11500 return change;
11501}
Takashi Iwaid2738092007-08-16 14:59:45 +020011502
Kailang Yang8ef355d2008-08-26 13:10:22 +020011503static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11504 /* output mixer control */
11505 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11506 {
11507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11508 .name = "Master Playback Switch",
11509 .info = snd_hda_mixer_amp_switch_info,
11510 .get = snd_hda_mixer_amp_switch_get,
11511 .put = alc268_acer_master_sw_put,
11512 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11513 },
11514 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11515 { }
11516};
11517
Takashi Iwaid2738092007-08-16 14:59:45 +020011518static struct snd_kcontrol_new alc268_acer_mixer[] = {
11519 /* output mixer control */
11520 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11521 {
11522 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11523 .name = "Master Playback Switch",
11524 .info = snd_hda_mixer_amp_switch_info,
11525 .get = snd_hda_mixer_amp_switch_get,
11526 .put = alc268_acer_master_sw_put,
11527 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11528 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011529 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11530 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11531 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011532 { }
11533};
11534
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011535static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11536 /* output mixer control */
11537 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11538 {
11539 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11540 .name = "Master Playback Switch",
11541 .info = snd_hda_mixer_amp_switch_info,
11542 .get = snd_hda_mixer_amp_switch_get,
11543 .put = alc268_acer_master_sw_put,
11544 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11545 },
11546 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11547 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11548 { }
11549};
11550
Kailang Yang8ef355d2008-08-26 13:10:22 +020011551static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11552 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11553 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11554 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11555 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11556 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11557 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11558 { }
11559};
11560
Takashi Iwaid2738092007-08-16 14:59:45 +020011561static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011562 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11563 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011564 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11565 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011566 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11567 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011568 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11569 { }
11570};
11571
11572/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011573#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11574#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011575
11576static void alc268_acer_unsol_event(struct hda_codec *codec,
11577 unsigned int res)
11578{
Takashi Iwai889c4392007-08-23 18:56:52 +020011579 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011580 return;
11581 alc268_acer_automute(codec, 1);
11582}
11583
Takashi Iwai889c4392007-08-23 18:56:52 +020011584static void alc268_acer_init_hook(struct hda_codec *codec)
11585{
11586 alc268_acer_automute(codec, 1);
11587}
11588
Kailang Yang8ef355d2008-08-26 13:10:22 +020011589/* toggle speaker-output according to the hp-jack state */
11590static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11591{
11592 unsigned int present;
11593 unsigned char bits;
11594
11595 present = snd_hda_codec_read(codec, 0x15, 0,
11596 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11597 bits = present ? AMP_IN_MUTE(0) : 0;
11598 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11599 AMP_IN_MUTE(0), bits);
11600 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11601 AMP_IN_MUTE(0), bits);
11602}
11603
11604
11605static void alc268_acer_mic_automute(struct hda_codec *codec)
11606{
11607 unsigned int present;
11608
11609 present = snd_hda_codec_read(codec, 0x18, 0,
11610 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11611 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11612 present ? 0x0 : 0x6);
11613}
11614
11615static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11616 unsigned int res)
11617{
11618 if ((res >> 26) == ALC880_HP_EVENT)
11619 alc268_aspire_one_speaker_automute(codec);
11620 if ((res >> 26) == ALC880_MIC_EVENT)
11621 alc268_acer_mic_automute(codec);
11622}
11623
11624static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11625{
11626 alc268_aspire_one_speaker_automute(codec);
11627 alc268_acer_mic_automute(codec);
11628}
11629
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011630static struct snd_kcontrol_new alc268_dell_mixer[] = {
11631 /* output mixer control */
11632 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11633 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11634 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11635 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11636 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11637 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11638 { }
11639};
11640
11641static struct hda_verb alc268_dell_verbs[] = {
11642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11643 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11644 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11645 { }
11646};
11647
11648/* mute/unmute internal speaker according to the hp jack and mute state */
11649static void alc268_dell_automute(struct hda_codec *codec)
11650{
11651 unsigned int present;
11652 unsigned int mute;
11653
11654 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11655 if (present & 0x80000000)
11656 mute = HDA_AMP_MUTE;
11657 else
11658 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11659 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11660 HDA_AMP_MUTE, mute);
11661}
11662
11663static void alc268_dell_unsol_event(struct hda_codec *codec,
11664 unsigned int res)
11665{
11666 if ((res >> 26) != ALC880_HP_EVENT)
11667 return;
11668 alc268_dell_automute(codec);
11669}
11670
11671#define alc268_dell_init_hook alc268_dell_automute
11672
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011673static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11674 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11675 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11676 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11678 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11679 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11680 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11681 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11682 { }
11683};
11684
11685static struct hda_verb alc267_quanta_il1_verbs[] = {
11686 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11687 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11688 { }
11689};
11690
11691static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11692{
11693 unsigned int present;
11694
11695 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11696 & AC_PINSENSE_PRESENCE;
11697 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11698 present ? 0 : PIN_OUT);
11699}
11700
11701static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11702{
11703 unsigned int present;
11704
11705 present = snd_hda_codec_read(codec, 0x18, 0,
11706 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11707 snd_hda_codec_write(codec, 0x23, 0,
11708 AC_VERB_SET_CONNECT_SEL,
11709 present ? 0x00 : 0x01);
11710}
11711
11712static void alc267_quanta_il1_automute(struct hda_codec *codec)
11713{
11714 alc267_quanta_il1_hp_automute(codec);
11715 alc267_quanta_il1_mic_automute(codec);
11716}
11717
11718static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11719 unsigned int res)
11720{
11721 switch (res >> 26) {
11722 case ALC880_HP_EVENT:
11723 alc267_quanta_il1_hp_automute(codec);
11724 break;
11725 case ALC880_MIC_EVENT:
11726 alc267_quanta_il1_mic_automute(codec);
11727 break;
11728 }
11729}
11730
Kailang Yanga361d842007-06-05 12:30:55 +020011731/*
11732 * generic initialization of ADC, input mixers and output mixers
11733 */
11734static struct hda_verb alc268_base_init_verbs[] = {
11735 /* Unmute DAC0-1 and set vol = 0 */
11736 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011737 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011738
11739 /*
11740 * Set up output mixers (0x0c - 0x0e)
11741 */
11742 /* set vol=0 to output mixers */
11743 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011744 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11745
11746 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11747 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11748
11749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11750 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11751 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11752 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11753 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11754 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11755 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11756 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11757
11758 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11759 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11760 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11761 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011762 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011763
11764 /* set PCBEEP vol = 0, mute connections */
11765 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11766 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11767 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011768
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011769 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011770
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011771 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11772 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11773 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11774 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011775
Kailang Yanga361d842007-06-05 12:30:55 +020011776 { }
11777};
11778
11779/*
11780 * generic initialization of ADC, input mixers and output mixers
11781 */
11782static struct hda_verb alc268_volume_init_verbs[] = {
11783 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011784 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11785 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011786
11787 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11788 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11789 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11790 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11791 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11792
Kailang Yanga361d842007-06-05 12:30:55 +020011793 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011794 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11795 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11796
11797 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011798 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011799
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011800 /* set PCBEEP vol = 0, mute connections */
11801 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11802 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11803 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011804
11805 { }
11806};
11807
Kailang Yanga361d842007-06-05 12:30:55 +020011808static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11809 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11810 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11811 {
11812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11813 /* The multiple "Capture Source" controls confuse alsamixer
11814 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011815 */
11816 /* .name = "Capture Source", */
11817 .name = "Input Source",
11818 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011819 .info = alc_mux_enum_info,
11820 .get = alc_mux_enum_get,
11821 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011822 },
11823 { } /* end */
11824};
11825
11826static struct snd_kcontrol_new alc268_capture_mixer[] = {
11827 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11828 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11829 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11830 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11831 {
11832 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11833 /* The multiple "Capture Source" controls confuse alsamixer
11834 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011835 */
11836 /* .name = "Capture Source", */
11837 .name = "Input Source",
11838 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011839 .info = alc_mux_enum_info,
11840 .get = alc_mux_enum_get,
11841 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011842 },
11843 { } /* end */
11844};
11845
11846static struct hda_input_mux alc268_capture_source = {
11847 .num_items = 4,
11848 .items = {
11849 { "Mic", 0x0 },
11850 { "Front Mic", 0x1 },
11851 { "Line", 0x2 },
11852 { "CD", 0x3 },
11853 },
11854};
11855
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011856static struct hda_input_mux alc268_acer_capture_source = {
11857 .num_items = 3,
11858 .items = {
11859 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011860 { "Internal Mic", 0x1 },
11861 { "Line", 0x2 },
11862 },
11863};
11864
11865static struct hda_input_mux alc268_acer_dmic_capture_source = {
11866 .num_items = 3,
11867 .items = {
11868 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011869 { "Internal Mic", 0x6 },
11870 { "Line", 0x2 },
11871 },
11872};
11873
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011874#ifdef CONFIG_SND_DEBUG
11875static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011876 /* Volume widgets */
11877 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11878 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11879 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11880 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11881 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11882 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11883 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11884 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11885 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11886 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11887 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11888 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11889 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011890 /* The below appears problematic on some hardwares */
11891 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011892 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11893 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11894 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11895 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11896
11897 /* Modes for retasking pin widgets */
11898 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11899 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11900 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11901 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11902
11903 /* Controls for GPIO pins, assuming they are configured as outputs */
11904 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11905 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11906 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11907 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11908
11909 /* Switches to allow the digital SPDIF output pin to be enabled.
11910 * The ALC268 does not have an SPDIF input.
11911 */
11912 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11913
11914 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11915 * this output to turn on an external amplifier.
11916 */
11917 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11918 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11919
11920 { } /* end */
11921};
11922#endif
11923
Kailang Yanga361d842007-06-05 12:30:55 +020011924/* create input playback/capture controls for the given pin */
11925static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11926 const char *ctlname, int idx)
11927{
11928 char name[32];
11929 int err;
11930
11931 sprintf(name, "%s Playback Volume", ctlname);
11932 if (nid == 0x14) {
11933 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11934 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11935 HDA_OUTPUT));
11936 if (err < 0)
11937 return err;
11938 } else if (nid == 0x15) {
11939 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11940 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11941 HDA_OUTPUT));
11942 if (err < 0)
11943 return err;
11944 } else
11945 return -1;
11946 sprintf(name, "%s Playback Switch", ctlname);
11947 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11948 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11949 if (err < 0)
11950 return err;
11951 return 0;
11952}
11953
11954/* add playback controls from the parsed DAC table */
11955static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11956 const struct auto_pin_cfg *cfg)
11957{
11958 hda_nid_t nid;
11959 int err;
11960
11961 spec->multiout.num_dacs = 2; /* only use one dac */
11962 spec->multiout.dac_nids = spec->private_dac_nids;
11963 spec->multiout.dac_nids[0] = 2;
11964 spec->multiout.dac_nids[1] = 3;
11965
11966 nid = cfg->line_out_pins[0];
11967 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011968 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011969
11970 nid = cfg->speaker_pins[0];
11971 if (nid == 0x1d) {
11972 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11973 "Speaker Playback Volume",
11974 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11975 if (err < 0)
11976 return err;
11977 }
11978 nid = cfg->hp_pins[0];
11979 if (nid)
11980 alc268_new_analog_output(spec, nid, "Headphone", 0);
11981
11982 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11983 if (nid == 0x16) {
11984 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11985 "Mono Playback Switch",
11986 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11987 if (err < 0)
11988 return err;
11989 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011990 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011991}
11992
11993/* create playback/capture controls for input pins */
11994static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11995 const struct auto_pin_cfg *cfg)
11996{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011997 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011998 int i, idx1;
11999
12000 for (i = 0; i < AUTO_PIN_LAST; i++) {
12001 switch(cfg->input_pins[i]) {
12002 case 0x18:
12003 idx1 = 0; /* Mic 1 */
12004 break;
12005 case 0x19:
12006 idx1 = 1; /* Mic 2 */
12007 break;
12008 case 0x1a:
12009 idx1 = 2; /* Line In */
12010 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012011 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012012 idx1 = 3; /* CD */
12013 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012014 case 0x12:
12015 case 0x13:
12016 idx1 = 6; /* digital mics */
12017 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012018 default:
12019 continue;
12020 }
12021 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12022 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012023 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012024 }
12025 return 0;
12026}
12027
12028static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12029{
12030 struct alc_spec *spec = codec->spec;
12031 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12032 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12033 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12034 unsigned int dac_vol1, dac_vol2;
12035
12036 if (speaker_nid) {
12037 snd_hda_codec_write(codec, speaker_nid, 0,
12038 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12039 snd_hda_codec_write(codec, 0x0f, 0,
12040 AC_VERB_SET_AMP_GAIN_MUTE,
12041 AMP_IN_UNMUTE(1));
12042 snd_hda_codec_write(codec, 0x10, 0,
12043 AC_VERB_SET_AMP_GAIN_MUTE,
12044 AMP_IN_UNMUTE(1));
12045 } else {
12046 snd_hda_codec_write(codec, 0x0f, 0,
12047 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12048 snd_hda_codec_write(codec, 0x10, 0,
12049 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12050 }
12051
12052 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012053 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012054 dac_vol2 = AMP_OUT_ZERO;
12055 else if (line_nid == 0x15)
12056 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012057 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012058 dac_vol2 = AMP_OUT_ZERO;
12059 else if (hp_nid == 0x15)
12060 dac_vol1 = AMP_OUT_ZERO;
12061 if (line_nid != 0x16 || hp_nid != 0x16 ||
12062 spec->autocfg.line_out_pins[1] != 0x16 ||
12063 spec->autocfg.line_out_pins[2] != 0x16)
12064 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12065
12066 snd_hda_codec_write(codec, 0x02, 0,
12067 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12068 snd_hda_codec_write(codec, 0x03, 0,
12069 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12070}
12071
12072/* pcm configuration: identiacal with ALC880 */
12073#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12074#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012075#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012076#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12077
12078/*
12079 * BIOS auto configuration
12080 */
12081static int alc268_parse_auto_config(struct hda_codec *codec)
12082{
12083 struct alc_spec *spec = codec->spec;
12084 int err;
12085 static hda_nid_t alc268_ignore[] = { 0 };
12086
12087 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12088 alc268_ignore);
12089 if (err < 0)
12090 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012091 if (!spec->autocfg.line_outs) {
12092 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12093 spec->multiout.max_channels = 2;
12094 spec->no_analog = 1;
12095 goto dig_only;
12096 }
Kailang Yanga361d842007-06-05 12:30:55 +020012097 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012098 }
Kailang Yanga361d842007-06-05 12:30:55 +020012099 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12100 if (err < 0)
12101 return err;
12102 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12103 if (err < 0)
12104 return err;
12105
12106 spec->multiout.max_channels = 2;
12107
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012108 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012109 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012110 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012111 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012112 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12113 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012114 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012115 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012116
Takashi Iwai892981f2009-03-02 08:04:35 +010012117 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012118 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012119
Takashi Iwaid88897e2008-10-31 15:01:37 +010012120 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012121 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012122 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012123
Takashi Iwai776e1842007-08-29 15:07:11 +020012124 err = alc_auto_add_mic_boost(codec);
12125 if (err < 0)
12126 return err;
12127
Kailang Yanga361d842007-06-05 12:30:55 +020012128 return 1;
12129}
12130
12131#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12132#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12133#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12134
12135/* init callback for auto-configuration model -- overriding the default init */
12136static void alc268_auto_init(struct hda_codec *codec)
12137{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012138 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012139 alc268_auto_init_multi_out(codec);
12140 alc268_auto_init_hp_out(codec);
12141 alc268_auto_init_mono_speaker_out(codec);
12142 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012143 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012144 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012145}
12146
12147/*
12148 * configuration and preset
12149 */
12150static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012151 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012152 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012153 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012154 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012155 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012156 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012157 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012158 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012159#ifdef CONFIG_SND_DEBUG
12160 [ALC268_TEST] = "test",
12161#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012162 [ALC268_AUTO] = "auto",
12163};
12164
12165static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012166 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012167 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012168 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012169 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012170 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012171 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12172 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012173 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012174 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012175 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012176 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020012177 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020012178 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020012179 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012180 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012181 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012182 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012183 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012184 {}
12185};
12186
12187static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012188 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012189 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012190 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12191 alc267_quanta_il1_verbs },
12192 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12193 .dac_nids = alc268_dac_nids,
12194 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12195 .adc_nids = alc268_adc_nids_alt,
12196 .hp_nid = 0x03,
12197 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12198 .channel_mode = alc268_modes,
12199 .input_mux = &alc268_capture_source,
12200 .unsol_event = alc267_quanta_il1_unsol_event,
12201 .init_hook = alc267_quanta_il1_automute,
12202 },
Kailang Yanga361d842007-06-05 12:30:55 +020012203 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012204 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12205 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012206 .init_verbs = { alc268_base_init_verbs },
12207 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12208 .dac_nids = alc268_dac_nids,
12209 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12210 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012211 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012212 .hp_nid = 0x03,
12213 .dig_out_nid = ALC268_DIGOUT_NID,
12214 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12215 .channel_mode = alc268_modes,
12216 .input_mux = &alc268_capture_source,
12217 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012218 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012219 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012220 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012221 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12222 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012223 .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 Yangd1a991a2007-08-15 16:21:59 +020012228 .hp_nid = 0x03,
12229 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12230 .channel_mode = alc268_modes,
12231 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012232 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012233 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012234 },
12235 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012236 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12237 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012238 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12239 alc268_acer_verbs },
12240 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12241 .dac_nids = alc268_dac_nids,
12242 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12243 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012244 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012245 .hp_nid = 0x02,
12246 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12247 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012248 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012249 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012250 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012251 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012252 [ALC268_ACER_DMIC] = {
12253 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12254 alc268_beep_mixer },
12255 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12256 alc268_acer_verbs },
12257 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12258 .dac_nids = alc268_dac_nids,
12259 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12260 .adc_nids = alc268_adc_nids_alt,
12261 .capsrc_nids = alc268_capsrc_nids,
12262 .hp_nid = 0x02,
12263 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12264 .channel_mode = alc268_modes,
12265 .input_mux = &alc268_acer_dmic_capture_source,
12266 .unsol_event = alc268_acer_unsol_event,
12267 .init_hook = alc268_acer_init_hook,
12268 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012269 [ALC268_ACER_ASPIRE_ONE] = {
12270 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012271 alc268_beep_mixer,
12272 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012273 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12274 alc268_acer_aspire_one_verbs },
12275 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12276 .dac_nids = alc268_dac_nids,
12277 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12278 .adc_nids = alc268_adc_nids_alt,
12279 .capsrc_nids = alc268_capsrc_nids,
12280 .hp_nid = 0x03,
12281 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12282 .channel_mode = alc268_modes,
12283 .input_mux = &alc268_acer_lc_capture_source,
12284 .unsol_event = alc268_acer_lc_unsol_event,
12285 .init_hook = alc268_acer_lc_init_hook,
12286 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012287 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012288 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012289 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12290 alc268_dell_verbs },
12291 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12292 .dac_nids = alc268_dac_nids,
12293 .hp_nid = 0x02,
12294 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12295 .channel_mode = alc268_modes,
12296 .unsol_event = alc268_dell_unsol_event,
12297 .init_hook = alc268_dell_init_hook,
12298 .input_mux = &alc268_capture_source,
12299 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012300 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012301 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12302 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012303 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12304 alc268_toshiba_verbs },
12305 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12306 .dac_nids = alc268_dac_nids,
12307 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12308 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012309 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012310 .hp_nid = 0x03,
12311 .dig_out_nid = ALC268_DIGOUT_NID,
12312 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12313 .channel_mode = alc268_modes,
12314 .input_mux = &alc268_capture_source,
12315 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012316 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012317 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012318#ifdef CONFIG_SND_DEBUG
12319 [ALC268_TEST] = {
12320 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12321 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12322 alc268_volume_init_verbs },
12323 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12324 .dac_nids = alc268_dac_nids,
12325 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12326 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012327 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012328 .hp_nid = 0x03,
12329 .dig_out_nid = ALC268_DIGOUT_NID,
12330 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12331 .channel_mode = alc268_modes,
12332 .input_mux = &alc268_capture_source,
12333 },
12334#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012335};
12336
12337static int patch_alc268(struct hda_codec *codec)
12338{
12339 struct alc_spec *spec;
12340 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012341 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012342
12343 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12344 if (spec == NULL)
12345 return -ENOMEM;
12346
12347 codec->spec = spec;
12348
12349 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12350 alc268_models,
12351 alc268_cfg_tbl);
12352
12353 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12354 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12355 "trying auto-probe from BIOS...\n");
12356 board_config = ALC268_AUTO;
12357 }
12358
12359 if (board_config == ALC268_AUTO) {
12360 /* automatic parse from the BIOS config */
12361 err = alc268_parse_auto_config(codec);
12362 if (err < 0) {
12363 alc_free(codec);
12364 return err;
12365 } else if (!err) {
12366 printk(KERN_INFO
12367 "hda_codec: Cannot set up configuration "
12368 "from BIOS. Using base mode...\n");
12369 board_config = ALC268_3ST;
12370 }
12371 }
12372
12373 if (board_config != ALC268_AUTO)
12374 setup_preset(spec, &alc268_presets[board_config]);
12375
Kailang Yang2f893282008-05-27 12:14:47 +020012376 if (codec->vendor_id == 0x10ec0267) {
12377 spec->stream_name_analog = "ALC267 Analog";
12378 spec->stream_name_digital = "ALC267 Digital";
12379 } else {
12380 spec->stream_name_analog = "ALC268 Analog";
12381 spec->stream_name_digital = "ALC268 Digital";
12382 }
12383
Kailang Yanga361d842007-06-05 12:30:55 +020012384 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12385 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012386 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012387
Kailang Yanga361d842007-06-05 12:30:55 +020012388 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12389
Takashi Iwai22971e32009-02-10 11:56:44 +010012390 has_beep = 0;
12391 for (i = 0; i < spec->num_mixers; i++) {
12392 if (spec->mixers[i] == alc268_beep_mixer) {
12393 has_beep = 1;
12394 break;
12395 }
12396 }
12397
12398 if (has_beep) {
12399 err = snd_hda_attach_beep_device(codec, 0x1);
12400 if (err < 0) {
12401 alc_free(codec);
12402 return err;
12403 }
12404 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12405 /* override the amp caps for beep generator */
12406 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012407 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12408 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12409 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12410 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012411 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012412
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012413 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012414 /* check whether NID 0x07 is valid */
12415 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012416 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012417
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012418 /* get type */
12419 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012420 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012421 spec->adc_nids = alc268_adc_nids_alt;
12422 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012423 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012424 } else {
12425 spec->adc_nids = alc268_adc_nids;
12426 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012427 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012428 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012429 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012430 /* set default input source */
12431 for (i = 0; i < spec->num_adc_nids; i++)
12432 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12433 0, AC_VERB_SET_CONNECT_SEL,
12434 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012435 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012436
12437 spec->vmaster_nid = 0x02;
12438
Kailang Yanga361d842007-06-05 12:30:55 +020012439 codec->patch_ops = alc_patch_ops;
12440 if (board_config == ALC268_AUTO)
12441 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012442
Takashi Iwaidaead532008-11-28 12:55:36 +010012443 codec->proc_widget_hook = print_realtek_coef;
12444
Kailang Yanga361d842007-06-05 12:30:55 +020012445 return 0;
12446}
12447
12448/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012449 * ALC269 channel source setting (2 channel)
12450 */
12451#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12452
12453#define alc269_dac_nids alc260_dac_nids
12454
12455static hda_nid_t alc269_adc_nids[1] = {
12456 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012457 0x08,
12458};
12459
Takashi Iwaie01bf502008-08-21 16:25:07 +020012460static hda_nid_t alc269_capsrc_nids[1] = {
12461 0x23,
12462};
12463
12464/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12465 * not a mux!
12466 */
12467
Kailang Yangf53281e2008-07-18 12:36:43 +020012468static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12469 .num_items = 2,
12470 .items = {
12471 { "i-Mic", 0x5 },
12472 { "e-Mic", 0x0 },
12473 },
12474};
12475
12476static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12477 .num_items = 2,
12478 .items = {
12479 { "i-Mic", 0x1 },
12480 { "e-Mic", 0x0 },
12481 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012482};
12483
12484#define alc269_modes alc260_modes
12485#define alc269_capture_source alc880_lg_lw_capture_source
12486
12487static struct snd_kcontrol_new alc269_base_mixer[] = {
12488 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12489 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12490 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12491 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12492 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12493 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12494 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12495 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12496 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12497 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12498 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12499 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12500 { } /* end */
12501};
12502
Kailang Yang60db6b52008-08-26 13:13:00 +020012503static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12504 /* output mixer control */
12505 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12506 {
12507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12508 .name = "Master Playback Switch",
12509 .info = snd_hda_mixer_amp_switch_info,
12510 .get = snd_hda_mixer_amp_switch_get,
12511 .put = alc268_acer_master_sw_put,
12512 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12513 },
12514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12515 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12516 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12517 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12518 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12519 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012520 { }
12521};
12522
Tony Vroon64154832008-11-06 15:08:49 +000012523static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12524 /* output mixer control */
12525 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12526 {
12527 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12528 .name = "Master Playback Switch",
12529 .info = snd_hda_mixer_amp_switch_info,
12530 .get = snd_hda_mixer_amp_switch_get,
12531 .put = alc268_acer_master_sw_put,
12532 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12533 },
12534 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12535 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12536 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12537 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12538 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12539 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12540 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12541 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12542 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012543 { }
12544};
12545
Kailang Yangf53281e2008-07-18 12:36:43 +020012546/* bind volumes of both NID 0x0c and 0x0d */
12547static struct hda_bind_ctls alc269_epc_bind_vol = {
12548 .ops = &snd_hda_bind_vol,
12549 .values = {
12550 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12551 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12552 0
12553 },
12554};
12555
12556static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12557 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12558 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12559 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12560 { } /* end */
12561};
12562
Kailang Yangf6a92242007-12-13 16:52:54 +010012563/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012564static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12565 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12566 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012567 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12568 { } /* end */
12569};
12570
12571/* FSC amilo */
12572static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12573 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12574 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12575 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012576 { } /* end */
12577};
12578
Kailang Yang60db6b52008-08-26 13:13:00 +020012579static struct hda_verb alc269_quanta_fl1_verbs[] = {
12580 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12581 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12582 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12583 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12584 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12585 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12586 { }
12587};
12588
Tony Vroon64154832008-11-06 15:08:49 +000012589static struct hda_verb alc269_lifebook_verbs[] = {
12590 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12591 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12592 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12593 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12594 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12595 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12596 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12597 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12598 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12599 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12600 { }
12601};
12602
Kailang Yang60db6b52008-08-26 13:13:00 +020012603/* toggle speaker-output according to the hp-jack state */
12604static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12605{
12606 unsigned int present;
12607 unsigned char bits;
12608
12609 present = snd_hda_codec_read(codec, 0x15, 0,
12610 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12611 bits = present ? AMP_IN_MUTE(0) : 0;
12612 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12613 AMP_IN_MUTE(0), bits);
12614 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12615 AMP_IN_MUTE(0), bits);
12616
12617 snd_hda_codec_write(codec, 0x20, 0,
12618 AC_VERB_SET_COEF_INDEX, 0x0c);
12619 snd_hda_codec_write(codec, 0x20, 0,
12620 AC_VERB_SET_PROC_COEF, 0x680);
12621
12622 snd_hda_codec_write(codec, 0x20, 0,
12623 AC_VERB_SET_COEF_INDEX, 0x0c);
12624 snd_hda_codec_write(codec, 0x20, 0,
12625 AC_VERB_SET_PROC_COEF, 0x480);
12626}
12627
Tony Vroon64154832008-11-06 15:08:49 +000012628/* toggle speaker-output according to the hp-jacks state */
12629static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12630{
12631 unsigned int present;
12632 unsigned char bits;
12633
12634 /* Check laptop headphone socket */
12635 present = snd_hda_codec_read(codec, 0x15, 0,
12636 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12637
12638 /* Check port replicator headphone socket */
12639 present |= snd_hda_codec_read(codec, 0x1a, 0,
12640 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12641
12642 bits = present ? AMP_IN_MUTE(0) : 0;
12643 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12644 AMP_IN_MUTE(0), bits);
12645 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12646 AMP_IN_MUTE(0), bits);
12647
12648 snd_hda_codec_write(codec, 0x20, 0,
12649 AC_VERB_SET_COEF_INDEX, 0x0c);
12650 snd_hda_codec_write(codec, 0x20, 0,
12651 AC_VERB_SET_PROC_COEF, 0x680);
12652
12653 snd_hda_codec_write(codec, 0x20, 0,
12654 AC_VERB_SET_COEF_INDEX, 0x0c);
12655 snd_hda_codec_write(codec, 0x20, 0,
12656 AC_VERB_SET_PROC_COEF, 0x480);
12657}
12658
Kailang Yang60db6b52008-08-26 13:13:00 +020012659static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12660{
12661 unsigned int present;
12662
12663 present = snd_hda_codec_read(codec, 0x18, 0,
12664 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12665 snd_hda_codec_write(codec, 0x23, 0,
12666 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12667}
12668
Tony Vroon64154832008-11-06 15:08:49 +000012669static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12670{
12671 unsigned int present_laptop;
12672 unsigned int present_dock;
12673
12674 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12675 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12676
12677 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12678 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12679
12680 /* Laptop mic port overrides dock mic port, design decision */
12681 if (present_dock)
12682 snd_hda_codec_write(codec, 0x23, 0,
12683 AC_VERB_SET_CONNECT_SEL, 0x3);
12684 if (present_laptop)
12685 snd_hda_codec_write(codec, 0x23, 0,
12686 AC_VERB_SET_CONNECT_SEL, 0x0);
12687 if (!present_dock && !present_laptop)
12688 snd_hda_codec_write(codec, 0x23, 0,
12689 AC_VERB_SET_CONNECT_SEL, 0x1);
12690}
12691
Kailang Yang60db6b52008-08-26 13:13:00 +020012692static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12693 unsigned int res)
12694{
12695 if ((res >> 26) == ALC880_HP_EVENT)
12696 alc269_quanta_fl1_speaker_automute(codec);
12697 if ((res >> 26) == ALC880_MIC_EVENT)
12698 alc269_quanta_fl1_mic_automute(codec);
12699}
12700
Tony Vroon64154832008-11-06 15:08:49 +000012701static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12702 unsigned int res)
12703{
12704 if ((res >> 26) == ALC880_HP_EVENT)
12705 alc269_lifebook_speaker_automute(codec);
12706 if ((res >> 26) == ALC880_MIC_EVENT)
12707 alc269_lifebook_mic_autoswitch(codec);
12708}
12709
Kailang Yang60db6b52008-08-26 13:13:00 +020012710static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12711{
12712 alc269_quanta_fl1_speaker_automute(codec);
12713 alc269_quanta_fl1_mic_automute(codec);
12714}
12715
Tony Vroon64154832008-11-06 15:08:49 +000012716static void alc269_lifebook_init_hook(struct hda_codec *codec)
12717{
12718 alc269_lifebook_speaker_automute(codec);
12719 alc269_lifebook_mic_autoswitch(codec);
12720}
12721
Kailang Yang60db6b52008-08-26 13:13:00 +020012722static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12723 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12724 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12725 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12726 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12727 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12728 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12729 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12730 {}
12731};
12732
12733static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12734 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12735 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12736 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12737 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12738 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12739 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12740 {}
12741};
12742
12743/* toggle speaker-output according to the hp-jack state */
12744static void alc269_speaker_automute(struct hda_codec *codec)
12745{
12746 unsigned int present;
12747 unsigned char bits;
12748
12749 present = snd_hda_codec_read(codec, 0x15, 0,
12750 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12751 bits = present ? AMP_IN_MUTE(0) : 0;
12752 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12753 AMP_IN_MUTE(0), bits);
12754 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12755 AMP_IN_MUTE(0), bits);
12756}
12757
12758static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12759{
12760 unsigned int present;
12761
12762 present = snd_hda_codec_read(codec, 0x18, 0,
12763 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12764 snd_hda_codec_write(codec, 0x23, 0,
12765 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12766}
12767
12768static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12769{
12770 unsigned int present;
12771
12772 present = snd_hda_codec_read(codec, 0x18, 0,
12773 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12774 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12775 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12776 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12777 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12778}
12779
12780/* unsolicited event for HP jack sensing */
12781static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12782 unsigned int res)
12783{
12784 if ((res >> 26) == ALC880_HP_EVENT)
12785 alc269_speaker_automute(codec);
12786
12787 if ((res >> 26) == ALC880_MIC_EVENT)
12788 alc269_eeepc_dmic_automute(codec);
12789}
12790
12791static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12792{
12793 alc269_speaker_automute(codec);
12794 alc269_eeepc_dmic_automute(codec);
12795}
12796
12797/* unsolicited event for HP jack sensing */
12798static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12799 unsigned int res)
12800{
12801 if ((res >> 26) == ALC880_HP_EVENT)
12802 alc269_speaker_automute(codec);
12803
12804 if ((res >> 26) == ALC880_MIC_EVENT)
12805 alc269_eeepc_amic_automute(codec);
12806}
12807
12808static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12809{
12810 alc269_speaker_automute(codec);
12811 alc269_eeepc_amic_automute(codec);
12812}
12813
Kailang Yangf6a92242007-12-13 16:52:54 +010012814/*
12815 * generic initialization of ADC, input mixers and output mixers
12816 */
12817static struct hda_verb alc269_init_verbs[] = {
12818 /*
12819 * Unmute ADC0 and set the default input to mic-in
12820 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012822
12823 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12824 * analog-loopback mixer widget
12825 * Note: PASD motherboards uses the Line In 2 as the input for
12826 * front panel mic (mic 2)
12827 */
12828 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12831 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12834
12835 /*
12836 * Set up output mixers (0x0c - 0x0e)
12837 */
12838 /* set vol=0 to output mixers */
12839 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12840 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12841
12842 /* set up input amps for analog loopback */
12843 /* Amp Indices: DAC = 0, mixer = 1 */
12844 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12845 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12846 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12847 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12848 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12849 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12850
12851 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12852 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12853 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12854 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12855 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12856 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12857 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12858
12859 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12861 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12862 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12863 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12864 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12865 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12866
12867 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12868 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12869
12870 /* FIXME: use matrix-type input source selection */
12871 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12872 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012873 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12874 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012875 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12876 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12877
12878 /* set EAPD */
12879 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12880 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12881 { }
12882};
12883
12884/* add playback controls from the parsed DAC table */
12885static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12886 const struct auto_pin_cfg *cfg)
12887{
12888 hda_nid_t nid;
12889 int err;
12890
12891 spec->multiout.num_dacs = 1; /* only use one dac */
12892 spec->multiout.dac_nids = spec->private_dac_nids;
12893 spec->multiout.dac_nids[0] = 2;
12894
12895 nid = cfg->line_out_pins[0];
12896 if (nid) {
12897 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12898 "Front Playback Volume",
12899 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12900 if (err < 0)
12901 return err;
12902 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12903 "Front Playback Switch",
12904 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12905 if (err < 0)
12906 return err;
12907 }
12908
12909 nid = cfg->speaker_pins[0];
12910 if (nid) {
12911 if (!cfg->line_out_pins[0]) {
12912 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12913 "Speaker Playback Volume",
12914 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12915 HDA_OUTPUT));
12916 if (err < 0)
12917 return err;
12918 }
12919 if (nid == 0x16) {
12920 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12921 "Speaker Playback Switch",
12922 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12923 HDA_OUTPUT));
12924 if (err < 0)
12925 return err;
12926 } else {
12927 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12928 "Speaker Playback Switch",
12929 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12930 HDA_OUTPUT));
12931 if (err < 0)
12932 return err;
12933 }
12934 }
12935 nid = cfg->hp_pins[0];
12936 if (nid) {
12937 /* spec->multiout.hp_nid = 2; */
12938 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12939 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12940 "Headphone Playback Volume",
12941 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12942 HDA_OUTPUT));
12943 if (err < 0)
12944 return err;
12945 }
12946 if (nid == 0x16) {
12947 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12948 "Headphone Playback Switch",
12949 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12950 HDA_OUTPUT));
12951 if (err < 0)
12952 return err;
12953 } else {
12954 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12955 "Headphone Playback Switch",
12956 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12957 HDA_OUTPUT));
12958 if (err < 0)
12959 return err;
12960 }
12961 }
12962 return 0;
12963}
12964
Takashi Iwaiee956e02008-10-31 17:16:31 +010012965static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12966 const struct auto_pin_cfg *cfg)
12967{
12968 int err;
12969
12970 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12971 if (err < 0)
12972 return err;
12973 /* digital-mic input pin is excluded in alc880_auto_create..()
12974 * because it's under 0x18
12975 */
12976 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12977 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012978 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012979 imux->items[imux->num_items].label = "Int Mic";
12980 imux->items[imux->num_items].index = 0x05;
12981 imux->num_items++;
12982 }
12983 return 0;
12984}
Kailang Yangf6a92242007-12-13 16:52:54 +010012985
12986#ifdef CONFIG_SND_HDA_POWER_SAVE
12987#define alc269_loopbacks alc880_loopbacks
12988#endif
12989
12990/* pcm configuration: identiacal with ALC880 */
12991#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12992#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12993#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12994#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12995
Takashi Iwaif03d3112009-03-05 14:18:16 +010012996static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12997 .substreams = 1,
12998 .channels_min = 2,
12999 .channels_max = 8,
13000 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13001 /* NID is set in alc_build_pcms */
13002 .ops = {
13003 .open = alc880_playback_pcm_open,
13004 .prepare = alc880_playback_pcm_prepare,
13005 .cleanup = alc880_playback_pcm_cleanup
13006 },
13007};
13008
13009static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13010 .substreams = 1,
13011 .channels_min = 2,
13012 .channels_max = 2,
13013 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13014 /* NID is set in alc_build_pcms */
13015};
13016
Kailang Yangf6a92242007-12-13 16:52:54 +010013017/*
13018 * BIOS auto configuration
13019 */
13020static int alc269_parse_auto_config(struct hda_codec *codec)
13021{
13022 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013023 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013024 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13025
13026 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13027 alc269_ignore);
13028 if (err < 0)
13029 return err;
13030
13031 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13032 if (err < 0)
13033 return err;
13034 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13035 if (err < 0)
13036 return err;
13037
13038 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13039
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013040 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013041 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13042
Takashi Iwai603c4012008-07-30 15:01:44 +020013043 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013044 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013045
Takashi Iwaid88897e2008-10-31 15:01:37 +010013046 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013047 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013048 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013049 /* set default input source */
13050 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13051 0, AC_VERB_SET_CONNECT_SEL,
13052 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013053
13054 err = alc_auto_add_mic_boost(codec);
13055 if (err < 0)
13056 return err;
13057
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013058 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013059 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013060
Kailang Yangf6a92242007-12-13 16:52:54 +010013061 return 1;
13062}
13063
13064#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13065#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13066#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13067
13068
13069/* init callback for auto-configuration model -- overriding the default init */
13070static void alc269_auto_init(struct hda_codec *codec)
13071{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013072 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013073 alc269_auto_init_multi_out(codec);
13074 alc269_auto_init_hp_out(codec);
13075 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013076 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013077 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013078}
13079
13080/*
13081 * configuration and preset
13082 */
13083static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013084 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013085 [ALC269_QUANTA_FL1] = "quanta",
13086 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013087 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013088 [ALC269_FUJITSU] = "fujitsu",
13089 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013090};
13091
13092static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013093 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013094 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13095 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013096 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13097 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13098 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13099 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13100 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13101 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013102 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13103 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013104 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13105 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013106 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013107 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013108 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013109 {}
13110};
13111
13112static struct alc_config_preset alc269_presets[] = {
13113 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013114 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013115 .init_verbs = { alc269_init_verbs },
13116 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13117 .dac_nids = alc269_dac_nids,
13118 .hp_nid = 0x03,
13119 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13120 .channel_mode = alc269_modes,
13121 .input_mux = &alc269_capture_source,
13122 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013123 [ALC269_QUANTA_FL1] = {
13124 .mixers = { alc269_quanta_fl1_mixer },
13125 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13126 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13127 .dac_nids = alc269_dac_nids,
13128 .hp_nid = 0x03,
13129 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13130 .channel_mode = alc269_modes,
13131 .input_mux = &alc269_capture_source,
13132 .unsol_event = alc269_quanta_fl1_unsol_event,
13133 .init_hook = alc269_quanta_fl1_init_hook,
13134 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013135 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013136 .mixers = { alc269_eeepc_mixer },
13137 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013138 .init_verbs = { alc269_init_verbs,
13139 alc269_eeepc_amic_init_verbs },
13140 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13141 .dac_nids = alc269_dac_nids,
13142 .hp_nid = 0x03,
13143 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13144 .channel_mode = alc269_modes,
13145 .input_mux = &alc269_eeepc_amic_capture_source,
13146 .unsol_event = alc269_eeepc_amic_unsol_event,
13147 .init_hook = alc269_eeepc_amic_inithook,
13148 },
13149 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013150 .mixers = { alc269_eeepc_mixer },
13151 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013152 .init_verbs = { alc269_init_verbs,
13153 alc269_eeepc_dmic_init_verbs },
13154 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13155 .dac_nids = alc269_dac_nids,
13156 .hp_nid = 0x03,
13157 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13158 .channel_mode = alc269_modes,
13159 .input_mux = &alc269_eeepc_dmic_capture_source,
13160 .unsol_event = alc269_eeepc_dmic_unsol_event,
13161 .init_hook = alc269_eeepc_dmic_inithook,
13162 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013163 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013164 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013165 .cap_mixer = alc269_epc_capture_mixer,
13166 .init_verbs = { alc269_init_verbs,
13167 alc269_eeepc_dmic_init_verbs },
13168 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13169 .dac_nids = alc269_dac_nids,
13170 .hp_nid = 0x03,
13171 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13172 .channel_mode = alc269_modes,
13173 .input_mux = &alc269_eeepc_dmic_capture_source,
13174 .unsol_event = alc269_eeepc_dmic_unsol_event,
13175 .init_hook = alc269_eeepc_dmic_inithook,
13176 },
Tony Vroon64154832008-11-06 15:08:49 +000013177 [ALC269_LIFEBOOK] = {
13178 .mixers = { alc269_lifebook_mixer },
13179 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13180 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13181 .dac_nids = alc269_dac_nids,
13182 .hp_nid = 0x03,
13183 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13184 .channel_mode = alc269_modes,
13185 .input_mux = &alc269_capture_source,
13186 .unsol_event = alc269_lifebook_unsol_event,
13187 .init_hook = alc269_lifebook_init_hook,
13188 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013189};
13190
13191static int patch_alc269(struct hda_codec *codec)
13192{
13193 struct alc_spec *spec;
13194 int board_config;
13195 int err;
13196
13197 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13198 if (spec == NULL)
13199 return -ENOMEM;
13200
13201 codec->spec = spec;
13202
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013203 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13204
Kailang Yangf6a92242007-12-13 16:52:54 +010013205 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13206 alc269_models,
13207 alc269_cfg_tbl);
13208
13209 if (board_config < 0) {
13210 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
13211 "trying auto-probe from BIOS...\n");
13212 board_config = ALC269_AUTO;
13213 }
13214
13215 if (board_config == ALC269_AUTO) {
13216 /* automatic parse from the BIOS config */
13217 err = alc269_parse_auto_config(codec);
13218 if (err < 0) {
13219 alc_free(codec);
13220 return err;
13221 } else if (!err) {
13222 printk(KERN_INFO
13223 "hda_codec: Cannot set up configuration "
13224 "from BIOS. Using base mode...\n");
13225 board_config = ALC269_BASIC;
13226 }
13227 }
13228
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013229 err = snd_hda_attach_beep_device(codec, 0x1);
13230 if (err < 0) {
13231 alc_free(codec);
13232 return err;
13233 }
13234
Kailang Yangf6a92242007-12-13 16:52:54 +010013235 if (board_config != ALC269_AUTO)
13236 setup_preset(spec, &alc269_presets[board_config]);
13237
13238 spec->stream_name_analog = "ALC269 Analog";
Takashi Iwaif03d3112009-03-05 14:18:16 +010013239 if (codec->subsystem_id == 0x17aa3bf8) {
13240 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13241 * fix the sample rate of analog I/O to 44.1kHz
13242 */
13243 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13244 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13245 } else {
13246 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13247 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13248 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013249 spec->stream_name_digital = "ALC269 Digital";
13250 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13251 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13252
13253 spec->adc_nids = alc269_adc_nids;
13254 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013255 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013256 if (!spec->cap_mixer)
13257 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013258 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013259
13260 codec->patch_ops = alc_patch_ops;
13261 if (board_config == ALC269_AUTO)
13262 spec->init_hook = alc269_auto_init;
13263#ifdef CONFIG_SND_HDA_POWER_SAVE
13264 if (!spec->loopback.amplist)
13265 spec->loopback.amplist = alc269_loopbacks;
13266#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013267 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013268
13269 return 0;
13270}
13271
13272/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013273 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13274 */
13275
13276/*
13277 * set the path ways for 2 channel output
13278 * need to set the codec line out and mic 1 pin widgets to inputs
13279 */
13280static struct hda_verb alc861_threestack_ch2_init[] = {
13281 /* set pin widget 1Ah (line in) for input */
13282 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013283 /* set pin widget 18h (mic1/2) for input, for mic also enable
13284 * the vref
13285 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013286 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13287
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013288 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13289#if 0
13290 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13291 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13292#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013293 { } /* end */
13294};
13295/*
13296 * 6ch mode
13297 * need to set the codec line out and mic 1 pin widgets to outputs
13298 */
13299static struct hda_verb alc861_threestack_ch6_init[] = {
13300 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13301 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13302 /* set pin widget 18h (mic1) for output (CLFE)*/
13303 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13304
13305 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013306 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013307
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013308 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13309#if 0
13310 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13311 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13312#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013313 { } /* end */
13314};
13315
13316static struct hda_channel_mode alc861_threestack_modes[2] = {
13317 { 2, alc861_threestack_ch2_init },
13318 { 6, alc861_threestack_ch6_init },
13319};
Takashi Iwai22309c32006-08-09 16:57:28 +020013320/* Set mic1 as input and unmute the mixer */
13321static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13322 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13323 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13324 { } /* end */
13325};
13326/* Set mic1 as output and mute mixer */
13327static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13328 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13329 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13330 { } /* end */
13331};
13332
13333static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13334 { 2, alc861_uniwill_m31_ch2_init },
13335 { 4, alc861_uniwill_m31_ch4_init },
13336};
Kailang Yangdf694da2005-12-05 19:42:22 +010013337
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013338/* Set mic1 and line-in as input and unmute the mixer */
13339static struct hda_verb alc861_asus_ch2_init[] = {
13340 /* set pin widget 1Ah (line in) for input */
13341 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013342 /* set pin widget 18h (mic1/2) for input, for mic also enable
13343 * the vref
13344 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013345 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13346
13347 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13348#if 0
13349 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13350 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13351#endif
13352 { } /* end */
13353};
13354/* Set mic1 nad line-in as output and mute mixer */
13355static struct hda_verb alc861_asus_ch6_init[] = {
13356 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13357 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13358 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13359 /* set pin widget 18h (mic1) for output (CLFE)*/
13360 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13361 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13362 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13363 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13364
13365 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13366#if 0
13367 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13368 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13369#endif
13370 { } /* end */
13371};
13372
13373static struct hda_channel_mode alc861_asus_modes[2] = {
13374 { 2, alc861_asus_ch2_init },
13375 { 6, alc861_asus_ch6_init },
13376};
13377
Kailang Yangdf694da2005-12-05 19:42:22 +010013378/* patch-ALC861 */
13379
13380static struct snd_kcontrol_new alc861_base_mixer[] = {
13381 /* output mixer control */
13382 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13383 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13384 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13385 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13386 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13387
13388 /*Input mixer control */
13389 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13390 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13391 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13392 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13393 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13394 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13395 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13396 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13397 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13398 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013399
Kailang Yangdf694da2005-12-05 19:42:22 +010013400 { } /* end */
13401};
13402
13403static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13404 /* output mixer control */
13405 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13406 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13407 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13408 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13409 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13410
13411 /* Input mixer control */
13412 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13413 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13414 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13415 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13416 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13417 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13419 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13420 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13421 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013422
Kailang Yangdf694da2005-12-05 19:42:22 +010013423 {
13424 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13425 .name = "Channel Mode",
13426 .info = alc_ch_mode_info,
13427 .get = alc_ch_mode_get,
13428 .put = alc_ch_mode_put,
13429 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13430 },
13431 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013432};
13433
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013434static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013435 /* output mixer control */
13436 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13438 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013439
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013440 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013441};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013442
Takashi Iwai22309c32006-08-09 16:57:28 +020013443static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13444 /* output mixer control */
13445 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13446 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13447 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13448 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13449 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13450
13451 /* Input mixer control */
13452 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13453 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13454 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13455 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13456 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13457 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13459 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13460 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13461 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013462
Takashi Iwai22309c32006-08-09 16:57:28 +020013463 {
13464 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13465 .name = "Channel Mode",
13466 .info = alc_ch_mode_info,
13467 .get = alc_ch_mode_get,
13468 .put = alc_ch_mode_put,
13469 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13470 },
13471 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013472};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013473
13474static struct snd_kcontrol_new alc861_asus_mixer[] = {
13475 /* output mixer control */
13476 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13477 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13478 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13479 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13480 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13481
13482 /* Input mixer control */
13483 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13484 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13485 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13486 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13487 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13488 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13489 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13490 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13491 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013492 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13493
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013494 {
13495 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13496 .name = "Channel Mode",
13497 .info = alc_ch_mode_info,
13498 .get = alc_ch_mode_get,
13499 .put = alc_ch_mode_put,
13500 .private_value = ARRAY_SIZE(alc861_asus_modes),
13501 },
13502 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013503};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013504
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013505/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013506static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013507 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13508 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013509 { }
13510};
13511
Kailang Yangdf694da2005-12-05 19:42:22 +010013512/*
13513 * generic initialization of ADC, input mixers and output mixers
13514 */
13515static struct hda_verb alc861_base_init_verbs[] = {
13516 /*
13517 * Unmute ADC0 and set the default input to mic-in
13518 */
13519 /* port-A for surround (rear panel) */
13520 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13521 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13522 /* port-B for mic-in (rear panel) with vref */
13523 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13524 /* port-C for line-in (rear panel) */
13525 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13526 /* port-D for Front */
13527 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13528 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13529 /* port-E for HP out (front panel) */
13530 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13531 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013532 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013533 /* port-F for mic-in (front panel) with vref */
13534 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13535 /* port-G for CLFE (rear panel) */
13536 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13537 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13538 /* port-H for side (rear panel) */
13539 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13540 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13541 /* CD-in */
13542 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13543 /* route front mic to ADC1*/
13544 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13545 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013546
Kailang Yangdf694da2005-12-05 19:42:22 +010013547 /* Unmute DAC0~3 & spdif out*/
13548 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13549 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13550 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13551 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013553
Kailang Yangdf694da2005-12-05 19:42:22 +010013554 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13555 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13556 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13557 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13558 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013559
Kailang Yangdf694da2005-12-05 19:42:22 +010013560 /* Unmute Stereo Mixer 15 */
13561 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013565
13566 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13567 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13568 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13569 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13570 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13571 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13572 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13573 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013574 /* hp used DAC 3 (Front) */
13575 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13577
13578 { }
13579};
13580
13581static struct hda_verb alc861_threestack_init_verbs[] = {
13582 /*
13583 * Unmute ADC0 and set the default input to mic-in
13584 */
13585 /* port-A for surround (rear panel) */
13586 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13587 /* port-B for mic-in (rear panel) with vref */
13588 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13589 /* port-C for line-in (rear panel) */
13590 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13591 /* port-D for Front */
13592 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13593 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13594 /* port-E for HP out (front panel) */
13595 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13596 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013597 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013598 /* port-F for mic-in (front panel) with vref */
13599 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13600 /* port-G for CLFE (rear panel) */
13601 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13602 /* port-H for side (rear panel) */
13603 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13604 /* CD-in */
13605 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13606 /* route front mic to ADC1*/
13607 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13608 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13609 /* Unmute DAC0~3 & spdif out*/
13610 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13611 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13612 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13613 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013615
Kailang Yangdf694da2005-12-05 19:42:22 +010013616 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13617 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13618 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13619 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13620 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013621
Kailang Yangdf694da2005-12-05 19:42:22 +010013622 /* Unmute Stereo Mixer 15 */
13623 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013626 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013627
13628 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13629 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13630 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13631 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13632 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13633 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13634 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13635 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013636 /* hp used DAC 3 (Front) */
13637 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013638 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13639 { }
13640};
Takashi Iwai22309c32006-08-09 16:57:28 +020013641
13642static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13643 /*
13644 * Unmute ADC0 and set the default input to mic-in
13645 */
13646 /* port-A for surround (rear panel) */
13647 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13648 /* port-B for mic-in (rear panel) with vref */
13649 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13650 /* port-C for line-in (rear panel) */
13651 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13652 /* port-D for Front */
13653 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13654 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13655 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013656 /* this has to be set to VREF80 */
13657 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013658 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013659 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013660 /* port-F for mic-in (front panel) with vref */
13661 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13662 /* port-G for CLFE (rear panel) */
13663 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13664 /* port-H for side (rear panel) */
13665 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13666 /* CD-in */
13667 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13668 /* route front mic to ADC1*/
13669 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13670 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13671 /* Unmute DAC0~3 & spdif out*/
13672 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13673 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13674 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13675 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013677
Takashi Iwai22309c32006-08-09 16:57:28 +020013678 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13679 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13680 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13681 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13682 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013683
Takashi Iwai22309c32006-08-09 16:57:28 +020013684 /* Unmute Stereo Mixer 15 */
13685 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13686 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13687 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013688 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013689
13690 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13691 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13692 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13693 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13694 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13695 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13696 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13697 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013698 /* hp used DAC 3 (Front) */
13699 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013700 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13701 { }
13702};
13703
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013704static struct hda_verb alc861_asus_init_verbs[] = {
13705 /*
13706 * Unmute ADC0 and set the default input to mic-in
13707 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013708 /* port-A for surround (rear panel)
13709 * according to codec#0 this is the HP jack
13710 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013711 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13712 /* route front PCM to HP */
13713 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13714 /* port-B for mic-in (rear panel) with vref */
13715 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13716 /* port-C for line-in (rear panel) */
13717 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13718 /* port-D for Front */
13719 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13720 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13721 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013722 /* this has to be set to VREF80 */
13723 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013724 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013725 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013726 /* port-F for mic-in (front panel) with vref */
13727 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13728 /* port-G for CLFE (rear panel) */
13729 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13730 /* port-H for side (rear panel) */
13731 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13732 /* CD-in */
13733 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13734 /* route front mic to ADC1*/
13735 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13736 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13737 /* Unmute DAC0~3 & spdif out*/
13738 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13739 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13740 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13741 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13742 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13743 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13744 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13745 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13746 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13747 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013748
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013749 /* Unmute Stereo Mixer 15 */
13750 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13751 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013753 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013754
13755 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13756 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13757 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13758 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13759 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13760 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13761 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13762 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013763 /* hp used DAC 3 (Front) */
13764 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013765 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13766 { }
13767};
13768
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013769/* additional init verbs for ASUS laptops */
13770static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13771 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13772 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13773 { }
13774};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013775
Kailang Yangdf694da2005-12-05 19:42:22 +010013776/*
13777 * generic initialization of ADC, input mixers and output mixers
13778 */
13779static struct hda_verb alc861_auto_init_verbs[] = {
13780 /*
13781 * Unmute ADC0 and set the default input to mic-in
13782 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013783 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013784 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013785
Kailang Yangdf694da2005-12-05 19:42:22 +010013786 /* Unmute DAC0~3 & spdif out*/
13787 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13788 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13789 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13790 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13791 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013792
Kailang Yangdf694da2005-12-05 19:42:22 +010013793 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13794 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13795 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13796 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13797 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013798
Kailang Yangdf694da2005-12-05 19:42:22 +010013799 /* Unmute Stereo Mixer 15 */
13800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13802 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13803 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13804
13805 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13806 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13807 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13808 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13809 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13810 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13811 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13812 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13813
13814 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13815 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013816 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13817 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013818 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13819 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013820 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13821 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013822
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013823 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013824
13825 { }
13826};
13827
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013828static struct hda_verb alc861_toshiba_init_verbs[] = {
13829 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013830
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013831 { }
13832};
13833
13834/* toggle speaker-output according to the hp-jack state */
13835static void alc861_toshiba_automute(struct hda_codec *codec)
13836{
13837 unsigned int present;
13838
13839 present = snd_hda_codec_read(codec, 0x0f, 0,
13840 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013841 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13842 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13843 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13844 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013845}
13846
13847static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13848 unsigned int res)
13849{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013850 if ((res >> 26) == ALC880_HP_EVENT)
13851 alc861_toshiba_automute(codec);
13852}
13853
Kailang Yangdf694da2005-12-05 19:42:22 +010013854/* pcm configuration: identiacal with ALC880 */
13855#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13856#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13857#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13858#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13859
13860
13861#define ALC861_DIGOUT_NID 0x07
13862
13863static struct hda_channel_mode alc861_8ch_modes[1] = {
13864 { 8, NULL }
13865};
13866
13867static hda_nid_t alc861_dac_nids[4] = {
13868 /* front, surround, clfe, side */
13869 0x03, 0x06, 0x05, 0x04
13870};
13871
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013872static hda_nid_t alc660_dac_nids[3] = {
13873 /* front, clfe, surround */
13874 0x03, 0x05, 0x06
13875};
13876
Kailang Yangdf694da2005-12-05 19:42:22 +010013877static hda_nid_t alc861_adc_nids[1] = {
13878 /* ADC0-2 */
13879 0x08,
13880};
13881
13882static struct hda_input_mux alc861_capture_source = {
13883 .num_items = 5,
13884 .items = {
13885 { "Mic", 0x0 },
13886 { "Front Mic", 0x3 },
13887 { "Line", 0x1 },
13888 { "CD", 0x4 },
13889 { "Mixer", 0x5 },
13890 },
13891};
13892
13893/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013894static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13895 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013896{
13897 int i;
13898 hda_nid_t nid;
13899
13900 spec->multiout.dac_nids = spec->private_dac_nids;
13901 for (i = 0; i < cfg->line_outs; i++) {
13902 nid = cfg->line_out_pins[i];
13903 if (nid) {
13904 if (i >= ARRAY_SIZE(alc861_dac_nids))
13905 continue;
13906 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13907 }
13908 }
13909 spec->multiout.num_dacs = cfg->line_outs;
13910 return 0;
13911}
13912
13913/* add playback controls from the parsed DAC table */
13914static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13915 const struct auto_pin_cfg *cfg)
13916{
13917 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013918 static const char *chname[4] = {
13919 "Front", "Surround", NULL /*CLFE*/, "Side"
13920 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013921 hda_nid_t nid;
13922 int i, idx, err;
13923
13924 for (i = 0; i < cfg->line_outs; i++) {
13925 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013926 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013927 continue;
13928 if (nid == 0x05) {
13929 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013930 err = add_control(spec, ALC_CTL_BIND_MUTE,
13931 "Center Playback Switch",
13932 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13933 HDA_OUTPUT));
13934 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013935 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013936 err = add_control(spec, ALC_CTL_BIND_MUTE,
13937 "LFE Playback Switch",
13938 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13939 HDA_OUTPUT));
13940 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013941 return err;
13942 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013943 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13944 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013945 if (nid == alc861_dac_nids[idx])
13946 break;
13947 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013948 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13949 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13950 HDA_OUTPUT));
13951 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013952 return err;
13953 }
13954 }
13955 return 0;
13956}
13957
13958static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13959{
13960 int err;
13961 hda_nid_t nid;
13962
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013963 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013964 return 0;
13965
13966 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13967 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013968 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13969 "Headphone Playback Switch",
13970 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13971 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013972 return err;
13973 spec->multiout.hp_nid = nid;
13974 }
13975 return 0;
13976}
13977
13978/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013979static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13980 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013981{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013982 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013983 int i, err, idx, idx1;
13984
13985 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013986 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013987 case 0x0c:
13988 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013989 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013990 break;
13991 case 0x0f:
13992 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013993 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013994 break;
13995 case 0x0d:
13996 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013997 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013998 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013999 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014000 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014001 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014002 break;
14003 case 0x11:
14004 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014005 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014006 break;
14007 default:
14008 continue;
14009 }
14010
Takashi Iwai4a471b72005-12-07 13:56:29 +010014011 err = new_analog_input(spec, cfg->input_pins[i],
14012 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014013 if (err < 0)
14014 return err;
14015
Takashi Iwai4a471b72005-12-07 13:56:29 +010014016 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014017 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014018 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014019 }
14020 return 0;
14021}
14022
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014023static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14024 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010014025 int pin_type, int dac_idx)
14026{
Jacek Luczak564c5be2008-05-03 18:41:23 +020014027 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14028 pin_type);
14029 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14030 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010014031}
14032
14033static void alc861_auto_init_multi_out(struct hda_codec *codec)
14034{
14035 struct alc_spec *spec = codec->spec;
14036 int i;
14037
14038 for (i = 0; i < spec->autocfg.line_outs; i++) {
14039 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014040 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014041 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014042 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014043 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014044 }
14045}
14046
14047static void alc861_auto_init_hp_out(struct hda_codec *codec)
14048{
14049 struct alc_spec *spec = codec->spec;
14050 hda_nid_t pin;
14051
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014052 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014053 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014054 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14055 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014056 pin = spec->autocfg.speaker_pins[0];
14057 if (pin)
14058 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014059}
14060
14061static void alc861_auto_init_analog_input(struct hda_codec *codec)
14062{
14063 struct alc_spec *spec = codec->spec;
14064 int i;
14065
14066 for (i = 0; i < AUTO_PIN_LAST; i++) {
14067 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014068 if (nid >= 0x0c && nid <= 0x11)
14069 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014070 }
14071}
14072
14073/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014074/* return 1 if successful, 0 if the proper config is not found,
14075 * or a negative error code
14076 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014077static int alc861_parse_auto_config(struct hda_codec *codec)
14078{
14079 struct alc_spec *spec = codec->spec;
14080 int err;
14081 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14082
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014083 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14084 alc861_ignore);
14085 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014086 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014087 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014088 return 0; /* can't find valid BIOS pin config */
14089
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014090 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14091 if (err < 0)
14092 return err;
14093 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14094 if (err < 0)
14095 return err;
14096 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14097 if (err < 0)
14098 return err;
14099 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14100 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014101 return err;
14102
14103 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14104
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014105 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014106 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14107
Takashi Iwai603c4012008-07-30 15:01:44 +020014108 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014109 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014110
Takashi Iwaid88897e2008-10-31 15:01:37 +010014111 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014112
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014113 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014114 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014115
14116 spec->adc_nids = alc861_adc_nids;
14117 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014118 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014119
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014120 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14121
Kailang Yangdf694da2005-12-05 19:42:22 +010014122 return 1;
14123}
14124
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014125/* additional initialization for auto-configuration model */
14126static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014127{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014128 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014129 alc861_auto_init_multi_out(codec);
14130 alc861_auto_init_hp_out(codec);
14131 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014132 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014133 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014134}
14135
Takashi Iwaicb53c622007-08-10 17:21:45 +020014136#ifdef CONFIG_SND_HDA_POWER_SAVE
14137static struct hda_amp_list alc861_loopbacks[] = {
14138 { 0x15, HDA_INPUT, 0 },
14139 { 0x15, HDA_INPUT, 1 },
14140 { 0x15, HDA_INPUT, 2 },
14141 { 0x15, HDA_INPUT, 3 },
14142 { } /* end */
14143};
14144#endif
14145
Kailang Yangdf694da2005-12-05 19:42:22 +010014146
14147/*
14148 * configuration and preset
14149 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014150static const char *alc861_models[ALC861_MODEL_LAST] = {
14151 [ALC861_3ST] = "3stack",
14152 [ALC660_3ST] = "3stack-660",
14153 [ALC861_3ST_DIG] = "3stack-dig",
14154 [ALC861_6ST_DIG] = "6stack-dig",
14155 [ALC861_UNIWILL_M31] = "uniwill-m31",
14156 [ALC861_TOSHIBA] = "toshiba",
14157 [ALC861_ASUS] = "asus",
14158 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14159 [ALC861_AUTO] = "auto",
14160};
14161
14162static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014163 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014164 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14165 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14166 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014167 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014168 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014169 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014170 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14171 * Any other models that need this preset?
14172 */
14173 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014174 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14175 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014176 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14177 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14178 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14179 /* FIXME: the below seems conflict */
14180 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14181 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14182 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014183 {}
14184};
14185
14186static struct alc_config_preset alc861_presets[] = {
14187 [ALC861_3ST] = {
14188 .mixers = { alc861_3ST_mixer },
14189 .init_verbs = { alc861_threestack_init_verbs },
14190 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14191 .dac_nids = alc861_dac_nids,
14192 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14193 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014194 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014195 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14196 .adc_nids = alc861_adc_nids,
14197 .input_mux = &alc861_capture_source,
14198 },
14199 [ALC861_3ST_DIG] = {
14200 .mixers = { alc861_base_mixer },
14201 .init_verbs = { alc861_threestack_init_verbs },
14202 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14203 .dac_nids = alc861_dac_nids,
14204 .dig_out_nid = ALC861_DIGOUT_NID,
14205 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14206 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014207 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014208 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14209 .adc_nids = alc861_adc_nids,
14210 .input_mux = &alc861_capture_source,
14211 },
14212 [ALC861_6ST_DIG] = {
14213 .mixers = { alc861_base_mixer },
14214 .init_verbs = { alc861_base_init_verbs },
14215 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14216 .dac_nids = alc861_dac_nids,
14217 .dig_out_nid = ALC861_DIGOUT_NID,
14218 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14219 .channel_mode = alc861_8ch_modes,
14220 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14221 .adc_nids = alc861_adc_nids,
14222 .input_mux = &alc861_capture_source,
14223 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014224 [ALC660_3ST] = {
14225 .mixers = { alc861_3ST_mixer },
14226 .init_verbs = { alc861_threestack_init_verbs },
14227 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14228 .dac_nids = alc660_dac_nids,
14229 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14230 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014231 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014232 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14233 .adc_nids = alc861_adc_nids,
14234 .input_mux = &alc861_capture_source,
14235 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014236 [ALC861_UNIWILL_M31] = {
14237 .mixers = { alc861_uniwill_m31_mixer },
14238 .init_verbs = { alc861_uniwill_m31_init_verbs },
14239 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14240 .dac_nids = alc861_dac_nids,
14241 .dig_out_nid = ALC861_DIGOUT_NID,
14242 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14243 .channel_mode = alc861_uniwill_m31_modes,
14244 .need_dac_fix = 1,
14245 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14246 .adc_nids = alc861_adc_nids,
14247 .input_mux = &alc861_capture_source,
14248 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014249 [ALC861_TOSHIBA] = {
14250 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014251 .init_verbs = { alc861_base_init_verbs,
14252 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014253 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14254 .dac_nids = alc861_dac_nids,
14255 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14256 .channel_mode = alc883_3ST_2ch_modes,
14257 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14258 .adc_nids = alc861_adc_nids,
14259 .input_mux = &alc861_capture_source,
14260 .unsol_event = alc861_toshiba_unsol_event,
14261 .init_hook = alc861_toshiba_automute,
14262 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014263 [ALC861_ASUS] = {
14264 .mixers = { alc861_asus_mixer },
14265 .init_verbs = { alc861_asus_init_verbs },
14266 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14267 .dac_nids = alc861_dac_nids,
14268 .dig_out_nid = ALC861_DIGOUT_NID,
14269 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14270 .channel_mode = alc861_asus_modes,
14271 .need_dac_fix = 1,
14272 .hp_nid = 0x06,
14273 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14274 .adc_nids = alc861_adc_nids,
14275 .input_mux = &alc861_capture_source,
14276 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014277 [ALC861_ASUS_LAPTOP] = {
14278 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14279 .init_verbs = { alc861_asus_init_verbs,
14280 alc861_asus_laptop_init_verbs },
14281 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14282 .dac_nids = alc861_dac_nids,
14283 .dig_out_nid = ALC861_DIGOUT_NID,
14284 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14285 .channel_mode = alc883_3ST_2ch_modes,
14286 .need_dac_fix = 1,
14287 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14288 .adc_nids = alc861_adc_nids,
14289 .input_mux = &alc861_capture_source,
14290 },
14291};
Kailang Yangdf694da2005-12-05 19:42:22 +010014292
14293
14294static int patch_alc861(struct hda_codec *codec)
14295{
14296 struct alc_spec *spec;
14297 int board_config;
14298 int err;
14299
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014300 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014301 if (spec == NULL)
14302 return -ENOMEM;
14303
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014304 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014305
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014306 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14307 alc861_models,
14308 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014309
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014310 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014311 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14312 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014313 board_config = ALC861_AUTO;
14314 }
14315
14316 if (board_config == ALC861_AUTO) {
14317 /* automatic parse from the BIOS config */
14318 err = alc861_parse_auto_config(codec);
14319 if (err < 0) {
14320 alc_free(codec);
14321 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014322 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014323 printk(KERN_INFO
14324 "hda_codec: Cannot set up configuration "
14325 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014326 board_config = ALC861_3ST_DIG;
14327 }
14328 }
14329
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014330 err = snd_hda_attach_beep_device(codec, 0x23);
14331 if (err < 0) {
14332 alc_free(codec);
14333 return err;
14334 }
14335
Kailang Yangdf694da2005-12-05 19:42:22 +010014336 if (board_config != ALC861_AUTO)
14337 setup_preset(spec, &alc861_presets[board_config]);
14338
14339 spec->stream_name_analog = "ALC861 Analog";
14340 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14341 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14342
14343 spec->stream_name_digital = "ALC861 Digital";
14344 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14345 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14346
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014347 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14348
Takashi Iwai2134ea42008-01-10 16:53:55 +010014349 spec->vmaster_nid = 0x03;
14350
Kailang Yangdf694da2005-12-05 19:42:22 +010014351 codec->patch_ops = alc_patch_ops;
14352 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014353 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014354#ifdef CONFIG_SND_HDA_POWER_SAVE
14355 if (!spec->loopback.amplist)
14356 spec->loopback.amplist = alc861_loopbacks;
14357#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014358 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014359
Kailang Yangdf694da2005-12-05 19:42:22 +010014360 return 0;
14361}
14362
14363/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014364 * ALC861-VD support
14365 *
14366 * Based on ALC882
14367 *
14368 * In addition, an independent DAC
14369 */
14370#define ALC861VD_DIGOUT_NID 0x06
14371
14372static hda_nid_t alc861vd_dac_nids[4] = {
14373 /* front, surr, clfe, side surr */
14374 0x02, 0x03, 0x04, 0x05
14375};
14376
14377/* dac_nids for ALC660vd are in a different order - according to
14378 * Realtek's driver.
14379 * This should probably tesult in a different mixer for 6stack models
14380 * of ALC660vd codecs, but for now there is only 3stack mixer
14381 * - and it is the same as in 861vd.
14382 * adc_nids in ALC660vd are (is) the same as in 861vd
14383 */
14384static hda_nid_t alc660vd_dac_nids[3] = {
14385 /* front, rear, clfe, rear_surr */
14386 0x02, 0x04, 0x03
14387};
14388
14389static hda_nid_t alc861vd_adc_nids[1] = {
14390 /* ADC0 */
14391 0x09,
14392};
14393
Takashi Iwaie1406342008-02-11 18:32:32 +010014394static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14395
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014396/* input MUX */
14397/* FIXME: should be a matrix-type input source selection */
14398static struct hda_input_mux alc861vd_capture_source = {
14399 .num_items = 4,
14400 .items = {
14401 { "Mic", 0x0 },
14402 { "Front Mic", 0x1 },
14403 { "Line", 0x2 },
14404 { "CD", 0x4 },
14405 },
14406};
14407
Kailang Yang272a5272007-05-14 11:00:38 +020014408static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014409 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014410 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014411 { "Ext Mic", 0x0 },
14412 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014413 },
14414};
14415
Kailang Yangd1a991a2007-08-15 16:21:59 +020014416static struct hda_input_mux alc861vd_hp_capture_source = {
14417 .num_items = 2,
14418 .items = {
14419 { "Front Mic", 0x0 },
14420 { "ATAPI Mic", 0x1 },
14421 },
14422};
14423
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014424/*
14425 * 2ch mode
14426 */
14427static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14428 { 2, NULL }
14429};
14430
14431/*
14432 * 6ch mode
14433 */
14434static struct hda_verb alc861vd_6stack_ch6_init[] = {
14435 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14436 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14437 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14438 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14439 { } /* end */
14440};
14441
14442/*
14443 * 8ch mode
14444 */
14445static struct hda_verb alc861vd_6stack_ch8_init[] = {
14446 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14447 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14448 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14449 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14450 { } /* end */
14451};
14452
14453static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14454 { 6, alc861vd_6stack_ch6_init },
14455 { 8, alc861vd_6stack_ch8_init },
14456};
14457
14458static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14459 {
14460 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14461 .name = "Channel Mode",
14462 .info = alc_ch_mode_info,
14463 .get = alc_ch_mode_get,
14464 .put = alc_ch_mode_put,
14465 },
14466 { } /* end */
14467};
14468
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014469/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14470 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14471 */
14472static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14473 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14474 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14475
14476 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14477 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14478
14479 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14480 HDA_OUTPUT),
14481 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14482 HDA_OUTPUT),
14483 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14484 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14485
14486 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14487 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14488
14489 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14490
14491 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14492 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14493 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14494
14495 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14496 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14497 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14498
14499 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14500 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14501
14502 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14503 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14504
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014505 { } /* end */
14506};
14507
14508static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14509 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14510 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14511
14512 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14513
14514 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14515 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14516 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14517
14518 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14519 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14520 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14521
14522 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14523 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14524
14525 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14526 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14527
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014528 { } /* end */
14529};
14530
Kailang Yangbdd148a2007-05-08 15:19:08 +020014531static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14532 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14533 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14534 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14535
14536 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14537
14538 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14541
14542 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14543 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14544 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14545
14546 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14547 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14548
14549 { } /* end */
14550};
14551
Tobin Davisb419f342008-03-07 11:57:51 +010014552/* Pin assignment: Speaker=0x14, HP = 0x15,
14553 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014554 */
14555static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014556 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14557 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014558 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14559 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014560 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14561 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14562 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14563 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14564 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14565 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014566 { } /* end */
14567};
14568
Kailang Yangd1a991a2007-08-15 16:21:59 +020014569/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14570 * Front Mic=0x18, ATAPI Mic = 0x19,
14571 */
14572static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14573 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14574 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14575 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14576 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14577 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14578 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14579 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14580 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014581
Kailang Yangd1a991a2007-08-15 16:21:59 +020014582 { } /* end */
14583};
14584
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014585/*
14586 * generic initialization of ADC, input mixers and output mixers
14587 */
14588static struct hda_verb alc861vd_volume_init_verbs[] = {
14589 /*
14590 * Unmute ADC0 and set the default input to mic-in
14591 */
14592 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14594
14595 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14596 * the analog-loopback mixer widget
14597 */
14598 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014599 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14600 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14601 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014604
14605 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014606 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014610
14611 /*
14612 * Set up output mixers (0x02 - 0x05)
14613 */
14614 /* set vol=0 to output mixers */
14615 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14616 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14617 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14618 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14619
14620 /* set up input amps for analog loopback */
14621 /* Amp Indices: DAC = 0, mixer = 1 */
14622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14624 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14625 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14626 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14627 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14628 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14629 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14630
14631 { }
14632};
14633
14634/*
14635 * 3-stack pin configuration:
14636 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14637 */
14638static struct hda_verb alc861vd_3stack_init_verbs[] = {
14639 /*
14640 * Set pin mode and muting
14641 */
14642 /* set front pin widgets 0x14 for output */
14643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14645 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14646
14647 /* Mic (rear) pin: input vref at 80% */
14648 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14649 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14650 /* Front Mic pin: input vref at 80% */
14651 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14652 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14653 /* Line In pin: input */
14654 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14655 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14656 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14657 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14658 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14659 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14660 /* CD pin widget for input */
14661 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14662
14663 { }
14664};
14665
14666/*
14667 * 6-stack pin configuration:
14668 */
14669static struct hda_verb alc861vd_6stack_init_verbs[] = {
14670 /*
14671 * Set pin mode and muting
14672 */
14673 /* set front pin widgets 0x14 for output */
14674 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14675 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14676 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14677
14678 /* Rear Pin: output 1 (0x0d) */
14679 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14681 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14682 /* CLFE Pin: output 2 (0x0e) */
14683 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14684 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14685 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14686 /* Side Pin: output 3 (0x0f) */
14687 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14688 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14689 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14690
14691 /* Mic (rear) pin: input vref at 80% */
14692 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14693 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14694 /* Front Mic pin: input vref at 80% */
14695 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14696 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14697 /* Line In pin: input */
14698 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14699 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14700 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14701 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14702 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14703 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14704 /* CD pin widget for input */
14705 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14706
14707 { }
14708};
14709
Kailang Yangbdd148a2007-05-08 15:19:08 +020014710static struct hda_verb alc861vd_eapd_verbs[] = {
14711 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14712 { }
14713};
14714
Kailang Yangf9423e72008-05-27 12:32:25 +020014715static struct hda_verb alc660vd_eapd_verbs[] = {
14716 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14717 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14718 { }
14719};
14720
Kailang Yangbdd148a2007-05-08 15:19:08 +020014721static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14725 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014726 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014727 {}
14728};
14729
14730/* toggle speaker-output according to the hp-jack state */
14731static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14732{
14733 unsigned int present;
14734 unsigned char bits;
14735
14736 present = snd_hda_codec_read(codec, 0x1b, 0,
14737 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014738 bits = present ? HDA_AMP_MUTE : 0;
14739 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14740 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014741}
14742
14743static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14744{
14745 unsigned int present;
14746 unsigned char bits;
14747
14748 present = snd_hda_codec_read(codec, 0x18, 0,
14749 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014750 bits = present ? HDA_AMP_MUTE : 0;
14751 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14752 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014753}
14754
14755static void alc861vd_lenovo_automute(struct hda_codec *codec)
14756{
14757 alc861vd_lenovo_hp_automute(codec);
14758 alc861vd_lenovo_mic_automute(codec);
14759}
14760
14761static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14762 unsigned int res)
14763{
14764 switch (res >> 26) {
14765 case ALC880_HP_EVENT:
14766 alc861vd_lenovo_hp_automute(codec);
14767 break;
14768 case ALC880_MIC_EVENT:
14769 alc861vd_lenovo_mic_automute(codec);
14770 break;
14771 }
14772}
14773
Kailang Yang272a5272007-05-14 11:00:38 +020014774static struct hda_verb alc861vd_dallas_verbs[] = {
14775 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14776 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14777 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14778 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14779
14780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14781 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14782 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14783 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14784 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14785 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14786 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14787 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014788
Kailang Yang272a5272007-05-14 11:00:38 +020014789 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14790 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14791 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14793 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14794 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14795 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14796 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14797
14798 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14800 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14802 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14803 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14804 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14805 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14806
14807 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14808 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14809 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14810 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14811
14812 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014813 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014814 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14815
14816 { } /* end */
14817};
14818
14819/* toggle speaker-output according to the hp-jack state */
14820static void alc861vd_dallas_automute(struct hda_codec *codec)
14821{
14822 unsigned int present;
14823
14824 present = snd_hda_codec_read(codec, 0x15, 0,
14825 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014826 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14827 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014828}
14829
14830static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14831{
14832 if ((res >> 26) == ALC880_HP_EVENT)
14833 alc861vd_dallas_automute(codec);
14834}
14835
Takashi Iwaicb53c622007-08-10 17:21:45 +020014836#ifdef CONFIG_SND_HDA_POWER_SAVE
14837#define alc861vd_loopbacks alc880_loopbacks
14838#endif
14839
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014840/* pcm configuration: identiacal with ALC880 */
14841#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14842#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14843#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14844#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14845
14846/*
14847 * configuration and preset
14848 */
14849static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14850 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014851 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014852 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014853 [ALC861VD_3ST] = "3stack",
14854 [ALC861VD_3ST_DIG] = "3stack-digout",
14855 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014856 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014857 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014858 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014859 [ALC861VD_AUTO] = "auto",
14860};
14861
14862static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014863 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14864 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014865 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014866 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014867 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014868 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014869 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014870 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014871 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014872 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014873 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014874 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014875 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014876 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014877 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014878 {}
14879};
14880
14881static struct alc_config_preset alc861vd_presets[] = {
14882 [ALC660VD_3ST] = {
14883 .mixers = { alc861vd_3st_mixer },
14884 .init_verbs = { alc861vd_volume_init_verbs,
14885 alc861vd_3stack_init_verbs },
14886 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14887 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014888 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14889 .channel_mode = alc861vd_3stack_2ch_modes,
14890 .input_mux = &alc861vd_capture_source,
14891 },
Mike Crash6963f842007-06-25 12:12:51 +020014892 [ALC660VD_3ST_DIG] = {
14893 .mixers = { alc861vd_3st_mixer },
14894 .init_verbs = { alc861vd_volume_init_verbs,
14895 alc861vd_3stack_init_verbs },
14896 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14897 .dac_nids = alc660vd_dac_nids,
14898 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014899 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14900 .channel_mode = alc861vd_3stack_2ch_modes,
14901 .input_mux = &alc861vd_capture_source,
14902 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014903 [ALC861VD_3ST] = {
14904 .mixers = { alc861vd_3st_mixer },
14905 .init_verbs = { alc861vd_volume_init_verbs,
14906 alc861vd_3stack_init_verbs },
14907 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14908 .dac_nids = alc861vd_dac_nids,
14909 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14910 .channel_mode = alc861vd_3stack_2ch_modes,
14911 .input_mux = &alc861vd_capture_source,
14912 },
14913 [ALC861VD_3ST_DIG] = {
14914 .mixers = { alc861vd_3st_mixer },
14915 .init_verbs = { alc861vd_volume_init_verbs,
14916 alc861vd_3stack_init_verbs },
14917 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14918 .dac_nids = alc861vd_dac_nids,
14919 .dig_out_nid = ALC861VD_DIGOUT_NID,
14920 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14921 .channel_mode = alc861vd_3stack_2ch_modes,
14922 .input_mux = &alc861vd_capture_source,
14923 },
14924 [ALC861VD_6ST_DIG] = {
14925 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14926 .init_verbs = { alc861vd_volume_init_verbs,
14927 alc861vd_6stack_init_verbs },
14928 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14929 .dac_nids = alc861vd_dac_nids,
14930 .dig_out_nid = ALC861VD_DIGOUT_NID,
14931 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14932 .channel_mode = alc861vd_6stack_modes,
14933 .input_mux = &alc861vd_capture_source,
14934 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014935 [ALC861VD_LENOVO] = {
14936 .mixers = { alc861vd_lenovo_mixer },
14937 .init_verbs = { alc861vd_volume_init_verbs,
14938 alc861vd_3stack_init_verbs,
14939 alc861vd_eapd_verbs,
14940 alc861vd_lenovo_unsol_verbs },
14941 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14942 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014943 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14944 .channel_mode = alc861vd_3stack_2ch_modes,
14945 .input_mux = &alc861vd_capture_source,
14946 .unsol_event = alc861vd_lenovo_unsol_event,
14947 .init_hook = alc861vd_lenovo_automute,
14948 },
Kailang Yang272a5272007-05-14 11:00:38 +020014949 [ALC861VD_DALLAS] = {
14950 .mixers = { alc861vd_dallas_mixer },
14951 .init_verbs = { alc861vd_dallas_verbs },
14952 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14953 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014954 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14955 .channel_mode = alc861vd_3stack_2ch_modes,
14956 .input_mux = &alc861vd_dallas_capture_source,
14957 .unsol_event = alc861vd_dallas_unsol_event,
14958 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014959 },
14960 [ALC861VD_HP] = {
14961 .mixers = { alc861vd_hp_mixer },
14962 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14963 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14964 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014965 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014966 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14967 .channel_mode = alc861vd_3stack_2ch_modes,
14968 .input_mux = &alc861vd_hp_capture_source,
14969 .unsol_event = alc861vd_dallas_unsol_event,
14970 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014971 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014972 [ALC660VD_ASUS_V1S] = {
14973 .mixers = { alc861vd_lenovo_mixer },
14974 .init_verbs = { alc861vd_volume_init_verbs,
14975 alc861vd_3stack_init_verbs,
14976 alc861vd_eapd_verbs,
14977 alc861vd_lenovo_unsol_verbs },
14978 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14979 .dac_nids = alc660vd_dac_nids,
14980 .dig_out_nid = ALC861VD_DIGOUT_NID,
14981 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14982 .channel_mode = alc861vd_3stack_2ch_modes,
14983 .input_mux = &alc861vd_capture_source,
14984 .unsol_event = alc861vd_lenovo_unsol_event,
14985 .init_hook = alc861vd_lenovo_automute,
14986 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014987};
14988
14989/*
14990 * BIOS auto configuration
14991 */
14992static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14993 hda_nid_t nid, int pin_type, int dac_idx)
14994{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014995 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014996}
14997
14998static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14999{
15000 struct alc_spec *spec = codec->spec;
15001 int i;
15002
15003 for (i = 0; i <= HDA_SIDE; i++) {
15004 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015005 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015006 if (nid)
15007 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015008 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015009 }
15010}
15011
15012
15013static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15014{
15015 struct alc_spec *spec = codec->spec;
15016 hda_nid_t pin;
15017
15018 pin = spec->autocfg.hp_pins[0];
15019 if (pin) /* connect to front and use dac 0 */
15020 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015021 pin = spec->autocfg.speaker_pins[0];
15022 if (pin)
15023 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015024}
15025
15026#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15027#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15028
15029static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15030{
15031 struct alc_spec *spec = codec->spec;
15032 int i;
15033
15034 for (i = 0; i < AUTO_PIN_LAST; i++) {
15035 hda_nid_t nid = spec->autocfg.input_pins[i];
15036 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015037 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015038 if (nid != ALC861VD_PIN_CD_NID &&
15039 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015040 snd_hda_codec_write(codec, nid, 0,
15041 AC_VERB_SET_AMP_GAIN_MUTE,
15042 AMP_OUT_MUTE);
15043 }
15044 }
15045}
15046
Takashi Iwaif511b012008-08-15 16:46:42 +020015047#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15048
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015049#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15050#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15051
15052/* add playback controls from the parsed DAC table */
15053/* Based on ALC880 version. But ALC861VD has separate,
15054 * different NIDs for mute/unmute switch and volume control */
15055static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15056 const struct auto_pin_cfg *cfg)
15057{
15058 char name[32];
15059 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15060 hda_nid_t nid_v, nid_s;
15061 int i, err;
15062
15063 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015064 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015065 continue;
15066 nid_v = alc861vd_idx_to_mixer_vol(
15067 alc880_dac_to_idx(
15068 spec->multiout.dac_nids[i]));
15069 nid_s = alc861vd_idx_to_mixer_switch(
15070 alc880_dac_to_idx(
15071 spec->multiout.dac_nids[i]));
15072
15073 if (i == 2) {
15074 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015075 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15076 "Center Playback Volume",
15077 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15078 HDA_OUTPUT));
15079 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015080 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015081 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15082 "LFE Playback Volume",
15083 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15084 HDA_OUTPUT));
15085 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015086 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015087 err = add_control(spec, ALC_CTL_BIND_MUTE,
15088 "Center Playback Switch",
15089 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15090 HDA_INPUT));
15091 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015092 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015093 err = add_control(spec, ALC_CTL_BIND_MUTE,
15094 "LFE Playback Switch",
15095 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15096 HDA_INPUT));
15097 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015098 return err;
15099 } else {
15100 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015101 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15102 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15103 HDA_OUTPUT));
15104 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015105 return err;
15106 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015107 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015108 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015109 HDA_INPUT));
15110 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015111 return err;
15112 }
15113 }
15114 return 0;
15115}
15116
15117/* add playback controls for speaker and HP outputs */
15118/* Based on ALC880 version. But ALC861VD has separate,
15119 * different NIDs for mute/unmute switch and volume control */
15120static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15121 hda_nid_t pin, const char *pfx)
15122{
15123 hda_nid_t nid_v, nid_s;
15124 int err;
15125 char name[32];
15126
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015127 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015128 return 0;
15129
15130 if (alc880_is_fixed_pin(pin)) {
15131 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15132 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015133 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015134 spec->multiout.hp_nid = nid_v;
15135 else
15136 spec->multiout.extra_out_nid[0] = nid_v;
15137 /* control HP volume/switch on the output mixer amp */
15138 nid_v = alc861vd_idx_to_mixer_vol(
15139 alc880_fixed_pin_idx(pin));
15140 nid_s = alc861vd_idx_to_mixer_switch(
15141 alc880_fixed_pin_idx(pin));
15142
15143 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015144 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15145 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15146 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015147 return err;
15148 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015149 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15150 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15151 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015152 return err;
15153 } else if (alc880_is_multi_pin(pin)) {
15154 /* set manual connection */
15155 /* we have only a switch on HP-out PIN */
15156 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015157 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15158 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15159 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015160 return err;
15161 }
15162 return 0;
15163}
15164
15165/* parse the BIOS configuration and set up the alc_spec
15166 * return 1 if successful, 0 if the proper config is not found,
15167 * or a negative error code
15168 * Based on ALC880 version - had to change it to override
15169 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15170static int alc861vd_parse_auto_config(struct hda_codec *codec)
15171{
15172 struct alc_spec *spec = codec->spec;
15173 int err;
15174 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15175
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015176 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15177 alc861vd_ignore);
15178 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015179 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015180 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015181 return 0; /* can't find valid BIOS pin config */
15182
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015183 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15184 if (err < 0)
15185 return err;
15186 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15187 if (err < 0)
15188 return err;
15189 err = alc861vd_auto_create_extra_out(spec,
15190 spec->autocfg.speaker_pins[0],
15191 "Speaker");
15192 if (err < 0)
15193 return err;
15194 err = alc861vd_auto_create_extra_out(spec,
15195 spec->autocfg.hp_pins[0],
15196 "Headphone");
15197 if (err < 0)
15198 return err;
15199 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15200 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015201 return err;
15202
15203 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15204
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015205 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015206 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15207
Takashi Iwai603c4012008-07-30 15:01:44 +020015208 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015209 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015210
Takashi Iwaid88897e2008-10-31 15:01:37 +010015211 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015212
15213 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015214 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015215
Takashi Iwai776e1842007-08-29 15:07:11 +020015216 err = alc_auto_add_mic_boost(codec);
15217 if (err < 0)
15218 return err;
15219
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015220 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15221
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015222 return 1;
15223}
15224
15225/* additional initialization for auto-configuration model */
15226static void alc861vd_auto_init(struct hda_codec *codec)
15227{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015228 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015229 alc861vd_auto_init_multi_out(codec);
15230 alc861vd_auto_init_hp_out(codec);
15231 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015232 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015233 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015234 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015235}
15236
15237static int patch_alc861vd(struct hda_codec *codec)
15238{
15239 struct alc_spec *spec;
15240 int err, board_config;
15241
15242 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15243 if (spec == NULL)
15244 return -ENOMEM;
15245
15246 codec->spec = spec;
15247
15248 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15249 alc861vd_models,
15250 alc861vd_cfg_tbl);
15251
15252 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15253 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
15254 "ALC861VD, trying auto-probe from BIOS...\n");
15255 board_config = ALC861VD_AUTO;
15256 }
15257
15258 if (board_config == ALC861VD_AUTO) {
15259 /* automatic parse from the BIOS config */
15260 err = alc861vd_parse_auto_config(codec);
15261 if (err < 0) {
15262 alc_free(codec);
15263 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015264 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015265 printk(KERN_INFO
15266 "hda_codec: Cannot set up configuration "
15267 "from BIOS. Using base mode...\n");
15268 board_config = ALC861VD_3ST;
15269 }
15270 }
15271
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015272 err = snd_hda_attach_beep_device(codec, 0x23);
15273 if (err < 0) {
15274 alc_free(codec);
15275 return err;
15276 }
15277
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015278 if (board_config != ALC861VD_AUTO)
15279 setup_preset(spec, &alc861vd_presets[board_config]);
15280
Kailang Yang2f893282008-05-27 12:14:47 +020015281 if (codec->vendor_id == 0x10ec0660) {
15282 spec->stream_name_analog = "ALC660-VD Analog";
15283 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020015284 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015285 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015286 } else {
15287 spec->stream_name_analog = "ALC861VD Analog";
15288 spec->stream_name_digital = "ALC861VD Digital";
15289 }
15290
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015291 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15292 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15293
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015294 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15295 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15296
15297 spec->adc_nids = alc861vd_adc_nids;
15298 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015299 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015300 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015301
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015302 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015303 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015304
Takashi Iwai2134ea42008-01-10 16:53:55 +010015305 spec->vmaster_nid = 0x02;
15306
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015307 codec->patch_ops = alc_patch_ops;
15308
15309 if (board_config == ALC861VD_AUTO)
15310 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015311#ifdef CONFIG_SND_HDA_POWER_SAVE
15312 if (!spec->loopback.amplist)
15313 spec->loopback.amplist = alc861vd_loopbacks;
15314#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015315 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015316
15317 return 0;
15318}
15319
15320/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015321 * ALC662 support
15322 *
15323 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15324 * configuration. Each pin widget can choose any input DACs and a mixer.
15325 * Each ADC is connected from a mixer of all inputs. This makes possible
15326 * 6-channel independent captures.
15327 *
15328 * In addition, an independent DAC for the multi-playback (not used in this
15329 * driver yet).
15330 */
15331#define ALC662_DIGOUT_NID 0x06
15332#define ALC662_DIGIN_NID 0x0a
15333
15334static hda_nid_t alc662_dac_nids[4] = {
15335 /* front, rear, clfe, rear_surr */
15336 0x02, 0x03, 0x04
15337};
15338
Kailang Yang622e84c2009-04-21 07:39:04 +020015339static hda_nid_t alc272_dac_nids[2] = {
15340 0x02, 0x03
15341};
15342
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015343static hda_nid_t alc662_adc_nids[1] = {
15344 /* ADC1-2 */
15345 0x09,
15346};
Takashi Iwaie1406342008-02-11 18:32:32 +010015347
Kailang Yang622e84c2009-04-21 07:39:04 +020015348static hda_nid_t alc272_adc_nids[1] = {
15349 /* ADC1-2 */
15350 0x08,
15351};
15352
Kailang Yang77a261b2008-02-19 11:38:05 +010015353static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015354static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15355
Takashi Iwaie1406342008-02-11 18:32:32 +010015356
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015357/* input MUX */
15358/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015359static struct hda_input_mux alc662_capture_source = {
15360 .num_items = 4,
15361 .items = {
15362 { "Mic", 0x0 },
15363 { "Front Mic", 0x1 },
15364 { "Line", 0x2 },
15365 { "CD", 0x4 },
15366 },
15367};
15368
15369static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15370 .num_items = 2,
15371 .items = {
15372 { "Mic", 0x1 },
15373 { "Line", 0x2 },
15374 },
15375};
Kailang Yang291702f2007-10-16 14:28:03 +020015376
15377static struct hda_input_mux alc662_eeepc_capture_source = {
15378 .num_items = 2,
15379 .items = {
15380 { "i-Mic", 0x1 },
15381 { "e-Mic", 0x0 },
15382 },
15383};
15384
Kailang Yang6dda9f42008-05-27 12:05:31 +020015385static struct hda_input_mux alc663_capture_source = {
15386 .num_items = 3,
15387 .items = {
15388 { "Mic", 0x0 },
15389 { "Front Mic", 0x1 },
15390 { "Line", 0x2 },
15391 },
15392};
15393
15394static struct hda_input_mux alc663_m51va_capture_source = {
15395 .num_items = 2,
15396 .items = {
15397 { "Ext-Mic", 0x0 },
15398 { "D-Mic", 0x9 },
15399 },
15400};
15401
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015402/*
15403 * 2ch mode
15404 */
15405static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15406 { 2, NULL }
15407};
15408
15409/*
15410 * 2ch mode
15411 */
15412static struct hda_verb alc662_3ST_ch2_init[] = {
15413 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15414 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15415 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15416 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15417 { } /* end */
15418};
15419
15420/*
15421 * 6ch mode
15422 */
15423static struct hda_verb alc662_3ST_ch6_init[] = {
15424 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15425 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15426 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15427 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15428 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15429 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15430 { } /* end */
15431};
15432
15433static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15434 { 2, alc662_3ST_ch2_init },
15435 { 6, alc662_3ST_ch6_init },
15436};
15437
15438/*
15439 * 2ch mode
15440 */
15441static struct hda_verb alc662_sixstack_ch6_init[] = {
15442 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15443 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15444 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15445 { } /* end */
15446};
15447
15448/*
15449 * 6ch mode
15450 */
15451static struct hda_verb alc662_sixstack_ch8_init[] = {
15452 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15453 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15454 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15455 { } /* end */
15456};
15457
15458static struct hda_channel_mode alc662_5stack_modes[2] = {
15459 { 2, alc662_sixstack_ch6_init },
15460 { 6, alc662_sixstack_ch8_init },
15461};
15462
15463/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15464 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15465 */
15466
15467static struct snd_kcontrol_new alc662_base_mixer[] = {
15468 /* output mixer control */
15469 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015470 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015471 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015472 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015473 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15474 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015475 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15476 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015477 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15478
15479 /*Input mixer control */
15480 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15481 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15482 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15483 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15484 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15485 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15486 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15487 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015488 { } /* end */
15489};
15490
15491static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15492 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015493 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015494 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15495 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15496 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15497 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15498 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15499 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15500 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15501 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15502 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015503 { } /* end */
15504};
15505
15506static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15507 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015508 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015509 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015510 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015511 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15512 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015513 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15514 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15516 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15517 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15518 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15519 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15520 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15521 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15522 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15523 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015524 { } /* end */
15525};
15526
15527static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15528 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15529 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015530 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15531 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015532 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15533 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15534 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15535 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15536 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015537 { } /* end */
15538};
15539
Kailang Yang291702f2007-10-16 14:28:03 +020015540static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015541 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15542 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015543
15544 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15545 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15546 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15547
15548 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15549 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15550 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15551 { } /* end */
15552};
15553
Kailang Yang8c427222008-01-10 13:03:59 +010015554static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015555 ALC262_HIPPO_MASTER_SWITCH,
15556 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015557 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015558 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15559 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015560 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15561 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15562 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15564 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15565 { } /* end */
15566};
15567
Kailang Yangf1d4e282008-08-26 14:03:29 +020015568static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15569 .ops = &snd_hda_bind_vol,
15570 .values = {
15571 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15572 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15573 0
15574 },
15575};
15576
15577static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15578 .ops = &snd_hda_bind_sw,
15579 .values = {
15580 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15581 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15582 0
15583 },
15584};
15585
Kailang Yang6dda9f42008-05-27 12:05:31 +020015586static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015587 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15588 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15591 { } /* end */
15592};
15593
15594static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15595 .ops = &snd_hda_bind_sw,
15596 .values = {
15597 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15598 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15599 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15600 0
15601 },
15602};
15603
15604static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15605 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15606 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15607 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15608 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15609 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15610 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15611
15612 { } /* end */
15613};
15614
15615static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15616 .ops = &snd_hda_bind_sw,
15617 .values = {
15618 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15619 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15620 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15621 0
15622 },
15623};
15624
15625static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15626 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15627 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15628 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15630 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15631 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15632 { } /* end */
15633};
15634
15635static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015636 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15637 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015638 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15640 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15641 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15642 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15643 { } /* end */
15644};
15645
15646static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15647 .ops = &snd_hda_bind_vol,
15648 .values = {
15649 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15650 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15651 0
15652 },
15653};
15654
15655static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15656 .ops = &snd_hda_bind_sw,
15657 .values = {
15658 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15659 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15660 0
15661 },
15662};
15663
15664static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15665 HDA_BIND_VOL("Master Playback Volume",
15666 &alc663_asus_two_bind_master_vol),
15667 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15668 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015669 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15671 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015672 { } /* end */
15673};
15674
15675static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15676 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15677 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15678 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15679 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015682 { } /* end */
15683};
15684
15685static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15686 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15687 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15688 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15689 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15690 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15691
15692 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15693 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15694 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15695 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15696 { } /* end */
15697};
15698
15699static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15700 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15701 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15702 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15703
15704 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15705 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15706 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15707 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15708 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15709 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15710 { } /* end */
15711};
15712
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015713static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15714 {
15715 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15716 .name = "Channel Mode",
15717 .info = alc_ch_mode_info,
15718 .get = alc_ch_mode_get,
15719 .put = alc_ch_mode_put,
15720 },
15721 { } /* end */
15722};
15723
15724static struct hda_verb alc662_init_verbs[] = {
15725 /* ADC: mute amp left and right */
15726 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15727 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15728 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15729
Takashi Iwaicb53c622007-08-10 17:21:45 +020015730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15732 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15733 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015735
Kailang Yangb60dd392007-09-20 12:50:29 +020015736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15738 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15739 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15740 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15741 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015742
15743 /* Front Pin: output 0 (0x0c) */
15744 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15746
15747 /* Rear Pin: output 1 (0x0d) */
15748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15749 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15750
15751 /* CLFE Pin: output 2 (0x0e) */
15752 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15753 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15754
15755 /* Mic (rear) pin: input vref at 80% */
15756 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15757 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15758 /* Front Mic pin: input vref at 80% */
15759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15760 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15761 /* Line In pin: input */
15762 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15764 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15765 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15766 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15767 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15768 /* CD pin widget for input */
15769 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15770
15771 /* FIXME: use matrix-type input source selection */
15772 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15773 /* Input mixer */
15774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015775 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015776
15777 /* always trun on EAPD */
15778 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15779 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15780
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015781 { }
15782};
15783
15784static struct hda_verb alc662_sue_init_verbs[] = {
15785 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15786 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015787 {}
15788};
15789
15790static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15791 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15792 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15793 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015794};
15795
Kailang Yang8c427222008-01-10 13:03:59 +010015796/* Set Unsolicited Event*/
15797static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15798 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15799 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15800 {}
15801};
15802
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015803/*
15804 * generic initialization of ADC, input mixers and output mixers
15805 */
15806static struct hda_verb alc662_auto_init_verbs[] = {
15807 /*
15808 * Unmute ADC and set the default input to mic-in
15809 */
15810 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15811 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15812
15813 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15814 * mixer widget
15815 * Note: PASD motherboards uses the Line In 2 as the input for front
15816 * panel mic (mic 2)
15817 */
15818 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015819 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15820 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15821 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15822 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15823 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015824
15825 /*
15826 * Set up output mixers (0x0c - 0x0f)
15827 */
15828 /* set vol=0 to output mixers */
15829 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15830 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15831 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15832
15833 /* set up input amps for analog loopback */
15834 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015835 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15837 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15838 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15839 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15840 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015841
15842
15843 /* FIXME: use matrix-type input source selection */
15844 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15845 /* Input mixer */
15846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015847 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015848 { }
15849};
15850
Takashi Iwai24fb9172008-09-02 14:48:20 +020015851/* additional verbs for ALC663 */
15852static struct hda_verb alc663_auto_init_verbs[] = {
15853 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15854 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15855 { }
15856};
15857
Kailang Yang6dda9f42008-05-27 12:05:31 +020015858static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015859 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15860 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015861 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15862 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015863 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15864 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15865 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015866 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15867 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15868 {}
15869};
15870
Kailang Yangf1d4e282008-08-26 14:03:29 +020015871static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15872 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15873 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15874 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15877 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15878 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15879 {}
15880};
15881
15882static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15883 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15884 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15885 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15886 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15887 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15888 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15889 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15890 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15891 {}
15892};
15893
15894static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15896 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15897 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15898 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15899 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15900 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15901 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15902 {}
15903};
15904
15905static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15906 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15907 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15908 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15909 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15912 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15915 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15916 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_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_m2_init_verbs[] = {
15922 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15923 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15924 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15925 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* 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, 0x01}, /* 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 {0x1b, 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
Kailang Yang6dda9f42008-05-27 12:05:31 +020015937static struct hda_verb alc663_g71v_init_verbs[] = {
15938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15939 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15940 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15941
15942 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15943 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15944 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15945
15946 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15947 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15948 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15949 {}
15950};
15951
15952static struct hda_verb alc663_g50v_init_verbs[] = {
15953 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15954 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15955 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15956
15957 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15958 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15959 {}
15960};
15961
Kailang Yangf1d4e282008-08-26 14:03:29 +020015962static struct hda_verb alc662_ecs_init_verbs[] = {
15963 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15964 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15965 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15966 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15967 {}
15968};
15969
Kailang Yang622e84c2009-04-21 07:39:04 +020015970static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15971 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15972 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15973 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15974 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15975 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15976 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15977 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15980 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15981 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15982 {}
15983};
15984
15985static struct hda_verb alc272_dell_init_verbs[] = {
15986 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15987 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15988 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15989 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15990 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15991 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15992 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15995 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15996 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15997 {}
15998};
15999
Kailang Yangf1d4e282008-08-26 14:03:29 +020016000static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16001 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16002 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16003 { } /* end */
16004};
16005
Kailang Yang622e84c2009-04-21 07:39:04 +020016006static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16007 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16008 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16009 { } /* end */
16010};
16011
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016012static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16013{
16014 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016015 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016016
16017 present = snd_hda_codec_read(codec, 0x14, 0,
16018 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016019 bits = present ? HDA_AMP_MUTE : 0;
16020 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16021 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016022}
16023
16024static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16025{
16026 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016027 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016028
16029 present = snd_hda_codec_read(codec, 0x1b, 0,
16030 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016031 bits = present ? HDA_AMP_MUTE : 0;
16032 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16033 HDA_AMP_MUTE, bits);
16034 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16035 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016036}
16037
16038static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16039 unsigned int res)
16040{
16041 if ((res >> 26) == ALC880_HP_EVENT)
16042 alc662_lenovo_101e_all_automute(codec);
16043 if ((res >> 26) == ALC880_FRONT_EVENT)
16044 alc662_lenovo_101e_ispeaker_automute(codec);
16045}
16046
Kailang Yang291702f2007-10-16 14:28:03 +020016047static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16048{
16049 unsigned int present;
16050
16051 present = snd_hda_codec_read(codec, 0x18, 0,
16052 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16053 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16054 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16055 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16056 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16057 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16058 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16059 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16060 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16061}
16062
16063/* unsolicited event for HP jack sensing */
16064static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16065 unsigned int res)
16066{
Kailang Yang291702f2007-10-16 14:28:03 +020016067 if ((res >> 26) == ALC880_MIC_EVENT)
16068 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016069 else
16070 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016071}
16072
16073static void alc662_eeepc_inithook(struct hda_codec *codec)
16074{
Takashi Iwai42171c12009-05-08 14:11:43 +020016075 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016076 alc662_eeepc_mic_automute(codec);
16077}
16078
Kailang Yang8c427222008-01-10 13:03:59 +010016079static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16080{
Takashi Iwai42171c12009-05-08 14:11:43 +020016081 struct alc_spec *spec = codec->spec;
16082
16083 spec->autocfg.hp_pins[0] = 0x14;
16084 spec->autocfg.speaker_pins[0] = 0x1b;
16085 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016086}
16087
Kailang Yang6dda9f42008-05-27 12:05:31 +020016088static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16089{
16090 unsigned int present;
16091 unsigned char bits;
16092
16093 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016094 AC_VERB_GET_PIN_SENSE, 0)
16095 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016096 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016097 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16098 AMP_IN_MUTE(0), bits);
16099 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16100 AMP_IN_MUTE(0), bits);
16101}
16102
16103static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16104{
16105 unsigned int present;
16106 unsigned char bits;
16107
16108 present = snd_hda_codec_read(codec, 0x21, 0,
16109 AC_VERB_GET_PIN_SENSE, 0)
16110 & AC_PINSENSE_PRESENCE;
16111 bits = present ? HDA_AMP_MUTE : 0;
16112 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16113 AMP_IN_MUTE(0), bits);
16114 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16115 AMP_IN_MUTE(0), bits);
16116 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16117 AMP_IN_MUTE(0), bits);
16118 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16119 AMP_IN_MUTE(0), bits);
16120}
16121
16122static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16123{
16124 unsigned int present;
16125 unsigned char bits;
16126
16127 present = snd_hda_codec_read(codec, 0x15, 0,
16128 AC_VERB_GET_PIN_SENSE, 0)
16129 & AC_PINSENSE_PRESENCE;
16130 bits = present ? HDA_AMP_MUTE : 0;
16131 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16132 AMP_IN_MUTE(0), bits);
16133 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16134 AMP_IN_MUTE(0), bits);
16135 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16136 AMP_IN_MUTE(0), bits);
16137 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16138 AMP_IN_MUTE(0), bits);
16139}
16140
16141static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16142{
16143 unsigned int present;
16144 unsigned char bits;
16145
16146 present = snd_hda_codec_read(codec, 0x1b, 0,
16147 AC_VERB_GET_PIN_SENSE, 0)
16148 & AC_PINSENSE_PRESENCE;
16149 bits = present ? 0 : PIN_OUT;
16150 snd_hda_codec_write(codec, 0x14, 0,
16151 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16152}
16153
16154static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16155{
16156 unsigned int present1, present2;
16157
16158 present1 = snd_hda_codec_read(codec, 0x21, 0,
16159 AC_VERB_GET_PIN_SENSE, 0)
16160 & AC_PINSENSE_PRESENCE;
16161 present2 = snd_hda_codec_read(codec, 0x15, 0,
16162 AC_VERB_GET_PIN_SENSE, 0)
16163 & AC_PINSENSE_PRESENCE;
16164
16165 if (present1 || present2) {
16166 snd_hda_codec_write_cache(codec, 0x14, 0,
16167 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16168 } else {
16169 snd_hda_codec_write_cache(codec, 0x14, 0,
16170 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16171 }
16172}
16173
16174static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16175{
16176 unsigned int present1, present2;
16177
16178 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16179 AC_VERB_GET_PIN_SENSE, 0)
16180 & AC_PINSENSE_PRESENCE;
16181 present2 = snd_hda_codec_read(codec, 0x15, 0,
16182 AC_VERB_GET_PIN_SENSE, 0)
16183 & AC_PINSENSE_PRESENCE;
16184
16185 if (present1 || present2) {
16186 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16187 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16188 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16189 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16190 } else {
16191 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16192 AMP_IN_MUTE(0), 0);
16193 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16194 AMP_IN_MUTE(0), 0);
16195 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016196}
16197
16198static void alc663_m51va_mic_automute(struct hda_codec *codec)
16199{
16200 unsigned int present;
16201
16202 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016203 AC_VERB_GET_PIN_SENSE, 0)
16204 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016205 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016206 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016207 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016208 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016209 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016210 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016211 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016212 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016213}
16214
16215static void alc663_m51va_unsol_event(struct hda_codec *codec,
16216 unsigned int res)
16217{
16218 switch (res >> 26) {
16219 case ALC880_HP_EVENT:
16220 alc663_m51va_speaker_automute(codec);
16221 break;
16222 case ALC880_MIC_EVENT:
16223 alc663_m51va_mic_automute(codec);
16224 break;
16225 }
16226}
16227
16228static void alc663_m51va_inithook(struct hda_codec *codec)
16229{
16230 alc663_m51va_speaker_automute(codec);
16231 alc663_m51va_mic_automute(codec);
16232}
16233
Kailang Yangf1d4e282008-08-26 14:03:29 +020016234/* ***************** Mode1 ******************************/
16235static void alc663_mode1_unsol_event(struct hda_codec *codec,
16236 unsigned int res)
16237{
16238 switch (res >> 26) {
16239 case ALC880_HP_EVENT:
16240 alc663_m51va_speaker_automute(codec);
16241 break;
16242 case ALC880_MIC_EVENT:
16243 alc662_eeepc_mic_automute(codec);
16244 break;
16245 }
16246}
16247
16248static void alc663_mode1_inithook(struct hda_codec *codec)
16249{
16250 alc663_m51va_speaker_automute(codec);
16251 alc662_eeepc_mic_automute(codec);
16252}
16253/* ***************** Mode2 ******************************/
16254static void alc662_mode2_unsol_event(struct hda_codec *codec,
16255 unsigned int res)
16256{
16257 switch (res >> 26) {
16258 case ALC880_HP_EVENT:
16259 alc662_f5z_speaker_automute(codec);
16260 break;
16261 case ALC880_MIC_EVENT:
16262 alc662_eeepc_mic_automute(codec);
16263 break;
16264 }
16265}
16266
16267static void alc662_mode2_inithook(struct hda_codec *codec)
16268{
16269 alc662_f5z_speaker_automute(codec);
16270 alc662_eeepc_mic_automute(codec);
16271}
16272/* ***************** Mode3 ******************************/
16273static void alc663_mode3_unsol_event(struct hda_codec *codec,
16274 unsigned int res)
16275{
16276 switch (res >> 26) {
16277 case ALC880_HP_EVENT:
16278 alc663_two_hp_m1_speaker_automute(codec);
16279 break;
16280 case ALC880_MIC_EVENT:
16281 alc662_eeepc_mic_automute(codec);
16282 break;
16283 }
16284}
16285
16286static void alc663_mode3_inithook(struct hda_codec *codec)
16287{
16288 alc663_two_hp_m1_speaker_automute(codec);
16289 alc662_eeepc_mic_automute(codec);
16290}
16291/* ***************** Mode4 ******************************/
16292static void alc663_mode4_unsol_event(struct hda_codec *codec,
16293 unsigned int res)
16294{
16295 switch (res >> 26) {
16296 case ALC880_HP_EVENT:
16297 alc663_21jd_two_speaker_automute(codec);
16298 break;
16299 case ALC880_MIC_EVENT:
16300 alc662_eeepc_mic_automute(codec);
16301 break;
16302 }
16303}
16304
16305static void alc663_mode4_inithook(struct hda_codec *codec)
16306{
16307 alc663_21jd_two_speaker_automute(codec);
16308 alc662_eeepc_mic_automute(codec);
16309}
16310/* ***************** Mode5 ******************************/
16311static void alc663_mode5_unsol_event(struct hda_codec *codec,
16312 unsigned int res)
16313{
16314 switch (res >> 26) {
16315 case ALC880_HP_EVENT:
16316 alc663_15jd_two_speaker_automute(codec);
16317 break;
16318 case ALC880_MIC_EVENT:
16319 alc662_eeepc_mic_automute(codec);
16320 break;
16321 }
16322}
16323
16324static void alc663_mode5_inithook(struct hda_codec *codec)
16325{
16326 alc663_15jd_two_speaker_automute(codec);
16327 alc662_eeepc_mic_automute(codec);
16328}
16329/* ***************** Mode6 ******************************/
16330static void alc663_mode6_unsol_event(struct hda_codec *codec,
16331 unsigned int res)
16332{
16333 switch (res >> 26) {
16334 case ALC880_HP_EVENT:
16335 alc663_two_hp_m2_speaker_automute(codec);
16336 break;
16337 case ALC880_MIC_EVENT:
16338 alc662_eeepc_mic_automute(codec);
16339 break;
16340 }
16341}
16342
16343static void alc663_mode6_inithook(struct hda_codec *codec)
16344{
16345 alc663_two_hp_m2_speaker_automute(codec);
16346 alc662_eeepc_mic_automute(codec);
16347}
16348
Kailang Yang6dda9f42008-05-27 12:05:31 +020016349static void alc663_g71v_hp_automute(struct hda_codec *codec)
16350{
16351 unsigned int present;
16352 unsigned char bits;
16353
16354 present = snd_hda_codec_read(codec, 0x21, 0,
16355 AC_VERB_GET_PIN_SENSE, 0)
16356 & AC_PINSENSE_PRESENCE;
16357 bits = present ? HDA_AMP_MUTE : 0;
16358 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16359 HDA_AMP_MUTE, bits);
16360 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16361 HDA_AMP_MUTE, bits);
16362}
16363
16364static void alc663_g71v_front_automute(struct hda_codec *codec)
16365{
16366 unsigned int present;
16367 unsigned char bits;
16368
16369 present = snd_hda_codec_read(codec, 0x15, 0,
16370 AC_VERB_GET_PIN_SENSE, 0)
16371 & AC_PINSENSE_PRESENCE;
16372 bits = present ? HDA_AMP_MUTE : 0;
16373 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16374 HDA_AMP_MUTE, bits);
16375}
16376
16377static void alc663_g71v_unsol_event(struct hda_codec *codec,
16378 unsigned int res)
16379{
16380 switch (res >> 26) {
16381 case ALC880_HP_EVENT:
16382 alc663_g71v_hp_automute(codec);
16383 break;
16384 case ALC880_FRONT_EVENT:
16385 alc663_g71v_front_automute(codec);
16386 break;
16387 case ALC880_MIC_EVENT:
16388 alc662_eeepc_mic_automute(codec);
16389 break;
16390 }
16391}
16392
16393static void alc663_g71v_inithook(struct hda_codec *codec)
16394{
16395 alc663_g71v_front_automute(codec);
16396 alc663_g71v_hp_automute(codec);
16397 alc662_eeepc_mic_automute(codec);
16398}
16399
16400static void alc663_g50v_unsol_event(struct hda_codec *codec,
16401 unsigned int res)
16402{
16403 switch (res >> 26) {
16404 case ALC880_HP_EVENT:
16405 alc663_m51va_speaker_automute(codec);
16406 break;
16407 case ALC880_MIC_EVENT:
16408 alc662_eeepc_mic_automute(codec);
16409 break;
16410 }
16411}
16412
16413static void alc663_g50v_inithook(struct hda_codec *codec)
16414{
16415 alc663_m51va_speaker_automute(codec);
16416 alc662_eeepc_mic_automute(codec);
16417}
16418
Kailang Yangf1d4e282008-08-26 14:03:29 +020016419static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16420 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016421 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016422
16423 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16424 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16425 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16426
16427 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16428 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16429 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16430 { } /* end */
16431};
16432
Takashi Iwaicb53c622007-08-10 17:21:45 +020016433#ifdef CONFIG_SND_HDA_POWER_SAVE
16434#define alc662_loopbacks alc880_loopbacks
16435#endif
16436
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016437
16438/* pcm configuration: identiacal with ALC880 */
16439#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16440#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16441#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16442#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16443
16444/*
16445 * configuration and preset
16446 */
16447static const char *alc662_models[ALC662_MODEL_LAST] = {
16448 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16449 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16450 [ALC662_3ST_6ch] = "3stack-6ch",
16451 [ALC662_5ST_DIG] = "6stack-dig",
16452 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016453 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016454 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016455 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016456 [ALC663_ASUS_M51VA] = "m51va",
16457 [ALC663_ASUS_G71V] = "g71v",
16458 [ALC663_ASUS_H13] = "h13",
16459 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016460 [ALC663_ASUS_MODE1] = "asus-mode1",
16461 [ALC662_ASUS_MODE2] = "asus-mode2",
16462 [ALC663_ASUS_MODE3] = "asus-mode3",
16463 [ALC663_ASUS_MODE4] = "asus-mode4",
16464 [ALC663_ASUS_MODE5] = "asus-mode5",
16465 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016466 [ALC662_AUTO] = "auto",
16467};
16468
16469static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016470 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016471 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16472 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016473 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16474 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16475 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16476 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16477 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16478 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16479 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16480 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16481 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16482 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16483 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16484 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016485 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16486 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16487 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016488 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16489 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16490 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16491 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016492 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016493 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16494 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016495 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016496 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16497 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16498 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016499 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16500 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16501 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016502 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16503 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16504 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016505 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016506 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16507 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016508 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016509 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016510 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016511 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16512 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16513 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016514 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016515 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16516 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016517 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016518 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016519 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016520 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016521 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16522 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016523 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16524 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016525 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016526 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016527 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016528 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016529 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016530 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16531 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016532 {}
16533};
16534
16535static struct alc_config_preset alc662_presets[] = {
16536 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016537 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016538 .init_verbs = { alc662_init_verbs },
16539 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16540 .dac_nids = alc662_dac_nids,
16541 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016542 .dig_in_nid = ALC662_DIGIN_NID,
16543 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16544 .channel_mode = alc662_3ST_2ch_modes,
16545 .input_mux = &alc662_capture_source,
16546 },
16547 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016548 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016549 .init_verbs = { alc662_init_verbs },
16550 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16551 .dac_nids = alc662_dac_nids,
16552 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016553 .dig_in_nid = ALC662_DIGIN_NID,
16554 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16555 .channel_mode = alc662_3ST_6ch_modes,
16556 .need_dac_fix = 1,
16557 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016558 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016559 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016560 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016561 .init_verbs = { alc662_init_verbs },
16562 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16563 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016564 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16565 .channel_mode = alc662_3ST_6ch_modes,
16566 .need_dac_fix = 1,
16567 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016568 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016569 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016570 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016571 .init_verbs = { alc662_init_verbs },
16572 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16573 .dac_nids = alc662_dac_nids,
16574 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016575 .dig_in_nid = ALC662_DIGIN_NID,
16576 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16577 .channel_mode = alc662_5stack_modes,
16578 .input_mux = &alc662_capture_source,
16579 },
16580 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016581 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016582 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16583 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16584 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016585 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16586 .channel_mode = alc662_3ST_2ch_modes,
16587 .input_mux = &alc662_lenovo_101e_capture_source,
16588 .unsol_event = alc662_lenovo_101e_unsol_event,
16589 .init_hook = alc662_lenovo_101e_all_automute,
16590 },
Kailang Yang291702f2007-10-16 14:28:03 +020016591 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016592 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016593 .init_verbs = { alc662_init_verbs,
16594 alc662_eeepc_sue_init_verbs },
16595 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16596 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016597 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16598 .channel_mode = alc662_3ST_2ch_modes,
16599 .input_mux = &alc662_eeepc_capture_source,
16600 .unsol_event = alc662_eeepc_unsol_event,
16601 .init_hook = alc662_eeepc_inithook,
16602 },
Kailang Yang8c427222008-01-10 13:03:59 +010016603 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016604 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016605 alc662_chmode_mixer },
16606 .init_verbs = { alc662_init_verbs,
16607 alc662_eeepc_ep20_sue_init_verbs },
16608 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16609 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016610 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16611 .channel_mode = alc662_3ST_6ch_modes,
16612 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016613 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016614 .init_hook = alc662_eeepc_ep20_inithook,
16615 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016616 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016617 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016618 .init_verbs = { alc662_init_verbs,
16619 alc662_ecs_init_verbs },
16620 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16621 .dac_nids = alc662_dac_nids,
16622 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16623 .channel_mode = alc662_3ST_2ch_modes,
16624 .input_mux = &alc662_eeepc_capture_source,
16625 .unsol_event = alc662_eeepc_unsol_event,
16626 .init_hook = alc662_eeepc_inithook,
16627 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016628 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016629 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016630 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16631 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16632 .dac_nids = alc662_dac_nids,
16633 .dig_out_nid = ALC662_DIGOUT_NID,
16634 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16635 .channel_mode = alc662_3ST_2ch_modes,
16636 .input_mux = &alc663_m51va_capture_source,
16637 .unsol_event = alc663_m51va_unsol_event,
16638 .init_hook = alc663_m51va_inithook,
16639 },
16640 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016641 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016642 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16643 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16644 .dac_nids = alc662_dac_nids,
16645 .dig_out_nid = ALC662_DIGOUT_NID,
16646 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16647 .channel_mode = alc662_3ST_2ch_modes,
16648 .input_mux = &alc662_eeepc_capture_source,
16649 .unsol_event = alc663_g71v_unsol_event,
16650 .init_hook = alc663_g71v_inithook,
16651 },
16652 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016653 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016654 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16655 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16656 .dac_nids = alc662_dac_nids,
16657 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16658 .channel_mode = alc662_3ST_2ch_modes,
16659 .input_mux = &alc663_m51va_capture_source,
16660 .unsol_event = alc663_m51va_unsol_event,
16661 .init_hook = alc663_m51va_inithook,
16662 },
16663 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016664 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016665 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16666 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16667 .dac_nids = alc662_dac_nids,
16668 .dig_out_nid = ALC662_DIGOUT_NID,
16669 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16670 .channel_mode = alc662_3ST_6ch_modes,
16671 .input_mux = &alc663_capture_source,
16672 .unsol_event = alc663_g50v_unsol_event,
16673 .init_hook = alc663_g50v_inithook,
16674 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016675 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016676 .mixers = { alc663_m51va_mixer },
16677 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016678 .init_verbs = { alc662_init_verbs,
16679 alc663_21jd_amic_init_verbs },
16680 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16681 .hp_nid = 0x03,
16682 .dac_nids = alc662_dac_nids,
16683 .dig_out_nid = ALC662_DIGOUT_NID,
16684 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16685 .channel_mode = alc662_3ST_2ch_modes,
16686 .input_mux = &alc662_eeepc_capture_source,
16687 .unsol_event = alc663_mode1_unsol_event,
16688 .init_hook = alc663_mode1_inithook,
16689 },
16690 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016691 .mixers = { alc662_1bjd_mixer },
16692 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016693 .init_verbs = { alc662_init_verbs,
16694 alc662_1bjd_amic_init_verbs },
16695 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16696 .dac_nids = alc662_dac_nids,
16697 .dig_out_nid = ALC662_DIGOUT_NID,
16698 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16699 .channel_mode = alc662_3ST_2ch_modes,
16700 .input_mux = &alc662_eeepc_capture_source,
16701 .unsol_event = alc662_mode2_unsol_event,
16702 .init_hook = alc662_mode2_inithook,
16703 },
16704 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016705 .mixers = { alc663_two_hp_m1_mixer },
16706 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016707 .init_verbs = { alc662_init_verbs,
16708 alc663_two_hp_amic_m1_init_verbs },
16709 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16710 .hp_nid = 0x03,
16711 .dac_nids = alc662_dac_nids,
16712 .dig_out_nid = ALC662_DIGOUT_NID,
16713 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16714 .channel_mode = alc662_3ST_2ch_modes,
16715 .input_mux = &alc662_eeepc_capture_source,
16716 .unsol_event = alc663_mode3_unsol_event,
16717 .init_hook = alc663_mode3_inithook,
16718 },
16719 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016720 .mixers = { alc663_asus_21jd_clfe_mixer },
16721 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016722 .init_verbs = { alc662_init_verbs,
16723 alc663_21jd_amic_init_verbs},
16724 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16725 .hp_nid = 0x03,
16726 .dac_nids = alc662_dac_nids,
16727 .dig_out_nid = ALC662_DIGOUT_NID,
16728 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16729 .channel_mode = alc662_3ST_2ch_modes,
16730 .input_mux = &alc662_eeepc_capture_source,
16731 .unsol_event = alc663_mode4_unsol_event,
16732 .init_hook = alc663_mode4_inithook,
16733 },
16734 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016735 .mixers = { alc663_asus_15jd_clfe_mixer },
16736 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016737 .init_verbs = { alc662_init_verbs,
16738 alc663_15jd_amic_init_verbs },
16739 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16740 .hp_nid = 0x03,
16741 .dac_nids = alc662_dac_nids,
16742 .dig_out_nid = ALC662_DIGOUT_NID,
16743 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16744 .channel_mode = alc662_3ST_2ch_modes,
16745 .input_mux = &alc662_eeepc_capture_source,
16746 .unsol_event = alc663_mode5_unsol_event,
16747 .init_hook = alc663_mode5_inithook,
16748 },
16749 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016750 .mixers = { alc663_two_hp_m2_mixer },
16751 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016752 .init_verbs = { alc662_init_verbs,
16753 alc663_two_hp_amic_m2_init_verbs },
16754 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16755 .hp_nid = 0x03,
16756 .dac_nids = alc662_dac_nids,
16757 .dig_out_nid = ALC662_DIGOUT_NID,
16758 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16759 .channel_mode = alc662_3ST_2ch_modes,
16760 .input_mux = &alc662_eeepc_capture_source,
16761 .unsol_event = alc663_mode6_unsol_event,
16762 .init_hook = alc663_mode6_inithook,
16763 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016764 [ALC272_DELL] = {
16765 .mixers = { alc663_m51va_mixer },
16766 .cap_mixer = alc272_auto_capture_mixer,
16767 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16768 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16769 .dac_nids = alc662_dac_nids,
16770 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16771 .adc_nids = alc272_adc_nids,
16772 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16773 .capsrc_nids = alc272_capsrc_nids,
16774 .channel_mode = alc662_3ST_2ch_modes,
16775 .input_mux = &alc663_m51va_capture_source,
16776 .unsol_event = alc663_m51va_unsol_event,
16777 .init_hook = alc663_m51va_inithook,
16778 },
16779 [ALC272_DELL_ZM1] = {
16780 .mixers = { alc663_m51va_mixer },
16781 .cap_mixer = alc662_auto_capture_mixer,
16782 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16783 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16784 .dac_nids = alc662_dac_nids,
16785 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16786 .adc_nids = alc662_adc_nids,
16787 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16788 .capsrc_nids = alc662_capsrc_nids,
16789 .channel_mode = alc662_3ST_2ch_modes,
16790 .input_mux = &alc663_m51va_capture_source,
16791 .unsol_event = alc663_m51va_unsol_event,
16792 .init_hook = alc663_m51va_inithook,
16793 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016794};
16795
16796
16797/*
16798 * BIOS auto configuration
16799 */
16800
16801/* add playback controls from the parsed DAC table */
16802static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16803 const struct auto_pin_cfg *cfg)
16804{
16805 char name[32];
16806 static const char *chname[4] = {
16807 "Front", "Surround", NULL /*CLFE*/, "Side"
16808 };
16809 hda_nid_t nid;
16810 int i, err;
16811
16812 for (i = 0; i < cfg->line_outs; i++) {
16813 if (!spec->multiout.dac_nids[i])
16814 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016815 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016816 if (i == 2) {
16817 /* Center/LFE */
16818 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16819 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016820 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16821 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016822 if (err < 0)
16823 return err;
16824 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16825 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016826 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16827 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016828 if (err < 0)
16829 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016830 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016831 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016832 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016833 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016834 if (err < 0)
16835 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016836 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016837 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016838 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016839 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016840 if (err < 0)
16841 return err;
16842 } else {
16843 sprintf(name, "%s Playback Volume", chname[i]);
16844 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016845 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16846 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016847 if (err < 0)
16848 return err;
16849 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016850 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16851 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16852 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016853 if (err < 0)
16854 return err;
16855 }
16856 }
16857 return 0;
16858}
16859
16860/* add playback controls for speaker and HP outputs */
16861static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16862 const char *pfx)
16863{
16864 hda_nid_t nid;
16865 int err;
16866 char name[32];
16867
16868 if (!pin)
16869 return 0;
16870
Takashi Iwai24fb9172008-09-02 14:48:20 +020016871 if (pin == 0x17) {
16872 /* ALC663 has a mono output pin on 0x17 */
16873 sprintf(name, "%s Playback Switch", pfx);
16874 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16875 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16876 return err;
16877 }
16878
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016879 if (alc880_is_fixed_pin(pin)) {
16880 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016881 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016882 /* specify the DAC as the extra output */
16883 if (!spec->multiout.hp_nid)
16884 spec->multiout.hp_nid = nid;
16885 else
16886 spec->multiout.extra_out_nid[0] = nid;
16887 /* control HP volume/switch on the output mixer amp */
16888 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16889 sprintf(name, "%s Playback Volume", pfx);
16890 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16891 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16892 if (err < 0)
16893 return err;
16894 sprintf(name, "%s Playback Switch", pfx);
16895 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16896 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16897 if (err < 0)
16898 return err;
16899 } else if (alc880_is_multi_pin(pin)) {
16900 /* set manual connection */
16901 /* we have only a switch on HP-out PIN */
16902 sprintf(name, "%s Playback Switch", pfx);
16903 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16904 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16905 if (err < 0)
16906 return err;
16907 }
16908 return 0;
16909}
16910
Takashi Iwai2d864c42009-03-20 12:52:47 +010016911/* return the index of the src widget from the connection list of the nid.
16912 * return -1 if not found
16913 */
16914static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16915 hda_nid_t src)
16916{
16917 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16918 int i, conns;
16919
16920 conns = snd_hda_get_connections(codec, nid, conn_list,
16921 ARRAY_SIZE(conn_list));
16922 if (conns < 0)
16923 return -1;
16924 for (i = 0; i < conns; i++)
16925 if (conn_list[i] == src)
16926 return i;
16927 return -1;
16928}
16929
16930static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16931{
Takashi Iwai1327a322009-03-23 13:07:47 +010016932 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010016933 return (pincap & AC_PINCAP_IN) != 0;
16934}
16935
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016936/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010016937static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016938 const struct auto_pin_cfg *cfg)
16939{
Takashi Iwai2d864c42009-03-20 12:52:47 +010016940 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016941 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016942 int i, err, idx;
16943
16944 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010016945 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16946 idx = alc662_input_pin_idx(codec, 0x0b,
16947 cfg->input_pins[i]);
16948 if (idx >= 0) {
16949 err = new_analog_input(spec, cfg->input_pins[i],
16950 auto_pin_cfg_labels[i],
16951 idx, 0x0b);
16952 if (err < 0)
16953 return err;
16954 }
16955 idx = alc662_input_pin_idx(codec, 0x22,
16956 cfg->input_pins[i]);
16957 if (idx >= 0) {
16958 imux->items[imux->num_items].label =
16959 auto_pin_cfg_labels[i];
16960 imux->items[imux->num_items].index = idx;
16961 imux->num_items++;
16962 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016963 }
16964 }
16965 return 0;
16966}
16967
16968static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16969 hda_nid_t nid, int pin_type,
16970 int dac_idx)
16971{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016972 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016973 /* need the manual connection? */
16974 if (alc880_is_multi_pin(nid)) {
16975 struct alc_spec *spec = codec->spec;
16976 int idx = alc880_multi_pin_idx(nid);
16977 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16978 AC_VERB_SET_CONNECT_SEL,
16979 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16980 }
16981}
16982
16983static void alc662_auto_init_multi_out(struct hda_codec *codec)
16984{
16985 struct alc_spec *spec = codec->spec;
16986 int i;
16987
16988 for (i = 0; i <= HDA_SIDE; i++) {
16989 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016990 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016991 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016992 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016993 i);
16994 }
16995}
16996
16997static void alc662_auto_init_hp_out(struct hda_codec *codec)
16998{
16999 struct alc_spec *spec = codec->spec;
17000 hda_nid_t pin;
17001
17002 pin = spec->autocfg.hp_pins[0];
17003 if (pin) /* connect to front */
17004 /* use dac 0 */
17005 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017006 pin = spec->autocfg.speaker_pins[0];
17007 if (pin)
17008 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017009}
17010
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017011#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17012
17013static void alc662_auto_init_analog_input(struct hda_codec *codec)
17014{
17015 struct alc_spec *spec = codec->spec;
17016 int i;
17017
17018 for (i = 0; i < AUTO_PIN_LAST; i++) {
17019 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017020 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017021 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017022 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017023 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017024 snd_hda_codec_write(codec, nid, 0,
17025 AC_VERB_SET_AMP_GAIN_MUTE,
17026 AMP_OUT_MUTE);
17027 }
17028 }
17029}
17030
Takashi Iwaif511b012008-08-15 16:46:42 +020017031#define alc662_auto_init_input_src alc882_auto_init_input_src
17032
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017033static int alc662_parse_auto_config(struct hda_codec *codec)
17034{
17035 struct alc_spec *spec = codec->spec;
17036 int err;
17037 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17038
17039 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17040 alc662_ignore);
17041 if (err < 0)
17042 return err;
17043 if (!spec->autocfg.line_outs)
17044 return 0; /* can't find valid BIOS pin config */
17045
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017046 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17047 if (err < 0)
17048 return err;
17049 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17050 if (err < 0)
17051 return err;
17052 err = alc662_auto_create_extra_out(spec,
17053 spec->autocfg.speaker_pins[0],
17054 "Speaker");
17055 if (err < 0)
17056 return err;
17057 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17058 "Headphone");
17059 if (err < 0)
17060 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017061 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017062 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017063 return err;
17064
17065 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17066
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017067 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017068 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17069
Takashi Iwai603c4012008-07-30 15:01:44 +020017070 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017071 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017072
17073 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017074 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017075
Takashi Iwaid88897e2008-10-31 15:01:37 +010017076 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017077 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017078 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017079
17080 err = alc_auto_add_mic_boost(codec);
17081 if (err < 0)
17082 return err;
17083
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017084 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17085
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017086 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017087}
17088
17089/* additional initialization for auto-configuration model */
17090static void alc662_auto_init(struct hda_codec *codec)
17091{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017092 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017093 alc662_auto_init_multi_out(codec);
17094 alc662_auto_init_hp_out(codec);
17095 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017096 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017097 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017098 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017099}
17100
17101static int patch_alc662(struct hda_codec *codec)
17102{
17103 struct alc_spec *spec;
17104 int err, board_config;
17105
17106 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17107 if (!spec)
17108 return -ENOMEM;
17109
17110 codec->spec = spec;
17111
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017112 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17113
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017114 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17115 alc662_models,
17116 alc662_cfg_tbl);
17117 if (board_config < 0) {
17118 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
17119 "trying auto-probe from BIOS...\n");
17120 board_config = ALC662_AUTO;
17121 }
17122
17123 if (board_config == ALC662_AUTO) {
17124 /* automatic parse from the BIOS config */
17125 err = alc662_parse_auto_config(codec);
17126 if (err < 0) {
17127 alc_free(codec);
17128 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017129 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017130 printk(KERN_INFO
17131 "hda_codec: Cannot set up configuration "
17132 "from BIOS. Using base mode...\n");
17133 board_config = ALC662_3ST_2ch_DIG;
17134 }
17135 }
17136
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017137 err = snd_hda_attach_beep_device(codec, 0x1);
17138 if (err < 0) {
17139 alc_free(codec);
17140 return err;
17141 }
17142
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017143 if (board_config != ALC662_AUTO)
17144 setup_preset(spec, &alc662_presets[board_config]);
17145
Kailang Yang6dda9f42008-05-27 12:05:31 +020017146 if (codec->vendor_id == 0x10ec0663) {
17147 spec->stream_name_analog = "ALC663 Analog";
17148 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020017149 } else if (codec->vendor_id == 0x10ec0272) {
17150 spec->stream_name_analog = "ALC272 Analog";
17151 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020017152 } else {
17153 spec->stream_name_analog = "ALC662 Analog";
17154 spec->stream_name_digital = "ALC662 Digital";
17155 }
17156
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017157 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17158 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17159
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017160 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17161 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17162
Takashi Iwaie1406342008-02-11 18:32:32 +010017163 spec->adc_nids = alc662_adc_nids;
17164 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17165 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017166 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017167
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017168 if (!spec->cap_mixer)
17169 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017170 if (codec->vendor_id == 0x10ec0662)
17171 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17172 else
17173 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017174
Takashi Iwai2134ea42008-01-10 16:53:55 +010017175 spec->vmaster_nid = 0x02;
17176
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017177 codec->patch_ops = alc_patch_ops;
17178 if (board_config == ALC662_AUTO)
17179 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017180#ifdef CONFIG_SND_HDA_POWER_SAVE
17181 if (!spec->loopback.amplist)
17182 spec->loopback.amplist = alc662_loopbacks;
17183#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017184 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017185
17186 return 0;
17187}
17188
17189/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017190 * patch entries
17191 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017192static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017193 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017194 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017195 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017196 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017197 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017198 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017199 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017200 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017201 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17202 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17203 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017204 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17205 .patch = patch_alc883 },
17206 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17207 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017208 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017209 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017210 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017211 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017212 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17213 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017214 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017215 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017216 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017217 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017218 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17219 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017220 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017221 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017222 {} /* terminator */
17223};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017224
17225MODULE_ALIAS("snd-hda-codec-id:10ec*");
17226
17227MODULE_LICENSE("GPL");
17228MODULE_DESCRIPTION("Realtek HD-audio codec");
17229
17230static struct hda_codec_preset_list realtek_list = {
17231 .preset = snd_hda_preset_realtek,
17232 .owner = THIS_MODULE,
17233};
17234
17235static int __init patch_realtek_init(void)
17236{
17237 return snd_hda_add_codec_preset(&realtek_list);
17238}
17239
17240static void __exit patch_realtek_exit(void)
17241{
17242 snd_hda_delete_codec_preset(&realtek_list);
17243}
17244
17245module_init(patch_realtek_init)
17246module_exit(patch_realtek_exit)