blob: 3696ff31838f0e3ee95011b2e9af939b9d4df275 [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 Yangbc9f98a2007-04-12 13:06:07 +0200191 ALC662_AUTO,
192 ALC662_MODEL_LAST,
193};
194
Kailang Yangdf694da2005-12-05 19:42:22 +0100195/* ALC882 models */
196enum {
197 ALC882_3ST_DIG,
198 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200199 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200200 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200201 ALC882_TARGA,
202 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200203 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100204 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200205 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200206 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200207 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100208 ALC882_MODEL_LAST,
209};
210
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200211/* ALC883 models */
212enum {
213 ALC883_3ST_2ch_DIG,
214 ALC883_3ST_6ch_DIG,
215 ALC883_3ST_6ch,
216 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200217 ALC883_TARGA_DIG,
218 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200219 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200220 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800221 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200222 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200223 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100224 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200225 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200226 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200227 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200228 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200229 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200230 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100231 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100232 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100233 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100234 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800235 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200236 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200237 ALC888_ASUS_M90V,
238 ALC888_ASUS_EEE1601,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100239 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200240 ALC883_AUTO,
241 ALC883_MODEL_LAST,
242};
243
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200244/* styles of capture selection */
245enum {
246 CAPT_MUX = 0, /* only mux based */
247 CAPT_MIX, /* only mixer based */
248 CAPT_1MUX_MIX, /* first mux and other mixers */
249};
250
Kailang Yangdf694da2005-12-05 19:42:22 +0100251/* for GPIO Poll */
252#define GPIO_MASK 0x03
253
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254struct alc_spec {
255 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100256 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100258 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100259 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
Kailang Yangdf694da2005-12-05 19:42:22 +0100261 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200262 * don't forget NULL
263 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200264 */
265 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
Takashi Iwai16ded522005-06-10 19:58:24 +0200267 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 struct hda_pcm_stream *stream_analog_playback;
269 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100270 struct hda_pcm_stream *stream_analog_alt_playback;
271 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200273 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 struct hda_pcm_stream *stream_digital_playback;
275 struct hda_pcm_stream *stream_digital_capture;
276
277 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200278 struct hda_multi_out multiout; /* playback set-up
279 * max_channels, dacs must be set
280 * dig_out_nid and hp_nid are optional
281 */
Takashi Iwai63300792008-01-24 15:31:36 +0100282 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100283 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100284 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286 /* capture */
287 unsigned int num_adc_nids;
288 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100289 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200290 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200291 int capture_style; /* capture style (CAPT_*) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
293 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200294 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 const struct hda_input_mux *input_mux;
296 unsigned int cur_mux[3];
297
298 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100299 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200301 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100304 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200305
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200306 /* dynamic controls, init_verbs and input_mux */
307 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200308 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200309 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200310 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100311
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100312 /* hooks */
313 void (*init_hook)(struct hda_codec *codec);
314 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
315
Takashi Iwai834be882006-03-01 14:16:17 +0100316 /* for pin sensing */
317 unsigned int sense_updated: 1;
318 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100319 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200320
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100321 /* other flags */
322 unsigned int no_analog :1; /* digital I/O only */
323
Takashi Iwai2134ea42008-01-10 16:53:55 +0100324 /* for virtual master */
325 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200326#ifdef CONFIG_SND_HDA_POWER_SAVE
327 struct hda_loopback_check loopback;
328#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200329
330 /* for PLL fix */
331 hda_nid_t pll_nid;
332 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100333};
334
335/*
336 * configuration template - to be copied to the spec instance
337 */
338struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200339 struct snd_kcontrol_new *mixers[5]; /* should be identical size
340 * with spec
341 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100342 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100343 const struct hda_verb *init_verbs[5];
344 unsigned int num_dacs;
345 hda_nid_t *dac_nids;
346 hda_nid_t dig_out_nid; /* optional */
347 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800348 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100349 unsigned int num_adc_nids;
350 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100351 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100352 hda_nid_t dig_in_nid;
353 unsigned int num_channel_mode;
354 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200355 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200356 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100357 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100358 void (*unsol_event)(struct hda_codec *, unsigned int);
359 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200360#ifdef CONFIG_SND_HDA_POWER_SAVE
361 struct hda_amp_list *loopbacks;
362#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363};
364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
366/*
367 * input MUX handling
368 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200369static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
370 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371{
372 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
373 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200374 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
375 if (mux_idx >= spec->num_mux_defs)
376 mux_idx = 0;
377 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378}
379
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200380static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
381 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382{
383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
384 struct alc_spec *spec = codec->spec;
385 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
386
387 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
388 return 0;
389}
390
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200391static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
392 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393{
394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
395 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100396 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100398 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100399 hda_nid_t nid = spec->capsrc_nids ?
400 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
Takashi Iwaicd896c32008-11-18 12:36:33 +0100402 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
403 imux = &spec->input_mux[mux_idx];
404
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200405 if (spec->capture_style &&
406 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100407 /* Matrix-mixer style (e.g. ALC882) */
408 unsigned int *cur_val = &spec->cur_mux[adc_idx];
409 unsigned int i, idx;
410
411 idx = ucontrol->value.enumerated.item[0];
412 if (idx >= imux->num_items)
413 idx = imux->num_items - 1;
414 if (*cur_val == idx)
415 return 0;
416 for (i = 0; i < imux->num_items; i++) {
417 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
418 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
419 imux->items[i].index,
420 HDA_AMP_MUTE, v);
421 }
422 *cur_val = idx;
423 return 1;
424 } else {
425 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100426 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100427 &spec->cur_mux[adc_idx]);
428 }
429}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200430
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431/*
432 * channel mode setting
433 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200434static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
435 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436{
437 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
438 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100439 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
440 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441}
442
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200443static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445{
446 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
447 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100448 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200449 spec->num_channel_mode,
450 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451}
452
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200453static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
454 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455{
456 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
457 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200458 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
459 spec->num_channel_mode,
460 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200461 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200462 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
463 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464}
465
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100467 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200468 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100469 * being part of a format specifier. Maximum allowed length of a value is
470 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100471 *
472 * Note: some retasking pin complexes seem to ignore requests for input
473 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
474 * are requested. Therefore order this list so that this behaviour will not
475 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200476 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
477 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200478 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100479static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100480 "Mic 50pc bias", "Mic 80pc bias",
481 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100482};
483static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100484 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100485};
486/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200487 * in the pin being assumed to be exclusively an input or an output pin. In
488 * addition, "input" pins may or may not process the mic bias option
489 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
490 * accept requests for bias as of chip versions up to March 2006) and/or
491 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100492 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200493#define ALC_PIN_DIR_IN 0x00
494#define ALC_PIN_DIR_OUT 0x01
495#define ALC_PIN_DIR_INOUT 0x02
496#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
497#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100498
Kailang Yangea1fb292008-08-26 12:58:38 +0200499/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100500 * For each direction the minimum and maximum values are given.
501 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200502static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100503 { 0, 2 }, /* ALC_PIN_DIR_IN */
504 { 3, 4 }, /* ALC_PIN_DIR_OUT */
505 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200506 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
507 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100508};
509#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
510#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
511#define alc_pin_mode_n_items(_dir) \
512 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
513
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200514static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200516{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100517 unsigned int item_num = uinfo->value.enumerated.item;
518 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
519
520 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200521 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
523
524 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
525 item_num = alc_pin_mode_min(dir);
526 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200527 return 0;
528}
529
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
531 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200532{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
535 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200537 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200538 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
539 AC_VERB_GET_PIN_WIDGET_CONTROL,
540 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200541
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100542 /* Find enumerated value for current pinctl setting */
543 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200544 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200546 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100547 return 0;
548}
549
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200550static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
551 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552{
553 signed int change;
554 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
555 hda_nid_t nid = kcontrol->private_value & 0xffff;
556 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
557 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
559 AC_VERB_GET_PIN_WIDGET_CONTROL,
560 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100561
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200562 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563 val = alc_pin_mode_min(dir);
564
565 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100566 if (change) {
567 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200568 snd_hda_codec_write_cache(codec, nid, 0,
569 AC_VERB_SET_PIN_WIDGET_CONTROL,
570 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100571
Kailang Yangea1fb292008-08-26 12:58:38 +0200572 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100573 * for the requested pin mode. Enum values of 2 or less are
574 * input modes.
575 *
576 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200577 * reduces noise slightly (particularly on input) so we'll
578 * do it. However, having both input and output buffers
579 * enabled simultaneously doesn't seem to be problematic if
580 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100581 */
582 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200583 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
584 HDA_AMP_MUTE, HDA_AMP_MUTE);
585 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
586 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100587 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200588 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
589 HDA_AMP_MUTE, HDA_AMP_MUTE);
590 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
591 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100592 }
593 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200594 return change;
595}
596
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100597#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200598 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100599 .info = alc_pin_mode_info, \
600 .get = alc_pin_mode_get, \
601 .put = alc_pin_mode_put, \
602 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100603
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100604/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
605 * together using a mask with more than one bit set. This control is
606 * currently used only by the ALC260 test model. At this stage they are not
607 * needed for any "production" models.
608 */
609#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200610#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200611
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200612static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100614{
615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
616 hda_nid_t nid = kcontrol->private_value & 0xffff;
617 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
618 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200619 unsigned int val = snd_hda_codec_read(codec, nid, 0,
620 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100621
622 *valp = (val & mask) != 0;
623 return 0;
624}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200625static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100627{
628 signed int change;
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 hda_nid_t nid = kcontrol->private_value & 0xffff;
631 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
632 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200633 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
634 AC_VERB_GET_GPIO_DATA,
635 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100636
637 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200638 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
639 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100640 gpio_data &= ~mask;
641 else
642 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200643 snd_hda_codec_write_cache(codec, nid, 0,
644 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100645
646 return change;
647}
648#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
649 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
650 .info = alc_gpio_data_info, \
651 .get = alc_gpio_data_get, \
652 .put = alc_gpio_data_put, \
653 .private_value = nid | (mask<<16) }
654#endif /* CONFIG_SND_DEBUG */
655
Jonathan Woithe92621f12006-02-28 11:47:47 +0100656/* A switch control to allow the enabling of the digital IO pins on the
657 * ALC260. This is incredibly simplistic; the intention of this control is
658 * to provide something in the test model allowing digital outputs to be
659 * identified if present. If models are found which can utilise these
660 * outputs a more complete mixer control can be devised for those models if
661 * necessary.
662 */
663#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200664#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200665
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200666static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
667 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100668{
669 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
670 hda_nid_t nid = kcontrol->private_value & 0xffff;
671 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
672 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200673 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100674 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100675
676 *valp = (val & mask) != 0;
677 return 0;
678}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
680 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100681{
682 signed int change;
683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
684 hda_nid_t nid = kcontrol->private_value & 0xffff;
685 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
686 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200687 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100688 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200689 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100690
691 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200692 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100693 if (val==0)
694 ctrl_data &= ~mask;
695 else
696 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200697 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
698 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100699
700 return change;
701}
702#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
703 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
704 .info = alc_spdif_ctrl_info, \
705 .get = alc_spdif_ctrl_get, \
706 .put = alc_spdif_ctrl_put, \
707 .private_value = nid | (mask<<16) }
708#endif /* CONFIG_SND_DEBUG */
709
Jonathan Woithef8225f62008-01-08 12:16:54 +0100710/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
711 * Again, this is only used in the ALC26x test models to help identify when
712 * the EAPD line must be asserted for features to work.
713 */
714#ifdef CONFIG_SND_DEBUG
715#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
716
717static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
718 struct snd_ctl_elem_value *ucontrol)
719{
720 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
721 hda_nid_t nid = kcontrol->private_value & 0xffff;
722 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
723 long *valp = ucontrol->value.integer.value;
724 unsigned int val = snd_hda_codec_read(codec, nid, 0,
725 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
726
727 *valp = (val & mask) != 0;
728 return 0;
729}
730
731static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
732 struct snd_ctl_elem_value *ucontrol)
733{
734 int change;
735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
736 hda_nid_t nid = kcontrol->private_value & 0xffff;
737 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
738 long val = *ucontrol->value.integer.value;
739 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
740 AC_VERB_GET_EAPD_BTLENABLE,
741 0x00);
742
743 /* Set/unset the masked control bit(s) as needed */
744 change = (!val ? 0 : mask) != (ctrl_data & mask);
745 if (!val)
746 ctrl_data &= ~mask;
747 else
748 ctrl_data |= mask;
749 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
750 ctrl_data);
751
752 return change;
753}
754
755#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
756 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
757 .info = alc_eapd_ctrl_info, \
758 .get = alc_eapd_ctrl_get, \
759 .put = alc_eapd_ctrl_put, \
760 .private_value = nid | (mask<<16) }
761#endif /* CONFIG_SND_DEBUG */
762
Kailang Yangdf694da2005-12-05 19:42:22 +0100763/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100764 * set up the input pin config (depending on the given auto-pin type)
765 */
766static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
767 int auto_pin_type)
768{
769 unsigned int val = PIN_IN;
770
771 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
772 unsigned int pincap;
773 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
774 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
775 if (pincap & AC_PINCAP_VREF_80)
776 val = PIN_VREF80;
777 }
778 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
779}
780
781/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100782 */
783static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
784{
785 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
786 return;
787 spec->mixers[spec->num_mixers++] = mix;
788}
789
790static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
791{
792 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
793 return;
794 spec->init_verbs[spec->num_init_verbs++] = verb;
795}
796
Takashi Iwaidaead532008-11-28 12:55:36 +0100797#ifdef CONFIG_PROC_FS
798/*
799 * hook for proc
800 */
801static void print_realtek_coef(struct snd_info_buffer *buffer,
802 struct hda_codec *codec, hda_nid_t nid)
803{
804 int coeff;
805
806 if (nid != 0x20)
807 return;
808 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
809 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
810 coeff = snd_hda_codec_read(codec, nid, 0,
811 AC_VERB_GET_COEF_INDEX, 0);
812 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
813}
814#else
815#define print_realtek_coef NULL
816#endif
817
Takashi Iwaid88897e2008-10-31 15:01:37 +0100818/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100819 * set up from the preset table
820 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200821static void setup_preset(struct alc_spec *spec,
822 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100823{
824 int i;
825
826 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100827 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100828 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200829 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
830 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100831 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200832
Kailang Yangdf694da2005-12-05 19:42:22 +0100833 spec->channel_mode = preset->channel_mode;
834 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200835 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100836
837 spec->multiout.max_channels = spec->channel_mode[0].channels;
838
839 spec->multiout.num_dacs = preset->num_dacs;
840 spec->multiout.dac_nids = preset->dac_nids;
841 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800842 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100843 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200844
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200845 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200846 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200847 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100848 spec->input_mux = preset->input_mux;
849
850 spec->num_adc_nids = preset->num_adc_nids;
851 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100852 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100853 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100854
855 spec->unsol_event = preset->unsol_event;
856 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200857#ifdef CONFIG_SND_HDA_POWER_SAVE
858 spec->loopback.amplist = preset->loopbacks;
859#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100860}
861
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200862/* Enable GPIO mask and set output */
863static struct hda_verb alc_gpio1_init_verbs[] = {
864 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
865 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
866 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
867 { }
868};
869
870static struct hda_verb alc_gpio2_init_verbs[] = {
871 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
872 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
873 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
874 { }
875};
876
Kailang Yangbdd148a2007-05-08 15:19:08 +0200877static struct hda_verb alc_gpio3_init_verbs[] = {
878 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
879 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
880 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
881 { }
882};
883
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200884/*
885 * Fix hardware PLL issue
886 * On some codecs, the analog PLL gating control must be off while
887 * the default value is 1.
888 */
889static void alc_fix_pll(struct hda_codec *codec)
890{
891 struct alc_spec *spec = codec->spec;
892 unsigned int val;
893
894 if (!spec->pll_nid)
895 return;
896 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
897 spec->pll_coef_idx);
898 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
899 AC_VERB_GET_PROC_COEF, 0);
900 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
901 spec->pll_coef_idx);
902 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
903 val & ~(1 << spec->pll_coef_bit));
904}
905
906static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
907 unsigned int coef_idx, unsigned int coef_bit)
908{
909 struct alc_spec *spec = codec->spec;
910 spec->pll_nid = nid;
911 spec->pll_coef_idx = coef_idx;
912 spec->pll_coef_bit = coef_bit;
913 alc_fix_pll(codec);
914}
915
Kailang Yangc9b58002007-10-16 14:30:01 +0200916static void alc_sku_automute(struct hda_codec *codec)
917{
918 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200919 unsigned int present;
920 unsigned int hp_nid = spec->autocfg.hp_pins[0];
921 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
922
923 /* need to execute and sync at first */
924 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
925 present = snd_hda_codec_read(codec, hp_nid, 0,
926 AC_VERB_GET_PIN_SENSE, 0);
927 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100928 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
929 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200930}
931
Takashi Iwai4605b712008-10-31 14:18:24 +0100932#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200933static void alc_mic_automute(struct hda_codec *codec)
934{
935 struct alc_spec *spec = codec->spec;
936 unsigned int present;
937 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
938 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
939 unsigned int mix_nid = spec->capsrc_nids[0];
940 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
941
942 capsrc_idx_mic = mic_nid - 0x18;
943 capsrc_idx_fmic = fmic_nid - 0x18;
944 present = snd_hda_codec_read(codec, mic_nid, 0,
945 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
946 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
947 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
948 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
949 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
950 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
951 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
952}
Takashi Iwai4605b712008-10-31 14:18:24 +0100953#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100954#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100955#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200956
Kailang Yangc9b58002007-10-16 14:30:01 +0200957/* unsolicited event for HP jack sensing */
958static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
959{
960 if (codec->vendor_id == 0x10ec0880)
961 res >>= 28;
962 else
963 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200964 if (res == ALC880_HP_EVENT)
965 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200966
Kailang Yang7fb0d782008-10-15 11:12:35 +0200967 if (res == ALC880_MIC_EVENT)
968 alc_mic_automute(codec);
969}
970
971static void alc_inithook(struct hda_codec *codec)
972{
Kailang Yangc9b58002007-10-16 14:30:01 +0200973 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200974 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200975}
976
Kailang Yangf9423e72008-05-27 12:32:25 +0200977/* additional initialization for ALC888 variants */
978static void alc888_coef_init(struct hda_codec *codec)
979{
980 unsigned int tmp;
981
982 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
983 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
984 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
985 if ((tmp & 0xf0) == 2)
986 /* alc888S-VC */
987 snd_hda_codec_read(codec, 0x20, 0,
988 AC_VERB_SET_PROC_COEF, 0x830);
989 else
990 /* alc888-VB */
991 snd_hda_codec_read(codec, 0x20, 0,
992 AC_VERB_SET_PROC_COEF, 0x3030);
993}
994
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200995/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
996 * 31 ~ 16 : Manufacture ID
997 * 15 ~ 8 : SKU ID
998 * 7 ~ 0 : Assembly ID
999 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1000 */
1001static void alc_subsystem_id(struct hda_codec *codec,
1002 unsigned int porta, unsigned int porte,
1003 unsigned int portd)
1004{
Kailang Yangc9b58002007-10-16 14:30:01 +02001005 unsigned int ass, tmp, i;
1006 unsigned nid;
1007 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001008
Kailang Yangc9b58002007-10-16 14:30:01 +02001009 ass = codec->subsystem_id & 0xffff;
1010 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1011 goto do_sku;
1012
Kailang Yangea1fb292008-08-26 12:58:38 +02001013 /*
Kailang Yangc9b58002007-10-16 14:30:01 +02001014 * 31~30 : port conetcivity
1015 * 29~21 : reserve
1016 * 20 : PCBEEP input
1017 * 19~16 : Check sum (15:1)
1018 * 15~1 : Custom
1019 * 0 : override
1020 */
1021 nid = 0x1d;
1022 if (codec->vendor_id == 0x10ec0260)
1023 nid = 0x17;
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001024 ass = snd_hda_codec_get_pincfg(codec, nid);
Kailang Yangc9b58002007-10-16 14:30:01 +02001025 if (!(ass & 1) && !(ass & 0x100000))
1026 return;
1027 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001028 return;
1029
Kailang Yangc9b58002007-10-16 14:30:01 +02001030 /* check sum */
1031 tmp = 0;
1032 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +01001033 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +02001034 tmp++;
1035 }
1036 if (((ass >> 16) & 0xf) != tmp)
1037 return;
1038do_sku:
1039 /*
1040 * 0 : override
1041 * 1 : Swap Jack
1042 * 2 : 0 --> Desktop, 1 --> Laptop
1043 * 3~5 : External Amplifier control
1044 * 7~6 : Reserved
1045 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001046 tmp = (ass & 0x38) >> 3; /* external Amp control */
1047 switch (tmp) {
1048 case 1:
1049 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1050 break;
1051 case 3:
1052 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1053 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001054 case 7:
1055 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1056 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001057 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001058 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001059 case 0x10ec0260:
1060 snd_hda_codec_write(codec, 0x0f, 0,
1061 AC_VERB_SET_EAPD_BTLENABLE, 2);
1062 snd_hda_codec_write(codec, 0x10, 0,
1063 AC_VERB_SET_EAPD_BTLENABLE, 2);
1064 break;
1065 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001066 case 0x10ec0267:
1067 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001068 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001069 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001070 case 0x10ec0660:
1071 case 0x10ec0662:
1072 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001073 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001074 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001075 snd_hda_codec_write(codec, 0x14, 0,
1076 AC_VERB_SET_EAPD_BTLENABLE, 2);
1077 snd_hda_codec_write(codec, 0x15, 0,
1078 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001079 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001080 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001081 switch (codec->vendor_id) {
1082 case 0x10ec0260:
1083 snd_hda_codec_write(codec, 0x1a, 0,
1084 AC_VERB_SET_COEF_INDEX, 7);
1085 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1086 AC_VERB_GET_PROC_COEF, 0);
1087 snd_hda_codec_write(codec, 0x1a, 0,
1088 AC_VERB_SET_COEF_INDEX, 7);
1089 snd_hda_codec_write(codec, 0x1a, 0,
1090 AC_VERB_SET_PROC_COEF,
1091 tmp | 0x2010);
1092 break;
1093 case 0x10ec0262:
1094 case 0x10ec0880:
1095 case 0x10ec0882:
1096 case 0x10ec0883:
1097 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001098 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001099 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001100 snd_hda_codec_write(codec, 0x20, 0,
1101 AC_VERB_SET_COEF_INDEX, 7);
1102 tmp = snd_hda_codec_read(codec, 0x20, 0,
1103 AC_VERB_GET_PROC_COEF, 0);
1104 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001105 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001106 snd_hda_codec_write(codec, 0x20, 0,
1107 AC_VERB_SET_PROC_COEF,
1108 tmp | 0x2010);
1109 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001110 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001111 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001112 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001113 case 0x10ec0267:
1114 case 0x10ec0268:
1115 snd_hda_codec_write(codec, 0x20, 0,
1116 AC_VERB_SET_COEF_INDEX, 7);
1117 tmp = snd_hda_codec_read(codec, 0x20, 0,
1118 AC_VERB_GET_PROC_COEF, 0);
1119 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001120 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001121 snd_hda_codec_write(codec, 0x20, 0,
1122 AC_VERB_SET_PROC_COEF,
1123 tmp | 0x3000);
1124 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001125 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001127 break;
1128 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001129
Kailang Yang8c427222008-01-10 13:03:59 +01001130 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001131 * when the external headphone out jack is plugged"
1132 */
Kailang Yang8c427222008-01-10 13:03:59 +01001133 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001134 return;
1135 /*
1136 * 10~8 : Jack location
1137 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1138 * 14~13: Resvered
1139 * 15 : 1 --> enable the function "Mute internal speaker
1140 * when the external headphone out jack is plugged"
1141 */
1142 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001143 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001144 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001145 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001146 else
1147 return;
1148 }
1149
1150 if (!spec->autocfg.hp_pins[0]) {
1151 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1152 if (tmp == 0)
1153 spec->autocfg.hp_pins[0] = porta;
1154 else if (tmp == 1)
1155 spec->autocfg.hp_pins[0] = porte;
1156 else if (tmp == 2)
1157 spec->autocfg.hp_pins[0] = portd;
1158 else
1159 return;
1160 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001161 if (spec->autocfg.hp_pins[0])
1162 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1163 AC_VERB_SET_UNSOLICITED_ENABLE,
1164 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001165
Takashi Iwai4605b712008-10-31 14:18:24 +01001166#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001167 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1168 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1169 snd_hda_codec_write(codec,
1170 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1171 AC_VERB_SET_UNSOLICITED_ENABLE,
1172 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001173#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001174
Kailang Yangc9b58002007-10-16 14:30:01 +02001175 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001176}
1177
Takashi Iwai41e41f12005-06-08 14:48:49 +02001178/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001179 * Fix-up pin default configurations
1180 */
1181
1182struct alc_pincfg {
1183 hda_nid_t nid;
1184 u32 val;
1185};
1186
1187static void alc_fix_pincfg(struct hda_codec *codec,
1188 const struct snd_pci_quirk *quirk,
1189 const struct alc_pincfg **pinfix)
1190{
1191 const struct alc_pincfg *cfg;
1192
1193 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1194 if (!quirk)
1195 return;
1196
1197 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001198 for (; cfg->nid; cfg++)
1199 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001200}
1201
1202/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001203 * ALC888
1204 */
1205
1206/*
1207 * 2ch mode
1208 */
1209static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1210/* Mic-in jack as mic in */
1211 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1212 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1213/* Line-in jack as Line in */
1214 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1215 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1216/* Line-Out as Front */
1217 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1218 { } /* end */
1219};
1220
1221/*
1222 * 4ch mode
1223 */
1224static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1225/* Mic-in jack as mic in */
1226 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1227 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1228/* Line-in jack as Surround */
1229 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1230 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1231/* Line-Out as Front */
1232 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1233 { } /* end */
1234};
1235
1236/*
1237 * 6ch mode
1238 */
1239static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1240/* Mic-in jack as CLFE */
1241 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1242 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1243/* Line-in jack as Surround */
1244 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1245 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1246/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1247 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1248 { } /* end */
1249};
1250
1251/*
1252 * 8ch mode
1253 */
1254static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1255/* Mic-in jack as CLFE */
1256 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1257 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1258/* Line-in jack as Surround */
1259 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1260 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1261/* Line-Out as Side */
1262 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1263 { } /* end */
1264};
1265
1266static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1267 { 2, alc888_4ST_ch2_intel_init },
1268 { 4, alc888_4ST_ch4_intel_init },
1269 { 6, alc888_4ST_ch6_intel_init },
1270 { 8, alc888_4ST_ch8_intel_init },
1271};
1272
1273/*
1274 * ALC888 Fujitsu Siemens Amillo xa3530
1275 */
1276
1277static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1278/* Front Mic: set to PIN_IN (empty by default) */
1279 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1280/* Connect Internal HP to Front */
1281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1282 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1283 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1284/* Connect Bass HP to Front */
1285 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1286 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1288/* Connect Line-Out side jack (SPDIF) to Side */
1289 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1290 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1291 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1292/* Connect Mic jack to CLFE */
1293 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1294 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1295 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1296/* Connect Line-in jack to Surround */
1297 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1298 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1299 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1300/* Connect HP out jack to Front */
1301 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1302 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1303 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1304/* Enable unsolicited event for HP jack and Line-out jack */
1305 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1306 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1307 {}
1308};
1309
1310static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1311{
1312 unsigned int present;
1313 unsigned int bits;
1314 /* Line out presence */
1315 present = snd_hda_codec_read(codec, 0x17, 0,
1316 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1317 /* HP out presence */
1318 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1319 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1320 bits = present ? HDA_AMP_MUTE : 0;
1321 /* Toggle internal speakers muting */
1322 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1323 HDA_AMP_MUTE, bits);
1324 /* Toggle internal bass muting */
1325 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1326 HDA_AMP_MUTE, bits);
1327}
1328
1329static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1330 unsigned int res)
1331{
1332 if (res >> 26 == ALC880_HP_EVENT)
1333 alc888_fujitsu_xa3530_automute(codec);
1334}
1335
1336
1337/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001338 * ALC888 Acer Aspire 4930G model
1339 */
1340
1341static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1342/* Front Mic: set to PIN_IN (empty by default) */
1343 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1344/* Unselect Front Mic by default in input mixer 3 */
1345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001346/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001347 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1348/* Connect Internal HP to front */
1349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1352/* Connect HP out to front */
1353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1355 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1356 { }
1357};
1358
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001359static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001360 /* Front mic only available on one ADC */
1361 {
1362 .num_items = 4,
1363 .items = {
1364 { "Mic", 0x0 },
1365 { "Line", 0x2 },
1366 { "CD", 0x4 },
1367 { "Front Mic", 0xb },
1368 },
1369 },
1370 {
1371 .num_items = 3,
1372 .items = {
1373 { "Mic", 0x0 },
1374 { "Line", 0x2 },
1375 { "CD", 0x4 },
1376 },
1377 }
1378};
1379
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001380static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001381 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1382 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1383 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1384 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1385 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1386 HDA_OUTPUT),
1387 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1388 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1389 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1390 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1391 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1392 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1393 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1394 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1395 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1397 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1398 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001399 { } /* end */
1400};
1401
1402static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1403{
1404 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001405 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001406 present = snd_hda_codec_read(codec, 0x15, 0,
1407 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001408 bits = present ? HDA_AMP_MUTE : 0;
1409 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1410 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001411}
1412
1413static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1414 unsigned int res)
1415{
1416 if (res >> 26 == ALC880_HP_EVENT)
1417 alc888_acer_aspire_4930g_automute(codec);
1418}
1419
1420/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001421 * ALC880 3-stack model
1422 *
1423 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001424 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1425 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001426 */
1427
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001428static hda_nid_t alc880_dac_nids[4] = {
1429 /* front, rear, clfe, rear_surr */
1430 0x02, 0x05, 0x04, 0x03
1431};
1432
1433static hda_nid_t alc880_adc_nids[3] = {
1434 /* ADC0-2 */
1435 0x07, 0x08, 0x09,
1436};
1437
1438/* The datasheet says the node 0x07 is connected from inputs,
1439 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001440 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001442static hda_nid_t alc880_adc_nids_alt[2] = {
1443 /* ADC1-2 */
1444 0x08, 0x09,
1445};
1446
1447#define ALC880_DIGOUT_NID 0x06
1448#define ALC880_DIGIN_NID 0x0a
1449
1450static struct hda_input_mux alc880_capture_source = {
1451 .num_items = 4,
1452 .items = {
1453 { "Mic", 0x0 },
1454 { "Front Mic", 0x3 },
1455 { "Line", 0x2 },
1456 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001458};
1459
1460/* channel source setting (2/6 channel selection for 3-stack) */
1461/* 2ch mode */
1462static struct hda_verb alc880_threestack_ch2_init[] = {
1463 /* set line-in to input, mute it */
1464 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1465 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1466 /* set mic-in to input vref 80%, mute it */
1467 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1468 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 { } /* end */
1470};
1471
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001472/* 6ch mode */
1473static struct hda_verb alc880_threestack_ch6_init[] = {
1474 /* set line-in to output, unmute it */
1475 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1476 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1477 /* set mic-in to output, unmute it */
1478 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1479 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1480 { } /* end */
1481};
1482
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001483static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001484 { 2, alc880_threestack_ch2_init },
1485 { 6, alc880_threestack_ch6_init },
1486};
1487
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001488static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001489 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001490 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001491 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001492 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001493 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1494 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001495 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1496 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1498 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1499 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1500 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1502 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1503 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001506 {
1507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1508 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001509 .info = alc_ch_mode_info,
1510 .get = alc_ch_mode_get,
1511 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001512 },
1513 { } /* end */
1514};
1515
1516/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001517static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1518 struct snd_ctl_elem_info *uinfo)
1519{
1520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1521 struct alc_spec *spec = codec->spec;
1522 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001523
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001524 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001525 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1526 HDA_INPUT);
1527 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001528 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001529 return err;
1530}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001531
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001532static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1533 unsigned int size, unsigned int __user *tlv)
1534{
1535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1536 struct alc_spec *spec = codec->spec;
1537 int err;
1538
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001539 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001540 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1541 HDA_INPUT);
1542 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001543 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001544 return err;
1545}
1546
1547typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1548 struct snd_ctl_elem_value *ucontrol);
1549
1550static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1551 struct snd_ctl_elem_value *ucontrol,
1552 getput_call_t func)
1553{
1554 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1555 struct alc_spec *spec = codec->spec;
1556 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1557 int err;
1558
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001559 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001560 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1561 3, 0, HDA_INPUT);
1562 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001563 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001564 return err;
1565}
1566
1567static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1568 struct snd_ctl_elem_value *ucontrol)
1569{
1570 return alc_cap_getput_caller(kcontrol, ucontrol,
1571 snd_hda_mixer_amp_volume_get);
1572}
1573
1574static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1575 struct snd_ctl_elem_value *ucontrol)
1576{
1577 return alc_cap_getput_caller(kcontrol, ucontrol,
1578 snd_hda_mixer_amp_volume_put);
1579}
1580
1581/* capture mixer elements */
1582#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1583
1584static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1585 struct snd_ctl_elem_value *ucontrol)
1586{
1587 return alc_cap_getput_caller(kcontrol, ucontrol,
1588 snd_hda_mixer_amp_switch_get);
1589}
1590
1591static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1592 struct snd_ctl_elem_value *ucontrol)
1593{
1594 return alc_cap_getput_caller(kcontrol, ucontrol,
1595 snd_hda_mixer_amp_switch_put);
1596}
1597
1598#define DEFINE_CAPMIX(num) \
1599static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1600 { \
1601 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1602 .name = "Capture Switch", \
1603 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1604 .count = num, \
1605 .info = alc_cap_sw_info, \
1606 .get = alc_cap_sw_get, \
1607 .put = alc_cap_sw_put, \
1608 }, \
1609 { \
1610 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1611 .name = "Capture Volume", \
1612 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1613 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1614 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1615 .count = num, \
1616 .info = alc_cap_vol_info, \
1617 .get = alc_cap_vol_get, \
1618 .put = alc_cap_vol_put, \
1619 .tlv = { .c = alc_cap_vol_tlv }, \
1620 }, \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001621 { \
1622 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1623 /* .name = "Capture Source", */ \
1624 .name = "Input Source", \
1625 .count = num, \
1626 .info = alc_mux_enum_info, \
1627 .get = alc_mux_enum_get, \
1628 .put = alc_mux_enum_put, \
1629 }, \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001630 { } /* end */ \
1631}
1632
1633/* up to three ADCs */
1634DEFINE_CAPMIX(1);
1635DEFINE_CAPMIX(2);
1636DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001637
1638
1639/*
1640 * ALC880 5-stack model
1641 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001642 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1643 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001644 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1645 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1646 */
1647
1648/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001649static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001650 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001651 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001652 { } /* end */
1653};
1654
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001655/* channel source setting (6/8 channel selection for 5-stack) */
1656/* 6ch mode */
1657static struct hda_verb alc880_fivestack_ch6_init[] = {
1658 /* set line-in to input, mute it */
1659 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1660 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001661 { } /* end */
1662};
1663
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001664/* 8ch mode */
1665static struct hda_verb alc880_fivestack_ch8_init[] = {
1666 /* set line-in to output, unmute it */
1667 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1668 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1669 { } /* end */
1670};
1671
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001672static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001673 { 6, alc880_fivestack_ch6_init },
1674 { 8, alc880_fivestack_ch8_init },
1675};
1676
1677
1678/*
1679 * ALC880 6-stack model
1680 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001681 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1682 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001683 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1684 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1685 */
1686
1687static hda_nid_t alc880_6st_dac_nids[4] = {
1688 /* front, rear, clfe, rear_surr */
1689 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001690};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001691
1692static struct hda_input_mux alc880_6stack_capture_source = {
1693 .num_items = 4,
1694 .items = {
1695 { "Mic", 0x0 },
1696 { "Front Mic", 0x1 },
1697 { "Line", 0x2 },
1698 { "CD", 0x4 },
1699 },
1700};
1701
1702/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001703static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001704 { 8, NULL },
1705};
1706
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001707static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001708 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001709 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001710 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001711 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001712 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1713 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001714 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1715 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001716 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001717 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001718 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1719 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1720 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1721 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1723 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1724 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1725 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001726 {
1727 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1728 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001729 .info = alc_ch_mode_info,
1730 .get = alc_ch_mode_get,
1731 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001732 },
1733 { } /* end */
1734};
1735
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001736
1737/*
1738 * ALC880 W810 model
1739 *
1740 * W810 has rear IO for:
1741 * Front (DAC 02)
1742 * Surround (DAC 03)
1743 * Center/LFE (DAC 04)
1744 * Digital out (06)
1745 *
1746 * The system also has a pair of internal speakers, and a headphone jack.
1747 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001748 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001749 * There is a variable resistor to control the speaker or headphone
1750 * volume. This is a hardware-only device without a software API.
1751 *
1752 * Plugging headphones in will disable the internal speakers. This is
1753 * implemented in hardware, not via the driver using jack sense. In
1754 * a similar fashion, plugging into the rear socket marked "front" will
1755 * disable both the speakers and headphones.
1756 *
1757 * For input, there's a microphone jack, and an "audio in" jack.
1758 * These may not do anything useful with this driver yet, because I
1759 * haven't setup any initialization verbs for these yet...
1760 */
1761
1762static hda_nid_t alc880_w810_dac_nids[3] = {
1763 /* front, rear/surround, clfe */
1764 0x02, 0x03, 0x04
1765};
1766
1767/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001768static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001769 { 6, NULL }
1770};
1771
1772/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001773static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001774 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001775 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001776 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001777 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001778 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1779 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001780 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1781 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001782 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1783 { } /* end */
1784};
1785
1786
1787/*
1788 * Z710V model
1789 *
1790 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001791 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1792 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001793 */
1794
1795static hda_nid_t alc880_z71v_dac_nids[1] = {
1796 0x02
1797};
1798#define ALC880_Z71V_HP_DAC 0x03
1799
1800/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001801static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001802 { 2, NULL }
1803};
1804
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001805static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001806 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001807 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001808 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001809 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001810 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1811 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1814 { } /* end */
1815};
1816
1817
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001818/*
1819 * ALC880 F1734 model
1820 *
1821 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1822 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1823 */
1824
1825static hda_nid_t alc880_f1734_dac_nids[1] = {
1826 0x03
1827};
1828#define ALC880_F1734_HP_DAC 0x02
1829
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001830static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001831 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001832 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001833 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1834 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001835 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1836 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1838 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001839 { } /* end */
1840};
1841
Takashi Iwai937b4162008-02-11 14:52:36 +01001842static struct hda_input_mux alc880_f1734_capture_source = {
1843 .num_items = 2,
1844 .items = {
1845 { "Mic", 0x1 },
1846 { "CD", 0x4 },
1847 },
1848};
1849
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001850
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001851/*
1852 * ALC880 ASUS model
1853 *
1854 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1855 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1856 * Mic = 0x18, Line = 0x1a
1857 */
1858
1859#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1860#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1861
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001862static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001863 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001864 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001865 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001866 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001867 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1868 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001869 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1870 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001871 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1872 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1873 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1874 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1876 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001877 {
1878 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1879 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001880 .info = alc_ch_mode_info,
1881 .get = alc_ch_mode_get,
1882 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001883 },
1884 { } /* end */
1885};
1886
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001887/*
1888 * ALC880 ASUS W1V model
1889 *
1890 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1891 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1892 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1893 */
1894
1895/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001896static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001897 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1898 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001899 { } /* end */
1900};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001901
Kailang Yangdf694da2005-12-05 19:42:22 +01001902/* TCL S700 */
1903static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1904 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1905 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1906 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1907 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1908 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1909 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1910 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1911 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1912 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001913 { } /* end */
1914};
1915
Kailang Yangccc656c2006-10-17 12:32:26 +02001916/* Uniwill */
1917static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001918 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1919 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1920 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1921 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001922 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1923 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1924 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1925 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1926 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1927 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1928 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1929 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1930 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1931 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1932 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1933 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001934 {
1935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1936 .name = "Channel Mode",
1937 .info = alc_ch_mode_info,
1938 .get = alc_ch_mode_get,
1939 .put = alc_ch_mode_put,
1940 },
1941 { } /* end */
1942};
1943
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001944static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1945 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1946 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1947 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1948 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1949 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1950 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1951 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1952 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1953 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1954 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1955 { } /* end */
1956};
1957
Kailang Yangccc656c2006-10-17 12:32:26 +02001958static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001959 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1960 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1961 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1962 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001963 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1964 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1965 { } /* end */
1966};
1967
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001969 * virtual master controls
1970 */
1971
1972/*
1973 * slave controls for virtual master
1974 */
1975static const char *alc_slave_vols[] = {
1976 "Front Playback Volume",
1977 "Surround Playback Volume",
1978 "Center Playback Volume",
1979 "LFE Playback Volume",
1980 "Side Playback Volume",
1981 "Headphone Playback Volume",
1982 "Speaker Playback Volume",
1983 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001984 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001985 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001986 NULL,
1987};
1988
1989static const char *alc_slave_sws[] = {
1990 "Front Playback Switch",
1991 "Surround Playback Switch",
1992 "Center Playback Switch",
1993 "LFE Playback Switch",
1994 "Side Playback Switch",
1995 "Headphone Playback Switch",
1996 "Speaker Playback Switch",
1997 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001998 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001999 NULL,
2000};
2001
2002/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002003 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002004 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002005
2006static void alc_free_kctls(struct hda_codec *codec);
2007
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002008/* additional beep mixers; the actual parameters are overwritten at build */
2009static struct snd_kcontrol_new alc_beep_mixer[] = {
2010 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2011 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2012 { } /* end */
2013};
2014
Linus Torvalds1da177e2005-04-16 15:20:36 -07002015static int alc_build_controls(struct hda_codec *codec)
2016{
2017 struct alc_spec *spec = codec->spec;
2018 int err;
2019 int i;
2020
2021 for (i = 0; i < spec->num_mixers; i++) {
2022 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2023 if (err < 0)
2024 return err;
2025 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002026 if (spec->cap_mixer) {
2027 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2028 if (err < 0)
2029 return err;
2030 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002032 err = snd_hda_create_spdif_out_ctls(codec,
2033 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002034 if (err < 0)
2035 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002036 if (!spec->no_analog) {
2037 err = snd_hda_create_spdif_share_sw(codec,
2038 &spec->multiout);
2039 if (err < 0)
2040 return err;
2041 spec->multiout.share_spdif = 1;
2042 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002043 }
2044 if (spec->dig_in_nid) {
2045 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2046 if (err < 0)
2047 return err;
2048 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002049
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002050 /* create beep controls if needed */
2051 if (spec->beep_amp) {
2052 struct snd_kcontrol_new *knew;
2053 for (knew = alc_beep_mixer; knew->name; knew++) {
2054 struct snd_kcontrol *kctl;
2055 kctl = snd_ctl_new1(knew, codec);
2056 if (!kctl)
2057 return -ENOMEM;
2058 kctl->private_value = spec->beep_amp;
2059 err = snd_hda_ctl_add(codec, kctl);
2060 if (err < 0)
2061 return err;
2062 }
2063 }
2064
Takashi Iwai2134ea42008-01-10 16:53:55 +01002065 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002066 if (!spec->no_analog &&
2067 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002068 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002069 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002070 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002071 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002072 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002073 if (err < 0)
2074 return err;
2075 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002076 if (!spec->no_analog &&
2077 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002078 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2079 NULL, alc_slave_sws);
2080 if (err < 0)
2081 return err;
2082 }
2083
Takashi Iwai603c4012008-07-30 15:01:44 +02002084 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 return 0;
2086}
2087
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002088
Linus Torvalds1da177e2005-04-16 15:20:36 -07002089/*
2090 * initialize the codec volumes, etc
2091 */
2092
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002093/*
2094 * generic initialization of ADC, input mixers and output mixers
2095 */
2096static struct hda_verb alc880_volume_init_verbs[] = {
2097 /*
2098 * Unmute ADC0-2 and set the default input to mic-in
2099 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002100 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002101 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002102 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002103 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002104 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002105 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002106
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002107 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2108 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002109 * Note: PASD motherboards uses the Line In 2 as the input for front
2110 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002111 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002112 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002120
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002121 /*
2122 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002123 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002124 /* set vol=0 to output mixers */
2125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2126 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2127 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2128 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2129 /* set up input amps for analog loopback */
2130 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2132 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002133 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2134 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002135 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2136 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002137 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2138 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002139
2140 { }
2141};
2142
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002143/*
2144 * 3-stack pin configuration:
2145 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2146 */
2147static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2148 /*
2149 * preset connection lists of input pins
2150 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2151 */
2152 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2153 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2154 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2155
2156 /*
2157 * Set pin mode and muting
2158 */
2159 /* set front pin widgets 0x14 for output */
2160 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2161 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2162 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2163 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2164 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2165 /* Mic2 (as headphone out) for HP output */
2166 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2167 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2168 /* Line In pin widget for input */
2169 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2170 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2171 /* Line2 (as front mic) pin widget for input and vref at 80% */
2172 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2173 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2174 /* CD pin widget for input */
2175 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2176
2177 { }
2178};
2179
2180/*
2181 * 5-stack pin configuration:
2182 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2183 * line-in/side = 0x1a, f-mic = 0x1b
2184 */
2185static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2186 /*
2187 * preset connection lists of input pins
2188 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2189 */
2190 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2191 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2192
2193 /*
2194 * Set pin mode and muting
2195 */
2196 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002197 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2199 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2200 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002201 /* unmute pins for output (no gain on this amp) */
2202 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2203 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2204 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2205 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2206
Linus Torvalds1da177e2005-04-16 15:20:36 -07002207 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002208 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002209 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2210 /* Mic2 (as headphone out) for HP output */
2211 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002212 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002213 /* Line In pin widget for input */
2214 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2215 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2216 /* Line2 (as front mic) pin widget for input and vref at 80% */
2217 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2218 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2219 /* CD pin widget for input */
2220 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221
2222 { }
2223};
2224
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002225/*
2226 * W810 pin configuration:
2227 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2228 */
2229static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002230 /* hphone/speaker input selector: front DAC */
2231 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2232
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002233 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2234 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2237 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2238 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2239
2240 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002241 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002242
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243 { }
2244};
2245
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002246/*
2247 * Z71V pin configuration:
2248 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2249 */
2250static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002251 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002252 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002253 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002255
Takashi Iwai16ded522005-06-10 19:58:24 +02002256 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002257 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002258 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002259 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002260
2261 { }
2262};
2263
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002264/*
2265 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002266 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2267 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002268 */
2269static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2270 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2271
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002273 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002274 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002275 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002276 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002277 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002278 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002279 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2280
Takashi Iwai16ded522005-06-10 19:58:24 +02002281 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002282 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002283 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002284 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002285 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002286 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002287 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002288 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002289 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002290
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002291 { }
2292};
Takashi Iwai16ded522005-06-10 19:58:24 +02002293
Kailang Yangccc656c2006-10-17 12:32:26 +02002294/*
2295 * Uniwill pin configuration:
2296 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2297 * line = 0x1a
2298 */
2299static struct hda_verb alc880_uniwill_init_verbs[] = {
2300 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2301
2302 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2304 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2305 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2306 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2307 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2308 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2309 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2312 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2313 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2314 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2315 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2316
2317 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2318 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2319 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2320 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2321 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2322 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2323 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2324 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2325 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2326
2327 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2328 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2329
2330 { }
2331};
2332
2333/*
2334* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002335* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002336 */
2337static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2338 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2339
2340 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2343 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2344 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2345 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2349 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2350 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2351 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2352
2353 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2354 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2356 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2357 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2358 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2359
2360 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2361 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2362
2363 { }
2364};
2365
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002366static struct hda_verb alc880_beep_init_verbs[] = {
2367 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2368 { }
2369};
2370
Kailang Yangccc656c2006-10-17 12:32:26 +02002371/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002372static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002373{
2374 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002375 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002376
2377 present = snd_hda_codec_read(codec, 0x14, 0,
2378 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002379 bits = present ? HDA_AMP_MUTE : 0;
2380 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2381 HDA_AMP_MUTE, bits);
2382 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2383 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002384}
2385
2386/* auto-toggle front mic */
2387static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2388{
2389 unsigned int present;
2390 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002391
2392 present = snd_hda_codec_read(codec, 0x18, 0,
2393 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002394 bits = present ? HDA_AMP_MUTE : 0;
2395 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002396}
2397
2398static void alc880_uniwill_automute(struct hda_codec *codec)
2399{
2400 alc880_uniwill_hp_automute(codec);
2401 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002402}
2403
2404static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2405 unsigned int res)
2406{
2407 /* Looks like the unsol event is incompatible with the standard
2408 * definition. 4bit tag is placed at 28 bit!
2409 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002410 switch (res >> 28) {
2411 case ALC880_HP_EVENT:
2412 alc880_uniwill_hp_automute(codec);
2413 break;
2414 case ALC880_MIC_EVENT:
2415 alc880_uniwill_mic_automute(codec);
2416 break;
2417 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002418}
2419
2420static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2421{
2422 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002423 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002424
2425 present = snd_hda_codec_read(codec, 0x14, 0,
2426 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002427 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002428 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002429}
2430
2431static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2432{
2433 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002434
Kailang Yangccc656c2006-10-17 12:32:26 +02002435 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002436 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2437 present &= HDA_AMP_VOLMASK;
2438 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2439 HDA_AMP_VOLMASK, present);
2440 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2441 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002442}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002443
Kailang Yangccc656c2006-10-17 12:32:26 +02002444static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2445 unsigned int res)
2446{
2447 /* Looks like the unsol event is incompatible with the standard
2448 * definition. 4bit tag is placed at 28 bit!
2449 */
2450 if ((res >> 28) == ALC880_HP_EVENT)
2451 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002452 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002453 alc880_uniwill_p53_dcvol_automute(codec);
2454}
2455
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002456/*
2457 * F1734 pin configuration:
2458 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2459 */
2460static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002461 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002462 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2463 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2464 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2465 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2466
2467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2468 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2471
2472 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2473 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002474 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002475 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2476 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2477 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2478 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2479 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2480 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002481
Takashi Iwai937b4162008-02-11 14:52:36 +01002482 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2483 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2484
Takashi Iwai16ded522005-06-10 19:58:24 +02002485 { }
2486};
2487
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002488/*
2489 * ASUS pin configuration:
2490 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2491 */
2492static struct hda_verb alc880_pin_asus_init_verbs[] = {
2493 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2494 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2495 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2496 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2497
2498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2500 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2502 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2503 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2504 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2506
2507 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2509 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2510 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2511 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2513 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2514 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2515 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002516
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002517 { }
2518};
2519
2520/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002521#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2522#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002523
Kailang Yangdf694da2005-12-05 19:42:22 +01002524/* Clevo m520g init */
2525static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2526 /* headphone output */
2527 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2528 /* line-out */
2529 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2530 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2531 /* Line-in */
2532 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2533 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2534 /* CD */
2535 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2536 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2537 /* Mic1 (rear panel) */
2538 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2539 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2540 /* Mic2 (front panel) */
2541 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2542 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2543 /* headphone */
2544 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2545 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2546 /* change to EAPD mode */
2547 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2548 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2549
2550 { }
2551};
2552
2553static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002554 /* change to EAPD mode */
2555 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2556 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2557
Kailang Yangdf694da2005-12-05 19:42:22 +01002558 /* Headphone output */
2559 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2560 /* Front output*/
2561 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2562 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2563
2564 /* Line In pin widget for input */
2565 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2566 /* CD pin widget for input */
2567 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2568 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2569 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2570
2571 /* change to EAPD mode */
2572 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2573 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2574
2575 { }
2576};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002577
2578/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002579 * LG m1 express dual
2580 *
2581 * Pin assignment:
2582 * Rear Line-In/Out (blue): 0x14
2583 * Build-in Mic-In: 0x15
2584 * Speaker-out: 0x17
2585 * HP-Out (green): 0x1b
2586 * Mic-In/Out (red): 0x19
2587 * SPDIF-Out: 0x1e
2588 */
2589
2590/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2591static hda_nid_t alc880_lg_dac_nids[3] = {
2592 0x05, 0x02, 0x03
2593};
2594
2595/* seems analog CD is not working */
2596static struct hda_input_mux alc880_lg_capture_source = {
2597 .num_items = 3,
2598 .items = {
2599 { "Mic", 0x1 },
2600 { "Line", 0x5 },
2601 { "Internal Mic", 0x6 },
2602 },
2603};
2604
2605/* 2,4,6 channel modes */
2606static struct hda_verb alc880_lg_ch2_init[] = {
2607 /* set line-in and mic-in to input */
2608 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2609 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2610 { }
2611};
2612
2613static struct hda_verb alc880_lg_ch4_init[] = {
2614 /* set line-in to out and mic-in to input */
2615 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2616 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2617 { }
2618};
2619
2620static struct hda_verb alc880_lg_ch6_init[] = {
2621 /* set line-in and mic-in to output */
2622 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2623 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2624 { }
2625};
2626
2627static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2628 { 2, alc880_lg_ch2_init },
2629 { 4, alc880_lg_ch4_init },
2630 { 6, alc880_lg_ch6_init },
2631};
2632
2633static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002634 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2635 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002636 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2637 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2638 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2639 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2640 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2641 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2643 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2644 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2645 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2646 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2647 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2648 {
2649 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2650 .name = "Channel Mode",
2651 .info = alc_ch_mode_info,
2652 .get = alc_ch_mode_get,
2653 .put = alc_ch_mode_put,
2654 },
2655 { } /* end */
2656};
2657
2658static struct hda_verb alc880_lg_init_verbs[] = {
2659 /* set capture source to mic-in */
2660 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2661 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2662 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2663 /* mute all amp mixer inputs */
2664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2666 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002667 /* line-in to input */
2668 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2669 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2670 /* built-in mic */
2671 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2672 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2673 /* speaker-out */
2674 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2675 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2676 /* mic-in to input */
2677 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2678 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2679 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2680 /* HP-out */
2681 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2682 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2683 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2684 /* jack sense */
2685 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2686 { }
2687};
2688
2689/* toggle speaker-output according to the hp-jack state */
2690static void alc880_lg_automute(struct hda_codec *codec)
2691{
2692 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002693 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002694
2695 present = snd_hda_codec_read(codec, 0x1b, 0,
2696 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002697 bits = present ? HDA_AMP_MUTE : 0;
2698 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2699 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002700}
2701
2702static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2703{
2704 /* Looks like the unsol event is incompatible with the standard
2705 * definition. 4bit tag is placed at 28 bit!
2706 */
2707 if ((res >> 28) == 0x01)
2708 alc880_lg_automute(codec);
2709}
2710
2711/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002712 * LG LW20
2713 *
2714 * Pin assignment:
2715 * Speaker-out: 0x14
2716 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002717 * Built-in Mic-In: 0x19
2718 * Line-In: 0x1b
2719 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002720 * SPDIF-Out: 0x1e
2721 */
2722
Takashi Iwaid6815182006-03-23 16:06:23 +01002723static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002724 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002725 .items = {
2726 { "Mic", 0x0 },
2727 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002728 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002729 },
2730};
2731
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002732#define alc880_lg_lw_modes alc880_threestack_modes
2733
Takashi Iwaid6815182006-03-23 16:06:23 +01002734static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002735 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2736 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2737 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2738 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2739 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2740 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2741 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2742 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2743 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2744 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002745 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2747 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2748 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002749 {
2750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2751 .name = "Channel Mode",
2752 .info = alc_ch_mode_info,
2753 .get = alc_ch_mode_get,
2754 .put = alc_ch_mode_put,
2755 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002756 { } /* end */
2757};
2758
2759static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002760 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2761 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2762 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2763
Takashi Iwaid6815182006-03-23 16:06:23 +01002764 /* set capture source to mic-in */
2765 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2766 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2767 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002768 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002769 /* speaker-out */
2770 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2771 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2772 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002773 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2774 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2775 /* mic-in to input */
2776 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2777 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2778 /* built-in mic */
2779 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2780 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2781 /* jack sense */
2782 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2783 { }
2784};
2785
2786/* toggle speaker-output according to the hp-jack state */
2787static void alc880_lg_lw_automute(struct hda_codec *codec)
2788{
2789 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002790 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002791
2792 present = snd_hda_codec_read(codec, 0x1b, 0,
2793 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002794 bits = present ? HDA_AMP_MUTE : 0;
2795 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2796 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002797}
2798
2799static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2800{
2801 /* Looks like the unsol event is incompatible with the standard
2802 * definition. 4bit tag is placed at 28 bit!
2803 */
2804 if ((res >> 28) == 0x01)
2805 alc880_lg_lw_automute(codec);
2806}
2807
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002808static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2809 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2810 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2813 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2814 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2815 { } /* end */
2816};
2817
2818static struct hda_input_mux alc880_medion_rim_capture_source = {
2819 .num_items = 2,
2820 .items = {
2821 { "Mic", 0x0 },
2822 { "Internal Mic", 0x1 },
2823 },
2824};
2825
2826static struct hda_verb alc880_medion_rim_init_verbs[] = {
2827 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2828
2829 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2830 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2831
2832 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2833 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2834 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2835 /* Mic2 (as headphone out) for HP output */
2836 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2837 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2838 /* Internal Speaker */
2839 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2840 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2841
2842 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2843 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2844
2845 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2846 { }
2847};
2848
2849/* toggle speaker-output according to the hp-jack state */
2850static void alc880_medion_rim_automute(struct hda_codec *codec)
2851{
2852 unsigned int present;
2853 unsigned char bits;
2854
2855 present = snd_hda_codec_read(codec, 0x14, 0,
2856 AC_VERB_GET_PIN_SENSE, 0)
2857 & AC_PINSENSE_PRESENCE;
2858 bits = present ? HDA_AMP_MUTE : 0;
2859 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2860 HDA_AMP_MUTE, bits);
2861 if (present)
2862 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2863 else
2864 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2865}
2866
2867static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2868 unsigned int res)
2869{
2870 /* Looks like the unsol event is incompatible with the standard
2871 * definition. 4bit tag is placed at 28 bit!
2872 */
2873 if ((res >> 28) == ALC880_HP_EVENT)
2874 alc880_medion_rim_automute(codec);
2875}
2876
Takashi Iwaicb53c622007-08-10 17:21:45 +02002877#ifdef CONFIG_SND_HDA_POWER_SAVE
2878static struct hda_amp_list alc880_loopbacks[] = {
2879 { 0x0b, HDA_INPUT, 0 },
2880 { 0x0b, HDA_INPUT, 1 },
2881 { 0x0b, HDA_INPUT, 2 },
2882 { 0x0b, HDA_INPUT, 3 },
2883 { 0x0b, HDA_INPUT, 4 },
2884 { } /* end */
2885};
2886
2887static struct hda_amp_list alc880_lg_loopbacks[] = {
2888 { 0x0b, HDA_INPUT, 1 },
2889 { 0x0b, HDA_INPUT, 6 },
2890 { 0x0b, HDA_INPUT, 7 },
2891 { } /* end */
2892};
2893#endif
2894
Takashi Iwaid6815182006-03-23 16:06:23 +01002895/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002896 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002897 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002898
Linus Torvalds1da177e2005-04-16 15:20:36 -07002899static int alc_init(struct hda_codec *codec)
2900{
2901 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002902 unsigned int i;
2903
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002904 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002905 if (codec->vendor_id == 0x10ec0888)
2906 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002907
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002908 for (i = 0; i < spec->num_init_verbs; i++)
2909 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002910
2911 if (spec->init_hook)
2912 spec->init_hook(codec);
2913
Linus Torvalds1da177e2005-04-16 15:20:36 -07002914 return 0;
2915}
2916
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002917static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2918{
2919 struct alc_spec *spec = codec->spec;
2920
2921 if (spec->unsol_event)
2922 spec->unsol_event(codec, res);
2923}
2924
Takashi Iwaicb53c622007-08-10 17:21:45 +02002925#ifdef CONFIG_SND_HDA_POWER_SAVE
2926static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2927{
2928 struct alc_spec *spec = codec->spec;
2929 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2930}
2931#endif
2932
Linus Torvalds1da177e2005-04-16 15:20:36 -07002933/*
2934 * Analog playback callbacks
2935 */
2936static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2937 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002938 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002939{
2940 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002941 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2942 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002943}
2944
2945static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2946 struct hda_codec *codec,
2947 unsigned int stream_tag,
2948 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002949 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002950{
2951 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002952 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2953 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002954}
2955
2956static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2957 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002958 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002959{
2960 struct alc_spec *spec = codec->spec;
2961 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2962}
2963
2964/*
2965 * Digital out
2966 */
2967static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2968 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002969 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002970{
2971 struct alc_spec *spec = codec->spec;
2972 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2973}
2974
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002975static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2976 struct hda_codec *codec,
2977 unsigned int stream_tag,
2978 unsigned int format,
2979 struct snd_pcm_substream *substream)
2980{
2981 struct alc_spec *spec = codec->spec;
2982 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2983 stream_tag, format, substream);
2984}
2985
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01002986static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2987 struct hda_codec *codec,
2988 struct snd_pcm_substream *substream)
2989{
2990 struct alc_spec *spec = codec->spec;
2991 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2992}
2993
Linus Torvalds1da177e2005-04-16 15:20:36 -07002994static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2995 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002996 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002997{
2998 struct alc_spec *spec = codec->spec;
2999 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3000}
3001
3002/*
3003 * Analog capture
3004 */
Takashi Iwai63300792008-01-24 15:31:36 +01003005static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003006 struct hda_codec *codec,
3007 unsigned int stream_tag,
3008 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003009 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003010{
3011 struct alc_spec *spec = codec->spec;
3012
Takashi Iwai63300792008-01-24 15:31:36 +01003013 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003014 stream_tag, 0, format);
3015 return 0;
3016}
3017
Takashi Iwai63300792008-01-24 15:31:36 +01003018static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003019 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003020 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003021{
3022 struct alc_spec *spec = codec->spec;
3023
Takashi Iwai888afa12008-03-18 09:57:50 +01003024 snd_hda_codec_cleanup_stream(codec,
3025 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003026 return 0;
3027}
3028
3029
3030/*
3031 */
3032static struct hda_pcm_stream alc880_pcm_analog_playback = {
3033 .substreams = 1,
3034 .channels_min = 2,
3035 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003036 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003037 .ops = {
3038 .open = alc880_playback_pcm_open,
3039 .prepare = alc880_playback_pcm_prepare,
3040 .cleanup = alc880_playback_pcm_cleanup
3041 },
3042};
3043
3044static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003045 .substreams = 1,
3046 .channels_min = 2,
3047 .channels_max = 2,
3048 /* NID is set in alc_build_pcms */
3049};
3050
3051static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3052 .substreams = 1,
3053 .channels_min = 2,
3054 .channels_max = 2,
3055 /* NID is set in alc_build_pcms */
3056};
3057
3058static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3059 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003060 .channels_min = 2,
3061 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003062 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003063 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003064 .prepare = alc880_alt_capture_pcm_prepare,
3065 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003066 },
3067};
3068
3069static struct hda_pcm_stream alc880_pcm_digital_playback = {
3070 .substreams = 1,
3071 .channels_min = 2,
3072 .channels_max = 2,
3073 /* NID is set in alc_build_pcms */
3074 .ops = {
3075 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003076 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003077 .prepare = alc880_dig_playback_pcm_prepare,
3078 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003079 },
3080};
3081
3082static struct hda_pcm_stream alc880_pcm_digital_capture = {
3083 .substreams = 1,
3084 .channels_min = 2,
3085 .channels_max = 2,
3086 /* NID is set in alc_build_pcms */
3087};
3088
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003089/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003090static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003091 .substreams = 0,
3092 .channels_min = 0,
3093 .channels_max = 0,
3094};
3095
Linus Torvalds1da177e2005-04-16 15:20:36 -07003096static int alc_build_pcms(struct hda_codec *codec)
3097{
3098 struct alc_spec *spec = codec->spec;
3099 struct hda_pcm *info = spec->pcm_rec;
3100 int i;
3101
3102 codec->num_pcms = 1;
3103 codec->pcm_info = info;
3104
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003105 if (spec->no_analog)
3106 goto skip_analog;
3107
Linus Torvalds1da177e2005-04-16 15:20:36 -07003108 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003109 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003110 if (snd_BUG_ON(!spec->multiout.dac_nids))
3111 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003112 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3113 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3114 }
3115 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003116 if (snd_BUG_ON(!spec->adc_nids))
3117 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003118 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3119 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3120 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003121
Takashi Iwai4a471b72005-12-07 13:56:29 +01003122 if (spec->channel_mode) {
3123 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3124 for (i = 0; i < spec->num_channel_mode; i++) {
3125 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3126 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3127 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003128 }
3129 }
3130
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003131 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003132 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003133 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003134 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003135 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003136 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003137 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003138 if (spec->dig_out_type)
3139 info->pcm_type = spec->dig_out_type;
3140 else
3141 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003142 if (spec->multiout.dig_out_nid &&
3143 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003144 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3145 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3146 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003147 if (spec->dig_in_nid &&
3148 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003149 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3150 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3151 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003152 /* FIXME: do we need this for all Realtek codec models? */
3153 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003154 }
3155
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003156 if (spec->no_analog)
3157 return 0;
3158
Takashi Iwaie08a0072006-09-07 17:52:14 +02003159 /* If the use of more than one ADC is requested for the current
3160 * model, configure a second analog capture-only PCM.
3161 */
3162 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003163 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3164 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003165 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003166 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003167 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003168 if (spec->alt_dac_nid) {
3169 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3170 *spec->stream_analog_alt_playback;
3171 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3172 spec->alt_dac_nid;
3173 } else {
3174 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3175 alc_pcm_null_stream;
3176 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3177 }
3178 if (spec->num_adc_nids > 1) {
3179 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3180 *spec->stream_analog_alt_capture;
3181 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3182 spec->adc_nids[1];
3183 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3184 spec->num_adc_nids - 1;
3185 } else {
3186 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3187 alc_pcm_null_stream;
3188 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003189 }
3190 }
3191
Linus Torvalds1da177e2005-04-16 15:20:36 -07003192 return 0;
3193}
3194
Takashi Iwai603c4012008-07-30 15:01:44 +02003195static void alc_free_kctls(struct hda_codec *codec)
3196{
3197 struct alc_spec *spec = codec->spec;
3198
3199 if (spec->kctls.list) {
3200 struct snd_kcontrol_new *kctl = spec->kctls.list;
3201 int i;
3202 for (i = 0; i < spec->kctls.used; i++)
3203 kfree(kctl[i].name);
3204 }
3205 snd_array_free(&spec->kctls);
3206}
3207
Linus Torvalds1da177e2005-04-16 15:20:36 -07003208static void alc_free(struct hda_codec *codec)
3209{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003210 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003211
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003212 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003213 return;
3214
Takashi Iwai603c4012008-07-30 15:01:44 +02003215 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003216 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003217 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003218}
3219
Takashi Iwaie044c392008-10-27 16:56:24 +01003220#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003221static int alc_resume(struct hda_codec *codec)
3222{
Takashi Iwaie044c392008-10-27 16:56:24 +01003223 codec->patch_ops.init(codec);
3224 snd_hda_codec_resume_amp(codec);
3225 snd_hda_codec_resume_cache(codec);
3226 return 0;
3227}
Takashi Iwaie044c392008-10-27 16:56:24 +01003228#endif
3229
Linus Torvalds1da177e2005-04-16 15:20:36 -07003230/*
3231 */
3232static struct hda_codec_ops alc_patch_ops = {
3233 .build_controls = alc_build_controls,
3234 .build_pcms = alc_build_pcms,
3235 .init = alc_init,
3236 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003237 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003238#ifdef SND_HDA_NEEDS_RESUME
3239 .resume = alc_resume,
3240#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003241#ifdef CONFIG_SND_HDA_POWER_SAVE
3242 .check_power_status = alc_check_power_status,
3243#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003244};
3245
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003246
3247/*
3248 * Test configuration for debugging
3249 *
3250 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3251 * enum controls.
3252 */
3253#ifdef CONFIG_SND_DEBUG
3254static hda_nid_t alc880_test_dac_nids[4] = {
3255 0x02, 0x03, 0x04, 0x05
3256};
3257
3258static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003259 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003260 .items = {
3261 { "In-1", 0x0 },
3262 { "In-2", 0x1 },
3263 { "In-3", 0x2 },
3264 { "In-4", 0x3 },
3265 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003266 { "Front", 0x5 },
3267 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003268 },
3269};
3270
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003271static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003272 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003273 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003274 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003275 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003276};
3277
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003278static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3279 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003280{
3281 static char *texts[] = {
3282 "N/A", "Line Out", "HP Out",
3283 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3284 };
3285 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3286 uinfo->count = 1;
3287 uinfo->value.enumerated.items = 8;
3288 if (uinfo->value.enumerated.item >= 8)
3289 uinfo->value.enumerated.item = 7;
3290 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3291 return 0;
3292}
3293
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003294static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3295 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003296{
3297 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3298 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3299 unsigned int pin_ctl, item = 0;
3300
3301 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3302 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3303 if (pin_ctl & AC_PINCTL_OUT_EN) {
3304 if (pin_ctl & AC_PINCTL_HP_EN)
3305 item = 2;
3306 else
3307 item = 1;
3308 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3309 switch (pin_ctl & AC_PINCTL_VREFEN) {
3310 case AC_PINCTL_VREF_HIZ: item = 3; break;
3311 case AC_PINCTL_VREF_50: item = 4; break;
3312 case AC_PINCTL_VREF_GRD: item = 5; break;
3313 case AC_PINCTL_VREF_80: item = 6; break;
3314 case AC_PINCTL_VREF_100: item = 7; break;
3315 }
3316 }
3317 ucontrol->value.enumerated.item[0] = item;
3318 return 0;
3319}
3320
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003321static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3322 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003323{
3324 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3325 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3326 static unsigned int ctls[] = {
3327 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3328 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3329 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3330 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3331 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3332 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3333 };
3334 unsigned int old_ctl, new_ctl;
3335
3336 old_ctl = snd_hda_codec_read(codec, nid, 0,
3337 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3338 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3339 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003340 int val;
3341 snd_hda_codec_write_cache(codec, nid, 0,
3342 AC_VERB_SET_PIN_WIDGET_CONTROL,
3343 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003344 val = ucontrol->value.enumerated.item[0] >= 3 ?
3345 HDA_AMP_MUTE : 0;
3346 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3347 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003348 return 1;
3349 }
3350 return 0;
3351}
3352
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003353static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3354 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003355{
3356 static char *texts[] = {
3357 "Front", "Surround", "CLFE", "Side"
3358 };
3359 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3360 uinfo->count = 1;
3361 uinfo->value.enumerated.items = 4;
3362 if (uinfo->value.enumerated.item >= 4)
3363 uinfo->value.enumerated.item = 3;
3364 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3365 return 0;
3366}
3367
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003368static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3369 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003370{
3371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3372 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3373 unsigned int sel;
3374
3375 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3376 ucontrol->value.enumerated.item[0] = sel & 3;
3377 return 0;
3378}
3379
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003380static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3381 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003382{
3383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3384 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3385 unsigned int sel;
3386
3387 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3388 if (ucontrol->value.enumerated.item[0] != sel) {
3389 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003390 snd_hda_codec_write_cache(codec, nid, 0,
3391 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003392 return 1;
3393 }
3394 return 0;
3395}
3396
3397#define PIN_CTL_TEST(xname,nid) { \
3398 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3399 .name = xname, \
3400 .info = alc_test_pin_ctl_info, \
3401 .get = alc_test_pin_ctl_get, \
3402 .put = alc_test_pin_ctl_put, \
3403 .private_value = nid \
3404 }
3405
3406#define PIN_SRC_TEST(xname,nid) { \
3407 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3408 .name = xname, \
3409 .info = alc_test_pin_src_info, \
3410 .get = alc_test_pin_src_get, \
3411 .put = alc_test_pin_src_put, \
3412 .private_value = nid \
3413 }
3414
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003415static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003416 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3417 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3418 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3419 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003420 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3421 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3422 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3423 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003424 PIN_CTL_TEST("Front Pin Mode", 0x14),
3425 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3426 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3427 PIN_CTL_TEST("Side Pin Mode", 0x17),
3428 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3429 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3430 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3431 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3432 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3433 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3434 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3435 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3436 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3437 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3438 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3439 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3440 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3441 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3442 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3443 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3444 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3445 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003446 {
3447 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3448 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003449 .info = alc_ch_mode_info,
3450 .get = alc_ch_mode_get,
3451 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003452 },
3453 { } /* end */
3454};
3455
3456static struct hda_verb alc880_test_init_verbs[] = {
3457 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3461 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003466 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003467 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3468 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3469 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3470 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003471 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3473 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3474 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3475 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003476 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3478 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3479 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3480 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003481 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003482 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003484 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3485 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3486 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003487 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003488 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3489 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3490 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3491 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003492 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003493 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003494 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003495 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003496 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003497 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003498 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003499 /* Analog input/passthru */
3500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003505 { }
3506};
3507#endif
3508
Linus Torvalds1da177e2005-04-16 15:20:36 -07003509/*
3510 */
3511
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003512static const char *alc880_models[ALC880_MODEL_LAST] = {
3513 [ALC880_3ST] = "3stack",
3514 [ALC880_TCL_S700] = "tcl",
3515 [ALC880_3ST_DIG] = "3stack-digout",
3516 [ALC880_CLEVO] = "clevo",
3517 [ALC880_5ST] = "5stack",
3518 [ALC880_5ST_DIG] = "5stack-digout",
3519 [ALC880_W810] = "w810",
3520 [ALC880_Z71V] = "z71v",
3521 [ALC880_6ST] = "6stack",
3522 [ALC880_6ST_DIG] = "6stack-digout",
3523 [ALC880_ASUS] = "asus",
3524 [ALC880_ASUS_W1V] = "asus-w1v",
3525 [ALC880_ASUS_DIG] = "asus-dig",
3526 [ALC880_ASUS_DIG2] = "asus-dig2",
3527 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003528 [ALC880_UNIWILL_P53] = "uniwill-p53",
3529 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003530 [ALC880_F1734] = "F1734",
3531 [ALC880_LG] = "lg",
3532 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003533 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003534#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003535 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003536#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003537 [ALC880_AUTO] = "auto",
3538};
3539
3540static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003541 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003542 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3543 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3544 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3545 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3546 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3547 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3548 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3549 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003550 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3551 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003552 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3553 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3554 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3555 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3556 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3557 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3558 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3559 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3560 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3561 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003562 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003563 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3564 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3565 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003566 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003567 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003568 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3569 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003570 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3571 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003572 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3573 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3574 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3575 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003576 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3577 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003578 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003579 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003580 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003581 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003582 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3583 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003584 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003585 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003586 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003587 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003588 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003589 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003590 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003591 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003592 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003593 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3594 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003595 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003596 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3597 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3598 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3599 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003600 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3601 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003602 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003603 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003604 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3605 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003606 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3607 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3608 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003609 /* default Intel */
3610 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003611 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3612 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003613 {}
3614};
3615
Takashi Iwai16ded522005-06-10 19:58:24 +02003616/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003617 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003618 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003619static struct alc_config_preset alc880_presets[] = {
3620 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003621 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003622 .init_verbs = { alc880_volume_init_verbs,
3623 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003624 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003625 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003626 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3627 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003628 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003629 .input_mux = &alc880_capture_source,
3630 },
3631 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003632 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003633 .init_verbs = { alc880_volume_init_verbs,
3634 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003635 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003636 .dac_nids = alc880_dac_nids,
3637 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003638 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3639 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003640 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003641 .input_mux = &alc880_capture_source,
3642 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003643 [ALC880_TCL_S700] = {
3644 .mixers = { alc880_tcl_s700_mixer },
3645 .init_verbs = { alc880_volume_init_verbs,
3646 alc880_pin_tcl_S700_init_verbs,
3647 alc880_gpio2_init_verbs },
3648 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3649 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003650 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3651 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003652 .hp_nid = 0x03,
3653 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3654 .channel_mode = alc880_2_jack_modes,
3655 .input_mux = &alc880_capture_source,
3656 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003657 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003658 .mixers = { alc880_three_stack_mixer,
3659 alc880_five_stack_mixer},
3660 .init_verbs = { alc880_volume_init_verbs,
3661 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003662 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3663 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003664 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3665 .channel_mode = alc880_fivestack_modes,
3666 .input_mux = &alc880_capture_source,
3667 },
3668 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003669 .mixers = { alc880_three_stack_mixer,
3670 alc880_five_stack_mixer },
3671 .init_verbs = { alc880_volume_init_verbs,
3672 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003673 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3674 .dac_nids = alc880_dac_nids,
3675 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003676 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3677 .channel_mode = alc880_fivestack_modes,
3678 .input_mux = &alc880_capture_source,
3679 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003680 [ALC880_6ST] = {
3681 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003682 .init_verbs = { alc880_volume_init_verbs,
3683 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003684 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3685 .dac_nids = alc880_6st_dac_nids,
3686 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3687 .channel_mode = alc880_sixstack_modes,
3688 .input_mux = &alc880_6stack_capture_source,
3689 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003690 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003691 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003692 .init_verbs = { alc880_volume_init_verbs,
3693 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003694 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3695 .dac_nids = alc880_6st_dac_nids,
3696 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003697 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3698 .channel_mode = alc880_sixstack_modes,
3699 .input_mux = &alc880_6stack_capture_source,
3700 },
3701 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003702 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003703 .init_verbs = { alc880_volume_init_verbs,
3704 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003705 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003706 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3707 .dac_nids = alc880_w810_dac_nids,
3708 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003709 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3710 .channel_mode = alc880_w810_modes,
3711 .input_mux = &alc880_capture_source,
3712 },
3713 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003714 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003715 .init_verbs = { alc880_volume_init_verbs,
3716 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003717 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3718 .dac_nids = alc880_z71v_dac_nids,
3719 .dig_out_nid = ALC880_DIGOUT_NID,
3720 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003721 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3722 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003723 .input_mux = &alc880_capture_source,
3724 },
3725 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003726 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003727 .init_verbs = { alc880_volume_init_verbs,
3728 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003729 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3730 .dac_nids = alc880_f1734_dac_nids,
3731 .hp_nid = 0x02,
3732 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3733 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003734 .input_mux = &alc880_f1734_capture_source,
3735 .unsol_event = alc880_uniwill_p53_unsol_event,
3736 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003737 },
3738 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003739 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003740 .init_verbs = { alc880_volume_init_verbs,
3741 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003742 alc880_gpio1_init_verbs },
3743 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3744 .dac_nids = alc880_asus_dac_nids,
3745 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3746 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003747 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003748 .input_mux = &alc880_capture_source,
3749 },
3750 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003751 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003752 .init_verbs = { alc880_volume_init_verbs,
3753 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003754 alc880_gpio1_init_verbs },
3755 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3756 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003757 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003758 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3759 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003760 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003761 .input_mux = &alc880_capture_source,
3762 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003763 [ALC880_ASUS_DIG2] = {
3764 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003765 .init_verbs = { alc880_volume_init_verbs,
3766 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003767 alc880_gpio2_init_verbs }, /* use GPIO2 */
3768 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3769 .dac_nids = alc880_asus_dac_nids,
3770 .dig_out_nid = ALC880_DIGOUT_NID,
3771 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3772 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003773 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003774 .input_mux = &alc880_capture_source,
3775 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003776 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003777 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003778 .init_verbs = { alc880_volume_init_verbs,
3779 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003780 alc880_gpio1_init_verbs },
3781 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3782 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003783 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003784 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3785 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003786 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003787 .input_mux = &alc880_capture_source,
3788 },
3789 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003790 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003791 .init_verbs = { alc880_volume_init_verbs,
3792 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003793 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3794 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003795 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003796 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3797 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003798 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003799 .input_mux = &alc880_capture_source,
3800 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003801 [ALC880_UNIWILL] = {
3802 .mixers = { alc880_uniwill_mixer },
3803 .init_verbs = { alc880_volume_init_verbs,
3804 alc880_uniwill_init_verbs },
3805 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3806 .dac_nids = alc880_asus_dac_nids,
3807 .dig_out_nid = ALC880_DIGOUT_NID,
3808 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3809 .channel_mode = alc880_threestack_modes,
3810 .need_dac_fix = 1,
3811 .input_mux = &alc880_capture_source,
3812 .unsol_event = alc880_uniwill_unsol_event,
3813 .init_hook = alc880_uniwill_automute,
3814 },
3815 [ALC880_UNIWILL_P53] = {
3816 .mixers = { alc880_uniwill_p53_mixer },
3817 .init_verbs = { alc880_volume_init_verbs,
3818 alc880_uniwill_p53_init_verbs },
3819 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3820 .dac_nids = alc880_asus_dac_nids,
3821 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003822 .channel_mode = alc880_threestack_modes,
3823 .input_mux = &alc880_capture_source,
3824 .unsol_event = alc880_uniwill_p53_unsol_event,
3825 .init_hook = alc880_uniwill_p53_hp_automute,
3826 },
3827 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003828 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003829 .init_verbs = { alc880_volume_init_verbs,
3830 alc880_uniwill_p53_init_verbs,
3831 alc880_beep_init_verbs },
3832 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3833 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003834 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003835 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3836 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003837 .input_mux = &alc880_capture_source,
3838 .unsol_event = alc880_uniwill_p53_unsol_event,
3839 .init_hook = alc880_uniwill_p53_hp_automute,
3840 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003841 [ALC880_CLEVO] = {
3842 .mixers = { alc880_three_stack_mixer },
3843 .init_verbs = { alc880_volume_init_verbs,
3844 alc880_pin_clevo_init_verbs },
3845 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3846 .dac_nids = alc880_dac_nids,
3847 .hp_nid = 0x03,
3848 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3849 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003850 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003851 .input_mux = &alc880_capture_source,
3852 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003853 [ALC880_LG] = {
3854 .mixers = { alc880_lg_mixer },
3855 .init_verbs = { alc880_volume_init_verbs,
3856 alc880_lg_init_verbs },
3857 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3858 .dac_nids = alc880_lg_dac_nids,
3859 .dig_out_nid = ALC880_DIGOUT_NID,
3860 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3861 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003862 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003863 .input_mux = &alc880_lg_capture_source,
3864 .unsol_event = alc880_lg_unsol_event,
3865 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003866#ifdef CONFIG_SND_HDA_POWER_SAVE
3867 .loopbacks = alc880_lg_loopbacks,
3868#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003869 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003870 [ALC880_LG_LW] = {
3871 .mixers = { alc880_lg_lw_mixer },
3872 .init_verbs = { alc880_volume_init_verbs,
3873 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003874 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003875 .dac_nids = alc880_dac_nids,
3876 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003877 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3878 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003879 .input_mux = &alc880_lg_lw_capture_source,
3880 .unsol_event = alc880_lg_lw_unsol_event,
3881 .init_hook = alc880_lg_lw_automute,
3882 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003883 [ALC880_MEDION_RIM] = {
3884 .mixers = { alc880_medion_rim_mixer },
3885 .init_verbs = { alc880_volume_init_verbs,
3886 alc880_medion_rim_init_verbs,
3887 alc_gpio2_init_verbs },
3888 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3889 .dac_nids = alc880_dac_nids,
3890 .dig_out_nid = ALC880_DIGOUT_NID,
3891 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3892 .channel_mode = alc880_2_jack_modes,
3893 .input_mux = &alc880_medion_rim_capture_source,
3894 .unsol_event = alc880_medion_rim_unsol_event,
3895 .init_hook = alc880_medion_rim_automute,
3896 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003897#ifdef CONFIG_SND_DEBUG
3898 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003899 .mixers = { alc880_test_mixer },
3900 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003901 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3902 .dac_nids = alc880_test_dac_nids,
3903 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003904 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3905 .channel_mode = alc880_test_modes,
3906 .input_mux = &alc880_test_capture_source,
3907 },
3908#endif
3909};
3910
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003911/*
3912 * Automatic parse of I/O pins from the BIOS configuration
3913 */
3914
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003915enum {
3916 ALC_CTL_WIDGET_VOL,
3917 ALC_CTL_WIDGET_MUTE,
3918 ALC_CTL_BIND_MUTE,
3919};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003920static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003921 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3922 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003923 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003924};
3925
3926/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003927static int add_control(struct alc_spec *spec, int type, const char *name,
3928 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003929{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003930 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003931
Takashi Iwai603c4012008-07-30 15:01:44 +02003932 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3933 knew = snd_array_new(&spec->kctls);
3934 if (!knew)
3935 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003936 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003937 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003938 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003939 return -ENOMEM;
3940 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003941 return 0;
3942}
3943
3944#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3945#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3946#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3947#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3948#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3949#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3950#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3951#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3952#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3953#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3954#define ALC880_PIN_CD_NID 0x1c
3955
3956/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003957static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3958 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003959{
3960 hda_nid_t nid;
3961 int assigned[4];
3962 int i, j;
3963
3964 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003965 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003966
3967 /* check the pins hardwired to audio widget */
3968 for (i = 0; i < cfg->line_outs; i++) {
3969 nid = cfg->line_out_pins[i];
3970 if (alc880_is_fixed_pin(nid)) {
3971 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003972 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003973 assigned[idx] = 1;
3974 }
3975 }
3976 /* left pins can be connect to any audio widget */
3977 for (i = 0; i < cfg->line_outs; i++) {
3978 nid = cfg->line_out_pins[i];
3979 if (alc880_is_fixed_pin(nid))
3980 continue;
3981 /* search for an empty channel */
3982 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003983 if (!assigned[j]) {
3984 spec->multiout.dac_nids[i] =
3985 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003986 assigned[j] = 1;
3987 break;
3988 }
3989 }
3990 }
3991 spec->multiout.num_dacs = cfg->line_outs;
3992 return 0;
3993}
3994
3995/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003996static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3997 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003998{
3999 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004000 static const char *chname[4] = {
4001 "Front", "Surround", NULL /*CLFE*/, "Side"
4002 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004003 hda_nid_t nid;
4004 int i, err;
4005
4006 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004007 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004008 continue;
4009 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4010 if (i == 2) {
4011 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004012 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4013 "Center Playback Volume",
4014 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4015 HDA_OUTPUT));
4016 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004017 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004018 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4019 "LFE Playback Volume",
4020 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4021 HDA_OUTPUT));
4022 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004023 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004024 err = add_control(spec, ALC_CTL_BIND_MUTE,
4025 "Center Playback Switch",
4026 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4027 HDA_INPUT));
4028 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004029 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004030 err = add_control(spec, ALC_CTL_BIND_MUTE,
4031 "LFE Playback Switch",
4032 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4033 HDA_INPUT));
4034 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004035 return err;
4036 } else {
4037 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004038 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4039 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4040 HDA_OUTPUT));
4041 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004042 return err;
4043 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004044 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4045 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4046 HDA_INPUT));
4047 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004048 return err;
4049 }
4050 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004051 return 0;
4052}
4053
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004054/* add playback controls for speaker and HP outputs */
4055static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4056 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004057{
4058 hda_nid_t nid;
4059 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004060 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004061
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004062 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004063 return 0;
4064
4065 if (alc880_is_fixed_pin(pin)) {
4066 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004067 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004068 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004069 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004070 else
4071 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004072 /* control HP volume/switch on the output mixer amp */
4073 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004074 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004075 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4076 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4077 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004078 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004079 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004080 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4081 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4082 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004083 return err;
4084 } else if (alc880_is_multi_pin(pin)) {
4085 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004086 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004087 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004088 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4089 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4090 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004091 return err;
4092 }
4093 return 0;
4094}
4095
4096/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004097static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4098 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004099 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004100{
4101 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004102 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004103
4104 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004105 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4106 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4107 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004108 return err;
4109 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004110 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4111 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4112 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004113 return err;
4114 return 0;
4115}
4116
4117/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004118static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4119 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004120{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004121 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004122 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004123
4124 for (i = 0; i < AUTO_PIN_LAST; i++) {
4125 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004126 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004127 err = new_analog_input(spec, cfg->input_pins[i],
4128 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004129 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004130 if (err < 0)
4131 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004132 imux->items[imux->num_items].label =
4133 auto_pin_cfg_labels[i];
4134 imux->items[imux->num_items].index =
4135 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004136 imux->num_items++;
4137 }
4138 }
4139 return 0;
4140}
4141
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004142static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4143 unsigned int pin_type)
4144{
4145 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4146 pin_type);
4147 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004148 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4149 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004150}
4151
Kailang Yangdf694da2005-12-05 19:42:22 +01004152static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4153 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004154 int dac_idx)
4155{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004156 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004157 /* need the manual connection? */
4158 if (alc880_is_multi_pin(nid)) {
4159 struct alc_spec *spec = codec->spec;
4160 int idx = alc880_multi_pin_idx(nid);
4161 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4162 AC_VERB_SET_CONNECT_SEL,
4163 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4164 }
4165}
4166
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004167static int get_pin_type(int line_out_type)
4168{
4169 if (line_out_type == AUTO_PIN_HP_OUT)
4170 return PIN_HP;
4171 else
4172 return PIN_OUT;
4173}
4174
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004175static void alc880_auto_init_multi_out(struct hda_codec *codec)
4176{
4177 struct alc_spec *spec = codec->spec;
4178 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004179
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004180 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004181 for (i = 0; i < spec->autocfg.line_outs; i++) {
4182 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004183 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4184 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004185 }
4186}
4187
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004188static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004189{
4190 struct alc_spec *spec = codec->spec;
4191 hda_nid_t pin;
4192
Takashi Iwai82bc9552006-03-21 11:24:42 +01004193 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004194 if (pin) /* connect to front */
4195 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004196 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004197 if (pin) /* connect to front */
4198 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4199}
4200
4201static void alc880_auto_init_analog_input(struct hda_codec *codec)
4202{
4203 struct alc_spec *spec = codec->spec;
4204 int i;
4205
4206 for (i = 0; i < AUTO_PIN_LAST; i++) {
4207 hda_nid_t nid = spec->autocfg.input_pins[i];
4208 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004209 alc_set_input_pin(codec, nid, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004210 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004211 snd_hda_codec_write(codec, nid, 0,
4212 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004213 AMP_OUT_MUTE);
4214 }
4215 }
4216}
4217
4218/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004219/* return 1 if successful, 0 if the proper config is not found,
4220 * or a negative error code
4221 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004222static int alc880_parse_auto_config(struct hda_codec *codec)
4223{
4224 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004225 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004226 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004227
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004228 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4229 alc880_ignore);
4230 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004231 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004232 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004233 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004234
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004235 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4236 if (err < 0)
4237 return err;
4238 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4239 if (err < 0)
4240 return err;
4241 err = alc880_auto_create_extra_out(spec,
4242 spec->autocfg.speaker_pins[0],
4243 "Speaker");
4244 if (err < 0)
4245 return err;
4246 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4247 "Headphone");
4248 if (err < 0)
4249 return err;
4250 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4251 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004252 return err;
4253
4254 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4255
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004256 /* check multiple SPDIF-out (for recent codecs) */
4257 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4258 hda_nid_t dig_nid;
4259 err = snd_hda_get_connections(codec,
4260 spec->autocfg.dig_out_pins[i],
4261 &dig_nid, 1);
4262 if (err < 0)
4263 continue;
4264 if (!i)
4265 spec->multiout.dig_out_nid = dig_nid;
4266 else {
4267 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4268 spec->slave_dig_outs[i - 1] = dig_nid;
4269 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4270 break;
4271 }
4272 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004273 if (spec->autocfg.dig_in_pin)
4274 spec->dig_in_nid = ALC880_DIGIN_NID;
4275
Takashi Iwai603c4012008-07-30 15:01:44 +02004276 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004277 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004278
Takashi Iwaid88897e2008-10-31 15:01:37 +01004279 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004280
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004281 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004282 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004283
4284 return 1;
4285}
4286
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004287/* additional initialization for auto-configuration model */
4288static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004289{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004290 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004291 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004292 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004293 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004294 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004295 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004296}
4297
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004298static void set_capture_mixer(struct alc_spec *spec)
4299{
4300 static struct snd_kcontrol_new *caps[3] = {
4301 alc_capture_mixer1,
4302 alc_capture_mixer2,
4303 alc_capture_mixer3,
4304 };
Takashi Iwai30d72e92008-11-27 15:25:34 +01004305 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004306 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4307}
4308
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004309#define set_beep_amp(spec, nid, idx, dir) \
4310 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4311
4312/*
4313 * OK, here we have finally the patch for ALC880
4314 */
4315
Linus Torvalds1da177e2005-04-16 15:20:36 -07004316static int patch_alc880(struct hda_codec *codec)
4317{
4318 struct alc_spec *spec;
4319 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004320 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004321
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004322 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004323 if (spec == NULL)
4324 return -ENOMEM;
4325
4326 codec->spec = spec;
4327
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004328 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4329 alc880_models,
4330 alc880_cfg_tbl);
4331 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004332 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4333 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004334 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004335 }
4336
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004337 if (board_config == ALC880_AUTO) {
4338 /* automatic parse from the BIOS config */
4339 err = alc880_parse_auto_config(codec);
4340 if (err < 0) {
4341 alc_free(codec);
4342 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004343 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004344 printk(KERN_INFO
4345 "hda_codec: Cannot set up configuration "
4346 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004347 board_config = ALC880_3ST;
4348 }
4349 }
4350
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004351 err = snd_hda_attach_beep_device(codec, 0x1);
4352 if (err < 0) {
4353 alc_free(codec);
4354 return err;
4355 }
4356
Kailang Yangdf694da2005-12-05 19:42:22 +01004357 if (board_config != ALC880_AUTO)
4358 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004359
4360 spec->stream_name_analog = "ALC880 Analog";
4361 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4362 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004363 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004364
4365 spec->stream_name_digital = "ALC880 Digital";
4366 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4367 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4368
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004369 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004370 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004371 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004372 /* get type */
4373 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004374 if (wcap != AC_WID_AUD_IN) {
4375 spec->adc_nids = alc880_adc_nids_alt;
4376 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004377 } else {
4378 spec->adc_nids = alc880_adc_nids;
4379 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004380 }
4381 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004382 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004383 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004384
Takashi Iwai2134ea42008-01-10 16:53:55 +01004385 spec->vmaster_nid = 0x0c;
4386
Linus Torvalds1da177e2005-04-16 15:20:36 -07004387 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004388 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004389 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004390#ifdef CONFIG_SND_HDA_POWER_SAVE
4391 if (!spec->loopback.amplist)
4392 spec->loopback.amplist = alc880_loopbacks;
4393#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004394 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004395
4396 return 0;
4397}
4398
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004399
Linus Torvalds1da177e2005-04-16 15:20:36 -07004400/*
4401 * ALC260 support
4402 */
4403
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004404static hda_nid_t alc260_dac_nids[1] = {
4405 /* front */
4406 0x02,
4407};
4408
4409static hda_nid_t alc260_adc_nids[1] = {
4410 /* ADC0 */
4411 0x04,
4412};
4413
Kailang Yangdf694da2005-12-05 19:42:22 +01004414static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004415 /* ADC1 */
4416 0x05,
4417};
4418
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004419/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4420 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4421 */
4422static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004423 /* ADC0, ADC1 */
4424 0x04, 0x05
4425};
4426
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004427#define ALC260_DIGOUT_NID 0x03
4428#define ALC260_DIGIN_NID 0x06
4429
4430static struct hda_input_mux alc260_capture_source = {
4431 .num_items = 4,
4432 .items = {
4433 { "Mic", 0x0 },
4434 { "Front Mic", 0x1 },
4435 { "Line", 0x2 },
4436 { "CD", 0x4 },
4437 },
4438};
4439
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004440/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004441 * headphone jack and the internal CD lines since these are the only pins at
4442 * which audio can appear. For flexibility, also allow the option of
4443 * recording the mixer output on the second ADC (ADC0 doesn't have a
4444 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004445 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004446static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4447 {
4448 .num_items = 3,
4449 .items = {
4450 { "Mic/Line", 0x0 },
4451 { "CD", 0x4 },
4452 { "Headphone", 0x2 },
4453 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004454 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004455 {
4456 .num_items = 4,
4457 .items = {
4458 { "Mic/Line", 0x0 },
4459 { "CD", 0x4 },
4460 { "Headphone", 0x2 },
4461 { "Mixer", 0x5 },
4462 },
4463 },
4464
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004465};
4466
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004467/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4468 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004469 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004470static struct hda_input_mux alc260_acer_capture_sources[2] = {
4471 {
4472 .num_items = 4,
4473 .items = {
4474 { "Mic", 0x0 },
4475 { "Line", 0x2 },
4476 { "CD", 0x4 },
4477 { "Headphone", 0x5 },
4478 },
4479 },
4480 {
4481 .num_items = 5,
4482 .items = {
4483 { "Mic", 0x0 },
4484 { "Line", 0x2 },
4485 { "CD", 0x4 },
4486 { "Headphone", 0x6 },
4487 { "Mixer", 0x5 },
4488 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004489 },
4490};
Michael Schwingencc959482009-02-22 18:58:45 +01004491
4492/* Maxdata Favorit 100XS */
4493static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4494 {
4495 .num_items = 2,
4496 .items = {
4497 { "Line/Mic", 0x0 },
4498 { "CD", 0x4 },
4499 },
4500 },
4501 {
4502 .num_items = 3,
4503 .items = {
4504 { "Line/Mic", 0x0 },
4505 { "CD", 0x4 },
4506 { "Mixer", 0x5 },
4507 },
4508 },
4509};
4510
Linus Torvalds1da177e2005-04-16 15:20:36 -07004511/*
4512 * This is just place-holder, so there's something for alc_build_pcms to look
4513 * at when it calculates the maximum number of channels. ALC260 has no mixer
4514 * element which allows changing the channel mode, so the verb list is
4515 * never used.
4516 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004517static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004518 { 2, NULL },
4519};
4520
Kailang Yangdf694da2005-12-05 19:42:22 +01004521
4522/* Mixer combinations
4523 *
4524 * basic: base_output + input + pc_beep + capture
4525 * HP: base_output + input + capture_alt
4526 * HP_3013: hp_3013 + input + capture
4527 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004528 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004529 */
4530
4531static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004532 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004533 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004534 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4535 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4536 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4537 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4538 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004539};
Kailang Yangdf694da2005-12-05 19:42:22 +01004540
4541static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004542 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4543 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4544 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4545 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4546 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4547 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4548 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4549 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004550 { } /* end */
4551};
4552
Takashi Iwaibec15c32008-01-28 18:16:30 +01004553/* update HP, line and mono out pins according to the master switch */
4554static void alc260_hp_master_update(struct hda_codec *codec,
4555 hda_nid_t hp, hda_nid_t line,
4556 hda_nid_t mono)
4557{
4558 struct alc_spec *spec = codec->spec;
4559 unsigned int val = spec->master_sw ? PIN_HP : 0;
4560 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004561 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004562 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004563 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004564 val);
4565 /* mono (speaker) depending on the HP jack sense */
4566 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004567 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004568 val);
4569}
4570
4571static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4572 struct snd_ctl_elem_value *ucontrol)
4573{
4574 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4575 struct alc_spec *spec = codec->spec;
4576 *ucontrol->value.integer.value = spec->master_sw;
4577 return 0;
4578}
4579
4580static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4581 struct snd_ctl_elem_value *ucontrol)
4582{
4583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4584 struct alc_spec *spec = codec->spec;
4585 int val = !!*ucontrol->value.integer.value;
4586 hda_nid_t hp, line, mono;
4587
4588 if (val == spec->master_sw)
4589 return 0;
4590 spec->master_sw = val;
4591 hp = (kcontrol->private_value >> 16) & 0xff;
4592 line = (kcontrol->private_value >> 8) & 0xff;
4593 mono = kcontrol->private_value & 0xff;
4594 alc260_hp_master_update(codec, hp, line, mono);
4595 return 1;
4596}
4597
4598static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4599 {
4600 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4601 .name = "Master Playback Switch",
4602 .info = snd_ctl_boolean_mono_info,
4603 .get = alc260_hp_master_sw_get,
4604 .put = alc260_hp_master_sw_put,
4605 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4606 },
4607 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4608 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4609 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4610 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4611 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4612 HDA_OUTPUT),
4613 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4614 { } /* end */
4615};
4616
4617static struct hda_verb alc260_hp_unsol_verbs[] = {
4618 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4619 {},
4620};
4621
4622static void alc260_hp_automute(struct hda_codec *codec)
4623{
4624 struct alc_spec *spec = codec->spec;
4625 unsigned int present;
4626
4627 present = snd_hda_codec_read(codec, 0x10, 0,
4628 AC_VERB_GET_PIN_SENSE, 0);
4629 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4630 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4631}
4632
4633static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4634{
4635 if ((res >> 26) == ALC880_HP_EVENT)
4636 alc260_hp_automute(codec);
4637}
4638
Kailang Yangdf694da2005-12-05 19:42:22 +01004639static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004640 {
4641 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4642 .name = "Master Playback Switch",
4643 .info = snd_ctl_boolean_mono_info,
4644 .get = alc260_hp_master_sw_get,
4645 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004646 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004647 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004648 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4649 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4650 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4651 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4652 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4653 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004654 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4655 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004656 { } /* end */
4657};
4658
Kailang Yang3f878302008-08-26 13:02:23 +02004659static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4660 .ops = &snd_hda_bind_vol,
4661 .values = {
4662 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4663 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4664 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4665 0
4666 },
4667};
4668
4669static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4670 .ops = &snd_hda_bind_sw,
4671 .values = {
4672 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4673 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4674 0
4675 },
4676};
4677
4678static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4679 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4680 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4681 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4683 { } /* end */
4684};
4685
Takashi Iwaibec15c32008-01-28 18:16:30 +01004686static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4687 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4688 {},
4689};
4690
4691static void alc260_hp_3013_automute(struct hda_codec *codec)
4692{
4693 struct alc_spec *spec = codec->spec;
4694 unsigned int present;
4695
4696 present = snd_hda_codec_read(codec, 0x15, 0,
4697 AC_VERB_GET_PIN_SENSE, 0);
4698 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004699 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004700}
4701
4702static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4703 unsigned int res)
4704{
4705 if ((res >> 26) == ALC880_HP_EVENT)
4706 alc260_hp_3013_automute(codec);
4707}
4708
Kailang Yang3f878302008-08-26 13:02:23 +02004709static void alc260_hp_3012_automute(struct hda_codec *codec)
4710{
4711 unsigned int present, bits;
4712
4713 present = snd_hda_codec_read(codec, 0x10, 0,
4714 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4715
4716 bits = present ? 0 : PIN_OUT;
4717 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4718 bits);
4719 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4720 bits);
4721 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4722 bits);
4723}
4724
4725static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4726 unsigned int res)
4727{
4728 if ((res >> 26) == ALC880_HP_EVENT)
4729 alc260_hp_3012_automute(codec);
4730}
4731
4732/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004733 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4734 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004735static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004736 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004737 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004738 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004739 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4740 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4741 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4742 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004743 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004744 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4745 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004746 { } /* end */
4747};
4748
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004749/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4750 * versions of the ALC260 don't act on requests to enable mic bias from NID
4751 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4752 * datasheet doesn't mention this restriction. At this stage it's not clear
4753 * whether this behaviour is intentional or is a hardware bug in chip
4754 * revisions available in early 2006. Therefore for now allow the
4755 * "Headphone Jack Mode" control to span all choices, but if it turns out
4756 * that the lack of mic bias for this NID is intentional we could change the
4757 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4758 *
4759 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4760 * don't appear to make the mic bias available from the "line" jack, even
4761 * though the NID used for this jack (0x14) can supply it. The theory is
4762 * that perhaps Acer have included blocking capacitors between the ALC260
4763 * and the output jack. If this turns out to be the case for all such
4764 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4765 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004766 *
4767 * The C20x Tablet series have a mono internal speaker which is controlled
4768 * via the chip's Mono sum widget and pin complex, so include the necessary
4769 * controls for such models. On models without a "mono speaker" the control
4770 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004771 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004772static struct snd_kcontrol_new alc260_acer_mixer[] = {
4773 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4774 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004775 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004776 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004777 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004778 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004779 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004780 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4781 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4782 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4783 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4784 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4785 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4786 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4787 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004788 { } /* end */
4789};
4790
Michael Schwingencc959482009-02-22 18:58:45 +01004791/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4792 */
4793static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4794 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4795 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4796 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4797 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4798 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4799 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4800 { } /* end */
4801};
4802
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004803/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4804 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4805 */
4806static struct snd_kcontrol_new alc260_will_mixer[] = {
4807 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4808 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4810 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4811 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4812 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4813 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4814 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4815 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4816 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004817 { } /* end */
4818};
4819
4820/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4821 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4822 */
4823static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4824 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4825 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4827 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4828 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4829 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4830 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4831 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4832 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4833 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4834 { } /* end */
4835};
4836
Kailang Yangdf694da2005-12-05 19:42:22 +01004837/*
4838 * initialization verbs
4839 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004840static struct hda_verb alc260_init_verbs[] = {
4841 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004842 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004843 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004844 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004845 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004846 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004847 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004848 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004849 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004850 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004851 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004852 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004853 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004854 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004855 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004856 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004857 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004858 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4859 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004860 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004861 /* set connection select to line in (default select for this ADC) */
4862 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004863 /* mute capture amp left and right */
4864 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4865 /* set connection select to line in (default select for this ADC) */
4866 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004867 /* set vol=0 Line-Out mixer amp left and right */
4868 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4869 /* unmute pin widget amp left and right (no gain on this amp) */
4870 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4871 /* set vol=0 HP mixer amp left and right */
4872 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4873 /* unmute pin widget amp left and right (no gain on this amp) */
4874 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4875 /* set vol=0 Mono mixer amp left and right */
4876 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4877 /* unmute pin widget amp left and right (no gain on this amp) */
4878 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4879 /* unmute LINE-2 out pin */
4880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004881 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4882 * Line In 2 = 0x03
4883 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004884 /* mute analog inputs */
4885 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4888 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004890 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004891 /* mute Front out path */
4892 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4893 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4894 /* mute Headphone out path */
4895 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4896 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4897 /* mute Mono out path */
4898 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4899 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004900 { }
4901};
4902
Takashi Iwai474167d2006-05-17 17:17:43 +02004903#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004904static struct hda_verb alc260_hp_init_verbs[] = {
4905 /* Headphone and output */
4906 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4907 /* mono output */
4908 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4909 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4910 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4911 /* Mic2 (front panel) pin widget for input and vref at 80% */
4912 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4913 /* Line In pin widget for input */
4914 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4915 /* Line-2 pin widget for output */
4916 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4917 /* CD pin widget for input */
4918 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4919 /* unmute amp left and right */
4920 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4921 /* set connection select to line in (default select for this ADC) */
4922 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4923 /* unmute Line-Out mixer amp left and right (volume = 0) */
4924 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4925 /* mute pin widget amp left and right (no gain on this amp) */
4926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4927 /* unmute HP mixer amp left and right (volume = 0) */
4928 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4929 /* mute pin widget amp left and right (no gain on this amp) */
4930 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004931 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4932 * Line In 2 = 0x03
4933 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004934 /* mute analog inputs */
4935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004940 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4941 /* Unmute Front out path */
4942 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4943 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4944 /* Unmute Headphone out path */
4945 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4946 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4947 /* Unmute Mono out path */
4948 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4949 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4950 { }
4951};
Takashi Iwai474167d2006-05-17 17:17:43 +02004952#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004953
4954static struct hda_verb alc260_hp_3013_init_verbs[] = {
4955 /* Line out and output */
4956 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4957 /* mono output */
4958 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4959 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4960 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4961 /* Mic2 (front panel) pin widget for input and vref at 80% */
4962 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4963 /* Line In pin widget for input */
4964 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4965 /* Headphone pin widget for output */
4966 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4967 /* CD pin widget for input */
4968 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4969 /* unmute amp left and right */
4970 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4971 /* set connection select to line in (default select for this ADC) */
4972 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4973 /* unmute Line-Out mixer amp left and right (volume = 0) */
4974 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4975 /* mute pin widget amp left and right (no gain on this amp) */
4976 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4977 /* unmute HP mixer amp left and right (volume = 0) */
4978 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4979 /* mute pin widget amp left and right (no gain on this amp) */
4980 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004981 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4982 * Line In 2 = 0x03
4983 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004984 /* mute analog inputs */
4985 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4986 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4987 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4988 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4989 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004990 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4991 /* Unmute Front out path */
4992 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4993 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4994 /* Unmute Headphone out path */
4995 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4996 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4997 /* Unmute Mono out path */
4998 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4999 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5000 { }
5001};
5002
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005003/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005004 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5005 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005006 */
5007static struct hda_verb alc260_fujitsu_init_verbs[] = {
5008 /* Disable all GPIOs */
5009 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5010 /* Internal speaker is connected to headphone pin */
5011 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5012 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5013 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005014 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5015 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5016 /* Ensure all other unused pins are disabled and muted. */
5017 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5018 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005019 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005020 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005021 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005022 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5023 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5024 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005025
Jonathan Woithef7ace402006-02-28 11:46:14 +01005026 /* Disable digital (SPDIF) pins */
5027 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5028 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005029
Kailang Yangea1fb292008-08-26 12:58:38 +02005030 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005031 * when acting as an output.
5032 */
5033 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5034
5035 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005036 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5037 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5038 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5039 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5042 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5043 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5044 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005045
Jonathan Woithef7ace402006-02-28 11:46:14 +01005046 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5047 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5048 /* Unmute Line1 pin widget output buffer since it starts as an output.
5049 * If the pin mode is changed by the user the pin mode control will
5050 * take care of enabling the pin's input/output buffers as needed.
5051 * Therefore there's no need to enable the input buffer at this
5052 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005053 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005054 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005055 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005056 * mixer ctrl)
5057 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005058 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005059
Jonathan Woithef7ace402006-02-28 11:46:14 +01005060 /* Mute capture amp left and right */
5061 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005062 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005063 * in (on mic1 pin)
5064 */
5065 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005066
Jonathan Woithef7ace402006-02-28 11:46:14 +01005067 /* Do the same for the second ADC: mute capture input amp and
5068 * set ADC connection to line in (on mic1 pin)
5069 */
5070 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5071 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005072
Jonathan Woithef7ace402006-02-28 11:46:14 +01005073 /* Mute all inputs to mixer widget (even unconnected ones) */
5074 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5075 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5076 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5077 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5078 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5079 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5080 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005082
5083 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005084};
5085
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005086/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5087 * similar laptops (adapted from Fujitsu init verbs).
5088 */
5089static struct hda_verb alc260_acer_init_verbs[] = {
5090 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5091 * the headphone jack. Turn this on and rely on the standard mute
5092 * methods whenever the user wants to turn these outputs off.
5093 */
5094 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5095 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5096 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5097 /* Internal speaker/Headphone jack is connected to Line-out pin */
5098 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5099 /* Internal microphone/Mic jack is connected to Mic1 pin */
5100 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5101 /* Line In jack is connected to Line1 pin */
5102 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005103 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5104 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005105 /* Ensure all other unused pins are disabled and muted. */
5106 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5107 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005108 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5109 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5110 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5112 /* Disable digital (SPDIF) pins */
5113 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5114 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5115
Kailang Yangea1fb292008-08-26 12:58:38 +02005116 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005117 * bus when acting as outputs.
5118 */
5119 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5120 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5121
5122 /* Start with output sum widgets muted and their output gains at min */
5123 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5124 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5125 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5126 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5127 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5128 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5129 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5130 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5131 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5132
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005133 /* Unmute Line-out pin widget amp left and right
5134 * (no equiv mixer ctrl)
5135 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005136 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005137 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5138 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005139 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5140 * inputs. If the pin mode is changed by the user the pin mode control
5141 * will take care of enabling the pin's input/output buffers as needed.
5142 * Therefore there's no need to enable the input buffer at this
5143 * stage.
5144 */
5145 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5146 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5147
5148 /* Mute capture amp left and right */
5149 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5150 /* Set ADC connection select to match default mixer setting - mic
5151 * (on mic1 pin)
5152 */
5153 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5154
5155 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005156 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005157 */
5158 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005159 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005160
5161 /* Mute all inputs to mixer widget (even unconnected ones) */
5162 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5164 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5165 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5166 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5167 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5168 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5169 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5170
5171 { }
5172};
5173
Michael Schwingencc959482009-02-22 18:58:45 +01005174/* Initialisation sequence for Maxdata Favorit 100XS
5175 * (adapted from Acer init verbs).
5176 */
5177static struct hda_verb alc260_favorit100_init_verbs[] = {
5178 /* GPIO 0 enables the output jack.
5179 * Turn this on and rely on the standard mute
5180 * methods whenever the user wants to turn these outputs off.
5181 */
5182 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5183 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5184 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5185 /* Line/Mic input jack is connected to Mic1 pin */
5186 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5187 /* Ensure all other unused pins are disabled and muted. */
5188 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5189 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5190 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5191 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5192 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5193 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5194 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5195 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5196 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5197 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5198 /* Disable digital (SPDIF) pins */
5199 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5200 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5201
5202 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5203 * bus when acting as outputs.
5204 */
5205 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5206 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5207
5208 /* Start with output sum widgets muted and their output gains at min */
5209 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5210 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5211 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5212 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5214 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5215 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5216 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5217 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5218
5219 /* Unmute Line-out pin widget amp left and right
5220 * (no equiv mixer ctrl)
5221 */
5222 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5223 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5224 * inputs. If the pin mode is changed by the user the pin mode control
5225 * will take care of enabling the pin's input/output buffers as needed.
5226 * Therefore there's no need to enable the input buffer at this
5227 * stage.
5228 */
5229 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5230
5231 /* Mute capture amp left and right */
5232 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5233 /* Set ADC connection select to match default mixer setting - mic
5234 * (on mic1 pin)
5235 */
5236 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5237
5238 /* Do similar with the second ADC: mute capture input amp and
5239 * set ADC connection to mic to match ALSA's default state.
5240 */
5241 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5242 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5243
5244 /* Mute all inputs to mixer widget (even unconnected ones) */
5245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5253
5254 { }
5255};
5256
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005257static struct hda_verb alc260_will_verbs[] = {
5258 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5259 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5260 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5261 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5262 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5263 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5264 {}
5265};
5266
5267static struct hda_verb alc260_replacer_672v_verbs[] = {
5268 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5269 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5270 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5271
5272 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5273 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5274 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5275
5276 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5277 {}
5278};
5279
5280/* toggle speaker-output according to the hp-jack state */
5281static void alc260_replacer_672v_automute(struct hda_codec *codec)
5282{
5283 unsigned int present;
5284
5285 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5286 present = snd_hda_codec_read(codec, 0x0f, 0,
5287 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5288 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005289 snd_hda_codec_write_cache(codec, 0x01, 0,
5290 AC_VERB_SET_GPIO_DATA, 1);
5291 snd_hda_codec_write_cache(codec, 0x0f, 0,
5292 AC_VERB_SET_PIN_WIDGET_CONTROL,
5293 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005294 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005295 snd_hda_codec_write_cache(codec, 0x01, 0,
5296 AC_VERB_SET_GPIO_DATA, 0);
5297 snd_hda_codec_write_cache(codec, 0x0f, 0,
5298 AC_VERB_SET_PIN_WIDGET_CONTROL,
5299 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005300 }
5301}
5302
5303static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5304 unsigned int res)
5305{
5306 if ((res >> 26) == ALC880_HP_EVENT)
5307 alc260_replacer_672v_automute(codec);
5308}
5309
Kailang Yang3f878302008-08-26 13:02:23 +02005310static struct hda_verb alc260_hp_dc7600_verbs[] = {
5311 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5312 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5313 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5314 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5315 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5316 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5317 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5318 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5319 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5320 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5321 {}
5322};
5323
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005324/* Test configuration for debugging, modelled after the ALC880 test
5325 * configuration.
5326 */
5327#ifdef CONFIG_SND_DEBUG
5328static hda_nid_t alc260_test_dac_nids[1] = {
5329 0x02,
5330};
5331static hda_nid_t alc260_test_adc_nids[2] = {
5332 0x04, 0x05,
5333};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005334/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005335 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005336 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005337 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005338static struct hda_input_mux alc260_test_capture_sources[2] = {
5339 {
5340 .num_items = 7,
5341 .items = {
5342 { "MIC1 pin", 0x0 },
5343 { "MIC2 pin", 0x1 },
5344 { "LINE1 pin", 0x2 },
5345 { "LINE2 pin", 0x3 },
5346 { "CD pin", 0x4 },
5347 { "LINE-OUT pin", 0x5 },
5348 { "HP-OUT pin", 0x6 },
5349 },
5350 },
5351 {
5352 .num_items = 8,
5353 .items = {
5354 { "MIC1 pin", 0x0 },
5355 { "MIC2 pin", 0x1 },
5356 { "LINE1 pin", 0x2 },
5357 { "LINE2 pin", 0x3 },
5358 { "CD pin", 0x4 },
5359 { "Mixer", 0x5 },
5360 { "LINE-OUT pin", 0x6 },
5361 { "HP-OUT pin", 0x7 },
5362 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005363 },
5364};
5365static struct snd_kcontrol_new alc260_test_mixer[] = {
5366 /* Output driver widgets */
5367 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5368 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5369 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5370 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5371 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5372 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5373
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005374 /* Modes for retasking pin widgets
5375 * Note: the ALC260 doesn't seem to act on requests to enable mic
5376 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5377 * mention this restriction. At this stage it's not clear whether
5378 * this behaviour is intentional or is a hardware bug in chip
5379 * revisions available at least up until early 2006. Therefore for
5380 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5381 * choices, but if it turns out that the lack of mic bias for these
5382 * NIDs is intentional we could change their modes from
5383 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5384 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005385 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5386 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5387 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5388 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5389 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5390 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5391
5392 /* Loopback mixer controls */
5393 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5394 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5395 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5396 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5397 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5398 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5399 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5400 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5401 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5402 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005403 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5404 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5405 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5406 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005407
5408 /* Controls for GPIO pins, assuming they are configured as outputs */
5409 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5410 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5411 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5412 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5413
Jonathan Woithe92621f12006-02-28 11:47:47 +01005414 /* Switches to allow the digital IO pins to be enabled. The datasheet
5415 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005416 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005417 */
5418 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5419 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5420
Jonathan Woithef8225f62008-01-08 12:16:54 +01005421 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5422 * this output to turn on an external amplifier.
5423 */
5424 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5425 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5426
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005427 { } /* end */
5428};
5429static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005430 /* Enable all GPIOs as outputs with an initial value of 0 */
5431 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5432 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5433 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5434
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005435 /* Enable retasking pins as output, initially without power amp */
5436 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5437 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5439 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5440 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5441 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5442
Jonathan Woithe92621f12006-02-28 11:47:47 +01005443 /* Disable digital (SPDIF) pins initially, but users can enable
5444 * them via a mixer switch. In the case of SPDIF-out, this initverb
5445 * payload also sets the generation to 0, output to be in "consumer"
5446 * PCM format, copyright asserted, no pre-emphasis and no validity
5447 * control.
5448 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005449 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5450 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5451
Kailang Yangea1fb292008-08-26 12:58:38 +02005452 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005453 * OUT1 sum bus when acting as an output.
5454 */
5455 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5456 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5457 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5458 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5459
5460 /* Start with output sum widgets muted and their output gains at min */
5461 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5464 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5465 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5467 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5468 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5469 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5470
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005471 /* Unmute retasking pin widget output buffers since the default
5472 * state appears to be output. As the pin mode is changed by the
5473 * user the pin mode control will take care of enabling the pin's
5474 * input/output buffers as needed.
5475 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005476 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5477 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5478 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5480 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5481 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5482 /* Also unmute the mono-out pin widget */
5483 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5484
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005485 /* Mute capture amp left and right */
5486 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005487 /* Set ADC connection select to match default mixer setting (mic1
5488 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005489 */
5490 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5491
5492 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005493 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005494 */
5495 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5496 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5497
5498 /* Mute all inputs to mixer widget (even unconnected ones) */
5499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5507
5508 { }
5509};
5510#endif
5511
Takashi Iwai63300792008-01-24 15:31:36 +01005512#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5513#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005514
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005515#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5516#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5517
Kailang Yangdf694da2005-12-05 19:42:22 +01005518/*
5519 * for BIOS auto-configuration
5520 */
5521
5522static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005523 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005524{
5525 hda_nid_t nid_vol;
5526 unsigned long vol_val, sw_val;
5527 char name[32];
5528 int err;
5529
5530 if (nid >= 0x0f && nid < 0x11) {
5531 nid_vol = nid - 0x7;
5532 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5533 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5534 } else if (nid == 0x11) {
5535 nid_vol = nid - 0x7;
5536 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5537 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5538 } else if (nid >= 0x12 && nid <= 0x15) {
5539 nid_vol = 0x08;
5540 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5541 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5542 } else
5543 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005544
Takashi Iwai863b4512008-10-21 17:01:47 +02005545 if (!(*vol_bits & (1 << nid_vol))) {
5546 /* first control for the volume widget */
5547 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5548 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5549 if (err < 0)
5550 return err;
5551 *vol_bits |= (1 << nid_vol);
5552 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005553 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005554 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5555 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005556 return err;
5557 return 1;
5558}
5559
5560/* add playback controls from the parsed DAC table */
5561static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5562 const struct auto_pin_cfg *cfg)
5563{
5564 hda_nid_t nid;
5565 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005566 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005567
5568 spec->multiout.num_dacs = 1;
5569 spec->multiout.dac_nids = spec->private_dac_nids;
5570 spec->multiout.dac_nids[0] = 0x02;
5571
5572 nid = cfg->line_out_pins[0];
5573 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005574 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005575 if (err < 0)
5576 return err;
5577 }
5578
Takashi Iwai82bc9552006-03-21 11:24:42 +01005579 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005580 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005581 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005582 if (err < 0)
5583 return err;
5584 }
5585
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005586 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005587 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005588 err = alc260_add_playback_controls(spec, nid, "Headphone",
5589 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005590 if (err < 0)
5591 return err;
5592 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005593 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005594}
5595
5596/* create playback/capture controls for input pins */
5597static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5598 const struct auto_pin_cfg *cfg)
5599{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005600 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005601 int i, err, idx;
5602
5603 for (i = 0; i < AUTO_PIN_LAST; i++) {
5604 if (cfg->input_pins[i] >= 0x12) {
5605 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005606 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005607 auto_pin_cfg_labels[i], idx,
5608 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005609 if (err < 0)
5610 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005611 imux->items[imux->num_items].label =
5612 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005613 imux->items[imux->num_items].index = idx;
5614 imux->num_items++;
5615 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005616 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005617 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005618 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005619 auto_pin_cfg_labels[i], idx,
5620 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005621 if (err < 0)
5622 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005623 imux->items[imux->num_items].label =
5624 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005625 imux->items[imux->num_items].index = idx;
5626 imux->num_items++;
5627 }
5628 }
5629 return 0;
5630}
5631
5632static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5633 hda_nid_t nid, int pin_type,
5634 int sel_idx)
5635{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005636 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005637 /* need the manual connection? */
5638 if (nid >= 0x12) {
5639 int idx = nid - 0x12;
5640 snd_hda_codec_write(codec, idx + 0x0b, 0,
5641 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005642 }
5643}
5644
5645static void alc260_auto_init_multi_out(struct hda_codec *codec)
5646{
5647 struct alc_spec *spec = codec->spec;
5648 hda_nid_t nid;
5649
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005650 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005651 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005652 if (nid) {
5653 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5654 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5655 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005656
Takashi Iwai82bc9552006-03-21 11:24:42 +01005657 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005658 if (nid)
5659 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5660
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005661 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005662 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005663 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005664}
Kailang Yangdf694da2005-12-05 19:42:22 +01005665
5666#define ALC260_PIN_CD_NID 0x16
5667static void alc260_auto_init_analog_input(struct hda_codec *codec)
5668{
5669 struct alc_spec *spec = codec->spec;
5670 int i;
5671
5672 for (i = 0; i < AUTO_PIN_LAST; i++) {
5673 hda_nid_t nid = spec->autocfg.input_pins[i];
5674 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005675 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005676 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005677 snd_hda_codec_write(codec, nid, 0,
5678 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005679 AMP_OUT_MUTE);
5680 }
5681 }
5682}
5683
5684/*
5685 * generic initialization of ADC, input mixers and output mixers
5686 */
5687static struct hda_verb alc260_volume_init_verbs[] = {
5688 /*
5689 * Unmute ADC0-1 and set the default input to mic-in
5690 */
5691 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5692 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5693 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5694 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005695
Kailang Yangdf694da2005-12-05 19:42:22 +01005696 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5697 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005698 * Note: PASD motherboards uses the Line In 2 as the input for
5699 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005700 */
5701 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005702 /* mute analog inputs */
5703 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5704 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5705 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5706 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5707 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005708
5709 /*
5710 * Set up output mixers (0x08 - 0x0a)
5711 */
5712 /* set vol=0 to output mixers */
5713 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5714 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5715 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5716 /* set up input amps for analog loopback */
5717 /* Amp Indices: DAC = 0, mixer = 1 */
5718 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5719 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5720 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5721 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5722 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5723 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005724
Kailang Yangdf694da2005-12-05 19:42:22 +01005725 { }
5726};
5727
5728static int alc260_parse_auto_config(struct hda_codec *codec)
5729{
5730 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005731 int err;
5732 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5733
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005734 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5735 alc260_ignore);
5736 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005737 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005738 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5739 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005740 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005741 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005742 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005743 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5744 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005745 return err;
5746
5747 spec->multiout.max_channels = 2;
5748
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005749 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005750 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005751 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005752 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005753
Takashi Iwaid88897e2008-10-31 15:01:37 +01005754 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005755
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005756 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005757 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005758
Kailang Yangdf694da2005-12-05 19:42:22 +01005759 return 1;
5760}
5761
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005762/* additional initialization for auto-configuration model */
5763static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005764{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005765 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005766 alc260_auto_init_multi_out(codec);
5767 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005768 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005769 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005770}
5771
Takashi Iwaicb53c622007-08-10 17:21:45 +02005772#ifdef CONFIG_SND_HDA_POWER_SAVE
5773static struct hda_amp_list alc260_loopbacks[] = {
5774 { 0x07, HDA_INPUT, 0 },
5775 { 0x07, HDA_INPUT, 1 },
5776 { 0x07, HDA_INPUT, 2 },
5777 { 0x07, HDA_INPUT, 3 },
5778 { 0x07, HDA_INPUT, 4 },
5779 { } /* end */
5780};
5781#endif
5782
Kailang Yangdf694da2005-12-05 19:42:22 +01005783/*
5784 * ALC260 configurations
5785 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005786static const char *alc260_models[ALC260_MODEL_LAST] = {
5787 [ALC260_BASIC] = "basic",
5788 [ALC260_HP] = "hp",
5789 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005790 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005791 [ALC260_FUJITSU_S702X] = "fujitsu",
5792 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005793 [ALC260_WILL] = "will",
5794 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005795 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005796#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005797 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005798#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005799 [ALC260_AUTO] = "auto",
5800};
5801
5802static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005803 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005804 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01005805 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01005806 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005807 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005808 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005809 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005810 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005811 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5812 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5813 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5814 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5815 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5816 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5817 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5818 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5819 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005820 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005821 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005822 {}
5823};
5824
Kailang Yangdf694da2005-12-05 19:42:22 +01005825static struct alc_config_preset alc260_presets[] = {
5826 [ALC260_BASIC] = {
5827 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005828 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005829 .init_verbs = { alc260_init_verbs },
5830 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5831 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005832 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005833 .adc_nids = alc260_adc_nids,
5834 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5835 .channel_mode = alc260_modes,
5836 .input_mux = &alc260_capture_source,
5837 },
5838 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005839 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005840 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005841 .init_verbs = { alc260_init_verbs,
5842 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005843 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5844 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005845 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5846 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005847 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5848 .channel_mode = alc260_modes,
5849 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005850 .unsol_event = alc260_hp_unsol_event,
5851 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005852 },
Kailang Yang3f878302008-08-26 13:02:23 +02005853 [ALC260_HP_DC7600] = {
5854 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005855 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005856 .init_verbs = { alc260_init_verbs,
5857 alc260_hp_dc7600_verbs },
5858 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5859 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005860 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5861 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005862 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5863 .channel_mode = alc260_modes,
5864 .input_mux = &alc260_capture_source,
5865 .unsol_event = alc260_hp_3012_unsol_event,
5866 .init_hook = alc260_hp_3012_automute,
5867 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005868 [ALC260_HP_3013] = {
5869 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005870 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005871 .init_verbs = { alc260_hp_3013_init_verbs,
5872 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005873 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5874 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005875 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5876 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005877 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5878 .channel_mode = alc260_modes,
5879 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005880 .unsol_event = alc260_hp_3013_unsol_event,
5881 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005882 },
5883 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005884 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005885 .init_verbs = { alc260_fujitsu_init_verbs },
5886 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5887 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005888 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5889 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005890 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5891 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005892 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5893 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005894 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005895 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005896 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005897 .init_verbs = { alc260_acer_init_verbs },
5898 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5899 .dac_nids = alc260_dac_nids,
5900 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5901 .adc_nids = alc260_dual_adc_nids,
5902 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5903 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005904 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5905 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005906 },
Michael Schwingencc959482009-02-22 18:58:45 +01005907 [ALC260_FAVORIT100] = {
5908 .mixers = { alc260_favorit100_mixer },
5909 .init_verbs = { alc260_favorit100_init_verbs },
5910 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5911 .dac_nids = alc260_dac_nids,
5912 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5913 .adc_nids = alc260_dual_adc_nids,
5914 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5915 .channel_mode = alc260_modes,
5916 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
5917 .input_mux = alc260_favorit100_capture_sources,
5918 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005919 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005920 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005921 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5922 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5923 .dac_nids = alc260_dac_nids,
5924 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5925 .adc_nids = alc260_adc_nids,
5926 .dig_out_nid = ALC260_DIGOUT_NID,
5927 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5928 .channel_mode = alc260_modes,
5929 .input_mux = &alc260_capture_source,
5930 },
5931 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005932 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005933 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5934 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5935 .dac_nids = alc260_dac_nids,
5936 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5937 .adc_nids = alc260_adc_nids,
5938 .dig_out_nid = ALC260_DIGOUT_NID,
5939 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5940 .channel_mode = alc260_modes,
5941 .input_mux = &alc260_capture_source,
5942 .unsol_event = alc260_replacer_672v_unsol_event,
5943 .init_hook = alc260_replacer_672v_automute,
5944 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005945#ifdef CONFIG_SND_DEBUG
5946 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005947 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005948 .init_verbs = { alc260_test_init_verbs },
5949 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5950 .dac_nids = alc260_test_dac_nids,
5951 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5952 .adc_nids = alc260_test_adc_nids,
5953 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5954 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005955 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5956 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005957 },
5958#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005959};
5960
Linus Torvalds1da177e2005-04-16 15:20:36 -07005961static int patch_alc260(struct hda_codec *codec)
5962{
5963 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005964 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005965
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005966 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005967 if (spec == NULL)
5968 return -ENOMEM;
5969
5970 codec->spec = spec;
5971
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005972 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5973 alc260_models,
5974 alc260_cfg_tbl);
5975 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005976 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5977 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005978 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005979 }
5980
Kailang Yangdf694da2005-12-05 19:42:22 +01005981 if (board_config == ALC260_AUTO) {
5982 /* automatic parse from the BIOS config */
5983 err = alc260_parse_auto_config(codec);
5984 if (err < 0) {
5985 alc_free(codec);
5986 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005987 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005988 printk(KERN_INFO
5989 "hda_codec: Cannot set up configuration "
5990 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005991 board_config = ALC260_BASIC;
5992 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005993 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005994
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005995 err = snd_hda_attach_beep_device(codec, 0x1);
5996 if (err < 0) {
5997 alc_free(codec);
5998 return err;
5999 }
6000
Kailang Yangdf694da2005-12-05 19:42:22 +01006001 if (board_config != ALC260_AUTO)
6002 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006003
6004 spec->stream_name_analog = "ALC260 Analog";
6005 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6006 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6007
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006008 spec->stream_name_digital = "ALC260 Digital";
6009 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6010 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6011
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006012 if (!spec->adc_nids && spec->input_mux) {
6013 /* check whether NID 0x04 is valid */
6014 unsigned int wcap = get_wcaps(codec, 0x04);
6015 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6016 /* get type */
6017 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6018 spec->adc_nids = alc260_adc_nids_alt;
6019 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6020 } else {
6021 spec->adc_nids = alc260_adc_nids;
6022 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6023 }
6024 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006025 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006026 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006027
Takashi Iwai2134ea42008-01-10 16:53:55 +01006028 spec->vmaster_nid = 0x08;
6029
Linus Torvalds1da177e2005-04-16 15:20:36 -07006030 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006031 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006032 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006033#ifdef CONFIG_SND_HDA_POWER_SAVE
6034 if (!spec->loopback.amplist)
6035 spec->loopback.amplist = alc260_loopbacks;
6036#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006037 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006038
6039 return 0;
6040}
6041
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006042
Linus Torvalds1da177e2005-04-16 15:20:36 -07006043/*
6044 * ALC882 support
6045 *
6046 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6047 * configuration. Each pin widget can choose any input DACs and a mixer.
6048 * Each ADC is connected from a mixer of all inputs. This makes possible
6049 * 6-channel independent captures.
6050 *
6051 * In addition, an independent DAC for the multi-playback (not used in this
6052 * driver yet).
6053 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006054#define ALC882_DIGOUT_NID 0x06
6055#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006056
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006057static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006058 { 8, NULL }
6059};
6060
6061static hda_nid_t alc882_dac_nids[4] = {
6062 /* front, rear, clfe, rear_surr */
6063 0x02, 0x03, 0x04, 0x05
6064};
6065
Kailang Yangdf694da2005-12-05 19:42:22 +01006066/* identical with ALC880 */
6067#define alc882_adc_nids alc880_adc_nids
6068#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006069
Takashi Iwaie1406342008-02-11 18:32:32 +01006070static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6071static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6072
Linus Torvalds1da177e2005-04-16 15:20:36 -07006073/* input MUX */
6074/* FIXME: should be a matrix-type input source selection */
6075
6076static struct hda_input_mux alc882_capture_source = {
6077 .num_items = 4,
6078 .items = {
6079 { "Mic", 0x0 },
6080 { "Front Mic", 0x1 },
6081 { "Line", 0x2 },
6082 { "CD", 0x4 },
6083 },
6084};
Kailang Yangdf694da2005-12-05 19:42:22 +01006085/*
Kailang Yang272a5272007-05-14 11:00:38 +02006086 * 2ch mode
6087 */
6088static struct hda_verb alc882_3ST_ch2_init[] = {
6089 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6090 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6091 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6092 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6093 { } /* end */
6094};
6095
6096/*
6097 * 6ch mode
6098 */
6099static struct hda_verb alc882_3ST_ch6_init[] = {
6100 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6101 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6102 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6103 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6104 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6105 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6106 { } /* end */
6107};
6108
6109static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6110 { 2, alc882_3ST_ch2_init },
6111 { 6, alc882_3ST_ch6_init },
6112};
6113
6114/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006115 * 6ch mode
6116 */
6117static struct hda_verb alc882_sixstack_ch6_init[] = {
6118 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6119 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6120 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6121 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6122 { } /* end */
6123};
6124
6125/*
6126 * 8ch mode
6127 */
6128static struct hda_verb alc882_sixstack_ch8_init[] = {
6129 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6130 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6131 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6132 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6133 { } /* end */
6134};
6135
6136static struct hda_channel_mode alc882_sixstack_modes[2] = {
6137 { 6, alc882_sixstack_ch6_init },
6138 { 8, alc882_sixstack_ch8_init },
6139};
6140
Takashi Iwai87350ad2007-08-16 18:19:38 +02006141/*
6142 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6143 */
6144
6145/*
6146 * 2ch mode
6147 */
6148static struct hda_verb alc885_mbp_ch2_init[] = {
6149 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6150 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6151 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6152 { } /* end */
6153};
6154
6155/*
6156 * 6ch mode
6157 */
6158static struct hda_verb alc885_mbp_ch6_init[] = {
6159 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6160 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6161 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6162 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6163 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6164 { } /* end */
6165};
6166
6167static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6168 { 2, alc885_mbp_ch2_init },
6169 { 6, alc885_mbp_ch6_init },
6170};
6171
6172
Linus Torvalds1da177e2005-04-16 15:20:36 -07006173/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6174 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6175 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006176static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006177 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006178 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006179 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006180 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006181 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6182 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006183 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6184 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006185 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006186 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6188 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6189 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6190 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6191 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006193 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006194 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6195 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006196 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006197 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006198 { } /* end */
6199};
6200
Takashi Iwai87350ad2007-08-16 18:19:38 +02006201static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006202 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6203 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6204 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6205 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6206 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6207 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006208 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6209 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006210 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006211 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6212 { } /* end */
6213};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006214static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6215 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6216 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6217 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6218 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6219 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6220 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6222 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6223 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006224 { } /* end */
6225};
6226
Kailang Yang272a5272007-05-14 11:00:38 +02006227static struct snd_kcontrol_new alc882_targa_mixer[] = {
6228 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6229 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6230 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6231 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6232 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6233 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6234 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6235 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6236 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006237 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006238 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6239 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006240 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006241 { } /* end */
6242};
6243
6244/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6245 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6246 */
6247static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6248 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6249 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6250 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6251 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6252 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6253 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6254 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6255 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6256 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6257 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6258 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6259 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006260 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006261 { } /* end */
6262};
6263
Takashi Iwai914759b2007-09-06 14:52:04 +02006264static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6265 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6266 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6268 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6269 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6270 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6271 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6273 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6274 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006275 { } /* end */
6276};
6277
Kailang Yangdf694da2005-12-05 19:42:22 +01006278static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6279 {
6280 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6281 .name = "Channel Mode",
6282 .info = alc_ch_mode_info,
6283 .get = alc_ch_mode_get,
6284 .put = alc_ch_mode_put,
6285 },
6286 { } /* end */
6287};
6288
Linus Torvalds1da177e2005-04-16 15:20:36 -07006289static struct hda_verb alc882_init_verbs[] = {
6290 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006291 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6292 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6293 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006294 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006295 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6296 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006298 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6300 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006302 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006303 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6304 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6305 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006306
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006307 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006309 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006310 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006311 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006312 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006313 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006314 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006315 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006316 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006317 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006318 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006319 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006320 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006321 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006322 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006323 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006324 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006325 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6326 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006327 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006328 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6329 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006330 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006331 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6332 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6333 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6334 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6335 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006336 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006337 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006338
6339 /* FIXME: use matrix-type input source selection */
6340 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6341 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006346 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006347 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006351 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006352 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6353 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6354 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6355 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6356 /* ADC1: mute amp left and right */
6357 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006358 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006359 /* ADC2: mute amp left and right */
6360 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006361 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006362 /* ADC3: mute amp left and right */
6363 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006364 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006365
6366 { }
6367};
6368
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006369static struct hda_verb alc882_eapd_verbs[] = {
6370 /* change to EAPD mode */
6371 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006372 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006373 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006374};
6375
Tobin Davis9102cd12006-12-15 10:02:12 +01006376/* Mac Pro test */
6377static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6378 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6379 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6380 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6381 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6382 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006383 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006384 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6385 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006386 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006387 { } /* end */
6388};
6389
6390static struct hda_verb alc882_macpro_init_verbs[] = {
6391 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6395 /* Front Pin: output 0 (0x0c) */
6396 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6397 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6398 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6399 /* Front Mic pin: input vref at 80% */
6400 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6401 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6402 /* Speaker: output */
6403 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6404 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6405 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6406 /* Headphone output (output 0 - 0x0c) */
6407 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6408 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6409 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6410
6411 /* FIXME: use matrix-type input source selection */
6412 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6413 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6414 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6415 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6416 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6418 /* Input mixer2 */
6419 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6420 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6421 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6422 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6423 /* Input mixer3 */
6424 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6425 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6426 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6428 /* ADC1: mute amp left and right */
6429 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6430 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6431 /* ADC2: mute amp left and right */
6432 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6433 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6434 /* ADC3: mute amp left and right */
6435 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6436 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6437
6438 { }
6439};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006440
Takashi Iwai87350ad2007-08-16 18:19:38 +02006441/* Macbook Pro rev3 */
6442static struct hda_verb alc885_mbp3_init_verbs[] = {
6443 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6444 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6445 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6447 /* Rear mixer */
6448 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6449 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6450 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6451 /* Front Pin: output 0 (0x0c) */
6452 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6453 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6454 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6455 /* HP Pin: output 0 (0x0d) */
6456 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6457 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6458 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6459 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6460 /* Mic (rear) pin: input vref at 80% */
6461 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6462 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6463 /* Front Mic pin: input vref at 80% */
6464 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6465 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6466 /* Line In pin: use output 1 when in LineOut mode */
6467 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6468 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6469 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6470
6471 /* FIXME: use matrix-type input source selection */
6472 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6473 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6474 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6475 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6476 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6477 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6478 /* Input mixer2 */
6479 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6480 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6481 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6482 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6483 /* Input mixer3 */
6484 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6485 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6486 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6487 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6488 /* ADC1: mute amp left and right */
6489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6490 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6491 /* ADC2: mute amp left and right */
6492 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6493 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6494 /* ADC3: mute amp left and right */
6495 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6496 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6497
6498 { }
6499};
6500
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006501/* iMac 24 mixer. */
6502static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6503 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6504 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6505 { } /* end */
6506};
6507
6508/* iMac 24 init verbs. */
6509static struct hda_verb alc885_imac24_init_verbs[] = {
6510 /* Internal speakers: output 0 (0x0c) */
6511 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6512 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6513 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6514 /* Internal speakers: output 0 (0x0c) */
6515 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6516 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6517 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6518 /* Headphone: output 0 (0x0c) */
6519 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6521 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6522 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6523 /* Front Mic: input vref at 80% */
6524 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6525 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6526 { }
6527};
6528
6529/* Toggle speaker-output according to the hp-jack state */
6530static void alc885_imac24_automute(struct hda_codec *codec)
6531{
6532 unsigned int present;
6533
6534 present = snd_hda_codec_read(codec, 0x14, 0,
6535 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006536 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6537 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6538 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6539 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006540}
6541
6542/* Processes unsolicited events. */
6543static void alc885_imac24_unsol_event(struct hda_codec *codec,
6544 unsigned int res)
6545{
6546 /* Headphone insertion or removal. */
6547 if ((res >> 26) == ALC880_HP_EVENT)
6548 alc885_imac24_automute(codec);
6549}
6550
Takashi Iwai87350ad2007-08-16 18:19:38 +02006551static void alc885_mbp3_automute(struct hda_codec *codec)
6552{
6553 unsigned int present;
6554
6555 present = snd_hda_codec_read(codec, 0x15, 0,
6556 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6557 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6558 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6559 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6560 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6561
6562}
6563static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6564 unsigned int res)
6565{
6566 /* Headphone insertion or removal. */
6567 if ((res >> 26) == ALC880_HP_EVENT)
6568 alc885_mbp3_automute(codec);
6569}
6570
6571
Kailang Yang272a5272007-05-14 11:00:38 +02006572static struct hda_verb alc882_targa_verbs[] = {
6573 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6574 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6575
6576 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6577 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006578
Kailang Yang272a5272007-05-14 11:00:38 +02006579 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6580 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6581 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6582
6583 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6584 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6585 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6586 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6587 { } /* end */
6588};
6589
6590/* toggle speaker-output according to the hp-jack state */
6591static void alc882_targa_automute(struct hda_codec *codec)
6592{
6593 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006594
Kailang Yang272a5272007-05-14 11:00:38 +02006595 present = snd_hda_codec_read(codec, 0x14, 0,
6596 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006597 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6598 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006599 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6600 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006601}
6602
6603static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6604{
6605 /* Looks like the unsol event is incompatible with the standard
6606 * definition. 4bit tag is placed at 26 bit!
6607 */
6608 if (((res >> 26) == ALC880_HP_EVENT)) {
6609 alc882_targa_automute(codec);
6610 }
6611}
6612
6613static struct hda_verb alc882_asus_a7j_verbs[] = {
6614 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6615 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6616
6617 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6618 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6619 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006620
Kailang Yang272a5272007-05-14 11:00:38 +02006621 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6622 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6623 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6624
6625 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6626 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6627 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6628 { } /* end */
6629};
6630
Takashi Iwai914759b2007-09-06 14:52:04 +02006631static struct hda_verb alc882_asus_a7m_verbs[] = {
6632 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6633 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6634
6635 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6636 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6637 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006638
Takashi Iwai914759b2007-09-06 14:52:04 +02006639 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6640 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6641 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6642
6643 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6644 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6645 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6646 { } /* end */
6647};
6648
Tobin Davis9102cd12006-12-15 10:02:12 +01006649static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6650{
6651 unsigned int gpiostate, gpiomask, gpiodir;
6652
6653 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6654 AC_VERB_GET_GPIO_DATA, 0);
6655
6656 if (!muted)
6657 gpiostate |= (1 << pin);
6658 else
6659 gpiostate &= ~(1 << pin);
6660
6661 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6662 AC_VERB_GET_GPIO_MASK, 0);
6663 gpiomask |= (1 << pin);
6664
6665 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6666 AC_VERB_GET_GPIO_DIRECTION, 0);
6667 gpiodir |= (1 << pin);
6668
6669
6670 snd_hda_codec_write(codec, codec->afg, 0,
6671 AC_VERB_SET_GPIO_MASK, gpiomask);
6672 snd_hda_codec_write(codec, codec->afg, 0,
6673 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6674
6675 msleep(1);
6676
6677 snd_hda_codec_write(codec, codec->afg, 0,
6678 AC_VERB_SET_GPIO_DATA, gpiostate);
6679}
6680
Takashi Iwai7debbe52007-08-16 15:01:03 +02006681/* set up GPIO at initialization */
6682static void alc885_macpro_init_hook(struct hda_codec *codec)
6683{
6684 alc882_gpio_mute(codec, 0, 0);
6685 alc882_gpio_mute(codec, 1, 0);
6686}
6687
6688/* set up GPIO and update auto-muting at initialization */
6689static void alc885_imac24_init_hook(struct hda_codec *codec)
6690{
6691 alc885_macpro_init_hook(codec);
6692 alc885_imac24_automute(codec);
6693}
6694
Kailang Yangdf694da2005-12-05 19:42:22 +01006695/*
6696 * generic initialization of ADC, input mixers and output mixers
6697 */
6698static struct hda_verb alc882_auto_init_verbs[] = {
6699 /*
6700 * Unmute ADC0-2 and set the default input to mic-in
6701 */
6702 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6703 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6704 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6705 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6706 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6707 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6708
Takashi Iwaicb53c622007-08-10 17:21:45 +02006709 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006710 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006711 * Note: PASD motherboards uses the Line In 2 as the input for
6712 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006713 */
6714 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006715 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6716 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6717 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6718 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6719 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006720
6721 /*
6722 * Set up output mixers (0x0c - 0x0f)
6723 */
6724 /* set vol=0 to output mixers */
6725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6727 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6728 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6729 /* set up input amps for analog loopback */
6730 /* Amp Indices: DAC = 0, mixer = 1 */
6731 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6732 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6733 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6734 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6735 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6736 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6737 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6738 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6739 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6740 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6741
6742 /* FIXME: use matrix-type input source selection */
6743 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6744 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6745 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6746 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6747 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6749 /* Input mixer2 */
6750 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6751 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6752 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6754 /* Input mixer3 */
6755 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6756 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6757 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6759
6760 { }
6761};
6762
Takashi Iwaicb53c622007-08-10 17:21:45 +02006763#ifdef CONFIG_SND_HDA_POWER_SAVE
6764#define alc882_loopbacks alc880_loopbacks
6765#endif
6766
Kailang Yangdf694da2005-12-05 19:42:22 +01006767/* pcm configuration: identiacal with ALC880 */
6768#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6769#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6770#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6771#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6772
6773/*
6774 * configuration and preset
6775 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006776static const char *alc882_models[ALC882_MODEL_LAST] = {
6777 [ALC882_3ST_DIG] = "3stack-dig",
6778 [ALC882_6ST_DIG] = "6stack-dig",
6779 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006780 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006781 [ALC882_TARGA] = "targa",
6782 [ALC882_ASUS_A7J] = "asus-a7j",
6783 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006784 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006785 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006786 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006787 [ALC882_AUTO] = "auto",
6788};
6789
6790static struct snd_pci_quirk alc882_cfg_tbl[] = {
6791 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006792 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006793 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006794 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006795 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006796 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006797 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006798 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006799 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006800 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6801 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6802 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006803 {}
6804};
6805
6806static struct alc_config_preset alc882_presets[] = {
6807 [ALC882_3ST_DIG] = {
6808 .mixers = { alc882_base_mixer },
6809 .init_verbs = { alc882_init_verbs },
6810 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6811 .dac_nids = alc882_dac_nids,
6812 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006813 .dig_in_nid = ALC882_DIGIN_NID,
6814 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6815 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006816 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006817 .input_mux = &alc882_capture_source,
6818 },
6819 [ALC882_6ST_DIG] = {
6820 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6821 .init_verbs = { alc882_init_verbs },
6822 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6823 .dac_nids = alc882_dac_nids,
6824 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006825 .dig_in_nid = ALC882_DIGIN_NID,
6826 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6827 .channel_mode = alc882_sixstack_modes,
6828 .input_mux = &alc882_capture_source,
6829 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006830 [ALC882_ARIMA] = {
6831 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6832 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6833 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6834 .dac_nids = alc882_dac_nids,
6835 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6836 .channel_mode = alc882_sixstack_modes,
6837 .input_mux = &alc882_capture_source,
6838 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006839 [ALC882_W2JC] = {
6840 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6841 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6842 alc880_gpio1_init_verbs },
6843 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6844 .dac_nids = alc882_dac_nids,
6845 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6846 .channel_mode = alc880_threestack_modes,
6847 .need_dac_fix = 1,
6848 .input_mux = &alc882_capture_source,
6849 .dig_out_nid = ALC882_DIGOUT_NID,
6850 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006851 [ALC885_MBP3] = {
6852 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6853 .init_verbs = { alc885_mbp3_init_verbs,
6854 alc880_gpio1_init_verbs },
6855 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6856 .dac_nids = alc882_dac_nids,
6857 .channel_mode = alc885_mbp_6ch_modes,
6858 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6859 .input_mux = &alc882_capture_source,
6860 .dig_out_nid = ALC882_DIGOUT_NID,
6861 .dig_in_nid = ALC882_DIGIN_NID,
6862 .unsol_event = alc885_mbp3_unsol_event,
6863 .init_hook = alc885_mbp3_automute,
6864 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006865 [ALC885_MACPRO] = {
6866 .mixers = { alc882_macpro_mixer },
6867 .init_verbs = { alc882_macpro_init_verbs },
6868 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6869 .dac_nids = alc882_dac_nids,
6870 .dig_out_nid = ALC882_DIGOUT_NID,
6871 .dig_in_nid = ALC882_DIGIN_NID,
6872 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6873 .channel_mode = alc882_ch_modes,
6874 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006875 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006876 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006877 [ALC885_IMAC24] = {
6878 .mixers = { alc885_imac24_mixer },
6879 .init_verbs = { alc885_imac24_init_verbs },
6880 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6881 .dac_nids = alc882_dac_nids,
6882 .dig_out_nid = ALC882_DIGOUT_NID,
6883 .dig_in_nid = ALC882_DIGIN_NID,
6884 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6885 .channel_mode = alc882_ch_modes,
6886 .input_mux = &alc882_capture_source,
6887 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006888 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006889 },
Kailang Yang272a5272007-05-14 11:00:38 +02006890 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006891 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006892 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6893 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6894 .dac_nids = alc882_dac_nids,
6895 .dig_out_nid = ALC882_DIGOUT_NID,
6896 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6897 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006898 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006899 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6900 .channel_mode = alc882_3ST_6ch_modes,
6901 .need_dac_fix = 1,
6902 .input_mux = &alc882_capture_source,
6903 .unsol_event = alc882_targa_unsol_event,
6904 .init_hook = alc882_targa_automute,
6905 },
6906 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006907 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006908 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6909 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6910 .dac_nids = alc882_dac_nids,
6911 .dig_out_nid = ALC882_DIGOUT_NID,
6912 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6913 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006914 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006915 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6916 .channel_mode = alc882_3ST_6ch_modes,
6917 .need_dac_fix = 1,
6918 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006919 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006920 [ALC882_ASUS_A7M] = {
6921 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6922 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6923 alc880_gpio1_init_verbs,
6924 alc882_asus_a7m_verbs },
6925 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6926 .dac_nids = alc882_dac_nids,
6927 .dig_out_nid = ALC882_DIGOUT_NID,
6928 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6929 .channel_mode = alc880_threestack_modes,
6930 .need_dac_fix = 1,
6931 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006932 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006933};
6934
6935
6936/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006937 * Pin config fixes
6938 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006939enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006940 PINFIX_ABIT_AW9D_MAX
6941};
6942
6943static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6944 { 0x15, 0x01080104 }, /* side */
6945 { 0x16, 0x01011012 }, /* rear */
6946 { 0x17, 0x01016011 }, /* clfe */
6947 { }
6948};
6949
6950static const struct alc_pincfg *alc882_pin_fixes[] = {
6951 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6952};
6953
6954static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6955 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6956 {}
6957};
6958
6959/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006960 * BIOS auto configuration
6961 */
6962static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6963 hda_nid_t nid, int pin_type,
6964 int dac_idx)
6965{
6966 /* set as output */
6967 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006968 int idx;
6969
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006970 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006971 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6972 idx = 4;
6973 else
6974 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006975 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6976
6977}
6978
6979static void alc882_auto_init_multi_out(struct hda_codec *codec)
6980{
6981 struct alc_spec *spec = codec->spec;
6982 int i;
6983
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006984 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006985 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006986 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006987 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006988 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006989 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006990 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006991 }
6992}
6993
6994static void alc882_auto_init_hp_out(struct hda_codec *codec)
6995{
6996 struct alc_spec *spec = codec->spec;
6997 hda_nid_t pin;
6998
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006999 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007000 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007001 /* use dac 0 */
7002 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007003 pin = spec->autocfg.speaker_pins[0];
7004 if (pin)
7005 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007006}
7007
7008#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7009#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7010
7011static void alc882_auto_init_analog_input(struct hda_codec *codec)
7012{
7013 struct alc_spec *spec = codec->spec;
7014 int i;
7015
7016 for (i = 0; i < AUTO_PIN_LAST; i++) {
7017 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007018 if (!nid)
7019 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007020 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007021 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7022 snd_hda_codec_write(codec, nid, 0,
7023 AC_VERB_SET_AMP_GAIN_MUTE,
7024 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007025 }
7026}
7027
Takashi Iwaif511b012008-08-15 16:46:42 +02007028static void alc882_auto_init_input_src(struct hda_codec *codec)
7029{
7030 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007031 int c;
7032
7033 for (c = 0; c < spec->num_adc_nids; c++) {
7034 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7035 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007036 unsigned int mux_idx;
7037 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007038 int conns, mute, idx, item;
7039
7040 conns = snd_hda_get_connections(codec, nid, conn_list,
7041 ARRAY_SIZE(conn_list));
7042 if (conns < 0)
7043 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007044 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7045 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007046 for (idx = 0; idx < conns; idx++) {
7047 /* if the current connection is the selected one,
7048 * unmute it as default - otherwise mute it
7049 */
7050 mute = AMP_IN_MUTE(idx);
7051 for (item = 0; item < imux->num_items; item++) {
7052 if (imux->items[item].index == idx) {
7053 if (spec->cur_mux[c] == item)
7054 mute = AMP_IN_UNMUTE(idx);
7055 break;
7056 }
7057 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007058 /* check if we have a selector or mixer
7059 * we could check for the widget type instead, but
7060 * just check for Amp-In presence (in case of mixer
7061 * without amp-in there is something wrong, this
7062 * function shouldn't be used or capsrc nid is wrong)
7063 */
7064 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7065 snd_hda_codec_write(codec, nid, 0,
7066 AC_VERB_SET_AMP_GAIN_MUTE,
7067 mute);
7068 else if (mute != AMP_IN_MUTE(idx))
7069 snd_hda_codec_write(codec, nid, 0,
7070 AC_VERB_SET_CONNECT_SEL,
7071 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007072 }
7073 }
7074}
7075
Takashi Iwai776e1842007-08-29 15:07:11 +02007076/* add mic boosts if needed */
7077static int alc_auto_add_mic_boost(struct hda_codec *codec)
7078{
7079 struct alc_spec *spec = codec->spec;
7080 int err;
7081 hda_nid_t nid;
7082
7083 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007084 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007085 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7086 "Mic Boost",
7087 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7088 if (err < 0)
7089 return err;
7090 }
7091 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007092 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007093 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7094 "Front Mic Boost",
7095 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7096 if (err < 0)
7097 return err;
7098 }
7099 return 0;
7100}
7101
Kailang Yangdf694da2005-12-05 19:42:22 +01007102/* almost identical with ALC880 parser... */
7103static int alc882_parse_auto_config(struct hda_codec *codec)
7104{
7105 struct alc_spec *spec = codec->spec;
7106 int err = alc880_parse_auto_config(codec);
7107
7108 if (err < 0)
7109 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007110 else if (!err)
7111 return 0; /* no config found */
7112
7113 err = alc_auto_add_mic_boost(codec);
7114 if (err < 0)
7115 return err;
7116
7117 /* hack - override the init verbs */
7118 spec->init_verbs[0] = alc882_auto_init_verbs;
7119
7120 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007121}
7122
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007123/* additional initialization for auto-configuration model */
7124static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007125{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007126 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007127 alc882_auto_init_multi_out(codec);
7128 alc882_auto_init_hp_out(codec);
7129 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007130 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007131 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007132 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007133}
7134
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007135static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7136
Linus Torvalds1da177e2005-04-16 15:20:36 -07007137static int patch_alc882(struct hda_codec *codec)
7138{
7139 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007140 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007141
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007142 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007143 if (spec == NULL)
7144 return -ENOMEM;
7145
Linus Torvalds1da177e2005-04-16 15:20:36 -07007146 codec->spec = spec;
7147
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007148 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7149 alc882_models,
7150 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007151
Kailang Yangdf694da2005-12-05 19:42:22 +01007152 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007153 /* Pick up systems that don't supply PCI SSID */
7154 switch (codec->subsystem_id) {
7155 case 0x106b0c00: /* Mac Pro */
7156 board_config = ALC885_MACPRO;
7157 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007158 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007159 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007160 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007161 board_config = ALC885_IMAC24;
7162 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007163 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007164 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007165 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007166 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007167 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007168 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007169 board_config = ALC885_MBP3;
7170 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007171 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007172 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007173 if (codec->revision_id == 0x100101 ||
7174 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007175 alc_free(codec);
7176 return patch_alc883(codec);
7177 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007178 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7179 "trying auto-probe from BIOS...\n");
7180 board_config = ALC882_AUTO;
7181 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007182 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007183
Takashi Iwaif95474e2007-07-10 00:47:43 +02007184 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7185
Kailang Yangdf694da2005-12-05 19:42:22 +01007186 if (board_config == ALC882_AUTO) {
7187 /* automatic parse from the BIOS config */
7188 err = alc882_parse_auto_config(codec);
7189 if (err < 0) {
7190 alc_free(codec);
7191 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007192 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007193 printk(KERN_INFO
7194 "hda_codec: Cannot set up configuration "
7195 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007196 board_config = ALC882_3ST_DIG;
7197 }
7198 }
7199
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007200 err = snd_hda_attach_beep_device(codec, 0x1);
7201 if (err < 0) {
7202 alc_free(codec);
7203 return err;
7204 }
7205
Kailang Yangdf694da2005-12-05 19:42:22 +01007206 if (board_config != ALC882_AUTO)
7207 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007208
Kailang Yang2f893282008-05-27 12:14:47 +02007209 if (codec->vendor_id == 0x10ec0885) {
7210 spec->stream_name_analog = "ALC885 Analog";
7211 spec->stream_name_digital = "ALC885 Digital";
7212 } else {
7213 spec->stream_name_analog = "ALC882 Analog";
7214 spec->stream_name_digital = "ALC882 Digital";
7215 }
7216
Kailang Yangdf694da2005-12-05 19:42:22 +01007217 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7218 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007219 /* FIXME: setup DAC5 */
7220 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7221 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007222
Kailang Yangdf694da2005-12-05 19:42:22 +01007223 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7224 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007225
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007226 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007227 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007228 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007229 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007230 /* get type */
7231 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007232 if (wcap != AC_WID_AUD_IN) {
7233 spec->adc_nids = alc882_adc_nids_alt;
7234 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007235 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007236 } else {
7237 spec->adc_nids = alc882_adc_nids;
7238 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007239 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007240 }
7241 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007242 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007243 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007244
Takashi Iwai2134ea42008-01-10 16:53:55 +01007245 spec->vmaster_nid = 0x0c;
7246
Linus Torvalds1da177e2005-04-16 15:20:36 -07007247 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007248 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007249 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007250#ifdef CONFIG_SND_HDA_POWER_SAVE
7251 if (!spec->loopback.amplist)
7252 spec->loopback.amplist = alc882_loopbacks;
7253#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007254 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007255
7256 return 0;
7257}
7258
7259/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007260 * ALC883 support
7261 *
7262 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7263 * configuration. Each pin widget can choose any input DACs and a mixer.
7264 * Each ADC is connected from a mixer of all inputs. This makes possible
7265 * 6-channel independent captures.
7266 *
7267 * In addition, an independent DAC for the multi-playback (not used in this
7268 * driver yet).
7269 */
7270#define ALC883_DIGOUT_NID 0x06
7271#define ALC883_DIGIN_NID 0x0a
7272
Wu Fengguang3ab90932008-11-17 09:51:09 +01007273#define ALC1200_DIGOUT_NID 0x10
7274
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007275static hda_nid_t alc883_dac_nids[4] = {
7276 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007277 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007278};
7279
7280static hda_nid_t alc883_adc_nids[2] = {
7281 /* ADC1-2 */
7282 0x08, 0x09,
7283};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007284
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007285static hda_nid_t alc883_adc_nids_alt[1] = {
7286 /* ADC1 */
7287 0x08,
7288};
7289
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007290static hda_nid_t alc883_adc_nids_rev[2] = {
7291 /* ADC2-1 */
7292 0x09, 0x08
7293};
7294
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007295#define alc889_adc_nids alc880_adc_nids
7296
Takashi Iwaie1406342008-02-11 18:32:32 +01007297static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7298
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007299static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7300
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007301#define alc889_capsrc_nids alc882_capsrc_nids
7302
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007303/* input MUX */
7304/* FIXME: should be a matrix-type input source selection */
7305
7306static struct hda_input_mux alc883_capture_source = {
7307 .num_items = 4,
7308 .items = {
7309 { "Mic", 0x0 },
7310 { "Front Mic", 0x1 },
7311 { "Line", 0x2 },
7312 { "CD", 0x4 },
7313 },
7314};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007315
Jiang zhe17bba1b2008-06-04 12:11:07 +02007316static struct hda_input_mux alc883_3stack_6ch_intel = {
7317 .num_items = 4,
7318 .items = {
7319 { "Mic", 0x1 },
7320 { "Front Mic", 0x0 },
7321 { "Line", 0x2 },
7322 { "CD", 0x4 },
7323 },
7324};
7325
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007326static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7327 .num_items = 2,
7328 .items = {
7329 { "Mic", 0x1 },
7330 { "Line", 0x2 },
7331 },
7332};
7333
Kailang Yang272a5272007-05-14 11:00:38 +02007334static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7335 .num_items = 4,
7336 .items = {
7337 { "Mic", 0x0 },
7338 { "iMic", 0x1 },
7339 { "Line", 0x2 },
7340 { "CD", 0x4 },
7341 },
7342};
7343
Jiang zhefb97dc62008-03-06 11:07:11 +01007344static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7345 .num_items = 2,
7346 .items = {
7347 { "Mic", 0x0 },
7348 { "Int Mic", 0x1 },
7349 },
7350};
7351
Kailang Yange2757d52008-08-26 13:17:46 +02007352static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7353 .num_items = 3,
7354 .items = {
7355 { "Mic", 0x0 },
7356 { "Front Mic", 0x1 },
7357 { "Line", 0x4 },
7358 },
7359};
7360
7361static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7362 .num_items = 2,
7363 .items = {
7364 { "Mic", 0x0 },
7365 { "Line", 0x2 },
7366 },
7367};
7368
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007369/*
7370 * 2ch mode
7371 */
7372static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7373 { 2, NULL }
7374};
7375
7376/*
7377 * 2ch mode
7378 */
7379static struct hda_verb alc883_3ST_ch2_init[] = {
7380 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7381 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7382 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7383 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7384 { } /* end */
7385};
7386
7387/*
Tobin Davisb2011312007-09-17 12:45:11 +02007388 * 4ch mode
7389 */
7390static struct hda_verb alc883_3ST_ch4_init[] = {
7391 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7392 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7393 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7394 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7395 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7396 { } /* end */
7397};
7398
7399/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007400 * 6ch mode
7401 */
7402static struct hda_verb alc883_3ST_ch6_init[] = {
7403 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7404 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7405 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7406 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7407 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7408 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7409 { } /* end */
7410};
7411
Tobin Davisb2011312007-09-17 12:45:11 +02007412static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007413 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007414 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007415 { 6, alc883_3ST_ch6_init },
7416};
7417
7418/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007419 * 2ch mode
7420 */
7421static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7422 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7423 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7424 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7425 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7426 { } /* end */
7427};
7428
7429/*
7430 * 4ch mode
7431 */
7432static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7433 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7434 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7435 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7436 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7437 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7438 { } /* end */
7439};
7440
7441/*
7442 * 6ch mode
7443 */
7444static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7445 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7446 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7447 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7448 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7449 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7450 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7451 { } /* end */
7452};
7453
7454static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7455 { 2, alc883_3ST_ch2_intel_init },
7456 { 4, alc883_3ST_ch4_intel_init },
7457 { 6, alc883_3ST_ch6_intel_init },
7458};
7459
7460/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007461 * 6ch mode
7462 */
7463static struct hda_verb alc883_sixstack_ch6_init[] = {
7464 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7465 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7466 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7467 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7468 { } /* end */
7469};
7470
7471/*
7472 * 8ch mode
7473 */
7474static struct hda_verb alc883_sixstack_ch8_init[] = {
7475 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7476 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7477 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7478 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7479 { } /* end */
7480};
7481
7482static struct hda_channel_mode alc883_sixstack_modes[2] = {
7483 { 6, alc883_sixstack_ch6_init },
7484 { 8, alc883_sixstack_ch8_init },
7485};
7486
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007487static struct hda_verb alc883_medion_eapd_verbs[] = {
7488 /* eanable EAPD on medion laptop */
7489 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7490 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7491 { }
7492};
7493
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007494/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7495 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7496 */
7497
7498static struct snd_kcontrol_new alc883_base_mixer[] = {
7499 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7500 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7501 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7502 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7503 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7504 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7505 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7506 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7507 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7508 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7509 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7510 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7511 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7512 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7513 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007515 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007516 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7517 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007518 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007519 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007520 { } /* end */
7521};
7522
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007523static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7524 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7525 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7526 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7527 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7528 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7529 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7530 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7532 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7533 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7534 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7535 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7536 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007537 { } /* end */
7538};
7539
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007540static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007541 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7542 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7543 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7544 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7546 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7547 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7548 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7549 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7550 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007551 { } /* end */
7552};
7553
Jiang zhefb97dc62008-03-06 11:07:11 +01007554static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7555 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7556 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7557 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7558 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7560 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7561 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7562 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7563 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7564 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007565 { } /* end */
7566};
7567
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007568static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7569 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7570 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7571 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7572 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7573 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7574 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7575 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7576 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007577 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007578 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7579 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007580 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007581 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007582 { } /* end */
7583};
7584
7585static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7586 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7587 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7588 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7589 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7590 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7591 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7592 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7593 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7594 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7595 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7596 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7597 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7598 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7599 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007600 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007601 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7602 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007603 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007604 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007605 { } /* end */
7606};
7607
Jiang zhe17bba1b2008-06-04 12:11:07 +02007608static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7609 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7610 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7611 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7612 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7613 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7614 HDA_OUTPUT),
7615 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7616 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7617 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7618 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7619 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7620 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7621 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7622 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7623 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7624 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7625 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7626 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7627 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7628 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007629 { } /* end */
7630};
7631
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007632static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007633 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007634 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007635 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007636 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007637 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7638 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007639 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7640 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007641 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7642 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7643 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7644 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7645 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007647 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007648 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7649 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007650 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007651 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007652 { } /* end */
7653};
7654
Kailang Yangccc656c2006-10-17 12:32:26 +02007655static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7656 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7657 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7658 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7659 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7660 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7661 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7662 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7663 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7664 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7665 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7666 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7667 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7668 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007670 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007671 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007672 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007673};
Kailang Yangccc656c2006-10-17 12:32:26 +02007674
7675static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7676 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7678 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7679 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7680 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007682 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007683 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007684 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7685 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7686 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007687 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007688};
Kailang Yangccc656c2006-10-17 12:32:26 +02007689
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007690static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7691 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7692 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007693 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7694 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007695 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7696 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7697 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7698 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007699 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007700};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007701
Kailang Yang272a5272007-05-14 11:00:38 +02007702static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7703 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7704 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7705 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7706 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7707 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7709 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7710 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7711 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007712 { } /* end */
7713};
7714
7715static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7716 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7717 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7718 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7719 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7720 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7721 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7722 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7723 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7724 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007725 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007726};
Kailang Yang272a5272007-05-14 11:00:38 +02007727
Tobin Davis2880a862007-08-07 11:50:26 +02007728static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007729 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7730 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007731 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007732 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7733 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007734 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7735 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7736 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007737 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007738};
Tobin Davis2880a862007-08-07 11:50:26 +02007739
Kailang Yange2757d52008-08-26 13:17:46 +02007740static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7741 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7742 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7743 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7744 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7745 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7746 0x0d, 1, 0x0, HDA_OUTPUT),
7747 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7748 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7749 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7750 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7751 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7752 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7753 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7754 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7755 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7756 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7757 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7759 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7761 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7762 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7763 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007764 { } /* end */
7765};
7766
7767static struct hda_bind_ctls alc883_bind_cap_vol = {
7768 .ops = &snd_hda_bind_vol,
7769 .values = {
7770 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7771 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7772 0
7773 },
7774};
7775
7776static struct hda_bind_ctls alc883_bind_cap_switch = {
7777 .ops = &snd_hda_bind_sw,
7778 .values = {
7779 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7780 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7781 0
7782 },
7783};
7784
7785static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7786 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7787 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7788 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7789 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7790 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7792 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007794 { } /* end */
7795};
7796
7797static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007798 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7799 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7800 {
7801 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7802 /* .name = "Capture Source", */
7803 .name = "Input Source",
7804 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007805 .info = alc_mux_enum_info,
7806 .get = alc_mux_enum_get,
7807 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007808 },
7809 { } /* end */
7810};
7811
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007812static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7813 {
7814 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7815 .name = "Channel Mode",
7816 .info = alc_ch_mode_info,
7817 .get = alc_ch_mode_get,
7818 .put = alc_ch_mode_put,
7819 },
7820 { } /* end */
7821};
7822
7823static struct hda_verb alc883_init_verbs[] = {
7824 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007825 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007826 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7827 /* ADC2: mute amp left and right */
7828 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7829 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7830 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7832 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7833 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7834 /* Rear mixer */
7835 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7836 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7837 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7838 /* CLFE mixer */
7839 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7840 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7841 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7842 /* Side mixer */
7843 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7844 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7845 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7846
Takashi Iwaicb53c622007-08-10 17:21:45 +02007847 /* mute analog input loopbacks */
7848 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7851 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7852 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007853
7854 /* Front Pin: output 0 (0x0c) */
7855 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7856 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7857 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7858 /* Rear Pin: output 1 (0x0d) */
7859 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7861 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7862 /* CLFE Pin: output 2 (0x0e) */
7863 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7864 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7865 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7866 /* Side Pin: output 3 (0x0f) */
7867 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7868 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7869 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7870 /* Mic (rear) pin: input vref at 80% */
7871 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7872 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7873 /* Front Mic pin: input vref at 80% */
7874 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7875 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7876 /* Line In pin: input */
7877 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7878 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7879 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7880 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7881 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7882 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7883 /* CD pin widget for input */
7884 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7885
7886 /* FIXME: use matrix-type input source selection */
7887 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7888 /* Input mixer2 */
7889 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007890 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7891 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7892 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007893 /* Input mixer3 */
7894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007895 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7897 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007898 { }
7899};
7900
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007901/* toggle speaker-output according to the hp-jack state */
7902static void alc883_mitac_hp_automute(struct hda_codec *codec)
7903{
7904 unsigned int present;
7905
7906 present = snd_hda_codec_read(codec, 0x15, 0,
7907 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7908 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7909 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7910 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7911 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7912}
7913
7914/* auto-toggle front mic */
7915/*
7916static void alc883_mitac_mic_automute(struct hda_codec *codec)
7917{
7918 unsigned int present;
7919 unsigned char bits;
7920
7921 present = snd_hda_codec_read(codec, 0x18, 0,
7922 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7923 bits = present ? HDA_AMP_MUTE : 0;
7924 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7925}
7926*/
7927
7928static void alc883_mitac_automute(struct hda_codec *codec)
7929{
7930 alc883_mitac_hp_automute(codec);
7931 /* alc883_mitac_mic_automute(codec); */
7932}
7933
7934static void alc883_mitac_unsol_event(struct hda_codec *codec,
7935 unsigned int res)
7936{
7937 switch (res >> 26) {
7938 case ALC880_HP_EVENT:
7939 alc883_mitac_hp_automute(codec);
7940 break;
7941 case ALC880_MIC_EVENT:
7942 /* alc883_mitac_mic_automute(codec); */
7943 break;
7944 }
7945}
7946
7947static struct hda_verb alc883_mitac_verbs[] = {
7948 /* HP */
7949 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7951 /* Subwoofer */
7952 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7953 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7954
7955 /* enable unsolicited event */
7956 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7957 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7958
7959 { } /* end */
7960};
7961
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007962static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007963 /* HP */
7964 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7965 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7966 /* Int speaker */
7967 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7968 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7969
7970 /* enable unsolicited event */
7971 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007972 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007973
7974 { } /* end */
7975};
7976
Jiang zhefb97dc62008-03-06 11:07:11 +01007977static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7978 /* HP */
7979 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7981 /* Subwoofer */
7982 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7984
7985 /* enable unsolicited event */
7986 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7987
7988 { } /* end */
7989};
7990
Kailang Yangccc656c2006-10-17 12:32:26 +02007991static struct hda_verb alc883_tagra_verbs[] = {
7992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7994
7995 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7996 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007997
Kailang Yangccc656c2006-10-17 12:32:26 +02007998 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7999 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8000 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8001
8002 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008003 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8004 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8005 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02008006
8007 { } /* end */
8008};
8009
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008010static struct hda_verb alc883_lenovo_101e_verbs[] = {
8011 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8012 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8013 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8014 { } /* end */
8015};
8016
Kailang Yang272a5272007-05-14 11:00:38 +02008017static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8018 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8019 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8020 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8021 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8022 { } /* end */
8023};
8024
8025static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8028 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8029 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8030 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8031 { } /* end */
8032};
8033
Kailang Yang189609a2007-08-20 11:31:23 +02008034static struct hda_verb alc883_haier_w66_verbs[] = {
8035 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8037
8038 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8039
8040 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8042 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8043 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8044 { } /* end */
8045};
8046
Kailang Yange2757d52008-08-26 13:17:46 +02008047static struct hda_verb alc888_lenovo_sky_verbs[] = {
8048 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8049 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8050 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8051 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8052 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8053 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8054 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8055 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8056 { } /* end */
8057};
8058
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008059static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008060 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008061 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8062 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008063 { }
8064};
8065
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008066static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008067 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8068 { }
8069};
8070
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008071/*
8072 * 2ch mode
8073 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008074static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008075 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8076 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8077 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8078 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008079 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008080};
8081
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008082/*
8083 * 4ch mode
8084 */
8085static struct hda_verb alc888_3st_hp_4ch_init[] = {
8086 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8087 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8088 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8089 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8090 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8091 { } /* end */
8092};
8093
8094/*
8095 * 6ch mode
8096 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008097static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008098 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8099 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008100 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008101 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8102 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008103 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8104 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008105};
8106
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008107static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008108 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008109 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008110 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008111};
8112
Kailang Yang272a5272007-05-14 11:00:38 +02008113/* toggle front-jack and RCA according to the hp-jack state */
8114static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8115{
8116 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008117
Kailang Yang272a5272007-05-14 11:00:38 +02008118 present = snd_hda_codec_read(codec, 0x1b, 0,
8119 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008120 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8121 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8122 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8123 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008124}
8125
8126/* toggle RCA according to the front-jack state */
8127static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8128{
8129 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008130
Kailang Yang272a5272007-05-14 11:00:38 +02008131 present = snd_hda_codec_read(codec, 0x14, 0,
8132 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008133 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8134 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008135}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008136
Kailang Yang272a5272007-05-14 11:00:38 +02008137static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8138 unsigned int res)
8139{
8140 if ((res >> 26) == ALC880_HP_EVENT)
8141 alc888_lenovo_ms7195_front_automute(codec);
8142 if ((res >> 26) == ALC880_FRONT_EVENT)
8143 alc888_lenovo_ms7195_rca_automute(codec);
8144}
8145
8146static struct hda_verb alc883_medion_md2_verbs[] = {
8147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8148 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8149
8150 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8151
8152 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8153 { } /* end */
8154};
8155
8156/* toggle speaker-output according to the hp-jack state */
8157static void alc883_medion_md2_automute(struct hda_codec *codec)
8158{
8159 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008160
Kailang Yang272a5272007-05-14 11:00:38 +02008161 present = snd_hda_codec_read(codec, 0x14, 0,
8162 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008163 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8164 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008165}
8166
8167static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8168 unsigned int res)
8169{
8170 if ((res >> 26) == ALC880_HP_EVENT)
8171 alc883_medion_md2_automute(codec);
8172}
8173
Kailang Yangccc656c2006-10-17 12:32:26 +02008174/* toggle speaker-output according to the hp-jack state */
8175static void alc883_tagra_automute(struct hda_codec *codec)
8176{
8177 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008178 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008179
8180 present = snd_hda_codec_read(codec, 0x14, 0,
8181 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008182 bits = present ? HDA_AMP_MUTE : 0;
8183 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8184 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008185 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8186 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008187}
8188
8189static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8190{
8191 if ((res >> 26) == ALC880_HP_EVENT)
8192 alc883_tagra_automute(codec);
8193}
8194
Jiang zhe368c7a92008-03-04 11:20:33 +01008195/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008196static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008197{
8198 unsigned int present;
8199 unsigned char bits;
8200
8201 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8202 & AC_PINSENSE_PRESENCE;
8203 bits = present ? HDA_AMP_MUTE : 0;
8204 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8205 HDA_AMP_MUTE, bits);
8206}
8207
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008208static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8209{
8210 unsigned int present;
8211
8212 present = snd_hda_codec_read(codec, 0x18, 0,
8213 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8214 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8215 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8216}
8217
8218static void alc883_clevo_m720_automute(struct hda_codec *codec)
8219{
8220 alc883_clevo_m720_hp_automute(codec);
8221 alc883_clevo_m720_mic_automute(codec);
8222}
8223
8224static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008225 unsigned int res)
8226{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008227 switch (res >> 26) {
8228 case ALC880_HP_EVENT:
8229 alc883_clevo_m720_hp_automute(codec);
8230 break;
8231 case ALC880_MIC_EVENT:
8232 alc883_clevo_m720_mic_automute(codec);
8233 break;
8234 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008235}
8236
Jiang zhefb97dc62008-03-06 11:07:11 +01008237/* toggle speaker-output according to the hp-jack state */
8238static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8239{
8240 unsigned int present;
8241 unsigned char bits;
8242
8243 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8244 & AC_PINSENSE_PRESENCE;
8245 bits = present ? HDA_AMP_MUTE : 0;
8246 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8247 HDA_AMP_MUTE, bits);
8248}
8249
8250static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8251 unsigned int res)
8252{
8253 if ((res >> 26) == ALC880_HP_EVENT)
8254 alc883_2ch_fujitsu_pi2515_automute(codec);
8255}
8256
Kailang Yang189609a2007-08-20 11:31:23 +02008257static void alc883_haier_w66_automute(struct hda_codec *codec)
8258{
8259 unsigned int present;
8260 unsigned char bits;
8261
8262 present = snd_hda_codec_read(codec, 0x1b, 0,
8263 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8264 bits = present ? 0x80 : 0;
8265 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8266 0x80, bits);
8267}
8268
8269static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8270 unsigned int res)
8271{
8272 if ((res >> 26) == ALC880_HP_EVENT)
8273 alc883_haier_w66_automute(codec);
8274}
8275
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008276static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8277{
8278 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008279 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008280
8281 present = snd_hda_codec_read(codec, 0x14, 0,
8282 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008283 bits = present ? HDA_AMP_MUTE : 0;
8284 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8285 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008286}
8287
8288static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8289{
8290 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008291 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008292
8293 present = snd_hda_codec_read(codec, 0x1b, 0,
8294 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008295 bits = present ? HDA_AMP_MUTE : 0;
8296 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8297 HDA_AMP_MUTE, bits);
8298 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8299 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008300}
8301
8302static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8303 unsigned int res)
8304{
8305 if ((res >> 26) == ALC880_HP_EVENT)
8306 alc883_lenovo_101e_all_automute(codec);
8307 if ((res >> 26) == ALC880_FRONT_EVENT)
8308 alc883_lenovo_101e_ispeaker_automute(codec);
8309}
8310
Takashi Iwai676a9b52007-08-16 15:23:35 +02008311/* toggle speaker-output according to the hp-jack state */
8312static void alc883_acer_aspire_automute(struct hda_codec *codec)
8313{
8314 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008315
Takashi Iwai676a9b52007-08-16 15:23:35 +02008316 present = snd_hda_codec_read(codec, 0x14, 0,
8317 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8318 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8319 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8320 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8321 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8322}
8323
8324static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8325 unsigned int res)
8326{
8327 if ((res >> 26) == ALC880_HP_EVENT)
8328 alc883_acer_aspire_automute(codec);
8329}
8330
Kailang Yangd1a991a2007-08-15 16:21:59 +02008331static struct hda_verb alc883_acer_eapd_verbs[] = {
8332 /* HP Pin: output 0 (0x0c) */
8333 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8334 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8335 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8336 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008337 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8338 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008339 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008340 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8341 /* eanable EAPD on medion laptop */
8342 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8343 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008344 /* enable unsolicited event */
8345 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008346 { }
8347};
8348
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008349static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8350{
8351 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008352
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008353 present = snd_hda_codec_read(codec, 0x1b, 0,
8354 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8355 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8356 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8357 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8358 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8359 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8360 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8361 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8362 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8363}
8364
8365static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8366 unsigned int res)
8367{
8368 switch (res >> 26) {
8369 case ALC880_HP_EVENT:
Takashi Iwai939778a2009-02-05 15:57:55 +01008370 /* printk(KERN_DEBUG "hp_event\n"); */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008371 alc888_6st_dell_front_automute(codec);
8372 break;
8373 }
8374}
8375
Kailang Yange2757d52008-08-26 13:17:46 +02008376static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8377{
8378 unsigned int mute;
8379 unsigned int present;
8380
8381 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8382 present = snd_hda_codec_read(codec, 0x1b, 0,
8383 AC_VERB_GET_PIN_SENSE, 0);
8384 present = (present & 0x80000000) != 0;
8385 if (present) {
8386 /* mute internal speaker */
8387 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8388 HDA_AMP_MUTE, HDA_AMP_MUTE);
8389 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8390 HDA_AMP_MUTE, HDA_AMP_MUTE);
8391 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8392 HDA_AMP_MUTE, HDA_AMP_MUTE);
8393 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8394 HDA_AMP_MUTE, HDA_AMP_MUTE);
8395 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8396 HDA_AMP_MUTE, HDA_AMP_MUTE);
8397 } else {
8398 /* unmute internal speaker if necessary */
8399 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8400 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8401 HDA_AMP_MUTE, mute);
8402 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8403 HDA_AMP_MUTE, mute);
8404 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8405 HDA_AMP_MUTE, mute);
8406 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8407 HDA_AMP_MUTE, mute);
8408 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8409 HDA_AMP_MUTE, mute);
8410 }
8411}
8412
8413static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8414 unsigned int res)
8415{
8416 if ((res >> 26) == ALC880_HP_EVENT)
8417 alc888_lenovo_sky_front_automute(codec);
8418}
8419
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008420/*
8421 * generic initialization of ADC, input mixers and output mixers
8422 */
8423static struct hda_verb alc883_auto_init_verbs[] = {
8424 /*
8425 * Unmute ADC0-2 and set the default input to mic-in
8426 */
8427 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8428 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8429 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8430 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8431
Takashi Iwaicb53c622007-08-10 17:21:45 +02008432 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008433 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008434 * Note: PASD motherboards uses the Line In 2 as the input for
8435 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008436 */
8437 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008438 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8439 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8440 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008443
8444 /*
8445 * Set up output mixers (0x0c - 0x0f)
8446 */
8447 /* set vol=0 to output mixers */
8448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8449 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8450 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8451 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8452 /* set up input amps for analog loopback */
8453 /* Amp Indices: DAC = 0, mixer = 1 */
8454 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8455 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8456 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8457 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8459 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8460 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8461 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8462 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8463 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8464
8465 /* FIXME: use matrix-type input source selection */
8466 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8467 /* Input mixer1 */
8468 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8469 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8470 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008471 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008472 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8473 /* Input mixer2 */
8474 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8475 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8476 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008477 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008478 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008479
8480 { }
8481};
8482
Kailang Yange2757d52008-08-26 13:17:46 +02008483static struct hda_verb alc888_asus_m90v_verbs[] = {
8484 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8487 /* enable unsolicited event */
8488 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8489 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8490 { } /* end */
8491};
8492
8493static void alc883_nb_mic_automute(struct hda_codec *codec)
8494{
8495 unsigned int present;
8496
8497 present = snd_hda_codec_read(codec, 0x18, 0,
8498 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8499 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8500 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8501 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8502 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8503}
8504
8505static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8506{
8507 unsigned int present;
8508 unsigned char bits;
8509
8510 present = snd_hda_codec_read(codec, 0x1b, 0,
8511 AC_VERB_GET_PIN_SENSE, 0)
8512 & AC_PINSENSE_PRESENCE;
8513 bits = present ? 0 : PIN_OUT;
8514 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8515 bits);
8516 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8517 bits);
8518 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8519 bits);
8520}
8521
8522static void alc883_mode2_unsol_event(struct hda_codec *codec,
8523 unsigned int res)
8524{
8525 switch (res >> 26) {
8526 case ALC880_HP_EVENT:
8527 alc883_M90V_speaker_automute(codec);
8528 break;
8529 case ALC880_MIC_EVENT:
8530 alc883_nb_mic_automute(codec);
8531 break;
8532 }
8533}
8534
8535static void alc883_mode2_inithook(struct hda_codec *codec)
8536{
8537 alc883_M90V_speaker_automute(codec);
8538 alc883_nb_mic_automute(codec);
8539}
8540
8541static struct hda_verb alc888_asus_eee1601_verbs[] = {
8542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8543 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8544 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8545 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8546 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8547 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8548 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8549 /* enable unsolicited event */
8550 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8551 { } /* end */
8552};
8553
8554static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8555{
8556 unsigned int present;
8557 unsigned char bits;
8558
8559 present = snd_hda_codec_read(codec, 0x14, 0,
8560 AC_VERB_GET_PIN_SENSE, 0)
8561 & AC_PINSENSE_PRESENCE;
8562 bits = present ? 0 : PIN_OUT;
8563 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8564 bits);
8565}
8566
8567static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8568 unsigned int res)
8569{
8570 switch (res >> 26) {
8571 case ALC880_HP_EVENT:
8572 alc883_eee1601_speaker_automute(codec);
8573 break;
8574 }
8575}
8576
8577static void alc883_eee1601_inithook(struct hda_codec *codec)
8578{
8579 alc883_eee1601_speaker_automute(codec);
8580}
8581
Takashi Iwaicb53c622007-08-10 17:21:45 +02008582#ifdef CONFIG_SND_HDA_POWER_SAVE
8583#define alc883_loopbacks alc880_loopbacks
8584#endif
8585
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008586/* pcm configuration: identiacal with ALC880 */
8587#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8588#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008589#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008590#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8591#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8592
8593/*
8594 * configuration and preset
8595 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008596static const char *alc883_models[ALC883_MODEL_LAST] = {
8597 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8598 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8599 [ALC883_3ST_6ch] = "3stack-6ch",
8600 [ALC883_6ST_DIG] = "6stack-dig",
8601 [ALC883_TARGA_DIG] = "targa-dig",
8602 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008603 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008604 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008605 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008606 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008607 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008608 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008609 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008610 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8611 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008612 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008613 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008614 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008615 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008616 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008617 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008618 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008619 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008620 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008621 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008622 [ALC883_AUTO] = "auto",
8623};
8624
8625static struct snd_pci_quirk alc883_cfg_tbl[] = {
8626 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008627 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008628 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008629 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8630 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008631 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008632 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8633 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008634 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8635 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01008636 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008637 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008638 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8639 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008640 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8641 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008642 /* default Acer */
8643 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008644 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008645 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008646 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8647 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008648 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008649 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008650 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008651 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008652 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008653 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008654 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008655 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008656 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008657 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008658 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8659 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008660 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008661 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008662 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008663 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8664 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8665 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008666 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008667 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008668 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008669 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8670 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8671 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8672 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8673 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8674 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8675 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8676 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8677 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008678 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8679 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008680 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008681 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008682 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008683 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008684 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008685 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008686 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008687 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8688 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008689 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008690 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008691 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaif67d8172009-02-04 23:30:19 +01008692 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8693 ALC883_FUJITSU_PI2515),
Jiang zhefb97dc62008-03-06 11:07:11 +01008694 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008695 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8696 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008697 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008698 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008699 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8700 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008701 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008702 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008703 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008704 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008705 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008706 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8707 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008708 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008709 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008710 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008711 {}
8712};
8713
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008714static hda_nid_t alc1200_slave_dig_outs[] = {
8715 ALC883_DIGOUT_NID, 0,
8716};
8717
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008718static struct alc_config_preset alc883_presets[] = {
8719 [ALC883_3ST_2ch_DIG] = {
8720 .mixers = { alc883_3ST_2ch_mixer },
8721 .init_verbs = { alc883_init_verbs },
8722 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8723 .dac_nids = alc883_dac_nids,
8724 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008725 .dig_in_nid = ALC883_DIGIN_NID,
8726 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8727 .channel_mode = alc883_3ST_2ch_modes,
8728 .input_mux = &alc883_capture_source,
8729 },
8730 [ALC883_3ST_6ch_DIG] = {
8731 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8732 .init_verbs = { alc883_init_verbs },
8733 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8734 .dac_nids = alc883_dac_nids,
8735 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008736 .dig_in_nid = ALC883_DIGIN_NID,
8737 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8738 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008739 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008740 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008741 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008742 [ALC883_3ST_6ch] = {
8743 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8744 .init_verbs = { alc883_init_verbs },
8745 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8746 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008747 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8748 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008749 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008750 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008751 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008752 [ALC883_3ST_6ch_INTEL] = {
8753 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8754 .init_verbs = { alc883_init_verbs },
8755 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8756 .dac_nids = alc883_dac_nids,
8757 .dig_out_nid = ALC883_DIGOUT_NID,
8758 .dig_in_nid = ALC883_DIGIN_NID,
8759 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8760 .channel_mode = alc883_3ST_6ch_intel_modes,
8761 .need_dac_fix = 1,
8762 .input_mux = &alc883_3stack_6ch_intel,
8763 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008764 [ALC883_6ST_DIG] = {
8765 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8766 .init_verbs = { alc883_init_verbs },
8767 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8768 .dac_nids = alc883_dac_nids,
8769 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008770 .dig_in_nid = ALC883_DIGIN_NID,
8771 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8772 .channel_mode = alc883_sixstack_modes,
8773 .input_mux = &alc883_capture_source,
8774 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008775 [ALC883_TARGA_DIG] = {
8776 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8777 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8778 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8779 .dac_nids = alc883_dac_nids,
8780 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008781 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8782 .channel_mode = alc883_3ST_6ch_modes,
8783 .need_dac_fix = 1,
8784 .input_mux = &alc883_capture_source,
8785 .unsol_event = alc883_tagra_unsol_event,
8786 .init_hook = alc883_tagra_automute,
8787 },
8788 [ALC883_TARGA_2ch_DIG] = {
8789 .mixers = { alc883_tagra_2ch_mixer},
8790 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8791 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8792 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008793 .adc_nids = alc883_adc_nids_alt,
8794 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008795 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008796 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8797 .channel_mode = alc883_3ST_2ch_modes,
8798 .input_mux = &alc883_capture_source,
8799 .unsol_event = alc883_tagra_unsol_event,
8800 .init_hook = alc883_tagra_automute,
8801 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008802 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008803 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008804 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8805 * and the headphone jack. Turn this on and rely on the
8806 * standard mute methods whenever the user wants to turn
8807 * these outputs off.
8808 */
8809 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8810 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8811 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008812 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8813 .channel_mode = alc883_3ST_2ch_modes,
8814 .input_mux = &alc883_capture_source,
8815 },
Tobin Davis2880a862007-08-07 11:50:26 +02008816 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008817 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008818 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008819 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8820 .dac_nids = alc883_dac_nids,
8821 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008822 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8823 .channel_mode = alc883_3ST_2ch_modes,
8824 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008825 .unsol_event = alc883_acer_aspire_unsol_event,
8826 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008827 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008828 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008829 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008830 alc883_chmode_mixer },
8831 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8832 alc888_acer_aspire_4930g_verbs },
8833 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8834 .dac_nids = alc883_dac_nids,
8835 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8836 .adc_nids = alc883_adc_nids_rev,
8837 .capsrc_nids = alc883_capsrc_nids_rev,
8838 .dig_out_nid = ALC883_DIGOUT_NID,
8839 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8840 .channel_mode = alc883_3ST_6ch_modes,
8841 .need_dac_fix = 1,
8842 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008843 ARRAY_SIZE(alc888_2_capture_sources),
8844 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008845 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8846 .init_hook = alc888_acer_aspire_4930g_automute,
8847 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008848 [ALC883_MEDION] = {
8849 .mixers = { alc883_fivestack_mixer,
8850 alc883_chmode_mixer },
8851 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008852 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008853 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8854 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008855 .adc_nids = alc883_adc_nids_alt,
8856 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008857 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8858 .channel_mode = alc883_sixstack_modes,
8859 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008860 },
Kailang Yang272a5272007-05-14 11:00:38 +02008861 [ALC883_MEDION_MD2] = {
8862 .mixers = { alc883_medion_md2_mixer},
8863 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8864 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8865 .dac_nids = alc883_dac_nids,
8866 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008867 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8868 .channel_mode = alc883_3ST_2ch_modes,
8869 .input_mux = &alc883_capture_source,
8870 .unsol_event = alc883_medion_md2_unsol_event,
8871 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008872 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008873 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008874 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008875 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8876 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8877 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008878 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8879 .channel_mode = alc883_3ST_2ch_modes,
8880 .input_mux = &alc883_capture_source,
8881 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008882 [ALC883_CLEVO_M720] = {
8883 .mixers = { alc883_clevo_m720_mixer },
8884 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008885 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8886 .dac_nids = alc883_dac_nids,
8887 .dig_out_nid = ALC883_DIGOUT_NID,
8888 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8889 .channel_mode = alc883_3ST_2ch_modes,
8890 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008891 .unsol_event = alc883_clevo_m720_unsol_event,
8892 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008893 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008894 [ALC883_LENOVO_101E_2ch] = {
8895 .mixers = { alc883_lenovo_101e_2ch_mixer},
8896 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8897 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8898 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008899 .adc_nids = alc883_adc_nids_alt,
8900 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008901 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8902 .channel_mode = alc883_3ST_2ch_modes,
8903 .input_mux = &alc883_lenovo_101e_capture_source,
8904 .unsol_event = alc883_lenovo_101e_unsol_event,
8905 .init_hook = alc883_lenovo_101e_all_automute,
8906 },
Kailang Yang272a5272007-05-14 11:00:38 +02008907 [ALC883_LENOVO_NB0763] = {
8908 .mixers = { alc883_lenovo_nb0763_mixer },
8909 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8910 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8911 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008912 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8913 .channel_mode = alc883_3ST_2ch_modes,
8914 .need_dac_fix = 1,
8915 .input_mux = &alc883_lenovo_nb0763_capture_source,
8916 .unsol_event = alc883_medion_md2_unsol_event,
8917 .init_hook = alc883_medion_md2_automute,
8918 },
8919 [ALC888_LENOVO_MS7195_DIG] = {
8920 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8921 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8922 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8923 .dac_nids = alc883_dac_nids,
8924 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008925 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8926 .channel_mode = alc883_3ST_6ch_modes,
8927 .need_dac_fix = 1,
8928 .input_mux = &alc883_capture_source,
8929 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8930 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008931 },
8932 [ALC883_HAIER_W66] = {
8933 .mixers = { alc883_tagra_2ch_mixer},
8934 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8935 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8936 .dac_nids = alc883_dac_nids,
8937 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008938 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8939 .channel_mode = alc883_3ST_2ch_modes,
8940 .input_mux = &alc883_capture_source,
8941 .unsol_event = alc883_haier_w66_unsol_event,
8942 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008943 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008944 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008945 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008946 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008947 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8948 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008949 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8950 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008951 .need_dac_fix = 1,
8952 .input_mux = &alc883_capture_source,
8953 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008954 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008955 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008956 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8957 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8958 .dac_nids = alc883_dac_nids,
8959 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008960 .dig_in_nid = ALC883_DIGIN_NID,
8961 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8962 .channel_mode = alc883_sixstack_modes,
8963 .input_mux = &alc883_capture_source,
8964 .unsol_event = alc888_6st_dell_unsol_event,
8965 .init_hook = alc888_6st_dell_front_automute,
8966 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008967 [ALC883_MITAC] = {
8968 .mixers = { alc883_mitac_mixer },
8969 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8970 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8971 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008972 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8973 .channel_mode = alc883_3ST_2ch_modes,
8974 .input_mux = &alc883_capture_source,
8975 .unsol_event = alc883_mitac_unsol_event,
8976 .init_hook = alc883_mitac_automute,
8977 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008978 [ALC883_FUJITSU_PI2515] = {
8979 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8980 .init_verbs = { alc883_init_verbs,
8981 alc883_2ch_fujitsu_pi2515_verbs},
8982 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8983 .dac_nids = alc883_dac_nids,
8984 .dig_out_nid = ALC883_DIGOUT_NID,
8985 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8986 .channel_mode = alc883_3ST_2ch_modes,
8987 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8988 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8989 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8990 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008991 [ALC888_FUJITSU_XA3530] = {
8992 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8993 .init_verbs = { alc883_init_verbs,
8994 alc888_fujitsu_xa3530_verbs },
8995 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8996 .dac_nids = alc883_dac_nids,
8997 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8998 .adc_nids = alc883_adc_nids_rev,
8999 .capsrc_nids = alc883_capsrc_nids_rev,
9000 .dig_out_nid = ALC883_DIGOUT_NID,
9001 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9002 .channel_mode = alc888_4ST_8ch_intel_modes,
9003 .num_mux_defs =
9004 ARRAY_SIZE(alc888_2_capture_sources),
9005 .input_mux = alc888_2_capture_sources,
9006 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
9007 .init_hook = alc888_fujitsu_xa3530_automute,
9008 },
Kailang Yange2757d52008-08-26 13:17:46 +02009009 [ALC888_LENOVO_SKY] = {
9010 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9011 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9012 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9013 .dac_nids = alc883_dac_nids,
9014 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009015 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9016 .channel_mode = alc883_sixstack_modes,
9017 .need_dac_fix = 1,
9018 .input_mux = &alc883_lenovo_sky_capture_source,
9019 .unsol_event = alc883_lenovo_sky_unsol_event,
9020 .init_hook = alc888_lenovo_sky_front_automute,
9021 },
9022 [ALC888_ASUS_M90V] = {
9023 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9024 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9025 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9026 .dac_nids = alc883_dac_nids,
9027 .dig_out_nid = ALC883_DIGOUT_NID,
9028 .dig_in_nid = ALC883_DIGIN_NID,
9029 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9030 .channel_mode = alc883_3ST_6ch_modes,
9031 .need_dac_fix = 1,
9032 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9033 .unsol_event = alc883_mode2_unsol_event,
9034 .init_hook = alc883_mode2_inithook,
9035 },
9036 [ALC888_ASUS_EEE1601] = {
9037 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009038 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009039 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9040 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9041 .dac_nids = alc883_dac_nids,
9042 .dig_out_nid = ALC883_DIGOUT_NID,
9043 .dig_in_nid = ALC883_DIGIN_NID,
9044 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9045 .channel_mode = alc883_3ST_2ch_modes,
9046 .need_dac_fix = 1,
9047 .input_mux = &alc883_asus_eee1601_capture_source,
9048 .unsol_event = alc883_eee1601_unsol_event,
9049 .init_hook = alc883_eee1601_inithook,
9050 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009051 [ALC1200_ASUS_P5Q] = {
9052 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9053 .init_verbs = { alc883_init_verbs },
9054 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9055 .dac_nids = alc883_dac_nids,
9056 .dig_out_nid = ALC1200_DIGOUT_NID,
9057 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009058 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009059 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9060 .channel_mode = alc883_sixstack_modes,
9061 .input_mux = &alc883_capture_source,
9062 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009063};
9064
9065
9066/*
9067 * BIOS auto configuration
9068 */
9069static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9070 hda_nid_t nid, int pin_type,
9071 int dac_idx)
9072{
9073 /* set as output */
9074 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009075 int idx;
9076
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009077 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009078 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9079 idx = 4;
9080 else
9081 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009082 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9083
9084}
9085
9086static void alc883_auto_init_multi_out(struct hda_codec *codec)
9087{
9088 struct alc_spec *spec = codec->spec;
9089 int i;
9090
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009091 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009092 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009093 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009094 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009095 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009096 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009097 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009098 }
9099}
9100
9101static void alc883_auto_init_hp_out(struct hda_codec *codec)
9102{
9103 struct alc_spec *spec = codec->spec;
9104 hda_nid_t pin;
9105
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009106 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009107 if (pin) /* connect to front */
9108 /* use dac 0 */
9109 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009110 pin = spec->autocfg.speaker_pins[0];
9111 if (pin)
9112 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009113}
9114
9115#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9116#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9117
9118static void alc883_auto_init_analog_input(struct hda_codec *codec)
9119{
9120 struct alc_spec *spec = codec->spec;
9121 int i;
9122
9123 for (i = 0; i < AUTO_PIN_LAST; i++) {
9124 hda_nid_t nid = spec->autocfg.input_pins[i];
9125 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009126 alc_set_input_pin(codec, nid, i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009127 if (nid != ALC883_PIN_CD_NID)
9128 snd_hda_codec_write(codec, nid, 0,
9129 AC_VERB_SET_AMP_GAIN_MUTE,
9130 AMP_OUT_MUTE);
9131 }
9132 }
9133}
9134
Takashi Iwaif511b012008-08-15 16:46:42 +02009135#define alc883_auto_init_input_src alc882_auto_init_input_src
9136
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009137/* almost identical with ALC880 parser... */
9138static int alc883_parse_auto_config(struct hda_codec *codec)
9139{
9140 struct alc_spec *spec = codec->spec;
9141 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009142 struct auto_pin_cfg *cfg = &spec->autocfg;
9143 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009144
9145 if (err < 0)
9146 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009147 else if (!err)
9148 return 0; /* no config found */
9149
9150 err = alc_auto_add_mic_boost(codec);
9151 if (err < 0)
9152 return err;
9153
9154 /* hack - override the init verbs */
9155 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009156
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009157 /* setup input_mux for ALC889 */
9158 if (codec->vendor_id == 0x10ec0889) {
9159 /* digital-mic input pin is excluded in alc880_auto_create..()
9160 * because it's under 0x18
9161 */
9162 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9163 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9164 struct hda_input_mux *imux = &spec->private_imux[0];
9165 for (i = 1; i < 3; i++)
9166 memcpy(&spec->private_imux[i],
9167 &spec->private_imux[0],
9168 sizeof(spec->private_imux[0]));
9169 imux->items[imux->num_items].label = "Int DMic";
9170 imux->items[imux->num_items].index = 0x0b;
9171 imux->num_items++;
9172 spec->num_mux_defs = 3;
9173 spec->input_mux = spec->private_imux;
9174 }
9175 }
9176
Takashi Iwai776e1842007-08-29 15:07:11 +02009177 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009178}
9179
9180/* additional initialization for auto-configuration model */
9181static void alc883_auto_init(struct hda_codec *codec)
9182{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009183 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009184 alc883_auto_init_multi_out(codec);
9185 alc883_auto_init_hp_out(codec);
9186 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009187 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009188 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009189 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009190}
9191
9192static int patch_alc883(struct hda_codec *codec)
9193{
9194 struct alc_spec *spec;
9195 int err, board_config;
9196
9197 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9198 if (spec == NULL)
9199 return -ENOMEM;
9200
9201 codec->spec = spec;
9202
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009203 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9204
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009205 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9206 alc883_models,
9207 alc883_cfg_tbl);
9208 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009209 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9210 "trying auto-probe from BIOS...\n");
9211 board_config = ALC883_AUTO;
9212 }
9213
9214 if (board_config == ALC883_AUTO) {
9215 /* automatic parse from the BIOS config */
9216 err = alc883_parse_auto_config(codec);
9217 if (err < 0) {
9218 alc_free(codec);
9219 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009220 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009221 printk(KERN_INFO
9222 "hda_codec: Cannot set up configuration "
9223 "from BIOS. Using base mode...\n");
9224 board_config = ALC883_3ST_2ch_DIG;
9225 }
9226 }
9227
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009228 err = snd_hda_attach_beep_device(codec, 0x1);
9229 if (err < 0) {
9230 alc_free(codec);
9231 return err;
9232 }
9233
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009234 if (board_config != ALC883_AUTO)
9235 setup_preset(spec, &alc883_presets[board_config]);
9236
Kailang Yang2f893282008-05-27 12:14:47 +02009237 switch (codec->vendor_id) {
9238 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009239 if (codec->revision_id == 0x100101) {
9240 spec->stream_name_analog = "ALC1200 Analog";
9241 spec->stream_name_digital = "ALC1200 Digital";
9242 } else {
9243 spec->stream_name_analog = "ALC888 Analog";
9244 spec->stream_name_digital = "ALC888 Digital";
9245 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009246 if (!spec->num_adc_nids) {
9247 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9248 spec->adc_nids = alc883_adc_nids;
9249 }
9250 if (!spec->capsrc_nids)
9251 spec->capsrc_nids = alc883_capsrc_nids;
9252 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009253 break;
9254 case 0x10ec0889:
9255 spec->stream_name_analog = "ALC889 Analog";
9256 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009257 if (!spec->num_adc_nids) {
9258 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9259 spec->adc_nids = alc889_adc_nids;
9260 }
9261 if (!spec->capsrc_nids)
9262 spec->capsrc_nids = alc889_capsrc_nids;
9263 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9264 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009265 break;
9266 default:
9267 spec->stream_name_analog = "ALC883 Analog";
9268 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009269 if (!spec->num_adc_nids) {
9270 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9271 spec->adc_nids = alc883_adc_nids;
9272 }
9273 if (!spec->capsrc_nids)
9274 spec->capsrc_nids = alc883_capsrc_nids;
9275 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009276 break;
9277 }
9278
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009279 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9280 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009281 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009282
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009283 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9284 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9285
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009286 if (!spec->cap_mixer)
9287 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009288 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009289
Takashi Iwai2134ea42008-01-10 16:53:55 +01009290 spec->vmaster_nid = 0x0c;
9291
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009292 codec->patch_ops = alc_patch_ops;
9293 if (board_config == ALC883_AUTO)
9294 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009295
Takashi Iwaicb53c622007-08-10 17:21:45 +02009296#ifdef CONFIG_SND_HDA_POWER_SAVE
9297 if (!spec->loopback.amplist)
9298 spec->loopback.amplist = alc883_loopbacks;
9299#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009300 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009301
9302 return 0;
9303}
9304
9305/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009306 * ALC262 support
9307 */
9308
9309#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9310#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9311
9312#define alc262_dac_nids alc260_dac_nids
9313#define alc262_adc_nids alc882_adc_nids
9314#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009315#define alc262_capsrc_nids alc882_capsrc_nids
9316#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009317
9318#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009319#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009320
Kailang Yang4e555fe2008-08-26 13:05:55 +02009321static hda_nid_t alc262_dmic_adc_nids[1] = {
9322 /* ADC0 */
9323 0x09
9324};
9325
9326static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9327
Kailang Yangdf694da2005-12-05 19:42:22 +01009328static struct snd_kcontrol_new alc262_base_mixer[] = {
9329 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9330 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9331 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9332 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9333 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9334 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009337 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009338 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9339 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009340 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009341 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9342 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9343 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9344 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009345 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009346};
9347
Kailang Yangccc656c2006-10-17 12:32:26 +02009348static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9349 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9350 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9351 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9352 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9353 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9354 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009357 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009358 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9359 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009360 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009361 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9362 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9363 { } /* end */
9364};
9365
Takashi Iwaice875f02008-01-28 18:17:43 +01009366/* update HP, line and mono-out pins according to the master switch */
9367static void alc262_hp_master_update(struct hda_codec *codec)
9368{
9369 struct alc_spec *spec = codec->spec;
9370 int val = spec->master_sw;
9371
9372 /* HP & line-out */
9373 snd_hda_codec_write_cache(codec, 0x1b, 0,
9374 AC_VERB_SET_PIN_WIDGET_CONTROL,
9375 val ? PIN_HP : 0);
9376 snd_hda_codec_write_cache(codec, 0x15, 0,
9377 AC_VERB_SET_PIN_WIDGET_CONTROL,
9378 val ? PIN_HP : 0);
9379 /* mono (speaker) depending on the HP jack sense */
9380 val = val && !spec->jack_present;
9381 snd_hda_codec_write_cache(codec, 0x16, 0,
9382 AC_VERB_SET_PIN_WIDGET_CONTROL,
9383 val ? PIN_OUT : 0);
9384}
9385
9386static void alc262_hp_bpc_automute(struct hda_codec *codec)
9387{
9388 struct alc_spec *spec = codec->spec;
9389 unsigned int presence;
9390 presence = snd_hda_codec_read(codec, 0x1b, 0,
9391 AC_VERB_GET_PIN_SENSE, 0);
9392 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9393 alc262_hp_master_update(codec);
9394}
9395
9396static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9397{
9398 if ((res >> 26) != ALC880_HP_EVENT)
9399 return;
9400 alc262_hp_bpc_automute(codec);
9401}
9402
9403static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9404{
9405 struct alc_spec *spec = codec->spec;
9406 unsigned int presence;
9407 presence = snd_hda_codec_read(codec, 0x15, 0,
9408 AC_VERB_GET_PIN_SENSE, 0);
9409 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9410 alc262_hp_master_update(codec);
9411}
9412
9413static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9414 unsigned int res)
9415{
9416 if ((res >> 26) != ALC880_HP_EVENT)
9417 return;
9418 alc262_hp_wildwest_automute(codec);
9419}
9420
9421static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9422 struct snd_ctl_elem_value *ucontrol)
9423{
9424 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9425 struct alc_spec *spec = codec->spec;
9426 *ucontrol->value.integer.value = spec->master_sw;
9427 return 0;
9428}
9429
9430static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9431 struct snd_ctl_elem_value *ucontrol)
9432{
9433 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9434 struct alc_spec *spec = codec->spec;
9435 int val = !!*ucontrol->value.integer.value;
9436
9437 if (val == spec->master_sw)
9438 return 0;
9439 spec->master_sw = val;
9440 alc262_hp_master_update(codec);
9441 return 1;
9442}
9443
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009444static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009445 {
9446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9447 .name = "Master Playback Switch",
9448 .info = snd_ctl_boolean_mono_info,
9449 .get = alc262_hp_master_sw_get,
9450 .put = alc262_hp_master_sw_put,
9451 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009452 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9453 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009455 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9456 HDA_OUTPUT),
9457 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9458 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9460 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009461 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009462 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9463 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009464 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009465 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9466 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9467 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9468 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009469 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9470 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9471 { } /* end */
9472};
9473
Kailang Yangcd7509a2007-01-26 18:33:17 +01009474static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009475 {
9476 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9477 .name = "Master Playback Switch",
9478 .info = snd_ctl_boolean_mono_info,
9479 .get = alc262_hp_master_sw_get,
9480 .put = alc262_hp_master_sw_put,
9481 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009482 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9483 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9484 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9485 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009486 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9487 HDA_OUTPUT),
9488 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9489 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009490 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9491 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009492 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009493 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9494 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9495 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9496 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009497 { } /* end */
9498};
9499
9500static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9501 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9502 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009503 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009504 { } /* end */
9505};
9506
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009507/* mute/unmute internal speaker according to the hp jack and mute state */
9508static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9509{
9510 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009511
9512 if (force || !spec->sense_updated) {
9513 unsigned int present;
9514 present = snd_hda_codec_read(codec, 0x15, 0,
9515 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009516 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009517 spec->sense_updated = 1;
9518 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009519 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9520 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009521}
9522
9523static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9524 unsigned int res)
9525{
9526 if ((res >> 26) != ALC880_HP_EVENT)
9527 return;
9528 alc262_hp_t5735_automute(codec, 1);
9529}
9530
9531static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9532{
9533 alc262_hp_t5735_automute(codec, 1);
9534}
9535
9536static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009537 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9538 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009539 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9540 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9541 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9542 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9543 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9544 { } /* end */
9545};
9546
9547static struct hda_verb alc262_hp_t5735_verbs[] = {
9548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9549 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9550
9551 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9552 { }
9553};
9554
Kailang Yang8c427222008-01-10 13:03:59 +01009555static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009556 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9557 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009558 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9559 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009560 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9561 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9562 { } /* end */
9563};
9564
9565static struct hda_verb alc262_hp_rp5700_verbs[] = {
9566 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9567 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9568 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9569 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9570 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9571 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9572 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9573 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9575 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9576 {}
9577};
9578
9579static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9580 .num_items = 1,
9581 .items = {
9582 { "Line", 0x1 },
9583 },
9584};
9585
Takashi Iwai0724ea22007-08-23 00:31:43 +02009586/* bind hp and internal speaker mute (with plug check) */
9587static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9588 struct snd_ctl_elem_value *ucontrol)
9589{
9590 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9591 long *valp = ucontrol->value.integer.value;
9592 int change;
9593
9594 /* change hp mute */
9595 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9596 HDA_AMP_MUTE,
9597 valp[0] ? 0 : HDA_AMP_MUTE);
9598 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9599 HDA_AMP_MUTE,
9600 valp[1] ? 0 : HDA_AMP_MUTE);
9601 if (change) {
9602 /* change speaker according to HP jack state */
9603 struct alc_spec *spec = codec->spec;
9604 unsigned int mute;
9605 if (spec->jack_present)
9606 mute = HDA_AMP_MUTE;
9607 else
9608 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9609 HDA_OUTPUT, 0);
9610 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9611 HDA_AMP_MUTE, mute);
9612 }
9613 return change;
9614}
Takashi Iwai5b319542007-07-26 11:49:22 +02009615
Kailang Yang272a5272007-05-14 11:00:38 +02009616static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009617 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9618 {
9619 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9620 .name = "Master Playback Switch",
9621 .info = snd_hda_mixer_amp_switch_info,
9622 .get = snd_hda_mixer_amp_switch_get,
9623 .put = alc262_sony_master_sw_put,
9624 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9625 },
Kailang Yang272a5272007-05-14 11:00:38 +02009626 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9627 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9628 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9629 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9630 { } /* end */
9631};
9632
Kailang Yang83c34212007-07-05 11:43:05 +02009633static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9634 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9635 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9636 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9637 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9638 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9639 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9640 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9641 { } /* end */
9642};
Kailang Yang272a5272007-05-14 11:00:38 +02009643
Tony Vroonba340e82009-02-02 19:01:30 +00009644static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9645 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9646 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9647 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9648 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9649 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9650 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9652 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9653 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9654 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9655 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9656 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9657 { } /* end */
9658};
9659
9660static struct hda_verb alc262_tyan_verbs[] = {
9661 /* Headphone automute */
9662 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9663 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9664 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9665
9666 /* P11 AUX_IN, white 4-pin connector */
9667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9668 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9669 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9670 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9671
9672 {}
9673};
9674
9675/* unsolicited event for HP jack sensing */
9676static void alc262_tyan_automute(struct hda_codec *codec)
9677{
9678 unsigned int mute;
9679 unsigned int present;
9680
9681 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9682 present = snd_hda_codec_read(codec, 0x1b, 0,
9683 AC_VERB_GET_PIN_SENSE, 0);
9684 present = (present & 0x80000000) != 0;
9685 if (present) {
9686 /* mute line output on ATX panel */
9687 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9688 HDA_AMP_MUTE, HDA_AMP_MUTE);
9689 } else {
9690 /* unmute line output if necessary */
9691 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9692 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9693 HDA_AMP_MUTE, mute);
9694 }
9695}
9696
9697static void alc262_tyan_unsol_event(struct hda_codec *codec,
9698 unsigned int res)
9699{
9700 if ((res >> 26) != ALC880_HP_EVENT)
9701 return;
9702 alc262_tyan_automute(codec);
9703}
9704
Kailang Yangdf694da2005-12-05 19:42:22 +01009705#define alc262_capture_mixer alc882_capture_mixer
9706#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9707
9708/*
9709 * generic initialization of ADC, input mixers and output mixers
9710 */
9711static struct hda_verb alc262_init_verbs[] = {
9712 /*
9713 * Unmute ADC0-2 and set the default input to mic-in
9714 */
9715 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9717 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9718 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9719 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9720 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9721
Takashi Iwaicb53c622007-08-10 17:21:45 +02009722 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009723 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009724 * Note: PASD motherboards uses the Line In 2 as the input for
9725 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009726 */
9727 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9729 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9732 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009733
9734 /*
9735 * Set up output mixers (0x0c - 0x0e)
9736 */
9737 /* set vol=0 to output mixers */
9738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9739 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9740 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9741 /* set up input amps for analog loopback */
9742 /* Amp Indices: DAC = 0, mixer = 1 */
9743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9745 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9746 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9747 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9749
9750 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9752 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9753 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9754 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9755 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9756
9757 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9759 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9760 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9761 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009762
Kailang Yangdf694da2005-12-05 19:42:22 +01009763 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9764 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009765
Kailang Yangdf694da2005-12-05 19:42:22 +01009766 /* FIXME: use matrix-type input source selection */
9767 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9768 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9772 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9773 /* Input mixer2 */
9774 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9775 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9776 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9777 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9778 /* Input mixer3 */
9779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9781 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009782 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009783
9784 { }
9785};
9786
Kailang Yang4e555fe2008-08-26 13:05:55 +02009787static struct hda_verb alc262_eapd_verbs[] = {
9788 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9789 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9790 { }
9791};
9792
Kailang Yangccc656c2006-10-17 12:32:26 +02009793static struct hda_verb alc262_hippo_unsol_verbs[] = {
9794 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9796 {}
9797};
9798
9799static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9800 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9801 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9802 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9803
9804 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9805 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9806 {}
9807};
9808
Kailang Yang272a5272007-05-14 11:00:38 +02009809static struct hda_verb alc262_sony_unsol_verbs[] = {
9810 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9811 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9812 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9813
9814 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9815 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009816 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009817};
9818
Kailang Yang4e555fe2008-08-26 13:05:55 +02009819static struct hda_input_mux alc262_dmic_capture_source = {
9820 .num_items = 2,
9821 .items = {
9822 { "Int DMic", 0x9 },
9823 { "Mic", 0x0 },
9824 },
9825};
9826
9827static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9828 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9829 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9830 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009833 { } /* end */
9834};
9835
9836static struct hda_verb alc262_toshiba_s06_verbs[] = {
9837 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9838 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9839 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9840 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9841 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9842 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9843 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9844 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9845 {}
9846};
9847
9848static void alc262_dmic_automute(struct hda_codec *codec)
9849{
9850 unsigned int present;
9851
9852 present = snd_hda_codec_read(codec, 0x18, 0,
9853 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9854 snd_hda_codec_write(codec, 0x22, 0,
9855 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9856}
9857
9858/* toggle speaker-output according to the hp-jack state */
9859static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9860{
9861 unsigned int present;
9862 unsigned char bits;
9863
9864 present = snd_hda_codec_read(codec, 0x15, 0,
9865 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9866 bits = present ? 0 : PIN_OUT;
9867 snd_hda_codec_write(codec, 0x14, 0,
9868 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9869}
9870
9871
9872
9873/* unsolicited event for HP jack sensing */
9874static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9875 unsigned int res)
9876{
9877 if ((res >> 26) == ALC880_HP_EVENT)
9878 alc262_toshiba_s06_speaker_automute(codec);
9879 if ((res >> 26) == ALC880_MIC_EVENT)
9880 alc262_dmic_automute(codec);
9881
9882}
9883
9884static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9885{
9886 alc262_toshiba_s06_speaker_automute(codec);
9887 alc262_dmic_automute(codec);
9888}
9889
Kailang Yangccc656c2006-10-17 12:32:26 +02009890/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009891static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009892{
9893 struct alc_spec *spec = codec->spec;
9894 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009895 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009896
Takashi Iwai5b319542007-07-26 11:49:22 +02009897 /* need to execute and sync at first */
9898 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9899 present = snd_hda_codec_read(codec, 0x15, 0,
9900 AC_VERB_GET_PIN_SENSE, 0);
9901 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009902 if (spec->jack_present) {
9903 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009904 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9905 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009906 } else {
9907 /* unmute internal speaker if necessary */
9908 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009909 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9910 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009911 }
9912}
9913
9914/* unsolicited event for HP jack sensing */
9915static void alc262_hippo_unsol_event(struct hda_codec *codec,
9916 unsigned int res)
9917{
9918 if ((res >> 26) != ALC880_HP_EVENT)
9919 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009920 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009921}
9922
Takashi Iwai5b319542007-07-26 11:49:22 +02009923static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009924{
Kailang Yangccc656c2006-10-17 12:32:26 +02009925 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009926 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009927
Takashi Iwai5b319542007-07-26 11:49:22 +02009928 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9929 present = snd_hda_codec_read(codec, 0x1b, 0,
9930 AC_VERB_GET_PIN_SENSE, 0);
9931 present = (present & 0x80000000) != 0;
9932 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009933 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009934 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9935 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009936 } else {
9937 /* unmute internal speaker if necessary */
9938 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009939 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9940 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009941 }
9942}
9943
9944/* unsolicited event for HP jack sensing */
9945static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9946 unsigned int res)
9947{
9948 if ((res >> 26) != ALC880_HP_EVENT)
9949 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009950 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009951}
9952
Takashi Iwai834be882006-03-01 14:16:17 +01009953/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009954 * nec model
9955 * 0x15 = headphone
9956 * 0x16 = internal speaker
9957 * 0x18 = external mic
9958 */
9959
9960static struct snd_kcontrol_new alc262_nec_mixer[] = {
9961 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9962 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9963
9964 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9965 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9966 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9967
9968 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9970 { } /* end */
9971};
9972
9973static struct hda_verb alc262_nec_verbs[] = {
9974 /* Unmute Speaker */
9975 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9976
9977 /* Headphone */
9978 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9980
9981 /* External mic to headphone */
9982 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9983 /* External mic to speaker */
9984 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9985 {}
9986};
9987
9988/*
Takashi Iwai834be882006-03-01 14:16:17 +01009989 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009990 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9991 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009992 */
9993
9994#define ALC_HP_EVENT 0x37
9995
9996static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9997 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9998 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009999 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10000 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010001 {}
10002};
10003
Jiang zhe0e31daf2008-03-20 12:12:39 +010010004static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10005 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10006 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10007 {}
10008};
10009
Takashi Iwai834be882006-03-01 14:16:17 +010010010static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010011 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010012 .items = {
10013 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010014 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010015 { "CD", 0x4 },
10016 },
10017};
10018
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010019static struct hda_input_mux alc262_HP_capture_source = {
10020 .num_items = 5,
10021 .items = {
10022 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010023 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010024 { "Line", 0x2 },
10025 { "CD", 0x4 },
10026 { "AUX IN", 0x6 },
10027 },
10028};
10029
zhejiangaccbe492007-08-31 12:36:05 +020010030static struct hda_input_mux alc262_HP_D7000_capture_source = {
10031 .num_items = 4,
10032 .items = {
10033 { "Mic", 0x0 },
10034 { "Front Mic", 0x2 },
10035 { "Line", 0x1 },
10036 { "CD", 0x4 },
10037 },
10038};
10039
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010040/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010041static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10042{
10043 struct alc_spec *spec = codec->spec;
10044 unsigned int mute;
10045
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010046 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010047 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010048 /* need to execute and sync at first */
10049 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010050 /* check laptop HP jack */
10051 present = snd_hda_codec_read(codec, 0x14, 0,
10052 AC_VERB_GET_PIN_SENSE, 0);
10053 /* need to execute and sync at first */
10054 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10055 /* check docking HP jack */
10056 present |= snd_hda_codec_read(codec, 0x1b, 0,
10057 AC_VERB_GET_PIN_SENSE, 0);
10058 if (present & AC_PINSENSE_PRESENCE)
10059 spec->jack_present = 1;
10060 else
10061 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010062 spec->sense_updated = 1;
10063 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010064 /* unmute internal speaker only if both HPs are unplugged and
10065 * master switch is on
10066 */
10067 if (spec->jack_present)
10068 mute = HDA_AMP_MUTE;
10069 else
Takashi Iwai834be882006-03-01 14:16:17 +010010070 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010071 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10072 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010073}
10074
10075/* unsolicited event for HP jack sensing */
10076static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10077 unsigned int res)
10078{
10079 if ((res >> 26) != ALC_HP_EVENT)
10080 return;
10081 alc262_fujitsu_automute(codec, 1);
10082}
10083
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010084static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10085{
10086 alc262_fujitsu_automute(codec, 1);
10087}
10088
Takashi Iwai834be882006-03-01 14:16:17 +010010089/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010090static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10091 .ops = &snd_hda_bind_vol,
10092 .values = {
10093 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10094 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10095 0
10096 },
10097};
Takashi Iwai834be882006-03-01 14:16:17 +010010098
Jiang zhe0e31daf2008-03-20 12:12:39 +010010099/* mute/unmute internal speaker according to the hp jack and mute state */
10100static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10101{
10102 struct alc_spec *spec = codec->spec;
10103 unsigned int mute;
10104
10105 if (force || !spec->sense_updated) {
10106 unsigned int present_int_hp;
10107 /* need to execute and sync at first */
10108 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10109 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10110 AC_VERB_GET_PIN_SENSE, 0);
10111 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10112 spec->sense_updated = 1;
10113 }
10114 if (spec->jack_present) {
10115 /* mute internal speaker */
10116 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10117 HDA_AMP_MUTE, HDA_AMP_MUTE);
10118 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10119 HDA_AMP_MUTE, HDA_AMP_MUTE);
10120 } else {
10121 /* unmute internal speaker if necessary */
10122 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10123 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10124 HDA_AMP_MUTE, mute);
10125 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10126 HDA_AMP_MUTE, mute);
10127 }
10128}
10129
10130/* unsolicited event for HP jack sensing */
10131static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10132 unsigned int res)
10133{
10134 if ((res >> 26) != ALC_HP_EVENT)
10135 return;
10136 alc262_lenovo_3000_automute(codec, 1);
10137}
10138
Takashi Iwai834be882006-03-01 14:16:17 +010010139/* bind hp and internal speaker mute (with plug check) */
10140static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10141 struct snd_ctl_elem_value *ucontrol)
10142{
10143 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10144 long *valp = ucontrol->value.integer.value;
10145 int change;
10146
Tony Vroon5d9fab22008-03-14 17:09:18 +010010147 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10148 HDA_AMP_MUTE,
10149 valp ? 0 : HDA_AMP_MUTE);
10150 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10151 HDA_AMP_MUTE,
10152 valp ? 0 : HDA_AMP_MUTE);
10153
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010154 if (change)
10155 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010156 return change;
10157}
10158
10159static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010160 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010161 {
10162 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10163 .name = "Master Playback Switch",
10164 .info = snd_hda_mixer_amp_switch_info,
10165 .get = snd_hda_mixer_amp_switch_get,
10166 .put = alc262_fujitsu_master_sw_put,
10167 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10168 },
10169 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10170 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10171 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10172 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10173 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010174 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10175 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10176 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010177 { } /* end */
10178};
10179
Jiang zhe0e31daf2008-03-20 12:12:39 +010010180/* bind hp and internal speaker mute (with plug check) */
10181static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10182 struct snd_ctl_elem_value *ucontrol)
10183{
10184 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10185 long *valp = ucontrol->value.integer.value;
10186 int change;
10187
10188 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10189 HDA_AMP_MUTE,
10190 valp ? 0 : HDA_AMP_MUTE);
10191
10192 if (change)
10193 alc262_lenovo_3000_automute(codec, 0);
10194 return change;
10195}
10196
10197static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10198 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10199 {
10200 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10201 .name = "Master Playback Switch",
10202 .info = snd_hda_mixer_amp_switch_info,
10203 .get = snd_hda_mixer_amp_switch_get,
10204 .put = alc262_lenovo_3000_master_sw_put,
10205 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10206 },
10207 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10208 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10209 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10212 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10213 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10214 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10215 { } /* end */
10216};
10217
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010218static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10219 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10220 {
10221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10222 .name = "Master Playback Switch",
10223 .info = snd_hda_mixer_amp_switch_info,
10224 .get = snd_hda_mixer_amp_switch_get,
10225 .put = alc262_sony_master_sw_put,
10226 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10227 },
10228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10230 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10231 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10232 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10233 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10234 { } /* end */
10235};
10236
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010237/* additional init verbs for Benq laptops */
10238static struct hda_verb alc262_EAPD_verbs[] = {
10239 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10240 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10241 {}
10242};
10243
Kailang Yang83c34212007-07-05 11:43:05 +020010244static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10245 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10246 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10247
10248 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10249 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10250 {}
10251};
10252
Tobin Davisf651b502007-10-26 12:40:47 +020010253/* Samsung Q1 Ultra Vista model setup */
10254static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010255 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10256 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010257 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10258 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10259 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010260 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010261 { } /* end */
10262};
10263
10264static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010265 /* output mixer */
10266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10268 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10269 /* speaker */
10270 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10271 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10272 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10273 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10274 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010275 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010276 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10277 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10278 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10279 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10280 /* internal mic */
10281 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10282 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10283 /* ADC, choose mic */
10284 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10285 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10290 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10291 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10292 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10293 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010294 {}
10295};
10296
Tobin Davisf651b502007-10-26 12:40:47 +020010297/* mute/unmute internal speaker according to the hp jack and mute state */
10298static void alc262_ultra_automute(struct hda_codec *codec)
10299{
10300 struct alc_spec *spec = codec->spec;
10301 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010302
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010303 mute = 0;
10304 /* auto-mute only when HP is used as HP */
10305 if (!spec->cur_mux[0]) {
10306 unsigned int present;
10307 /* need to execute and sync at first */
10308 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10309 present = snd_hda_codec_read(codec, 0x15, 0,
10310 AC_VERB_GET_PIN_SENSE, 0);
10311 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10312 if (spec->jack_present)
10313 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010314 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010315 /* mute/unmute internal speaker */
10316 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10317 HDA_AMP_MUTE, mute);
10318 /* mute/unmute HP */
10319 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10320 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010321}
10322
10323/* unsolicited event for HP jack sensing */
10324static void alc262_ultra_unsol_event(struct hda_codec *codec,
10325 unsigned int res)
10326{
10327 if ((res >> 26) != ALC880_HP_EVENT)
10328 return;
10329 alc262_ultra_automute(codec);
10330}
10331
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010332static struct hda_input_mux alc262_ultra_capture_source = {
10333 .num_items = 2,
10334 .items = {
10335 { "Mic", 0x1 },
10336 { "Headphone", 0x7 },
10337 },
10338};
10339
10340static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10341 struct snd_ctl_elem_value *ucontrol)
10342{
10343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10344 struct alc_spec *spec = codec->spec;
10345 int ret;
10346
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010347 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010348 if (!ret)
10349 return 0;
10350 /* reprogram the HP pin as mic or HP according to the input source */
10351 snd_hda_codec_write_cache(codec, 0x15, 0,
10352 AC_VERB_SET_PIN_WIDGET_CONTROL,
10353 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10354 alc262_ultra_automute(codec); /* mute/unmute HP */
10355 return ret;
10356}
10357
10358static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10359 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10360 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10361 {
10362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10363 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010364 .info = alc_mux_enum_info,
10365 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010366 .put = alc262_ultra_mux_enum_put,
10367 },
10368 { } /* end */
10369};
10370
Kailang Yangdf694da2005-12-05 19:42:22 +010010371/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010372static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10373 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010374{
10375 hda_nid_t nid;
10376 int err;
10377
10378 spec->multiout.num_dacs = 1; /* only use one dac */
10379 spec->multiout.dac_nids = spec->private_dac_nids;
10380 spec->multiout.dac_nids[0] = 2;
10381
10382 nid = cfg->line_out_pins[0];
10383 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010384 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10385 "Front Playback Volume",
10386 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10387 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010388 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010389 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10390 "Front Playback Switch",
10391 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10392 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010393 return err;
10394 }
10395
Takashi Iwai82bc9552006-03-21 11:24:42 +010010396 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010397 if (nid) {
10398 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010399 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10400 "Speaker Playback Volume",
10401 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10402 HDA_OUTPUT));
10403 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010404 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010405 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10406 "Speaker Playback Switch",
10407 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10408 HDA_OUTPUT));
10409 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010410 return err;
10411 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010412 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10413 "Speaker Playback Switch",
10414 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10415 HDA_OUTPUT));
10416 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010417 return err;
10418 }
10419 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010420 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010421 if (nid) {
10422 /* spec->multiout.hp_nid = 2; */
10423 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010424 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10425 "Headphone Playback Volume",
10426 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10427 HDA_OUTPUT));
10428 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010429 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010430 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10431 "Headphone Playback Switch",
10432 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10433 HDA_OUTPUT));
10434 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010435 return err;
10436 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010437 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10438 "Headphone Playback Switch",
10439 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10440 HDA_OUTPUT));
10441 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010442 return err;
10443 }
10444 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010445 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010446}
10447
10448/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010449#define alc262_auto_create_analog_input_ctls \
10450 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010451
10452/*
10453 * generic initialization of ADC, input mixers and output mixers
10454 */
10455static struct hda_verb alc262_volume_init_verbs[] = {
10456 /*
10457 * Unmute ADC0-2 and set the default input to mic-in
10458 */
10459 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10461 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10463 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10464 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10465
Takashi Iwaicb53c622007-08-10 17:21:45 +020010466 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010467 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010468 * Note: PASD motherboards uses the Line In 2 as the input for
10469 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010470 */
10471 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10474 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10475 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10476 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010477
10478 /*
10479 * Set up output mixers (0x0c - 0x0f)
10480 */
10481 /* set vol=0 to output mixers */
10482 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10483 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10484 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010485
Kailang Yangdf694da2005-12-05 19:42:22 +010010486 /* set up input amps for analog loopback */
10487 /* Amp Indices: DAC = 0, mixer = 1 */
10488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10490 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10491 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10492 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10493 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10494
10495 /* FIXME: use matrix-type input source selection */
10496 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10497 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10500 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10501 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10502 /* Input mixer2 */
10503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10505 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10506 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10507 /* Input mixer3 */
10508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10512
10513 { }
10514};
10515
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010516static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10517 /*
10518 * Unmute ADC0-2 and set the default input to mic-in
10519 */
10520 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10521 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10522 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10523 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10524 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10525 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10526
Takashi Iwaicb53c622007-08-10 17:21:45 +020010527 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010528 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010529 * Note: PASD motherboards uses the Line In 2 as the input for
10530 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010531 */
10532 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010533 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10535 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010540
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010541 /*
10542 * Set up output mixers (0x0c - 0x0e)
10543 */
10544 /* set vol=0 to output mixers */
10545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10546 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10547 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10548
10549 /* set up input amps for analog loopback */
10550 /* Amp Indices: DAC = 0, mixer = 1 */
10551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10553 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10554 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10555 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10556 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10557
Takashi Iwaice875f02008-01-28 18:17:43 +010010558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010559 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10560 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10561
10562 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10564
10565 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10566 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10567
10568 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10569 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10570 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10571 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10572 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10573
10574 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10575 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10576 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10578 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10579 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10580
10581
10582 /* FIXME: use matrix-type input source selection */
10583 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10584 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10585 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10586 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10587 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10589 /* Input mixer2 */
10590 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10592 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10594 /* Input mixer3 */
10595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10598 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10599
Takashi Iwaice875f02008-01-28 18:17:43 +010010600 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10601
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010602 { }
10603};
10604
Kailang Yangcd7509a2007-01-26 18:33:17 +010010605static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10606 /*
10607 * Unmute ADC0-2 and set the default input to mic-in
10608 */
10609 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10610 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10611 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10612 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10613 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10614 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10615
Takashi Iwaicb53c622007-08-10 17:21:45 +020010616 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010617 * mixer widget
10618 * Note: PASD motherboards uses the Line In 2 as the input for front
10619 * panel mic (mic 2)
10620 */
10621 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010622 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10623 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10624 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10625 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10626 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10627 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10628 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10629 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010630 /*
10631 * Set up output mixers (0x0c - 0x0e)
10632 */
10633 /* set vol=0 to output mixers */
10634 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10635 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10636 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10637
10638 /* set up input amps for analog loopback */
10639 /* Amp Indices: DAC = 0, mixer = 1 */
10640 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10641 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10642 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10643 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10644 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10645 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10646
10647
10648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10649 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10650 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10651 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10652 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10653 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10654 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10655
10656 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10657 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10658
10659 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10660 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10661
10662 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10663 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10664 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10665 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10666 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10667 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10668
10669 /* FIXME: use matrix-type input source selection */
10670 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10671 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10673 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10674 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10675 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10676 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10677 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10678 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10679 /* Input mixer2 */
10680 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10681 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10682 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10683 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10684 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10685 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10686 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10687 /* Input mixer3 */
10688 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10689 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10690 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10691 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10692 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10693 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10694 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10695
Takashi Iwaice875f02008-01-28 18:17:43 +010010696 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10697
Kailang Yangcd7509a2007-01-26 18:33:17 +010010698 { }
10699};
10700
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010701static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10702
10703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10705 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10706
10707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10708 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10709 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10710 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10711
10712 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10713 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10714 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10715 {}
10716};
10717
10718
Takashi Iwaicb53c622007-08-10 17:21:45 +020010719#ifdef CONFIG_SND_HDA_POWER_SAVE
10720#define alc262_loopbacks alc880_loopbacks
10721#endif
10722
Kailang Yangdf694da2005-12-05 19:42:22 +010010723/* pcm configuration: identiacal with ALC880 */
10724#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10725#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10726#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10727#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10728
10729/*
10730 * BIOS auto configuration
10731 */
10732static int alc262_parse_auto_config(struct hda_codec *codec)
10733{
10734 struct alc_spec *spec = codec->spec;
10735 int err;
10736 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10737
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010738 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10739 alc262_ignore);
10740 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010741 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010742 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010743 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010744 spec->multiout.max_channels = 2;
10745 spec->no_analog = 1;
10746 goto dig_only;
10747 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010748 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010749 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010750 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10751 if (err < 0)
10752 return err;
10753 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10754 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010755 return err;
10756
10757 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10758
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010759 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010760 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010761 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010762 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010763 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010764 if (spec->autocfg.dig_in_pin)
10765 spec->dig_in_nid = ALC262_DIGIN_NID;
10766
Takashi Iwai603c4012008-07-30 15:01:44 +020010767 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010768 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010769
Takashi Iwaid88897e2008-10-31 15:01:37 +010010770 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010771 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010772 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010773
Takashi Iwai776e1842007-08-29 15:07:11 +020010774 err = alc_auto_add_mic_boost(codec);
10775 if (err < 0)
10776 return err;
10777
Kailang Yangdf694da2005-12-05 19:42:22 +010010778 return 1;
10779}
10780
10781#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10782#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10783#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010784#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010785
10786
10787/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010788static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010789{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010790 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010791 alc262_auto_init_multi_out(codec);
10792 alc262_auto_init_hp_out(codec);
10793 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010794 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010795 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010796 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010797}
10798
10799/*
10800 * configuration and preset
10801 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010802static const char *alc262_models[ALC262_MODEL_LAST] = {
10803 [ALC262_BASIC] = "basic",
10804 [ALC262_HIPPO] = "hippo",
10805 [ALC262_HIPPO_1] = "hippo_1",
10806 [ALC262_FUJITSU] = "fujitsu",
10807 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010808 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010809 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010810 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010811 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010812 [ALC262_BENQ_T31] = "benq-t31",
10813 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010814 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010815 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010816 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010817 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010818 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010819 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010820 [ALC262_AUTO] = "auto",
10821};
10822
10823static struct snd_pci_quirk alc262_cfg_tbl[] = {
10824 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010825 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010826 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10827 ALC262_HP_BPC),
10828 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10829 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010010830 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10831 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010832 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010833 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010834 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010835 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010836 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010837 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010838 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010839 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010840 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10841 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10842 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010843 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10844 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010845 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010846 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010847 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010848 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010010849 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010010850 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10851 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010852 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010853 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010854 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010855 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010856 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010857 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010858 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10859 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010860 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010861 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010862 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010863 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010864 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010865 {}
10866};
10867
10868static struct alc_config_preset alc262_presets[] = {
10869 [ALC262_BASIC] = {
10870 .mixers = { alc262_base_mixer },
10871 .init_verbs = { alc262_init_verbs },
10872 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10873 .dac_nids = alc262_dac_nids,
10874 .hp_nid = 0x03,
10875 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10876 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010877 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010878 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010879 [ALC262_HIPPO] = {
10880 .mixers = { alc262_base_mixer },
10881 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10882 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10883 .dac_nids = alc262_dac_nids,
10884 .hp_nid = 0x03,
10885 .dig_out_nid = ALC262_DIGOUT_NID,
10886 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10887 .channel_mode = alc262_modes,
10888 .input_mux = &alc262_capture_source,
10889 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010890 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010891 },
10892 [ALC262_HIPPO_1] = {
10893 .mixers = { alc262_hippo1_mixer },
10894 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10895 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10896 .dac_nids = alc262_dac_nids,
10897 .hp_nid = 0x02,
10898 .dig_out_nid = ALC262_DIGOUT_NID,
10899 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10900 .channel_mode = alc262_modes,
10901 .input_mux = &alc262_capture_source,
10902 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010903 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010904 },
Takashi Iwai834be882006-03-01 14:16:17 +010010905 [ALC262_FUJITSU] = {
10906 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010907 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10908 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010909 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10910 .dac_nids = alc262_dac_nids,
10911 .hp_nid = 0x03,
10912 .dig_out_nid = ALC262_DIGOUT_NID,
10913 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10914 .channel_mode = alc262_modes,
10915 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010916 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010917 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010918 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010919 [ALC262_HP_BPC] = {
10920 .mixers = { alc262_HP_BPC_mixer },
10921 .init_verbs = { alc262_HP_BPC_init_verbs },
10922 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10923 .dac_nids = alc262_dac_nids,
10924 .hp_nid = 0x03,
10925 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10926 .channel_mode = alc262_modes,
10927 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010928 .unsol_event = alc262_hp_bpc_unsol_event,
10929 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010930 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010931 [ALC262_HP_BPC_D7000_WF] = {
10932 .mixers = { alc262_HP_BPC_WildWest_mixer },
10933 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10934 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10935 .dac_nids = alc262_dac_nids,
10936 .hp_nid = 0x03,
10937 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10938 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010939 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010940 .unsol_event = alc262_hp_wildwest_unsol_event,
10941 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010942 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010943 [ALC262_HP_BPC_D7000_WL] = {
10944 .mixers = { alc262_HP_BPC_WildWest_mixer,
10945 alc262_HP_BPC_WildWest_option_mixer },
10946 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10947 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10948 .dac_nids = alc262_dac_nids,
10949 .hp_nid = 0x03,
10950 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10951 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010952 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010953 .unsol_event = alc262_hp_wildwest_unsol_event,
10954 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010955 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010956 [ALC262_HP_TC_T5735] = {
10957 .mixers = { alc262_hp_t5735_mixer },
10958 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10959 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10960 .dac_nids = alc262_dac_nids,
10961 .hp_nid = 0x03,
10962 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10963 .channel_mode = alc262_modes,
10964 .input_mux = &alc262_capture_source,
10965 .unsol_event = alc262_hp_t5735_unsol_event,
10966 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010967 },
10968 [ALC262_HP_RP5700] = {
10969 .mixers = { alc262_hp_rp5700_mixer },
10970 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10971 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10972 .dac_nids = alc262_dac_nids,
10973 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10974 .channel_mode = alc262_modes,
10975 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010976 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010977 [ALC262_BENQ_ED8] = {
10978 .mixers = { alc262_base_mixer },
10979 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10980 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10981 .dac_nids = alc262_dac_nids,
10982 .hp_nid = 0x03,
10983 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10984 .channel_mode = alc262_modes,
10985 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010986 },
Kailang Yang272a5272007-05-14 11:00:38 +020010987 [ALC262_SONY_ASSAMD] = {
10988 .mixers = { alc262_sony_mixer },
10989 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10990 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10991 .dac_nids = alc262_dac_nids,
10992 .hp_nid = 0x02,
10993 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10994 .channel_mode = alc262_modes,
10995 .input_mux = &alc262_capture_source,
10996 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010997 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010998 },
10999 [ALC262_BENQ_T31] = {
11000 .mixers = { alc262_benq_t31_mixer },
11001 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11002 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11003 .dac_nids = alc262_dac_nids,
11004 .hp_nid = 0x03,
11005 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11006 .channel_mode = alc262_modes,
11007 .input_mux = &alc262_capture_source,
11008 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011009 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011010 },
Tobin Davisf651b502007-10-26 12:40:47 +020011011 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011012 .mixers = { alc262_ultra_mixer },
11013 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011014 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011015 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11016 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011017 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11018 .channel_mode = alc262_modes,
11019 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011020 .adc_nids = alc262_adc_nids, /* ADC0 */
11021 .capsrc_nids = alc262_capsrc_nids,
11022 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011023 .unsol_event = alc262_ultra_unsol_event,
11024 .init_hook = alc262_ultra_automute,
11025 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011026 [ALC262_LENOVO_3000] = {
11027 .mixers = { alc262_lenovo_3000_mixer },
11028 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11029 alc262_lenovo_3000_unsol_verbs },
11030 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11031 .dac_nids = alc262_dac_nids,
11032 .hp_nid = 0x03,
11033 .dig_out_nid = ALC262_DIGOUT_NID,
11034 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11035 .channel_mode = alc262_modes,
11036 .input_mux = &alc262_fujitsu_capture_source,
11037 .unsol_event = alc262_lenovo_3000_unsol_event,
11038 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011039 [ALC262_NEC] = {
11040 .mixers = { alc262_nec_mixer },
11041 .init_verbs = { alc262_nec_verbs },
11042 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11043 .dac_nids = alc262_dac_nids,
11044 .hp_nid = 0x03,
11045 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11046 .channel_mode = alc262_modes,
11047 .input_mux = &alc262_capture_source,
11048 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011049 [ALC262_TOSHIBA_S06] = {
11050 .mixers = { alc262_toshiba_s06_mixer },
11051 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11052 alc262_eapd_verbs },
11053 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11054 .capsrc_nids = alc262_dmic_capsrc_nids,
11055 .dac_nids = alc262_dac_nids,
11056 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11057 .dig_out_nid = ALC262_DIGOUT_NID,
11058 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11059 .channel_mode = alc262_modes,
11060 .input_mux = &alc262_dmic_capture_source,
11061 .unsol_event = alc262_toshiba_s06_unsol_event,
11062 .init_hook = alc262_toshiba_s06_init_hook,
11063 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011064 [ALC262_TOSHIBA_RX1] = {
11065 .mixers = { alc262_toshiba_rx1_mixer },
11066 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11067 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11068 .dac_nids = alc262_dac_nids,
11069 .hp_nid = 0x03,
11070 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11071 .channel_mode = alc262_modes,
11072 .input_mux = &alc262_capture_source,
11073 .unsol_event = alc262_hippo_unsol_event,
11074 .init_hook = alc262_hippo_automute,
11075 },
Tony Vroonba340e82009-02-02 19:01:30 +000011076 [ALC262_TYAN] = {
11077 .mixers = { alc262_tyan_mixer },
11078 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11079 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11080 .dac_nids = alc262_dac_nids,
11081 .hp_nid = 0x02,
11082 .dig_out_nid = ALC262_DIGOUT_NID,
11083 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11084 .channel_mode = alc262_modes,
11085 .input_mux = &alc262_capture_source,
11086 .unsol_event = alc262_tyan_unsol_event,
11087 .init_hook = alc262_tyan_automute,
11088 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011089};
11090
11091static int patch_alc262(struct hda_codec *codec)
11092{
11093 struct alc_spec *spec;
11094 int board_config;
11095 int err;
11096
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011097 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011098 if (spec == NULL)
11099 return -ENOMEM;
11100
11101 codec->spec = spec;
11102#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011103 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11104 * under-run
11105 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011106 {
11107 int tmp;
11108 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11109 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11110 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11111 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11112 }
11113#endif
11114
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011115 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11116
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011117 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11118 alc262_models,
11119 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011120
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011121 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011122 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11123 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011124 board_config = ALC262_AUTO;
11125 }
11126
11127 if (board_config == ALC262_AUTO) {
11128 /* automatic parse from the BIOS config */
11129 err = alc262_parse_auto_config(codec);
11130 if (err < 0) {
11131 alc_free(codec);
11132 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011133 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011134 printk(KERN_INFO
11135 "hda_codec: Cannot set up configuration "
11136 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011137 board_config = ALC262_BASIC;
11138 }
11139 }
11140
Takashi Iwai07eba612009-02-19 08:06:35 +010011141 if (!spec->no_analog) {
11142 err = snd_hda_attach_beep_device(codec, 0x1);
11143 if (err < 0) {
11144 alc_free(codec);
11145 return err;
11146 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011147 }
11148
Kailang Yangdf694da2005-12-05 19:42:22 +010011149 if (board_config != ALC262_AUTO)
11150 setup_preset(spec, &alc262_presets[board_config]);
11151
11152 spec->stream_name_analog = "ALC262 Analog";
11153 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11154 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011155
Kailang Yangdf694da2005-12-05 19:42:22 +010011156 spec->stream_name_digital = "ALC262 Digital";
11157 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11158 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11159
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011160 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011161 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011162 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011163 unsigned int wcap = get_wcaps(codec, 0x07);
11164
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011165 /* get type */
11166 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011167 if (wcap != AC_WID_AUD_IN) {
11168 spec->adc_nids = alc262_adc_nids_alt;
11169 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011170 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011171 } else {
11172 spec->adc_nids = alc262_adc_nids;
11173 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011174 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011175 }
11176 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011177 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011178 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011179 if (!spec->no_analog)
11180 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011181
Takashi Iwai2134ea42008-01-10 16:53:55 +010011182 spec->vmaster_nid = 0x0c;
11183
Kailang Yangdf694da2005-12-05 19:42:22 +010011184 codec->patch_ops = alc_patch_ops;
11185 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011186 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011187#ifdef CONFIG_SND_HDA_POWER_SAVE
11188 if (!spec->loopback.amplist)
11189 spec->loopback.amplist = alc262_loopbacks;
11190#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011191 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011192
Kailang Yangdf694da2005-12-05 19:42:22 +010011193 return 0;
11194}
11195
Kailang Yangdf694da2005-12-05 19:42:22 +010011196/*
Kailang Yanga361d842007-06-05 12:30:55 +020011197 * ALC268 channel source setting (2 channel)
11198 */
11199#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11200#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011201
Kailang Yanga361d842007-06-05 12:30:55 +020011202static hda_nid_t alc268_dac_nids[2] = {
11203 /* front, hp */
11204 0x02, 0x03
11205};
11206
11207static hda_nid_t alc268_adc_nids[2] = {
11208 /* ADC0-1 */
11209 0x08, 0x07
11210};
11211
11212static hda_nid_t alc268_adc_nids_alt[1] = {
11213 /* ADC0 */
11214 0x08
11215};
11216
Takashi Iwaie1406342008-02-11 18:32:32 +010011217static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11218
Kailang Yanga361d842007-06-05 12:30:55 +020011219static struct snd_kcontrol_new alc268_base_mixer[] = {
11220 /* output mixer control */
11221 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11222 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11223 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11224 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011225 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11226 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11227 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011228 { }
11229};
11230
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011231/* bind Beep switches of both NID 0x0f and 0x10 */
11232static struct hda_bind_ctls alc268_bind_beep_sw = {
11233 .ops = &snd_hda_bind_sw,
11234 .values = {
11235 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11236 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11237 0
11238 },
11239};
11240
11241static struct snd_kcontrol_new alc268_beep_mixer[] = {
11242 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11243 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11244 { }
11245};
11246
Kailang Yangd1a991a2007-08-15 16:21:59 +020011247static struct hda_verb alc268_eapd_verbs[] = {
11248 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11249 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11250 { }
11251};
11252
Takashi Iwaid2738092007-08-16 14:59:45 +020011253/* Toshiba specific */
11254#define alc268_toshiba_automute alc262_hippo_automute
11255
11256static struct hda_verb alc268_toshiba_verbs[] = {
11257 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11258 { } /* end */
11259};
11260
Kailang Yang8ef355d2008-08-26 13:10:22 +020011261static struct hda_input_mux alc268_acer_lc_capture_source = {
11262 .num_items = 2,
11263 .items = {
11264 { "i-Mic", 0x6 },
11265 { "E-Mic", 0x0 },
11266 },
11267};
11268
Takashi Iwaid2738092007-08-16 14:59:45 +020011269/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011270/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011271static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11272 .ops = &snd_hda_bind_vol,
11273 .values = {
11274 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11275 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11276 0
11277 },
11278};
11279
Takashi Iwai889c4392007-08-23 18:56:52 +020011280/* mute/unmute internal speaker according to the hp jack and mute state */
11281static void alc268_acer_automute(struct hda_codec *codec, int force)
11282{
11283 struct alc_spec *spec = codec->spec;
11284 unsigned int mute;
11285
11286 if (force || !spec->sense_updated) {
11287 unsigned int present;
11288 present = snd_hda_codec_read(codec, 0x14, 0,
11289 AC_VERB_GET_PIN_SENSE, 0);
11290 spec->jack_present = (present & 0x80000000) != 0;
11291 spec->sense_updated = 1;
11292 }
11293 if (spec->jack_present)
11294 mute = HDA_AMP_MUTE; /* mute internal speaker */
11295 else /* unmute internal speaker if necessary */
11296 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11297 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11298 HDA_AMP_MUTE, mute);
11299}
11300
11301
11302/* bind hp and internal speaker mute (with plug check) */
11303static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11304 struct snd_ctl_elem_value *ucontrol)
11305{
11306 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11307 long *valp = ucontrol->value.integer.value;
11308 int change;
11309
11310 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11311 HDA_AMP_MUTE,
11312 valp[0] ? 0 : HDA_AMP_MUTE);
11313 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11314 HDA_AMP_MUTE,
11315 valp[1] ? 0 : HDA_AMP_MUTE);
11316 if (change)
11317 alc268_acer_automute(codec, 0);
11318 return change;
11319}
Takashi Iwaid2738092007-08-16 14:59:45 +020011320
Kailang Yang8ef355d2008-08-26 13:10:22 +020011321static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11322 /* output mixer control */
11323 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11324 {
11325 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11326 .name = "Master Playback Switch",
11327 .info = snd_hda_mixer_amp_switch_info,
11328 .get = snd_hda_mixer_amp_switch_get,
11329 .put = alc268_acer_master_sw_put,
11330 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11331 },
11332 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11333 { }
11334};
11335
Takashi Iwaid2738092007-08-16 14:59:45 +020011336static struct snd_kcontrol_new alc268_acer_mixer[] = {
11337 /* output mixer control */
11338 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11339 {
11340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11341 .name = "Master Playback Switch",
11342 .info = snd_hda_mixer_amp_switch_info,
11343 .get = snd_hda_mixer_amp_switch_get,
11344 .put = alc268_acer_master_sw_put,
11345 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11346 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011347 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11348 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11349 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011350 { }
11351};
11352
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011353static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11354 /* output mixer control */
11355 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11356 {
11357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11358 .name = "Master Playback Switch",
11359 .info = snd_hda_mixer_amp_switch_info,
11360 .get = snd_hda_mixer_amp_switch_get,
11361 .put = alc268_acer_master_sw_put,
11362 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11363 },
11364 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11365 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11366 { }
11367};
11368
Kailang Yang8ef355d2008-08-26 13:10:22 +020011369static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11370 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11371 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11372 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11373 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11374 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11376 { }
11377};
11378
Takashi Iwaid2738092007-08-16 14:59:45 +020011379static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011380 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11381 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011382 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11383 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011384 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11385 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011386 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11387 { }
11388};
11389
11390/* unsolicited event for HP jack sensing */
11391static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11392 unsigned int res)
11393{
Takashi Iwai889c4392007-08-23 18:56:52 +020011394 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011395 return;
11396 alc268_toshiba_automute(codec);
11397}
11398
11399static void alc268_acer_unsol_event(struct hda_codec *codec,
11400 unsigned int res)
11401{
Takashi Iwai889c4392007-08-23 18:56:52 +020011402 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011403 return;
11404 alc268_acer_automute(codec, 1);
11405}
11406
Takashi Iwai889c4392007-08-23 18:56:52 +020011407static void alc268_acer_init_hook(struct hda_codec *codec)
11408{
11409 alc268_acer_automute(codec, 1);
11410}
11411
Kailang Yang8ef355d2008-08-26 13:10:22 +020011412/* toggle speaker-output according to the hp-jack state */
11413static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11414{
11415 unsigned int present;
11416 unsigned char bits;
11417
11418 present = snd_hda_codec_read(codec, 0x15, 0,
11419 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11420 bits = present ? AMP_IN_MUTE(0) : 0;
11421 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11422 AMP_IN_MUTE(0), bits);
11423 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11424 AMP_IN_MUTE(0), bits);
11425}
11426
11427
11428static void alc268_acer_mic_automute(struct hda_codec *codec)
11429{
11430 unsigned int present;
11431
11432 present = snd_hda_codec_read(codec, 0x18, 0,
11433 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11434 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11435 present ? 0x0 : 0x6);
11436}
11437
11438static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11439 unsigned int res)
11440{
11441 if ((res >> 26) == ALC880_HP_EVENT)
11442 alc268_aspire_one_speaker_automute(codec);
11443 if ((res >> 26) == ALC880_MIC_EVENT)
11444 alc268_acer_mic_automute(codec);
11445}
11446
11447static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11448{
11449 alc268_aspire_one_speaker_automute(codec);
11450 alc268_acer_mic_automute(codec);
11451}
11452
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011453static struct snd_kcontrol_new alc268_dell_mixer[] = {
11454 /* output mixer control */
11455 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11456 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11457 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11459 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11460 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11461 { }
11462};
11463
11464static struct hda_verb alc268_dell_verbs[] = {
11465 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11467 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11468 { }
11469};
11470
11471/* mute/unmute internal speaker according to the hp jack and mute state */
11472static void alc268_dell_automute(struct hda_codec *codec)
11473{
11474 unsigned int present;
11475 unsigned int mute;
11476
11477 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11478 if (present & 0x80000000)
11479 mute = HDA_AMP_MUTE;
11480 else
11481 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11482 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11483 HDA_AMP_MUTE, mute);
11484}
11485
11486static void alc268_dell_unsol_event(struct hda_codec *codec,
11487 unsigned int res)
11488{
11489 if ((res >> 26) != ALC880_HP_EVENT)
11490 return;
11491 alc268_dell_automute(codec);
11492}
11493
11494#define alc268_dell_init_hook alc268_dell_automute
11495
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011496static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11497 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11498 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11499 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11500 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11501 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11502 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11503 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11504 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11505 { }
11506};
11507
11508static struct hda_verb alc267_quanta_il1_verbs[] = {
11509 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11510 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11511 { }
11512};
11513
11514static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11515{
11516 unsigned int present;
11517
11518 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11519 & AC_PINSENSE_PRESENCE;
11520 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11521 present ? 0 : PIN_OUT);
11522}
11523
11524static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11525{
11526 unsigned int present;
11527
11528 present = snd_hda_codec_read(codec, 0x18, 0,
11529 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11530 snd_hda_codec_write(codec, 0x23, 0,
11531 AC_VERB_SET_CONNECT_SEL,
11532 present ? 0x00 : 0x01);
11533}
11534
11535static void alc267_quanta_il1_automute(struct hda_codec *codec)
11536{
11537 alc267_quanta_il1_hp_automute(codec);
11538 alc267_quanta_il1_mic_automute(codec);
11539}
11540
11541static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11542 unsigned int res)
11543{
11544 switch (res >> 26) {
11545 case ALC880_HP_EVENT:
11546 alc267_quanta_il1_hp_automute(codec);
11547 break;
11548 case ALC880_MIC_EVENT:
11549 alc267_quanta_il1_mic_automute(codec);
11550 break;
11551 }
11552}
11553
Kailang Yanga361d842007-06-05 12:30:55 +020011554/*
11555 * generic initialization of ADC, input mixers and output mixers
11556 */
11557static struct hda_verb alc268_base_init_verbs[] = {
11558 /* Unmute DAC0-1 and set vol = 0 */
11559 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011560 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011561
11562 /*
11563 * Set up output mixers (0x0c - 0x0e)
11564 */
11565 /* set vol=0 to output mixers */
11566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011567 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11568
11569 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11570 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11571
11572 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11573 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11574 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11575 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11576 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11577 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11578 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11579 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11580
11581 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11582 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11583 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11584 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011585 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011586
11587 /* set PCBEEP vol = 0, mute connections */
11588 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11589 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11590 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011591
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011592 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011593
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011594 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11595 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11596 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11597 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011598
Kailang Yanga361d842007-06-05 12:30:55 +020011599 { }
11600};
11601
11602/*
11603 * generic initialization of ADC, input mixers and output mixers
11604 */
11605static struct hda_verb alc268_volume_init_verbs[] = {
11606 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011607 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11608 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011609
11610 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11611 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11612 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11613 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11614 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11615
Kailang Yanga361d842007-06-05 12:30:55 +020011616 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011617 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11618 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11619
11620 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011621 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011622
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011623 /* set PCBEEP vol = 0, mute connections */
11624 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11625 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11626 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011627
11628 { }
11629};
11630
Kailang Yanga361d842007-06-05 12:30:55 +020011631static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11632 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11633 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11634 {
11635 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11636 /* The multiple "Capture Source" controls confuse alsamixer
11637 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011638 */
11639 /* .name = "Capture Source", */
11640 .name = "Input Source",
11641 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011642 .info = alc_mux_enum_info,
11643 .get = alc_mux_enum_get,
11644 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011645 },
11646 { } /* end */
11647};
11648
11649static struct snd_kcontrol_new alc268_capture_mixer[] = {
11650 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11651 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11652 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11653 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11654 {
11655 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11656 /* The multiple "Capture Source" controls confuse alsamixer
11657 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011658 */
11659 /* .name = "Capture Source", */
11660 .name = "Input Source",
11661 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011662 .info = alc_mux_enum_info,
11663 .get = alc_mux_enum_get,
11664 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011665 },
11666 { } /* end */
11667};
11668
11669static struct hda_input_mux alc268_capture_source = {
11670 .num_items = 4,
11671 .items = {
11672 { "Mic", 0x0 },
11673 { "Front Mic", 0x1 },
11674 { "Line", 0x2 },
11675 { "CD", 0x3 },
11676 },
11677};
11678
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011679static struct hda_input_mux alc268_acer_capture_source = {
11680 .num_items = 3,
11681 .items = {
11682 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011683 { "Internal Mic", 0x1 },
11684 { "Line", 0x2 },
11685 },
11686};
11687
11688static struct hda_input_mux alc268_acer_dmic_capture_source = {
11689 .num_items = 3,
11690 .items = {
11691 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011692 { "Internal Mic", 0x6 },
11693 { "Line", 0x2 },
11694 },
11695};
11696
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011697#ifdef CONFIG_SND_DEBUG
11698static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011699 /* Volume widgets */
11700 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11701 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11702 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11703 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11704 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11705 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11706 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11707 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11708 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11709 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11710 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11711 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11712 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011713 /* The below appears problematic on some hardwares */
11714 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011715 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11716 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11717 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11718 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11719
11720 /* Modes for retasking pin widgets */
11721 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11722 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11723 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11724 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11725
11726 /* Controls for GPIO pins, assuming they are configured as outputs */
11727 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11728 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11729 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11730 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11731
11732 /* Switches to allow the digital SPDIF output pin to be enabled.
11733 * The ALC268 does not have an SPDIF input.
11734 */
11735 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11736
11737 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11738 * this output to turn on an external amplifier.
11739 */
11740 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11741 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11742
11743 { } /* end */
11744};
11745#endif
11746
Kailang Yanga361d842007-06-05 12:30:55 +020011747/* create input playback/capture controls for the given pin */
11748static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11749 const char *ctlname, int idx)
11750{
11751 char name[32];
11752 int err;
11753
11754 sprintf(name, "%s Playback Volume", ctlname);
11755 if (nid == 0x14) {
11756 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11757 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11758 HDA_OUTPUT));
11759 if (err < 0)
11760 return err;
11761 } else if (nid == 0x15) {
11762 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11763 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11764 HDA_OUTPUT));
11765 if (err < 0)
11766 return err;
11767 } else
11768 return -1;
11769 sprintf(name, "%s Playback Switch", ctlname);
11770 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11771 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11772 if (err < 0)
11773 return err;
11774 return 0;
11775}
11776
11777/* add playback controls from the parsed DAC table */
11778static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11779 const struct auto_pin_cfg *cfg)
11780{
11781 hda_nid_t nid;
11782 int err;
11783
11784 spec->multiout.num_dacs = 2; /* only use one dac */
11785 spec->multiout.dac_nids = spec->private_dac_nids;
11786 spec->multiout.dac_nids[0] = 2;
11787 spec->multiout.dac_nids[1] = 3;
11788
11789 nid = cfg->line_out_pins[0];
11790 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011791 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011792
11793 nid = cfg->speaker_pins[0];
11794 if (nid == 0x1d) {
11795 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11796 "Speaker Playback Volume",
11797 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11798 if (err < 0)
11799 return err;
11800 }
11801 nid = cfg->hp_pins[0];
11802 if (nid)
11803 alc268_new_analog_output(spec, nid, "Headphone", 0);
11804
11805 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11806 if (nid == 0x16) {
11807 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11808 "Mono Playback Switch",
11809 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11810 if (err < 0)
11811 return err;
11812 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011813 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011814}
11815
11816/* create playback/capture controls for input pins */
11817static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11818 const struct auto_pin_cfg *cfg)
11819{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011820 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011821 int i, idx1;
11822
11823 for (i = 0; i < AUTO_PIN_LAST; i++) {
11824 switch(cfg->input_pins[i]) {
11825 case 0x18:
11826 idx1 = 0; /* Mic 1 */
11827 break;
11828 case 0x19:
11829 idx1 = 1; /* Mic 2 */
11830 break;
11831 case 0x1a:
11832 idx1 = 2; /* Line In */
11833 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011834 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011835 idx1 = 3; /* CD */
11836 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011837 case 0x12:
11838 case 0x13:
11839 idx1 = 6; /* digital mics */
11840 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011841 default:
11842 continue;
11843 }
11844 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11845 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011846 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011847 }
11848 return 0;
11849}
11850
11851static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11852{
11853 struct alc_spec *spec = codec->spec;
11854 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11855 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11856 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11857 unsigned int dac_vol1, dac_vol2;
11858
11859 if (speaker_nid) {
11860 snd_hda_codec_write(codec, speaker_nid, 0,
11861 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11862 snd_hda_codec_write(codec, 0x0f, 0,
11863 AC_VERB_SET_AMP_GAIN_MUTE,
11864 AMP_IN_UNMUTE(1));
11865 snd_hda_codec_write(codec, 0x10, 0,
11866 AC_VERB_SET_AMP_GAIN_MUTE,
11867 AMP_IN_UNMUTE(1));
11868 } else {
11869 snd_hda_codec_write(codec, 0x0f, 0,
11870 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11871 snd_hda_codec_write(codec, 0x10, 0,
11872 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11873 }
11874
11875 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011876 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011877 dac_vol2 = AMP_OUT_ZERO;
11878 else if (line_nid == 0x15)
11879 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011880 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011881 dac_vol2 = AMP_OUT_ZERO;
11882 else if (hp_nid == 0x15)
11883 dac_vol1 = AMP_OUT_ZERO;
11884 if (line_nid != 0x16 || hp_nid != 0x16 ||
11885 spec->autocfg.line_out_pins[1] != 0x16 ||
11886 spec->autocfg.line_out_pins[2] != 0x16)
11887 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11888
11889 snd_hda_codec_write(codec, 0x02, 0,
11890 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11891 snd_hda_codec_write(codec, 0x03, 0,
11892 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11893}
11894
11895/* pcm configuration: identiacal with ALC880 */
11896#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11897#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011898#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011899#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11900
11901/*
11902 * BIOS auto configuration
11903 */
11904static int alc268_parse_auto_config(struct hda_codec *codec)
11905{
11906 struct alc_spec *spec = codec->spec;
11907 int err;
11908 static hda_nid_t alc268_ignore[] = { 0 };
11909
11910 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11911 alc268_ignore);
11912 if (err < 0)
11913 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011914 if (!spec->autocfg.line_outs) {
11915 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11916 spec->multiout.max_channels = 2;
11917 spec->no_analog = 1;
11918 goto dig_only;
11919 }
Kailang Yanga361d842007-06-05 12:30:55 +020011920 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011921 }
Kailang Yanga361d842007-06-05 12:30:55 +020011922 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11923 if (err < 0)
11924 return err;
11925 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11926 if (err < 0)
11927 return err;
11928
11929 spec->multiout.max_channels = 2;
11930
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011931 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020011932 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011933 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020011934 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011935 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11936 }
Takashi Iwai603c4012008-07-30 15:01:44 +020011937 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011938 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011939
Takashi Iwai892981f2009-03-02 08:04:35 +010011940 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011941 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011942
Takashi Iwaid88897e2008-10-31 15:01:37 +010011943 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011944 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011945 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011946
Takashi Iwai776e1842007-08-29 15:07:11 +020011947 err = alc_auto_add_mic_boost(codec);
11948 if (err < 0)
11949 return err;
11950
Kailang Yanga361d842007-06-05 12:30:55 +020011951 return 1;
11952}
11953
11954#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11955#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11956#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11957
11958/* init callback for auto-configuration model -- overriding the default init */
11959static void alc268_auto_init(struct hda_codec *codec)
11960{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011961 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011962 alc268_auto_init_multi_out(codec);
11963 alc268_auto_init_hp_out(codec);
11964 alc268_auto_init_mono_speaker_out(codec);
11965 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011966 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011967 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011968}
11969
11970/*
11971 * configuration and preset
11972 */
11973static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011974 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011975 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011976 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011977 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011978 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011979 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011980 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011981 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011982#ifdef CONFIG_SND_DEBUG
11983 [ALC268_TEST] = "test",
11984#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011985 [ALC268_AUTO] = "auto",
11986};
11987
11988static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011989 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011990 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011991 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011992 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011993 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011994 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11995 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011996 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011997 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011998 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011999 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020012000 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020012001 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020012002 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012003 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012004 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012005 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012006 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012007 {}
12008};
12009
12010static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012011 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012012 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012013 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12014 alc267_quanta_il1_verbs },
12015 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12016 .dac_nids = alc268_dac_nids,
12017 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12018 .adc_nids = alc268_adc_nids_alt,
12019 .hp_nid = 0x03,
12020 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12021 .channel_mode = alc268_modes,
12022 .input_mux = &alc268_capture_source,
12023 .unsol_event = alc267_quanta_il1_unsol_event,
12024 .init_hook = alc267_quanta_il1_automute,
12025 },
Kailang Yanga361d842007-06-05 12:30:55 +020012026 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012027 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12028 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012029 .init_verbs = { alc268_base_init_verbs },
12030 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12031 .dac_nids = alc268_dac_nids,
12032 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12033 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012034 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012035 .hp_nid = 0x03,
12036 .dig_out_nid = ALC268_DIGOUT_NID,
12037 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12038 .channel_mode = alc268_modes,
12039 .input_mux = &alc268_capture_source,
12040 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012041 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012042 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12043 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012044 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12045 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012046 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12047 .dac_nids = alc268_dac_nids,
12048 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12049 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012050 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012051 .hp_nid = 0x03,
12052 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12053 .channel_mode = alc268_modes,
12054 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012055 .unsol_event = alc268_toshiba_unsol_event,
12056 .init_hook = alc268_toshiba_automute,
12057 },
12058 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012059 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12060 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012061 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12062 alc268_acer_verbs },
12063 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12064 .dac_nids = alc268_dac_nids,
12065 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12066 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012067 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012068 .hp_nid = 0x02,
12069 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12070 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012071 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012072 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012073 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012074 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012075 [ALC268_ACER_DMIC] = {
12076 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12077 alc268_beep_mixer },
12078 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12079 alc268_acer_verbs },
12080 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12081 .dac_nids = alc268_dac_nids,
12082 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12083 .adc_nids = alc268_adc_nids_alt,
12084 .capsrc_nids = alc268_capsrc_nids,
12085 .hp_nid = 0x02,
12086 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12087 .channel_mode = alc268_modes,
12088 .input_mux = &alc268_acer_dmic_capture_source,
12089 .unsol_event = alc268_acer_unsol_event,
12090 .init_hook = alc268_acer_init_hook,
12091 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012092 [ALC268_ACER_ASPIRE_ONE] = {
12093 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012094 alc268_beep_mixer,
12095 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012096 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12097 alc268_acer_aspire_one_verbs },
12098 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12099 .dac_nids = alc268_dac_nids,
12100 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12101 .adc_nids = alc268_adc_nids_alt,
12102 .capsrc_nids = alc268_capsrc_nids,
12103 .hp_nid = 0x03,
12104 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12105 .channel_mode = alc268_modes,
12106 .input_mux = &alc268_acer_lc_capture_source,
12107 .unsol_event = alc268_acer_lc_unsol_event,
12108 .init_hook = alc268_acer_lc_init_hook,
12109 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012110 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012111 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012112 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12113 alc268_dell_verbs },
12114 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12115 .dac_nids = alc268_dac_nids,
12116 .hp_nid = 0x02,
12117 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12118 .channel_mode = alc268_modes,
12119 .unsol_event = alc268_dell_unsol_event,
12120 .init_hook = alc268_dell_init_hook,
12121 .input_mux = &alc268_capture_source,
12122 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012123 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012124 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12125 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012126 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12127 alc268_toshiba_verbs },
12128 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12129 .dac_nids = alc268_dac_nids,
12130 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12131 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012132 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012133 .hp_nid = 0x03,
12134 .dig_out_nid = ALC268_DIGOUT_NID,
12135 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12136 .channel_mode = alc268_modes,
12137 .input_mux = &alc268_capture_source,
12138 .unsol_event = alc268_toshiba_unsol_event,
12139 .init_hook = alc268_toshiba_automute
12140 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012141#ifdef CONFIG_SND_DEBUG
12142 [ALC268_TEST] = {
12143 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12144 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12145 alc268_volume_init_verbs },
12146 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12147 .dac_nids = alc268_dac_nids,
12148 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12149 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012150 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012151 .hp_nid = 0x03,
12152 .dig_out_nid = ALC268_DIGOUT_NID,
12153 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12154 .channel_mode = alc268_modes,
12155 .input_mux = &alc268_capture_source,
12156 },
12157#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012158};
12159
12160static int patch_alc268(struct hda_codec *codec)
12161{
12162 struct alc_spec *spec;
12163 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012164 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012165
12166 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12167 if (spec == NULL)
12168 return -ENOMEM;
12169
12170 codec->spec = spec;
12171
12172 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12173 alc268_models,
12174 alc268_cfg_tbl);
12175
12176 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12177 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12178 "trying auto-probe from BIOS...\n");
12179 board_config = ALC268_AUTO;
12180 }
12181
12182 if (board_config == ALC268_AUTO) {
12183 /* automatic parse from the BIOS config */
12184 err = alc268_parse_auto_config(codec);
12185 if (err < 0) {
12186 alc_free(codec);
12187 return err;
12188 } else if (!err) {
12189 printk(KERN_INFO
12190 "hda_codec: Cannot set up configuration "
12191 "from BIOS. Using base mode...\n");
12192 board_config = ALC268_3ST;
12193 }
12194 }
12195
12196 if (board_config != ALC268_AUTO)
12197 setup_preset(spec, &alc268_presets[board_config]);
12198
Kailang Yang2f893282008-05-27 12:14:47 +020012199 if (codec->vendor_id == 0x10ec0267) {
12200 spec->stream_name_analog = "ALC267 Analog";
12201 spec->stream_name_digital = "ALC267 Digital";
12202 } else {
12203 spec->stream_name_analog = "ALC268 Analog";
12204 spec->stream_name_digital = "ALC268 Digital";
12205 }
12206
Kailang Yanga361d842007-06-05 12:30:55 +020012207 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12208 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012209 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012210
Kailang Yanga361d842007-06-05 12:30:55 +020012211 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12212
Takashi Iwai22971e32009-02-10 11:56:44 +010012213 has_beep = 0;
12214 for (i = 0; i < spec->num_mixers; i++) {
12215 if (spec->mixers[i] == alc268_beep_mixer) {
12216 has_beep = 1;
12217 break;
12218 }
12219 }
12220
12221 if (has_beep) {
12222 err = snd_hda_attach_beep_device(codec, 0x1);
12223 if (err < 0) {
12224 alc_free(codec);
12225 return err;
12226 }
12227 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12228 /* override the amp caps for beep generator */
12229 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012230 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12231 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12232 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12233 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012234 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012235
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012236 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012237 /* check whether NID 0x07 is valid */
12238 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012239 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012240
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012241 /* get type */
12242 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012243 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012244 spec->adc_nids = alc268_adc_nids_alt;
12245 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012246 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012247 } else {
12248 spec->adc_nids = alc268_adc_nids;
12249 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012250 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012251 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012252 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012253 /* set default input source */
12254 for (i = 0; i < spec->num_adc_nids; i++)
12255 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12256 0, AC_VERB_SET_CONNECT_SEL,
12257 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012258 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012259
12260 spec->vmaster_nid = 0x02;
12261
Kailang Yanga361d842007-06-05 12:30:55 +020012262 codec->patch_ops = alc_patch_ops;
12263 if (board_config == ALC268_AUTO)
12264 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012265
Takashi Iwaidaead532008-11-28 12:55:36 +010012266 codec->proc_widget_hook = print_realtek_coef;
12267
Kailang Yanga361d842007-06-05 12:30:55 +020012268 return 0;
12269}
12270
12271/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012272 * ALC269 channel source setting (2 channel)
12273 */
12274#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12275
12276#define alc269_dac_nids alc260_dac_nids
12277
12278static hda_nid_t alc269_adc_nids[1] = {
12279 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012280 0x08,
12281};
12282
Takashi Iwaie01bf502008-08-21 16:25:07 +020012283static hda_nid_t alc269_capsrc_nids[1] = {
12284 0x23,
12285};
12286
12287/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12288 * not a mux!
12289 */
12290
Kailang Yangf53281e2008-07-18 12:36:43 +020012291static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12292 .num_items = 2,
12293 .items = {
12294 { "i-Mic", 0x5 },
12295 { "e-Mic", 0x0 },
12296 },
12297};
12298
12299static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12300 .num_items = 2,
12301 .items = {
12302 { "i-Mic", 0x1 },
12303 { "e-Mic", 0x0 },
12304 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012305};
12306
12307#define alc269_modes alc260_modes
12308#define alc269_capture_source alc880_lg_lw_capture_source
12309
12310static struct snd_kcontrol_new alc269_base_mixer[] = {
12311 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12312 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12313 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12314 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12316 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12317 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12318 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12319 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12320 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12321 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12322 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12323 { } /* end */
12324};
12325
Kailang Yang60db6b52008-08-26 13:13:00 +020012326static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12327 /* output mixer control */
12328 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12329 {
12330 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12331 .name = "Master Playback Switch",
12332 .info = snd_hda_mixer_amp_switch_info,
12333 .get = snd_hda_mixer_amp_switch_get,
12334 .put = alc268_acer_master_sw_put,
12335 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12336 },
12337 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12338 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12339 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12340 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12341 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12342 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012343 { }
12344};
12345
Tony Vroon64154832008-11-06 15:08:49 +000012346static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12347 /* output mixer control */
12348 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12349 {
12350 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12351 .name = "Master Playback Switch",
12352 .info = snd_hda_mixer_amp_switch_info,
12353 .get = snd_hda_mixer_amp_switch_get,
12354 .put = alc268_acer_master_sw_put,
12355 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12356 },
12357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12358 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12359 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12360 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12361 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12362 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12363 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12364 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12365 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012366 { }
12367};
12368
Kailang Yangf53281e2008-07-18 12:36:43 +020012369/* bind volumes of both NID 0x0c and 0x0d */
12370static struct hda_bind_ctls alc269_epc_bind_vol = {
12371 .ops = &snd_hda_bind_vol,
12372 .values = {
12373 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12374 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12375 0
12376 },
12377};
12378
12379static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12380 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12381 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12382 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12383 { } /* end */
12384};
12385
Kailang Yangf6a92242007-12-13 16:52:54 +010012386/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012387static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12388 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12389 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012390 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12391 { } /* end */
12392};
12393
12394/* FSC amilo */
12395static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12396 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12397 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12398 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012399 { } /* end */
12400};
12401
Kailang Yang60db6b52008-08-26 13:13:00 +020012402static struct hda_verb alc269_quanta_fl1_verbs[] = {
12403 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12404 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12405 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12406 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12407 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12408 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12409 { }
12410};
12411
Tony Vroon64154832008-11-06 15:08:49 +000012412static struct hda_verb alc269_lifebook_verbs[] = {
12413 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12414 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12415 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12416 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12417 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12418 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12419 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12420 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12421 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12422 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12423 { }
12424};
12425
Kailang Yang60db6b52008-08-26 13:13:00 +020012426/* toggle speaker-output according to the hp-jack state */
12427static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12428{
12429 unsigned int present;
12430 unsigned char bits;
12431
12432 present = snd_hda_codec_read(codec, 0x15, 0,
12433 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12434 bits = present ? AMP_IN_MUTE(0) : 0;
12435 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12436 AMP_IN_MUTE(0), bits);
12437 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12438 AMP_IN_MUTE(0), bits);
12439
12440 snd_hda_codec_write(codec, 0x20, 0,
12441 AC_VERB_SET_COEF_INDEX, 0x0c);
12442 snd_hda_codec_write(codec, 0x20, 0,
12443 AC_VERB_SET_PROC_COEF, 0x680);
12444
12445 snd_hda_codec_write(codec, 0x20, 0,
12446 AC_VERB_SET_COEF_INDEX, 0x0c);
12447 snd_hda_codec_write(codec, 0x20, 0,
12448 AC_VERB_SET_PROC_COEF, 0x480);
12449}
12450
Tony Vroon64154832008-11-06 15:08:49 +000012451/* toggle speaker-output according to the hp-jacks state */
12452static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12453{
12454 unsigned int present;
12455 unsigned char bits;
12456
12457 /* Check laptop headphone socket */
12458 present = snd_hda_codec_read(codec, 0x15, 0,
12459 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12460
12461 /* Check port replicator headphone socket */
12462 present |= snd_hda_codec_read(codec, 0x1a, 0,
12463 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12464
12465 bits = present ? AMP_IN_MUTE(0) : 0;
12466 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12467 AMP_IN_MUTE(0), bits);
12468 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12469 AMP_IN_MUTE(0), bits);
12470
12471 snd_hda_codec_write(codec, 0x20, 0,
12472 AC_VERB_SET_COEF_INDEX, 0x0c);
12473 snd_hda_codec_write(codec, 0x20, 0,
12474 AC_VERB_SET_PROC_COEF, 0x680);
12475
12476 snd_hda_codec_write(codec, 0x20, 0,
12477 AC_VERB_SET_COEF_INDEX, 0x0c);
12478 snd_hda_codec_write(codec, 0x20, 0,
12479 AC_VERB_SET_PROC_COEF, 0x480);
12480}
12481
Kailang Yang60db6b52008-08-26 13:13:00 +020012482static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12483{
12484 unsigned int present;
12485
12486 present = snd_hda_codec_read(codec, 0x18, 0,
12487 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12488 snd_hda_codec_write(codec, 0x23, 0,
12489 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12490}
12491
Tony Vroon64154832008-11-06 15:08:49 +000012492static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12493{
12494 unsigned int present_laptop;
12495 unsigned int present_dock;
12496
12497 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12498 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12499
12500 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12501 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12502
12503 /* Laptop mic port overrides dock mic port, design decision */
12504 if (present_dock)
12505 snd_hda_codec_write(codec, 0x23, 0,
12506 AC_VERB_SET_CONNECT_SEL, 0x3);
12507 if (present_laptop)
12508 snd_hda_codec_write(codec, 0x23, 0,
12509 AC_VERB_SET_CONNECT_SEL, 0x0);
12510 if (!present_dock && !present_laptop)
12511 snd_hda_codec_write(codec, 0x23, 0,
12512 AC_VERB_SET_CONNECT_SEL, 0x1);
12513}
12514
Kailang Yang60db6b52008-08-26 13:13:00 +020012515static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12516 unsigned int res)
12517{
12518 if ((res >> 26) == ALC880_HP_EVENT)
12519 alc269_quanta_fl1_speaker_automute(codec);
12520 if ((res >> 26) == ALC880_MIC_EVENT)
12521 alc269_quanta_fl1_mic_automute(codec);
12522}
12523
Tony Vroon64154832008-11-06 15:08:49 +000012524static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12525 unsigned int res)
12526{
12527 if ((res >> 26) == ALC880_HP_EVENT)
12528 alc269_lifebook_speaker_automute(codec);
12529 if ((res >> 26) == ALC880_MIC_EVENT)
12530 alc269_lifebook_mic_autoswitch(codec);
12531}
12532
Kailang Yang60db6b52008-08-26 13:13:00 +020012533static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12534{
12535 alc269_quanta_fl1_speaker_automute(codec);
12536 alc269_quanta_fl1_mic_automute(codec);
12537}
12538
Tony Vroon64154832008-11-06 15:08:49 +000012539static void alc269_lifebook_init_hook(struct hda_codec *codec)
12540{
12541 alc269_lifebook_speaker_automute(codec);
12542 alc269_lifebook_mic_autoswitch(codec);
12543}
12544
Kailang Yang60db6b52008-08-26 13:13:00 +020012545static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12546 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12547 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12548 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12550 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12551 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12552 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12553 {}
12554};
12555
12556static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12557 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12558 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12559 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12560 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12561 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12562 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12563 {}
12564};
12565
12566/* toggle speaker-output according to the hp-jack state */
12567static void alc269_speaker_automute(struct hda_codec *codec)
12568{
12569 unsigned int present;
12570 unsigned char bits;
12571
12572 present = snd_hda_codec_read(codec, 0x15, 0,
12573 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12574 bits = present ? AMP_IN_MUTE(0) : 0;
12575 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12576 AMP_IN_MUTE(0), bits);
12577 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12578 AMP_IN_MUTE(0), bits);
12579}
12580
12581static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12582{
12583 unsigned int present;
12584
12585 present = snd_hda_codec_read(codec, 0x18, 0,
12586 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12587 snd_hda_codec_write(codec, 0x23, 0,
12588 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12589}
12590
12591static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12592{
12593 unsigned int present;
12594
12595 present = snd_hda_codec_read(codec, 0x18, 0,
12596 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12597 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12598 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12599 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12600 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12601}
12602
12603/* unsolicited event for HP jack sensing */
12604static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12605 unsigned int res)
12606{
12607 if ((res >> 26) == ALC880_HP_EVENT)
12608 alc269_speaker_automute(codec);
12609
12610 if ((res >> 26) == ALC880_MIC_EVENT)
12611 alc269_eeepc_dmic_automute(codec);
12612}
12613
12614static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12615{
12616 alc269_speaker_automute(codec);
12617 alc269_eeepc_dmic_automute(codec);
12618}
12619
12620/* unsolicited event for HP jack sensing */
12621static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12622 unsigned int res)
12623{
12624 if ((res >> 26) == ALC880_HP_EVENT)
12625 alc269_speaker_automute(codec);
12626
12627 if ((res >> 26) == ALC880_MIC_EVENT)
12628 alc269_eeepc_amic_automute(codec);
12629}
12630
12631static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12632{
12633 alc269_speaker_automute(codec);
12634 alc269_eeepc_amic_automute(codec);
12635}
12636
Kailang Yangf6a92242007-12-13 16:52:54 +010012637/*
12638 * generic initialization of ADC, input mixers and output mixers
12639 */
12640static struct hda_verb alc269_init_verbs[] = {
12641 /*
12642 * Unmute ADC0 and set the default input to mic-in
12643 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012645
12646 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12647 * analog-loopback mixer widget
12648 * Note: PASD motherboards uses the Line In 2 as the input for
12649 * front panel mic (mic 2)
12650 */
12651 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12657
12658 /*
12659 * Set up output mixers (0x0c - 0x0e)
12660 */
12661 /* set vol=0 to output mixers */
12662 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12663 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12664
12665 /* set up input amps for analog loopback */
12666 /* Amp Indices: DAC = 0, mixer = 1 */
12667 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12668 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12669 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12670 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12671 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12672 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12673
12674 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12675 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12676 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12677 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12678 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12679 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12680 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12681
12682 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12684 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12686 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12688 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12689
12690 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12691 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12692
12693 /* FIXME: use matrix-type input source selection */
12694 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12695 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012696 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12697 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012698 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12699 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12700
12701 /* set EAPD */
12702 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12703 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12704 { }
12705};
12706
12707/* add playback controls from the parsed DAC table */
12708static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12709 const struct auto_pin_cfg *cfg)
12710{
12711 hda_nid_t nid;
12712 int err;
12713
12714 spec->multiout.num_dacs = 1; /* only use one dac */
12715 spec->multiout.dac_nids = spec->private_dac_nids;
12716 spec->multiout.dac_nids[0] = 2;
12717
12718 nid = cfg->line_out_pins[0];
12719 if (nid) {
12720 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12721 "Front Playback Volume",
12722 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12723 if (err < 0)
12724 return err;
12725 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12726 "Front Playback Switch",
12727 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12728 if (err < 0)
12729 return err;
12730 }
12731
12732 nid = cfg->speaker_pins[0];
12733 if (nid) {
12734 if (!cfg->line_out_pins[0]) {
12735 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12736 "Speaker Playback Volume",
12737 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12738 HDA_OUTPUT));
12739 if (err < 0)
12740 return err;
12741 }
12742 if (nid == 0x16) {
12743 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12744 "Speaker Playback Switch",
12745 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12746 HDA_OUTPUT));
12747 if (err < 0)
12748 return err;
12749 } else {
12750 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12751 "Speaker Playback Switch",
12752 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12753 HDA_OUTPUT));
12754 if (err < 0)
12755 return err;
12756 }
12757 }
12758 nid = cfg->hp_pins[0];
12759 if (nid) {
12760 /* spec->multiout.hp_nid = 2; */
12761 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12762 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12763 "Headphone Playback Volume",
12764 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12765 HDA_OUTPUT));
12766 if (err < 0)
12767 return err;
12768 }
12769 if (nid == 0x16) {
12770 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12771 "Headphone Playback Switch",
12772 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12773 HDA_OUTPUT));
12774 if (err < 0)
12775 return err;
12776 } else {
12777 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12778 "Headphone Playback Switch",
12779 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12780 HDA_OUTPUT));
12781 if (err < 0)
12782 return err;
12783 }
12784 }
12785 return 0;
12786}
12787
Takashi Iwaiee956e02008-10-31 17:16:31 +010012788static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12789 const struct auto_pin_cfg *cfg)
12790{
12791 int err;
12792
12793 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12794 if (err < 0)
12795 return err;
12796 /* digital-mic input pin is excluded in alc880_auto_create..()
12797 * because it's under 0x18
12798 */
12799 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12800 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012801 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012802 imux->items[imux->num_items].label = "Int Mic";
12803 imux->items[imux->num_items].index = 0x05;
12804 imux->num_items++;
12805 }
12806 return 0;
12807}
Kailang Yangf6a92242007-12-13 16:52:54 +010012808
12809#ifdef CONFIG_SND_HDA_POWER_SAVE
12810#define alc269_loopbacks alc880_loopbacks
12811#endif
12812
12813/* pcm configuration: identiacal with ALC880 */
12814#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12815#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12816#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12817#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12818
12819/*
12820 * BIOS auto configuration
12821 */
12822static int alc269_parse_auto_config(struct hda_codec *codec)
12823{
12824 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012825 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012826 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12827
12828 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12829 alc269_ignore);
12830 if (err < 0)
12831 return err;
12832
12833 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12834 if (err < 0)
12835 return err;
12836 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12837 if (err < 0)
12838 return err;
12839
12840 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12841
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012842 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012843 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12844
Takashi Iwai603c4012008-07-30 15:01:44 +020012845 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012846 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012847
Takashi Iwaid88897e2008-10-31 15:01:37 +010012848 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012849 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012850 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012851 /* set default input source */
12852 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12853 0, AC_VERB_SET_CONNECT_SEL,
12854 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012855
12856 err = alc_auto_add_mic_boost(codec);
12857 if (err < 0)
12858 return err;
12859
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012860 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012861 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012862
Kailang Yangf6a92242007-12-13 16:52:54 +010012863 return 1;
12864}
12865
12866#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12867#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12868#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12869
12870
12871/* init callback for auto-configuration model -- overriding the default init */
12872static void alc269_auto_init(struct hda_codec *codec)
12873{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012874 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012875 alc269_auto_init_multi_out(codec);
12876 alc269_auto_init_hp_out(codec);
12877 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012878 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012879 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012880}
12881
12882/*
12883 * configuration and preset
12884 */
12885static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012886 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012887 [ALC269_QUANTA_FL1] = "quanta",
12888 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012889 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012890 [ALC269_FUJITSU] = "fujitsu",
12891 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012892};
12893
12894static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012895 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012896 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12897 ALC269_ASUS_EEEPC_P703),
12898 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12899 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012900 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12901 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012902 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012903 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012904 {}
12905};
12906
12907static struct alc_config_preset alc269_presets[] = {
12908 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012909 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012910 .init_verbs = { alc269_init_verbs },
12911 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12912 .dac_nids = alc269_dac_nids,
12913 .hp_nid = 0x03,
12914 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12915 .channel_mode = alc269_modes,
12916 .input_mux = &alc269_capture_source,
12917 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012918 [ALC269_QUANTA_FL1] = {
12919 .mixers = { alc269_quanta_fl1_mixer },
12920 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12921 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12922 .dac_nids = alc269_dac_nids,
12923 .hp_nid = 0x03,
12924 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12925 .channel_mode = alc269_modes,
12926 .input_mux = &alc269_capture_source,
12927 .unsol_event = alc269_quanta_fl1_unsol_event,
12928 .init_hook = alc269_quanta_fl1_init_hook,
12929 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012930 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012931 .mixers = { alc269_eeepc_mixer },
12932 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012933 .init_verbs = { alc269_init_verbs,
12934 alc269_eeepc_amic_init_verbs },
12935 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12936 .dac_nids = alc269_dac_nids,
12937 .hp_nid = 0x03,
12938 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12939 .channel_mode = alc269_modes,
12940 .input_mux = &alc269_eeepc_amic_capture_source,
12941 .unsol_event = alc269_eeepc_amic_unsol_event,
12942 .init_hook = alc269_eeepc_amic_inithook,
12943 },
12944 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012945 .mixers = { alc269_eeepc_mixer },
12946 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012947 .init_verbs = { alc269_init_verbs,
12948 alc269_eeepc_dmic_init_verbs },
12949 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12950 .dac_nids = alc269_dac_nids,
12951 .hp_nid = 0x03,
12952 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12953 .channel_mode = alc269_modes,
12954 .input_mux = &alc269_eeepc_dmic_capture_source,
12955 .unsol_event = alc269_eeepc_dmic_unsol_event,
12956 .init_hook = alc269_eeepc_dmic_inithook,
12957 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012958 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012959 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012960 .cap_mixer = alc269_epc_capture_mixer,
12961 .init_verbs = { alc269_init_verbs,
12962 alc269_eeepc_dmic_init_verbs },
12963 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12964 .dac_nids = alc269_dac_nids,
12965 .hp_nid = 0x03,
12966 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12967 .channel_mode = alc269_modes,
12968 .input_mux = &alc269_eeepc_dmic_capture_source,
12969 .unsol_event = alc269_eeepc_dmic_unsol_event,
12970 .init_hook = alc269_eeepc_dmic_inithook,
12971 },
Tony Vroon64154832008-11-06 15:08:49 +000012972 [ALC269_LIFEBOOK] = {
12973 .mixers = { alc269_lifebook_mixer },
12974 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12975 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12976 .dac_nids = alc269_dac_nids,
12977 .hp_nid = 0x03,
12978 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12979 .channel_mode = alc269_modes,
12980 .input_mux = &alc269_capture_source,
12981 .unsol_event = alc269_lifebook_unsol_event,
12982 .init_hook = alc269_lifebook_init_hook,
12983 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012984};
12985
12986static int patch_alc269(struct hda_codec *codec)
12987{
12988 struct alc_spec *spec;
12989 int board_config;
12990 int err;
12991
12992 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12993 if (spec == NULL)
12994 return -ENOMEM;
12995
12996 codec->spec = spec;
12997
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012998 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12999
Kailang Yangf6a92242007-12-13 16:52:54 +010013000 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13001 alc269_models,
13002 alc269_cfg_tbl);
13003
13004 if (board_config < 0) {
13005 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
13006 "trying auto-probe from BIOS...\n");
13007 board_config = ALC269_AUTO;
13008 }
13009
13010 if (board_config == ALC269_AUTO) {
13011 /* automatic parse from the BIOS config */
13012 err = alc269_parse_auto_config(codec);
13013 if (err < 0) {
13014 alc_free(codec);
13015 return err;
13016 } else if (!err) {
13017 printk(KERN_INFO
13018 "hda_codec: Cannot set up configuration "
13019 "from BIOS. Using base mode...\n");
13020 board_config = ALC269_BASIC;
13021 }
13022 }
13023
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013024 err = snd_hda_attach_beep_device(codec, 0x1);
13025 if (err < 0) {
13026 alc_free(codec);
13027 return err;
13028 }
13029
Kailang Yangf6a92242007-12-13 16:52:54 +010013030 if (board_config != ALC269_AUTO)
13031 setup_preset(spec, &alc269_presets[board_config]);
13032
13033 spec->stream_name_analog = "ALC269 Analog";
13034 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13035 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13036
13037 spec->stream_name_digital = "ALC269 Digital";
13038 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13039 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13040
13041 spec->adc_nids = alc269_adc_nids;
13042 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013043 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013044 if (!spec->cap_mixer)
13045 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013046 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013047
13048 codec->patch_ops = alc_patch_ops;
13049 if (board_config == ALC269_AUTO)
13050 spec->init_hook = alc269_auto_init;
13051#ifdef CONFIG_SND_HDA_POWER_SAVE
13052 if (!spec->loopback.amplist)
13053 spec->loopback.amplist = alc269_loopbacks;
13054#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013055 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013056
13057 return 0;
13058}
13059
13060/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013061 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13062 */
13063
13064/*
13065 * set the path ways for 2 channel output
13066 * need to set the codec line out and mic 1 pin widgets to inputs
13067 */
13068static struct hda_verb alc861_threestack_ch2_init[] = {
13069 /* set pin widget 1Ah (line in) for input */
13070 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013071 /* set pin widget 18h (mic1/2) for input, for mic also enable
13072 * the vref
13073 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013074 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13075
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013076 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13077#if 0
13078 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13079 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13080#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013081 { } /* end */
13082};
13083/*
13084 * 6ch mode
13085 * need to set the codec line out and mic 1 pin widgets to outputs
13086 */
13087static struct hda_verb alc861_threestack_ch6_init[] = {
13088 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13089 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13090 /* set pin widget 18h (mic1) for output (CLFE)*/
13091 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13092
13093 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013094 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013095
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013096 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13097#if 0
13098 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13099 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13100#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013101 { } /* end */
13102};
13103
13104static struct hda_channel_mode alc861_threestack_modes[2] = {
13105 { 2, alc861_threestack_ch2_init },
13106 { 6, alc861_threestack_ch6_init },
13107};
Takashi Iwai22309c32006-08-09 16:57:28 +020013108/* Set mic1 as input and unmute the mixer */
13109static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13110 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13111 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13112 { } /* end */
13113};
13114/* Set mic1 as output and mute mixer */
13115static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13116 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13117 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13118 { } /* end */
13119};
13120
13121static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13122 { 2, alc861_uniwill_m31_ch2_init },
13123 { 4, alc861_uniwill_m31_ch4_init },
13124};
Kailang Yangdf694da2005-12-05 19:42:22 +010013125
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013126/* Set mic1 and line-in as input and unmute the mixer */
13127static struct hda_verb alc861_asus_ch2_init[] = {
13128 /* set pin widget 1Ah (line in) for input */
13129 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013130 /* set pin widget 18h (mic1/2) for input, for mic also enable
13131 * the vref
13132 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013133 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13134
13135 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13136#if 0
13137 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13138 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13139#endif
13140 { } /* end */
13141};
13142/* Set mic1 nad line-in as output and mute mixer */
13143static struct hda_verb alc861_asus_ch6_init[] = {
13144 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13145 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13146 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13147 /* set pin widget 18h (mic1) for output (CLFE)*/
13148 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13149 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13150 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13151 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13152
13153 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13154#if 0
13155 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13156 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13157#endif
13158 { } /* end */
13159};
13160
13161static struct hda_channel_mode alc861_asus_modes[2] = {
13162 { 2, alc861_asus_ch2_init },
13163 { 6, alc861_asus_ch6_init },
13164};
13165
Kailang Yangdf694da2005-12-05 19:42:22 +010013166/* patch-ALC861 */
13167
13168static struct snd_kcontrol_new alc861_base_mixer[] = {
13169 /* output mixer control */
13170 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13171 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13172 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13173 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13174 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13175
13176 /*Input mixer control */
13177 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13178 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13179 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13180 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13181 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13182 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13183 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13184 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13185 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13186 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013187
Kailang Yangdf694da2005-12-05 19:42:22 +010013188 { } /* end */
13189};
13190
13191static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13192 /* output mixer control */
13193 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13194 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13195 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13196 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13197 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13198
13199 /* Input mixer control */
13200 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13201 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13202 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13203 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13204 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13205 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13206 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13207 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13208 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013210
Kailang Yangdf694da2005-12-05 19:42:22 +010013211 {
13212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13213 .name = "Channel Mode",
13214 .info = alc_ch_mode_info,
13215 .get = alc_ch_mode_get,
13216 .put = alc_ch_mode_put,
13217 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13218 },
13219 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013220};
13221
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013222static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013223 /* output mixer control */
13224 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13226 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013227
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013228 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013229};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013230
Takashi Iwai22309c32006-08-09 16:57:28 +020013231static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13232 /* output mixer control */
13233 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13234 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13235 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13236 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13237 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13238
13239 /* Input mixer control */
13240 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13241 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13242 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13243 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13244 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13245 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13247 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13248 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13249 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013250
Takashi Iwai22309c32006-08-09 16:57:28 +020013251 {
13252 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13253 .name = "Channel Mode",
13254 .info = alc_ch_mode_info,
13255 .get = alc_ch_mode_get,
13256 .put = alc_ch_mode_put,
13257 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13258 },
13259 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013260};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013261
13262static struct snd_kcontrol_new alc861_asus_mixer[] = {
13263 /* output mixer control */
13264 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13265 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13266 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13267 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13268 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13269
13270 /* Input mixer control */
13271 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13272 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13273 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13274 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13275 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13276 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13277 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13278 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13279 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013280 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13281
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013282 {
13283 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13284 .name = "Channel Mode",
13285 .info = alc_ch_mode_info,
13286 .get = alc_ch_mode_get,
13287 .put = alc_ch_mode_put,
13288 .private_value = ARRAY_SIZE(alc861_asus_modes),
13289 },
13290 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013291};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013292
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013293/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013294static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013295 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13296 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013297 { }
13298};
13299
Kailang Yangdf694da2005-12-05 19:42:22 +010013300/*
13301 * generic initialization of ADC, input mixers and output mixers
13302 */
13303static struct hda_verb alc861_base_init_verbs[] = {
13304 /*
13305 * Unmute ADC0 and set the default input to mic-in
13306 */
13307 /* port-A for surround (rear panel) */
13308 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13309 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13310 /* port-B for mic-in (rear panel) with vref */
13311 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13312 /* port-C for line-in (rear panel) */
13313 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13314 /* port-D for Front */
13315 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13316 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13317 /* port-E for HP out (front panel) */
13318 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13319 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013320 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013321 /* port-F for mic-in (front panel) with vref */
13322 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13323 /* port-G for CLFE (rear panel) */
13324 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13325 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13326 /* port-H for side (rear panel) */
13327 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13328 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13329 /* CD-in */
13330 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13331 /* route front mic to ADC1*/
13332 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13333 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013334
Kailang Yangdf694da2005-12-05 19:42:22 +010013335 /* Unmute DAC0~3 & spdif out*/
13336 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13337 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13338 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13339 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013341
Kailang Yangdf694da2005-12-05 19:42:22 +010013342 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13343 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13344 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13345 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13346 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013347
Kailang Yangdf694da2005-12-05 19:42:22 +010013348 /* Unmute Stereo Mixer 15 */
13349 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13350 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13351 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013353
13354 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13355 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13356 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13357 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13358 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13359 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13360 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13361 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013362 /* hp used DAC 3 (Front) */
13363 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013364 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13365
13366 { }
13367};
13368
13369static struct hda_verb alc861_threestack_init_verbs[] = {
13370 /*
13371 * Unmute ADC0 and set the default input to mic-in
13372 */
13373 /* port-A for surround (rear panel) */
13374 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13375 /* port-B for mic-in (rear panel) with vref */
13376 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13377 /* port-C for line-in (rear panel) */
13378 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13379 /* port-D for Front */
13380 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13381 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13382 /* port-E for HP out (front panel) */
13383 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13384 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013385 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013386 /* port-F for mic-in (front panel) with vref */
13387 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13388 /* port-G for CLFE (rear panel) */
13389 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13390 /* port-H for side (rear panel) */
13391 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13392 /* CD-in */
13393 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13394 /* route front mic to ADC1*/
13395 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13396 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13397 /* Unmute DAC0~3 & spdif out*/
13398 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13399 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13400 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13401 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013403
Kailang Yangdf694da2005-12-05 19:42:22 +010013404 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13405 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13406 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13407 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13408 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013409
Kailang Yangdf694da2005-12-05 19:42:22 +010013410 /* Unmute Stereo Mixer 15 */
13411 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13412 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13413 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013414 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013415
13416 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13417 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13418 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13419 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13420 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13421 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13422 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13423 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013424 /* hp used DAC 3 (Front) */
13425 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013426 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13427 { }
13428};
Takashi Iwai22309c32006-08-09 16:57:28 +020013429
13430static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13431 /*
13432 * Unmute ADC0 and set the default input to mic-in
13433 */
13434 /* port-A for surround (rear panel) */
13435 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13436 /* port-B for mic-in (rear panel) with vref */
13437 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13438 /* port-C for line-in (rear panel) */
13439 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13440 /* port-D for Front */
13441 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13442 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13443 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013444 /* this has to be set to VREF80 */
13445 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013446 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013447 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013448 /* port-F for mic-in (front panel) with vref */
13449 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13450 /* port-G for CLFE (rear panel) */
13451 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13452 /* port-H for side (rear panel) */
13453 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13454 /* CD-in */
13455 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13456 /* route front mic to ADC1*/
13457 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13458 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13459 /* Unmute DAC0~3 & spdif out*/
13460 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13461 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13462 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13463 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013465
Takashi Iwai22309c32006-08-09 16:57:28 +020013466 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13467 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13468 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13469 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13470 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013471
Takashi Iwai22309c32006-08-09 16:57:28 +020013472 /* Unmute Stereo Mixer 15 */
13473 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13474 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13475 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013476 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013477
13478 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13479 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13480 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13481 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13482 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13483 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13484 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13485 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013486 /* hp used DAC 3 (Front) */
13487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013488 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13489 { }
13490};
13491
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013492static struct hda_verb alc861_asus_init_verbs[] = {
13493 /*
13494 * Unmute ADC0 and set the default input to mic-in
13495 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013496 /* port-A for surround (rear panel)
13497 * according to codec#0 this is the HP jack
13498 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013499 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13500 /* route front PCM to HP */
13501 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13502 /* port-B for mic-in (rear panel) with vref */
13503 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13504 /* port-C for line-in (rear panel) */
13505 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13506 /* port-D for Front */
13507 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13508 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13509 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013510 /* this has to be set to VREF80 */
13511 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013512 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013513 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013514 /* port-F for mic-in (front panel) with vref */
13515 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13516 /* port-G for CLFE (rear panel) */
13517 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13518 /* port-H for side (rear panel) */
13519 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13520 /* CD-in */
13521 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13522 /* route front mic to ADC1*/
13523 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13524 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13525 /* Unmute DAC0~3 & spdif out*/
13526 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13527 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13528 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13529 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13530 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13531 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13532 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13533 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13534 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13535 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013536
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013537 /* Unmute Stereo Mixer 15 */
13538 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13539 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13540 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013541 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013542
13543 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13544 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13545 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13546 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13547 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13548 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13549 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13550 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013551 /* hp used DAC 3 (Front) */
13552 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013553 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13554 { }
13555};
13556
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013557/* additional init verbs for ASUS laptops */
13558static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13559 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13560 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13561 { }
13562};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013563
Kailang Yangdf694da2005-12-05 19:42:22 +010013564/*
13565 * generic initialization of ADC, input mixers and output mixers
13566 */
13567static struct hda_verb alc861_auto_init_verbs[] = {
13568 /*
13569 * Unmute ADC0 and set the default input to mic-in
13570 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013571 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013572 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013573
Kailang Yangdf694da2005-12-05 19:42:22 +010013574 /* Unmute DAC0~3 & spdif out*/
13575 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13576 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13577 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13578 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013580
Kailang Yangdf694da2005-12-05 19:42:22 +010013581 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13582 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13583 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13584 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13585 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013586
Kailang Yangdf694da2005-12-05 19:42:22 +010013587 /* Unmute Stereo Mixer 15 */
13588 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13589 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13591 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13592
13593 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13594 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13595 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13596 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13597 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13598 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13599 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13600 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13601
13602 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13603 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013604 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13605 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013606 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13607 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013608 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13609 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013610
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013611 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013612
13613 { }
13614};
13615
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013616static struct hda_verb alc861_toshiba_init_verbs[] = {
13617 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013618
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013619 { }
13620};
13621
13622/* toggle speaker-output according to the hp-jack state */
13623static void alc861_toshiba_automute(struct hda_codec *codec)
13624{
13625 unsigned int present;
13626
13627 present = snd_hda_codec_read(codec, 0x0f, 0,
13628 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013629 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13630 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13631 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13632 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013633}
13634
13635static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13636 unsigned int res)
13637{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013638 if ((res >> 26) == ALC880_HP_EVENT)
13639 alc861_toshiba_automute(codec);
13640}
13641
Kailang Yangdf694da2005-12-05 19:42:22 +010013642/* pcm configuration: identiacal with ALC880 */
13643#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13644#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13645#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13646#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13647
13648
13649#define ALC861_DIGOUT_NID 0x07
13650
13651static struct hda_channel_mode alc861_8ch_modes[1] = {
13652 { 8, NULL }
13653};
13654
13655static hda_nid_t alc861_dac_nids[4] = {
13656 /* front, surround, clfe, side */
13657 0x03, 0x06, 0x05, 0x04
13658};
13659
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013660static hda_nid_t alc660_dac_nids[3] = {
13661 /* front, clfe, surround */
13662 0x03, 0x05, 0x06
13663};
13664
Kailang Yangdf694da2005-12-05 19:42:22 +010013665static hda_nid_t alc861_adc_nids[1] = {
13666 /* ADC0-2 */
13667 0x08,
13668};
13669
13670static struct hda_input_mux alc861_capture_source = {
13671 .num_items = 5,
13672 .items = {
13673 { "Mic", 0x0 },
13674 { "Front Mic", 0x3 },
13675 { "Line", 0x1 },
13676 { "CD", 0x4 },
13677 { "Mixer", 0x5 },
13678 },
13679};
13680
13681/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013682static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13683 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013684{
13685 int i;
13686 hda_nid_t nid;
13687
13688 spec->multiout.dac_nids = spec->private_dac_nids;
13689 for (i = 0; i < cfg->line_outs; i++) {
13690 nid = cfg->line_out_pins[i];
13691 if (nid) {
13692 if (i >= ARRAY_SIZE(alc861_dac_nids))
13693 continue;
13694 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13695 }
13696 }
13697 spec->multiout.num_dacs = cfg->line_outs;
13698 return 0;
13699}
13700
13701/* add playback controls from the parsed DAC table */
13702static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13703 const struct auto_pin_cfg *cfg)
13704{
13705 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013706 static const char *chname[4] = {
13707 "Front", "Surround", NULL /*CLFE*/, "Side"
13708 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013709 hda_nid_t nid;
13710 int i, idx, err;
13711
13712 for (i = 0; i < cfg->line_outs; i++) {
13713 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013714 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013715 continue;
13716 if (nid == 0x05) {
13717 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013718 err = add_control(spec, ALC_CTL_BIND_MUTE,
13719 "Center Playback Switch",
13720 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13721 HDA_OUTPUT));
13722 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013723 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013724 err = add_control(spec, ALC_CTL_BIND_MUTE,
13725 "LFE Playback Switch",
13726 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13727 HDA_OUTPUT));
13728 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013729 return err;
13730 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013731 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13732 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013733 if (nid == alc861_dac_nids[idx])
13734 break;
13735 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013736 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13737 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13738 HDA_OUTPUT));
13739 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013740 return err;
13741 }
13742 }
13743 return 0;
13744}
13745
13746static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13747{
13748 int err;
13749 hda_nid_t nid;
13750
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013751 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013752 return 0;
13753
13754 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13755 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013756 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13757 "Headphone Playback Switch",
13758 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13759 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013760 return err;
13761 spec->multiout.hp_nid = nid;
13762 }
13763 return 0;
13764}
13765
13766/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013767static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13768 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013769{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013770 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013771 int i, err, idx, idx1;
13772
13773 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013774 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013775 case 0x0c:
13776 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013777 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013778 break;
13779 case 0x0f:
13780 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013781 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013782 break;
13783 case 0x0d:
13784 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013785 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013786 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013787 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013788 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013789 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013790 break;
13791 case 0x11:
13792 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013793 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013794 break;
13795 default:
13796 continue;
13797 }
13798
Takashi Iwai4a471b72005-12-07 13:56:29 +010013799 err = new_analog_input(spec, cfg->input_pins[i],
13800 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013801 if (err < 0)
13802 return err;
13803
Takashi Iwai4a471b72005-12-07 13:56:29 +010013804 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013805 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013806 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013807 }
13808 return 0;
13809}
13810
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013811static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13812 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013813 int pin_type, int dac_idx)
13814{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013815 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13816 pin_type);
13817 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13818 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013819}
13820
13821static void alc861_auto_init_multi_out(struct hda_codec *codec)
13822{
13823 struct alc_spec *spec = codec->spec;
13824 int i;
13825
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013826 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013827 for (i = 0; i < spec->autocfg.line_outs; i++) {
13828 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013829 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013830 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013831 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013832 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013833 }
13834}
13835
13836static void alc861_auto_init_hp_out(struct hda_codec *codec)
13837{
13838 struct alc_spec *spec = codec->spec;
13839 hda_nid_t pin;
13840
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013841 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013842 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013843 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13844 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013845 pin = spec->autocfg.speaker_pins[0];
13846 if (pin)
13847 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013848}
13849
13850static void alc861_auto_init_analog_input(struct hda_codec *codec)
13851{
13852 struct alc_spec *spec = codec->spec;
13853 int i;
13854
13855 for (i = 0; i < AUTO_PIN_LAST; i++) {
13856 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010013857 if (nid >= 0x0c && nid <= 0x11)
13858 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010013859 }
13860}
13861
13862/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013863/* return 1 if successful, 0 if the proper config is not found,
13864 * or a negative error code
13865 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013866static int alc861_parse_auto_config(struct hda_codec *codec)
13867{
13868 struct alc_spec *spec = codec->spec;
13869 int err;
13870 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13871
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013872 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13873 alc861_ignore);
13874 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013875 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013876 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013877 return 0; /* can't find valid BIOS pin config */
13878
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013879 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13880 if (err < 0)
13881 return err;
13882 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13883 if (err < 0)
13884 return err;
13885 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13886 if (err < 0)
13887 return err;
13888 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13889 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013890 return err;
13891
13892 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13893
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013894 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013895 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13896
Takashi Iwai603c4012008-07-30 15:01:44 +020013897 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013898 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013899
Takashi Iwaid88897e2008-10-31 15:01:37 +010013900 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013901
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013902 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013903 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013904
13905 spec->adc_nids = alc861_adc_nids;
13906 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013907 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013908
13909 return 1;
13910}
13911
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013912/* additional initialization for auto-configuration model */
13913static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013914{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013915 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013916 alc861_auto_init_multi_out(codec);
13917 alc861_auto_init_hp_out(codec);
13918 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013919 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013920 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013921}
13922
Takashi Iwaicb53c622007-08-10 17:21:45 +020013923#ifdef CONFIG_SND_HDA_POWER_SAVE
13924static struct hda_amp_list alc861_loopbacks[] = {
13925 { 0x15, HDA_INPUT, 0 },
13926 { 0x15, HDA_INPUT, 1 },
13927 { 0x15, HDA_INPUT, 2 },
13928 { 0x15, HDA_INPUT, 3 },
13929 { } /* end */
13930};
13931#endif
13932
Kailang Yangdf694da2005-12-05 19:42:22 +010013933
13934/*
13935 * configuration and preset
13936 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013937static const char *alc861_models[ALC861_MODEL_LAST] = {
13938 [ALC861_3ST] = "3stack",
13939 [ALC660_3ST] = "3stack-660",
13940 [ALC861_3ST_DIG] = "3stack-dig",
13941 [ALC861_6ST_DIG] = "6stack-dig",
13942 [ALC861_UNIWILL_M31] = "uniwill-m31",
13943 [ALC861_TOSHIBA] = "toshiba",
13944 [ALC861_ASUS] = "asus",
13945 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13946 [ALC861_AUTO] = "auto",
13947};
13948
13949static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013950 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013951 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13952 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13953 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013954 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013955 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013956 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013957 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13958 * Any other models that need this preset?
13959 */
13960 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013961 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13962 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013963 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13964 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13965 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13966 /* FIXME: the below seems conflict */
13967 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13968 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13969 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013970 {}
13971};
13972
13973static struct alc_config_preset alc861_presets[] = {
13974 [ALC861_3ST] = {
13975 .mixers = { alc861_3ST_mixer },
13976 .init_verbs = { alc861_threestack_init_verbs },
13977 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13978 .dac_nids = alc861_dac_nids,
13979 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13980 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013981 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013982 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13983 .adc_nids = alc861_adc_nids,
13984 .input_mux = &alc861_capture_source,
13985 },
13986 [ALC861_3ST_DIG] = {
13987 .mixers = { alc861_base_mixer },
13988 .init_verbs = { alc861_threestack_init_verbs },
13989 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13990 .dac_nids = alc861_dac_nids,
13991 .dig_out_nid = ALC861_DIGOUT_NID,
13992 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13993 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013994 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013995 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13996 .adc_nids = alc861_adc_nids,
13997 .input_mux = &alc861_capture_source,
13998 },
13999 [ALC861_6ST_DIG] = {
14000 .mixers = { alc861_base_mixer },
14001 .init_verbs = { alc861_base_init_verbs },
14002 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14003 .dac_nids = alc861_dac_nids,
14004 .dig_out_nid = ALC861_DIGOUT_NID,
14005 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14006 .channel_mode = alc861_8ch_modes,
14007 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14008 .adc_nids = alc861_adc_nids,
14009 .input_mux = &alc861_capture_source,
14010 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014011 [ALC660_3ST] = {
14012 .mixers = { alc861_3ST_mixer },
14013 .init_verbs = { alc861_threestack_init_verbs },
14014 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14015 .dac_nids = alc660_dac_nids,
14016 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14017 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014018 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014019 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14020 .adc_nids = alc861_adc_nids,
14021 .input_mux = &alc861_capture_source,
14022 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014023 [ALC861_UNIWILL_M31] = {
14024 .mixers = { alc861_uniwill_m31_mixer },
14025 .init_verbs = { alc861_uniwill_m31_init_verbs },
14026 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14027 .dac_nids = alc861_dac_nids,
14028 .dig_out_nid = ALC861_DIGOUT_NID,
14029 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14030 .channel_mode = alc861_uniwill_m31_modes,
14031 .need_dac_fix = 1,
14032 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14033 .adc_nids = alc861_adc_nids,
14034 .input_mux = &alc861_capture_source,
14035 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014036 [ALC861_TOSHIBA] = {
14037 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014038 .init_verbs = { alc861_base_init_verbs,
14039 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014040 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14041 .dac_nids = alc861_dac_nids,
14042 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14043 .channel_mode = alc883_3ST_2ch_modes,
14044 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14045 .adc_nids = alc861_adc_nids,
14046 .input_mux = &alc861_capture_source,
14047 .unsol_event = alc861_toshiba_unsol_event,
14048 .init_hook = alc861_toshiba_automute,
14049 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014050 [ALC861_ASUS] = {
14051 .mixers = { alc861_asus_mixer },
14052 .init_verbs = { alc861_asus_init_verbs },
14053 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14054 .dac_nids = alc861_dac_nids,
14055 .dig_out_nid = ALC861_DIGOUT_NID,
14056 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14057 .channel_mode = alc861_asus_modes,
14058 .need_dac_fix = 1,
14059 .hp_nid = 0x06,
14060 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14061 .adc_nids = alc861_adc_nids,
14062 .input_mux = &alc861_capture_source,
14063 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014064 [ALC861_ASUS_LAPTOP] = {
14065 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14066 .init_verbs = { alc861_asus_init_verbs,
14067 alc861_asus_laptop_init_verbs },
14068 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14069 .dac_nids = alc861_dac_nids,
14070 .dig_out_nid = ALC861_DIGOUT_NID,
14071 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14072 .channel_mode = alc883_3ST_2ch_modes,
14073 .need_dac_fix = 1,
14074 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14075 .adc_nids = alc861_adc_nids,
14076 .input_mux = &alc861_capture_source,
14077 },
14078};
Kailang Yangdf694da2005-12-05 19:42:22 +010014079
14080
14081static int patch_alc861(struct hda_codec *codec)
14082{
14083 struct alc_spec *spec;
14084 int board_config;
14085 int err;
14086
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014087 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014088 if (spec == NULL)
14089 return -ENOMEM;
14090
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014091 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014092
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014093 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14094 alc861_models,
14095 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014096
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014097 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014098 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14099 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014100 board_config = ALC861_AUTO;
14101 }
14102
14103 if (board_config == ALC861_AUTO) {
14104 /* automatic parse from the BIOS config */
14105 err = alc861_parse_auto_config(codec);
14106 if (err < 0) {
14107 alc_free(codec);
14108 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014109 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014110 printk(KERN_INFO
14111 "hda_codec: Cannot set up configuration "
14112 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014113 board_config = ALC861_3ST_DIG;
14114 }
14115 }
14116
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014117 err = snd_hda_attach_beep_device(codec, 0x23);
14118 if (err < 0) {
14119 alc_free(codec);
14120 return err;
14121 }
14122
Kailang Yangdf694da2005-12-05 19:42:22 +010014123 if (board_config != ALC861_AUTO)
14124 setup_preset(spec, &alc861_presets[board_config]);
14125
14126 spec->stream_name_analog = "ALC861 Analog";
14127 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14128 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14129
14130 spec->stream_name_digital = "ALC861 Digital";
14131 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14132 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14133
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014134 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14135
Takashi Iwai2134ea42008-01-10 16:53:55 +010014136 spec->vmaster_nid = 0x03;
14137
Kailang Yangdf694da2005-12-05 19:42:22 +010014138 codec->patch_ops = alc_patch_ops;
14139 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014140 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014141#ifdef CONFIG_SND_HDA_POWER_SAVE
14142 if (!spec->loopback.amplist)
14143 spec->loopback.amplist = alc861_loopbacks;
14144#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014145 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014146
Kailang Yangdf694da2005-12-05 19:42:22 +010014147 return 0;
14148}
14149
14150/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014151 * ALC861-VD support
14152 *
14153 * Based on ALC882
14154 *
14155 * In addition, an independent DAC
14156 */
14157#define ALC861VD_DIGOUT_NID 0x06
14158
14159static hda_nid_t alc861vd_dac_nids[4] = {
14160 /* front, surr, clfe, side surr */
14161 0x02, 0x03, 0x04, 0x05
14162};
14163
14164/* dac_nids for ALC660vd are in a different order - according to
14165 * Realtek's driver.
14166 * This should probably tesult in a different mixer for 6stack models
14167 * of ALC660vd codecs, but for now there is only 3stack mixer
14168 * - and it is the same as in 861vd.
14169 * adc_nids in ALC660vd are (is) the same as in 861vd
14170 */
14171static hda_nid_t alc660vd_dac_nids[3] = {
14172 /* front, rear, clfe, rear_surr */
14173 0x02, 0x04, 0x03
14174};
14175
14176static hda_nid_t alc861vd_adc_nids[1] = {
14177 /* ADC0 */
14178 0x09,
14179};
14180
Takashi Iwaie1406342008-02-11 18:32:32 +010014181static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14182
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014183/* input MUX */
14184/* FIXME: should be a matrix-type input source selection */
14185static struct hda_input_mux alc861vd_capture_source = {
14186 .num_items = 4,
14187 .items = {
14188 { "Mic", 0x0 },
14189 { "Front Mic", 0x1 },
14190 { "Line", 0x2 },
14191 { "CD", 0x4 },
14192 },
14193};
14194
Kailang Yang272a5272007-05-14 11:00:38 +020014195static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014196 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014197 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014198 { "Ext Mic", 0x0 },
14199 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014200 },
14201};
14202
Kailang Yangd1a991a2007-08-15 16:21:59 +020014203static struct hda_input_mux alc861vd_hp_capture_source = {
14204 .num_items = 2,
14205 .items = {
14206 { "Front Mic", 0x0 },
14207 { "ATAPI Mic", 0x1 },
14208 },
14209};
14210
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014211/*
14212 * 2ch mode
14213 */
14214static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14215 { 2, NULL }
14216};
14217
14218/*
14219 * 6ch mode
14220 */
14221static struct hda_verb alc861vd_6stack_ch6_init[] = {
14222 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14223 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14224 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14225 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14226 { } /* end */
14227};
14228
14229/*
14230 * 8ch mode
14231 */
14232static struct hda_verb alc861vd_6stack_ch8_init[] = {
14233 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14234 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14235 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14236 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14237 { } /* end */
14238};
14239
14240static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14241 { 6, alc861vd_6stack_ch6_init },
14242 { 8, alc861vd_6stack_ch8_init },
14243};
14244
14245static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14246 {
14247 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14248 .name = "Channel Mode",
14249 .info = alc_ch_mode_info,
14250 .get = alc_ch_mode_get,
14251 .put = alc_ch_mode_put,
14252 },
14253 { } /* end */
14254};
14255
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014256/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14257 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14258 */
14259static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14260 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14261 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14262
14263 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14264 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14265
14266 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14267 HDA_OUTPUT),
14268 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14269 HDA_OUTPUT),
14270 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14271 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14272
14273 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14274 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14275
14276 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14277
14278 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14280 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14281
14282 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14283 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14284 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14285
14286 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14287 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14288
14289 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14290 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14291
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014292 { } /* end */
14293};
14294
14295static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14296 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14297 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14298
14299 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14300
14301 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14303 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14304
14305 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14306 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14307 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14308
14309 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14310 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14311
14312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14313 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14314
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014315 { } /* end */
14316};
14317
Kailang Yangbdd148a2007-05-08 15:19:08 +020014318static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14319 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14320 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14321 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14322
14323 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14324
14325 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14327 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14328
14329 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14330 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14331 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14332
14333 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14334 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14335
14336 { } /* end */
14337};
14338
Tobin Davisb419f342008-03-07 11:57:51 +010014339/* Pin assignment: Speaker=0x14, HP = 0x15,
14340 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014341 */
14342static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014343 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14344 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014345 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14346 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014347 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14348 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14349 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14350 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14351 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14352 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014353 { } /* end */
14354};
14355
Kailang Yangd1a991a2007-08-15 16:21:59 +020014356/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14357 * Front Mic=0x18, ATAPI Mic = 0x19,
14358 */
14359static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14360 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14361 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14362 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14363 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14364 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14365 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14366 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14367 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014368
Kailang Yangd1a991a2007-08-15 16:21:59 +020014369 { } /* end */
14370};
14371
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014372/*
14373 * generic initialization of ADC, input mixers and output mixers
14374 */
14375static struct hda_verb alc861vd_volume_init_verbs[] = {
14376 /*
14377 * Unmute ADC0 and set the default input to mic-in
14378 */
14379 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14380 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14381
14382 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14383 * the analog-loopback mixer widget
14384 */
14385 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14389 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14390 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014391
14392 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14394 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014397
14398 /*
14399 * Set up output mixers (0x02 - 0x05)
14400 */
14401 /* set vol=0 to output mixers */
14402 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14403 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14404 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14405 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14406
14407 /* set up input amps for analog loopback */
14408 /* Amp Indices: DAC = 0, mixer = 1 */
14409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14410 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14411 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14412 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14415 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14417
14418 { }
14419};
14420
14421/*
14422 * 3-stack pin configuration:
14423 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14424 */
14425static struct hda_verb alc861vd_3stack_init_verbs[] = {
14426 /*
14427 * Set pin mode and muting
14428 */
14429 /* set front pin widgets 0x14 for output */
14430 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14431 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14432 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14433
14434 /* Mic (rear) pin: input vref at 80% */
14435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14436 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14437 /* Front Mic pin: input vref at 80% */
14438 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14439 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14440 /* Line In pin: input */
14441 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14442 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14443 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14444 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14445 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14446 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14447 /* CD pin widget for input */
14448 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14449
14450 { }
14451};
14452
14453/*
14454 * 6-stack pin configuration:
14455 */
14456static struct hda_verb alc861vd_6stack_init_verbs[] = {
14457 /*
14458 * Set pin mode and muting
14459 */
14460 /* set front pin widgets 0x14 for output */
14461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14462 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14463 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14464
14465 /* Rear Pin: output 1 (0x0d) */
14466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14468 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14469 /* CLFE Pin: output 2 (0x0e) */
14470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14471 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14472 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14473 /* Side Pin: output 3 (0x0f) */
14474 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14475 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14476 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14477
14478 /* Mic (rear) pin: input vref at 80% */
14479 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14481 /* Front Mic pin: input vref at 80% */
14482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14484 /* Line In pin: input */
14485 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14487 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14488 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14489 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14490 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14491 /* CD pin widget for input */
14492 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14493
14494 { }
14495};
14496
Kailang Yangbdd148a2007-05-08 15:19:08 +020014497static struct hda_verb alc861vd_eapd_verbs[] = {
14498 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14499 { }
14500};
14501
Kailang Yangf9423e72008-05-27 12:32:25 +020014502static struct hda_verb alc660vd_eapd_verbs[] = {
14503 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14504 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14505 { }
14506};
14507
Kailang Yangbdd148a2007-05-08 15:19:08 +020014508static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14511 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14512 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014513 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014514 {}
14515};
14516
14517/* toggle speaker-output according to the hp-jack state */
14518static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14519{
14520 unsigned int present;
14521 unsigned char bits;
14522
14523 present = snd_hda_codec_read(codec, 0x1b, 0,
14524 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014525 bits = present ? HDA_AMP_MUTE : 0;
14526 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14527 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014528}
14529
14530static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14531{
14532 unsigned int present;
14533 unsigned char bits;
14534
14535 present = snd_hda_codec_read(codec, 0x18, 0,
14536 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014537 bits = present ? HDA_AMP_MUTE : 0;
14538 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14539 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014540}
14541
14542static void alc861vd_lenovo_automute(struct hda_codec *codec)
14543{
14544 alc861vd_lenovo_hp_automute(codec);
14545 alc861vd_lenovo_mic_automute(codec);
14546}
14547
14548static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14549 unsigned int res)
14550{
14551 switch (res >> 26) {
14552 case ALC880_HP_EVENT:
14553 alc861vd_lenovo_hp_automute(codec);
14554 break;
14555 case ALC880_MIC_EVENT:
14556 alc861vd_lenovo_mic_automute(codec);
14557 break;
14558 }
14559}
14560
Kailang Yang272a5272007-05-14 11:00:38 +020014561static struct hda_verb alc861vd_dallas_verbs[] = {
14562 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14563 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14564 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14565 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14566
14567 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14568 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14569 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14570 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14571 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14572 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14573 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14574 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014575
Kailang Yang272a5272007-05-14 11:00:38 +020014576 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14577 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14578 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14579 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14580 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14581 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14582 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14583 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14584
14585 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14586 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14587 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14588 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14589 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14590 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14591 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14592 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14593
14594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14598
14599 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014600 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014601 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14602
14603 { } /* end */
14604};
14605
14606/* toggle speaker-output according to the hp-jack state */
14607static void alc861vd_dallas_automute(struct hda_codec *codec)
14608{
14609 unsigned int present;
14610
14611 present = snd_hda_codec_read(codec, 0x15, 0,
14612 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014613 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14614 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014615}
14616
14617static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14618{
14619 if ((res >> 26) == ALC880_HP_EVENT)
14620 alc861vd_dallas_automute(codec);
14621}
14622
Takashi Iwaicb53c622007-08-10 17:21:45 +020014623#ifdef CONFIG_SND_HDA_POWER_SAVE
14624#define alc861vd_loopbacks alc880_loopbacks
14625#endif
14626
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014627/* pcm configuration: identiacal with ALC880 */
14628#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14629#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14630#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14631#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14632
14633/*
14634 * configuration and preset
14635 */
14636static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14637 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014638 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014639 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014640 [ALC861VD_3ST] = "3stack",
14641 [ALC861VD_3ST_DIG] = "3stack-digout",
14642 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014643 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014644 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014645 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014646 [ALC861VD_AUTO] = "auto",
14647};
14648
14649static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014650 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14651 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014652 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014653 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014654 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014655 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014656 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014657 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014658 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014659 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014660 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014661 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014662 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014663 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014664 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014665 {}
14666};
14667
14668static struct alc_config_preset alc861vd_presets[] = {
14669 [ALC660VD_3ST] = {
14670 .mixers = { alc861vd_3st_mixer },
14671 .init_verbs = { alc861vd_volume_init_verbs,
14672 alc861vd_3stack_init_verbs },
14673 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14674 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014675 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14676 .channel_mode = alc861vd_3stack_2ch_modes,
14677 .input_mux = &alc861vd_capture_source,
14678 },
Mike Crash6963f842007-06-25 12:12:51 +020014679 [ALC660VD_3ST_DIG] = {
14680 .mixers = { alc861vd_3st_mixer },
14681 .init_verbs = { alc861vd_volume_init_verbs,
14682 alc861vd_3stack_init_verbs },
14683 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14684 .dac_nids = alc660vd_dac_nids,
14685 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014686 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14687 .channel_mode = alc861vd_3stack_2ch_modes,
14688 .input_mux = &alc861vd_capture_source,
14689 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014690 [ALC861VD_3ST] = {
14691 .mixers = { alc861vd_3st_mixer },
14692 .init_verbs = { alc861vd_volume_init_verbs,
14693 alc861vd_3stack_init_verbs },
14694 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14695 .dac_nids = alc861vd_dac_nids,
14696 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14697 .channel_mode = alc861vd_3stack_2ch_modes,
14698 .input_mux = &alc861vd_capture_source,
14699 },
14700 [ALC861VD_3ST_DIG] = {
14701 .mixers = { alc861vd_3st_mixer },
14702 .init_verbs = { alc861vd_volume_init_verbs,
14703 alc861vd_3stack_init_verbs },
14704 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14705 .dac_nids = alc861vd_dac_nids,
14706 .dig_out_nid = ALC861VD_DIGOUT_NID,
14707 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14708 .channel_mode = alc861vd_3stack_2ch_modes,
14709 .input_mux = &alc861vd_capture_source,
14710 },
14711 [ALC861VD_6ST_DIG] = {
14712 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14713 .init_verbs = { alc861vd_volume_init_verbs,
14714 alc861vd_6stack_init_verbs },
14715 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14716 .dac_nids = alc861vd_dac_nids,
14717 .dig_out_nid = ALC861VD_DIGOUT_NID,
14718 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14719 .channel_mode = alc861vd_6stack_modes,
14720 .input_mux = &alc861vd_capture_source,
14721 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014722 [ALC861VD_LENOVO] = {
14723 .mixers = { alc861vd_lenovo_mixer },
14724 .init_verbs = { alc861vd_volume_init_verbs,
14725 alc861vd_3stack_init_verbs,
14726 alc861vd_eapd_verbs,
14727 alc861vd_lenovo_unsol_verbs },
14728 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14729 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014730 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14731 .channel_mode = alc861vd_3stack_2ch_modes,
14732 .input_mux = &alc861vd_capture_source,
14733 .unsol_event = alc861vd_lenovo_unsol_event,
14734 .init_hook = alc861vd_lenovo_automute,
14735 },
Kailang Yang272a5272007-05-14 11:00:38 +020014736 [ALC861VD_DALLAS] = {
14737 .mixers = { alc861vd_dallas_mixer },
14738 .init_verbs = { alc861vd_dallas_verbs },
14739 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14740 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014741 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14742 .channel_mode = alc861vd_3stack_2ch_modes,
14743 .input_mux = &alc861vd_dallas_capture_source,
14744 .unsol_event = alc861vd_dallas_unsol_event,
14745 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014746 },
14747 [ALC861VD_HP] = {
14748 .mixers = { alc861vd_hp_mixer },
14749 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14750 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14751 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014752 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014753 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14754 .channel_mode = alc861vd_3stack_2ch_modes,
14755 .input_mux = &alc861vd_hp_capture_source,
14756 .unsol_event = alc861vd_dallas_unsol_event,
14757 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014758 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014759 [ALC660VD_ASUS_V1S] = {
14760 .mixers = { alc861vd_lenovo_mixer },
14761 .init_verbs = { alc861vd_volume_init_verbs,
14762 alc861vd_3stack_init_verbs,
14763 alc861vd_eapd_verbs,
14764 alc861vd_lenovo_unsol_verbs },
14765 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14766 .dac_nids = alc660vd_dac_nids,
14767 .dig_out_nid = ALC861VD_DIGOUT_NID,
14768 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14769 .channel_mode = alc861vd_3stack_2ch_modes,
14770 .input_mux = &alc861vd_capture_source,
14771 .unsol_event = alc861vd_lenovo_unsol_event,
14772 .init_hook = alc861vd_lenovo_automute,
14773 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014774};
14775
14776/*
14777 * BIOS auto configuration
14778 */
14779static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14780 hda_nid_t nid, int pin_type, int dac_idx)
14781{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014782 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014783}
14784
14785static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14786{
14787 struct alc_spec *spec = codec->spec;
14788 int i;
14789
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014790 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014791 for (i = 0; i <= HDA_SIDE; i++) {
14792 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014793 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014794 if (nid)
14795 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014796 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014797 }
14798}
14799
14800
14801static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14802{
14803 struct alc_spec *spec = codec->spec;
14804 hda_nid_t pin;
14805
14806 pin = spec->autocfg.hp_pins[0];
14807 if (pin) /* connect to front and use dac 0 */
14808 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014809 pin = spec->autocfg.speaker_pins[0];
14810 if (pin)
14811 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014812}
14813
14814#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14815#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14816
14817static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14818{
14819 struct alc_spec *spec = codec->spec;
14820 int i;
14821
14822 for (i = 0; i < AUTO_PIN_LAST; i++) {
14823 hda_nid_t nid = spec->autocfg.input_pins[i];
14824 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010014825 alc_set_input_pin(codec, nid, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014826 if (nid != ALC861VD_PIN_CD_NID)
14827 snd_hda_codec_write(codec, nid, 0,
14828 AC_VERB_SET_AMP_GAIN_MUTE,
14829 AMP_OUT_MUTE);
14830 }
14831 }
14832}
14833
Takashi Iwaif511b012008-08-15 16:46:42 +020014834#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14835
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014836#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14837#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14838
14839/* add playback controls from the parsed DAC table */
14840/* Based on ALC880 version. But ALC861VD has separate,
14841 * different NIDs for mute/unmute switch and volume control */
14842static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14843 const struct auto_pin_cfg *cfg)
14844{
14845 char name[32];
14846 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14847 hda_nid_t nid_v, nid_s;
14848 int i, err;
14849
14850 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014851 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014852 continue;
14853 nid_v = alc861vd_idx_to_mixer_vol(
14854 alc880_dac_to_idx(
14855 spec->multiout.dac_nids[i]));
14856 nid_s = alc861vd_idx_to_mixer_switch(
14857 alc880_dac_to_idx(
14858 spec->multiout.dac_nids[i]));
14859
14860 if (i == 2) {
14861 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014862 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14863 "Center Playback Volume",
14864 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14865 HDA_OUTPUT));
14866 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014867 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014868 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14869 "LFE Playback Volume",
14870 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14871 HDA_OUTPUT));
14872 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014873 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014874 err = add_control(spec, ALC_CTL_BIND_MUTE,
14875 "Center Playback Switch",
14876 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14877 HDA_INPUT));
14878 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014879 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014880 err = add_control(spec, ALC_CTL_BIND_MUTE,
14881 "LFE Playback Switch",
14882 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14883 HDA_INPUT));
14884 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014885 return err;
14886 } else {
14887 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014888 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14889 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14890 HDA_OUTPUT));
14891 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014892 return err;
14893 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014894 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014895 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014896 HDA_INPUT));
14897 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014898 return err;
14899 }
14900 }
14901 return 0;
14902}
14903
14904/* add playback controls for speaker and HP outputs */
14905/* Based on ALC880 version. But ALC861VD has separate,
14906 * different NIDs for mute/unmute switch and volume control */
14907static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14908 hda_nid_t pin, const char *pfx)
14909{
14910 hda_nid_t nid_v, nid_s;
14911 int err;
14912 char name[32];
14913
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014914 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014915 return 0;
14916
14917 if (alc880_is_fixed_pin(pin)) {
14918 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14919 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014920 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014921 spec->multiout.hp_nid = nid_v;
14922 else
14923 spec->multiout.extra_out_nid[0] = nid_v;
14924 /* control HP volume/switch on the output mixer amp */
14925 nid_v = alc861vd_idx_to_mixer_vol(
14926 alc880_fixed_pin_idx(pin));
14927 nid_s = alc861vd_idx_to_mixer_switch(
14928 alc880_fixed_pin_idx(pin));
14929
14930 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014931 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14932 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14933 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014934 return err;
14935 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014936 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14937 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14938 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014939 return err;
14940 } else if (alc880_is_multi_pin(pin)) {
14941 /* set manual connection */
14942 /* we have only a switch on HP-out PIN */
14943 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014944 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14945 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14946 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014947 return err;
14948 }
14949 return 0;
14950}
14951
14952/* parse the BIOS configuration and set up the alc_spec
14953 * return 1 if successful, 0 if the proper config is not found,
14954 * or a negative error code
14955 * Based on ALC880 version - had to change it to override
14956 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14957static int alc861vd_parse_auto_config(struct hda_codec *codec)
14958{
14959 struct alc_spec *spec = codec->spec;
14960 int err;
14961 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14962
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014963 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14964 alc861vd_ignore);
14965 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014966 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014967 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014968 return 0; /* can't find valid BIOS pin config */
14969
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014970 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14971 if (err < 0)
14972 return err;
14973 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14974 if (err < 0)
14975 return err;
14976 err = alc861vd_auto_create_extra_out(spec,
14977 spec->autocfg.speaker_pins[0],
14978 "Speaker");
14979 if (err < 0)
14980 return err;
14981 err = alc861vd_auto_create_extra_out(spec,
14982 spec->autocfg.hp_pins[0],
14983 "Headphone");
14984 if (err < 0)
14985 return err;
14986 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14987 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014988 return err;
14989
14990 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14991
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014992 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014993 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14994
Takashi Iwai603c4012008-07-30 15:01:44 +020014995 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014996 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014997
Takashi Iwaid88897e2008-10-31 15:01:37 +010014998 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014999
15000 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015001 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015002
Takashi Iwai776e1842007-08-29 15:07:11 +020015003 err = alc_auto_add_mic_boost(codec);
15004 if (err < 0)
15005 return err;
15006
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015007 return 1;
15008}
15009
15010/* additional initialization for auto-configuration model */
15011static void alc861vd_auto_init(struct hda_codec *codec)
15012{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015013 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015014 alc861vd_auto_init_multi_out(codec);
15015 alc861vd_auto_init_hp_out(codec);
15016 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015017 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015018 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015019 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015020}
15021
15022static int patch_alc861vd(struct hda_codec *codec)
15023{
15024 struct alc_spec *spec;
15025 int err, board_config;
15026
15027 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15028 if (spec == NULL)
15029 return -ENOMEM;
15030
15031 codec->spec = spec;
15032
15033 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15034 alc861vd_models,
15035 alc861vd_cfg_tbl);
15036
15037 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15038 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
15039 "ALC861VD, trying auto-probe from BIOS...\n");
15040 board_config = ALC861VD_AUTO;
15041 }
15042
15043 if (board_config == ALC861VD_AUTO) {
15044 /* automatic parse from the BIOS config */
15045 err = alc861vd_parse_auto_config(codec);
15046 if (err < 0) {
15047 alc_free(codec);
15048 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015049 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015050 printk(KERN_INFO
15051 "hda_codec: Cannot set up configuration "
15052 "from BIOS. Using base mode...\n");
15053 board_config = ALC861VD_3ST;
15054 }
15055 }
15056
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015057 err = snd_hda_attach_beep_device(codec, 0x23);
15058 if (err < 0) {
15059 alc_free(codec);
15060 return err;
15061 }
15062
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015063 if (board_config != ALC861VD_AUTO)
15064 setup_preset(spec, &alc861vd_presets[board_config]);
15065
Kailang Yang2f893282008-05-27 12:14:47 +020015066 if (codec->vendor_id == 0x10ec0660) {
15067 spec->stream_name_analog = "ALC660-VD Analog";
15068 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020015069 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015070 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015071 } else {
15072 spec->stream_name_analog = "ALC861VD Analog";
15073 spec->stream_name_digital = "ALC861VD Digital";
15074 }
15075
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015076 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15077 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15078
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015079 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15080 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15081
15082 spec->adc_nids = alc861vd_adc_nids;
15083 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015084 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015085 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015086
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015087 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015088 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015089
Takashi Iwai2134ea42008-01-10 16:53:55 +010015090 spec->vmaster_nid = 0x02;
15091
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015092 codec->patch_ops = alc_patch_ops;
15093
15094 if (board_config == ALC861VD_AUTO)
15095 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015096#ifdef CONFIG_SND_HDA_POWER_SAVE
15097 if (!spec->loopback.amplist)
15098 spec->loopback.amplist = alc861vd_loopbacks;
15099#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015100 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015101
15102 return 0;
15103}
15104
15105/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015106 * ALC662 support
15107 *
15108 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15109 * configuration. Each pin widget can choose any input DACs and a mixer.
15110 * Each ADC is connected from a mixer of all inputs. This makes possible
15111 * 6-channel independent captures.
15112 *
15113 * In addition, an independent DAC for the multi-playback (not used in this
15114 * driver yet).
15115 */
15116#define ALC662_DIGOUT_NID 0x06
15117#define ALC662_DIGIN_NID 0x0a
15118
15119static hda_nid_t alc662_dac_nids[4] = {
15120 /* front, rear, clfe, rear_surr */
15121 0x02, 0x03, 0x04
15122};
15123
15124static hda_nid_t alc662_adc_nids[1] = {
15125 /* ADC1-2 */
15126 0x09,
15127};
Takashi Iwaie1406342008-02-11 18:32:32 +010015128
Kailang Yang77a261b2008-02-19 11:38:05 +010015129static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010015130
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015131/* input MUX */
15132/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015133static struct hda_input_mux alc662_capture_source = {
15134 .num_items = 4,
15135 .items = {
15136 { "Mic", 0x0 },
15137 { "Front Mic", 0x1 },
15138 { "Line", 0x2 },
15139 { "CD", 0x4 },
15140 },
15141};
15142
15143static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15144 .num_items = 2,
15145 .items = {
15146 { "Mic", 0x1 },
15147 { "Line", 0x2 },
15148 },
15149};
Kailang Yang291702f2007-10-16 14:28:03 +020015150
15151static struct hda_input_mux alc662_eeepc_capture_source = {
15152 .num_items = 2,
15153 .items = {
15154 { "i-Mic", 0x1 },
15155 { "e-Mic", 0x0 },
15156 },
15157};
15158
Kailang Yang6dda9f42008-05-27 12:05:31 +020015159static struct hda_input_mux alc663_capture_source = {
15160 .num_items = 3,
15161 .items = {
15162 { "Mic", 0x0 },
15163 { "Front Mic", 0x1 },
15164 { "Line", 0x2 },
15165 },
15166};
15167
15168static struct hda_input_mux alc663_m51va_capture_source = {
15169 .num_items = 2,
15170 .items = {
15171 { "Ext-Mic", 0x0 },
15172 { "D-Mic", 0x9 },
15173 },
15174};
15175
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015176/*
15177 * 2ch mode
15178 */
15179static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15180 { 2, NULL }
15181};
15182
15183/*
15184 * 2ch mode
15185 */
15186static struct hda_verb alc662_3ST_ch2_init[] = {
15187 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15188 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15189 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15190 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15191 { } /* end */
15192};
15193
15194/*
15195 * 6ch mode
15196 */
15197static struct hda_verb alc662_3ST_ch6_init[] = {
15198 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15199 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15200 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15201 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15202 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15203 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15204 { } /* end */
15205};
15206
15207static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15208 { 2, alc662_3ST_ch2_init },
15209 { 6, alc662_3ST_ch6_init },
15210};
15211
15212/*
15213 * 2ch mode
15214 */
15215static struct hda_verb alc662_sixstack_ch6_init[] = {
15216 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15217 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15218 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15219 { } /* end */
15220};
15221
15222/*
15223 * 6ch mode
15224 */
15225static struct hda_verb alc662_sixstack_ch8_init[] = {
15226 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15227 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15228 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15229 { } /* end */
15230};
15231
15232static struct hda_channel_mode alc662_5stack_modes[2] = {
15233 { 2, alc662_sixstack_ch6_init },
15234 { 6, alc662_sixstack_ch8_init },
15235};
15236
15237/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15238 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15239 */
15240
15241static struct snd_kcontrol_new alc662_base_mixer[] = {
15242 /* output mixer control */
15243 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015244 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015245 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015246 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015247 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15248 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015249 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15250 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015251 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15252
15253 /*Input mixer control */
15254 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15255 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15256 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15257 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15258 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15259 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15260 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15261 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015262 { } /* end */
15263};
15264
15265static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15266 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015267 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015268 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15269 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15270 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15271 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15272 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15273 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15274 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15275 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15276 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015277 { } /* end */
15278};
15279
15280static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15281 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015282 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015283 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015284 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015285 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15286 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015287 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15288 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015289 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15290 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15291 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15292 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15293 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15296 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15297 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015298 { } /* end */
15299};
15300
15301static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15302 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15303 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015304 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15305 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015306 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15307 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15308 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15310 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015311 { } /* end */
15312};
15313
Kailang Yang291702f2007-10-16 14:28:03 +020015314static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015315 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015316
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015317 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15318 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015319
15320 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15321 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15322 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15323
15324 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15325 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15326 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15327 { } /* end */
15328};
15329
Kailang Yang8c427222008-01-10 13:03:59 +010015330static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015331 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15332 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015333 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15334 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15335 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15336 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15337 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15338 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015339 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015340 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15341 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15342 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15343 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15344 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15345 { } /* end */
15346};
15347
Kailang Yangf1d4e282008-08-26 14:03:29 +020015348static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15349 .ops = &snd_hda_bind_vol,
15350 .values = {
15351 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15352 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15353 0
15354 },
15355};
15356
15357static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15358 .ops = &snd_hda_bind_sw,
15359 .values = {
15360 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15361 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15362 0
15363 },
15364};
15365
Kailang Yang6dda9f42008-05-27 12:05:31 +020015366static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015367 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15368 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15370 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15371 { } /* end */
15372};
15373
15374static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15375 .ops = &snd_hda_bind_sw,
15376 .values = {
15377 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15378 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15379 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15380 0
15381 },
15382};
15383
15384static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15385 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15386 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15387 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15388 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15389 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15390 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15391
15392 { } /* end */
15393};
15394
15395static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15396 .ops = &snd_hda_bind_sw,
15397 .values = {
15398 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15399 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15400 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15401 0
15402 },
15403};
15404
15405static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15406 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15407 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15408 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15409 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15410 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15411 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15412 { } /* end */
15413};
15414
15415static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015416 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15417 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015418 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15419 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15420 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15421 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15422 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15423 { } /* end */
15424};
15425
15426static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15427 .ops = &snd_hda_bind_vol,
15428 .values = {
15429 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15430 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15431 0
15432 },
15433};
15434
15435static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15436 .ops = &snd_hda_bind_sw,
15437 .values = {
15438 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15439 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15440 0
15441 },
15442};
15443
15444static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15445 HDA_BIND_VOL("Master Playback Volume",
15446 &alc663_asus_two_bind_master_vol),
15447 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15448 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015449 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15450 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15451 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015452 { } /* end */
15453};
15454
15455static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15456 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15457 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15458 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015462 { } /* end */
15463};
15464
15465static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15466 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15467 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15468 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15469 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15470 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15471
15472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15474 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15475 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15476 { } /* end */
15477};
15478
15479static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15480 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15481 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15482 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15483
15484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15485 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15486 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15487 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15488 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15489 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15490 { } /* end */
15491};
15492
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015493static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15494 {
15495 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15496 .name = "Channel Mode",
15497 .info = alc_ch_mode_info,
15498 .get = alc_ch_mode_get,
15499 .put = alc_ch_mode_put,
15500 },
15501 { } /* end */
15502};
15503
15504static struct hda_verb alc662_init_verbs[] = {
15505 /* ADC: mute amp left and right */
15506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15507 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15508 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15509
Takashi Iwaicb53c622007-08-10 17:21:45 +020015510 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15511 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15512 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15513 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015515
Kailang Yangb60dd392007-09-20 12:50:29 +020015516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15520 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015522
15523 /* Front Pin: output 0 (0x0c) */
15524 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15525 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15526
15527 /* Rear Pin: output 1 (0x0d) */
15528 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15530
15531 /* CLFE Pin: output 2 (0x0e) */
15532 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15533 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15534
15535 /* Mic (rear) pin: input vref at 80% */
15536 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15537 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15538 /* Front Mic pin: input vref at 80% */
15539 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15540 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15541 /* Line In pin: input */
15542 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15543 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15544 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15545 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15546 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15547 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15548 /* CD pin widget for input */
15549 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15550
15551 /* FIXME: use matrix-type input source selection */
15552 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15553 /* Input mixer */
15554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15556 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15557 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015558
15559 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15560 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015563
15564 /* always trun on EAPD */
15565 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15566 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15567
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015568 { }
15569};
15570
15571static struct hda_verb alc662_sue_init_verbs[] = {
15572 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15573 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015574 {}
15575};
15576
15577static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15578 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15579 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15580 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015581};
15582
Kailang Yang8c427222008-01-10 13:03:59 +010015583/* Set Unsolicited Event*/
15584static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15585 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15586 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15587 {}
15588};
15589
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015590/*
15591 * generic initialization of ADC, input mixers and output mixers
15592 */
15593static struct hda_verb alc662_auto_init_verbs[] = {
15594 /*
15595 * Unmute ADC and set the default input to mic-in
15596 */
15597 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15598 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15599
15600 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15601 * mixer widget
15602 * Note: PASD motherboards uses the Line In 2 as the input for front
15603 * panel mic (mic 2)
15604 */
15605 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015606 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15607 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15608 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15609 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15610 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015611
15612 /*
15613 * Set up output mixers (0x0c - 0x0f)
15614 */
15615 /* set vol=0 to output mixers */
15616 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15617 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15618 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15619
15620 /* set up input amps for analog loopback */
15621 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15624 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15625 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15626 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15627 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015628
15629
15630 /* FIXME: use matrix-type input source selection */
15631 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15632 /* Input mixer */
15633 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015635 { }
15636};
15637
Takashi Iwai24fb9172008-09-02 14:48:20 +020015638/* additional verbs for ALC663 */
15639static struct hda_verb alc663_auto_init_verbs[] = {
15640 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15641 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15642 { }
15643};
15644
Kailang Yang6dda9f42008-05-27 12:05:31 +020015645static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015646 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15647 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015648 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15649 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015650 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15651 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15652 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015653 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15654 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15655 {}
15656};
15657
Kailang Yangf1d4e282008-08-26 14:03:29 +020015658static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15659 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15660 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15661 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15662 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15664 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15665 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15666 {}
15667};
15668
15669static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15670 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15672 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15673 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15676 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15677 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15678 {}
15679};
15680
15681static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15682 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15684 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15685 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15686 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15687 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15688 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15689 {}
15690};
15691
15692static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15693 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15694 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15695 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15696 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15697 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15698 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15699 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15700 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15701 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15702 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15703 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15704 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15705 {}
15706};
15707
15708static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15709 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15710 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15711 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15712 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15713 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15714 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15715 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15716 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15717 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15718 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15719 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15720 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15721 {}
15722};
15723
Kailang Yang6dda9f42008-05-27 12:05:31 +020015724static struct hda_verb alc663_g71v_init_verbs[] = {
15725 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15726 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15727 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15728
15729 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15730 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15731 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15732
15733 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15734 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15735 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15736 {}
15737};
15738
15739static struct hda_verb alc663_g50v_init_verbs[] = {
15740 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15741 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15742 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15743
15744 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15745 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15746 {}
15747};
15748
Kailang Yangf1d4e282008-08-26 14:03:29 +020015749static struct hda_verb alc662_ecs_init_verbs[] = {
15750 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15752 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15753 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15754 {}
15755};
15756
Kailang Yangf1d4e282008-08-26 14:03:29 +020015757static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15758 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15759 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15760 { } /* end */
15761};
15762
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015763static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15764{
15765 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015766 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015767
15768 present = snd_hda_codec_read(codec, 0x14, 0,
15769 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015770 bits = present ? HDA_AMP_MUTE : 0;
15771 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15772 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015773}
15774
15775static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15776{
15777 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015778 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015779
15780 present = snd_hda_codec_read(codec, 0x1b, 0,
15781 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015782 bits = present ? HDA_AMP_MUTE : 0;
15783 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15784 HDA_AMP_MUTE, bits);
15785 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15786 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015787}
15788
15789static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15790 unsigned int res)
15791{
15792 if ((res >> 26) == ALC880_HP_EVENT)
15793 alc662_lenovo_101e_all_automute(codec);
15794 if ((res >> 26) == ALC880_FRONT_EVENT)
15795 alc662_lenovo_101e_ispeaker_automute(codec);
15796}
15797
Kailang Yang291702f2007-10-16 14:28:03 +020015798static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15799{
15800 unsigned int present;
15801
15802 present = snd_hda_codec_read(codec, 0x18, 0,
15803 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15804 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15805 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15806 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15807 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15808 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15809 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15810 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15811 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15812}
15813
15814/* unsolicited event for HP jack sensing */
15815static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15816 unsigned int res)
15817{
15818 if ((res >> 26) == ALC880_HP_EVENT)
15819 alc262_hippo1_automute( codec );
15820
15821 if ((res >> 26) == ALC880_MIC_EVENT)
15822 alc662_eeepc_mic_automute(codec);
15823}
15824
15825static void alc662_eeepc_inithook(struct hda_codec *codec)
15826{
15827 alc262_hippo1_automute( codec );
15828 alc662_eeepc_mic_automute(codec);
15829}
15830
Kailang Yang8c427222008-01-10 13:03:59 +010015831static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15832{
15833 unsigned int mute;
15834 unsigned int present;
15835
15836 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15837 present = snd_hda_codec_read(codec, 0x14, 0,
15838 AC_VERB_GET_PIN_SENSE, 0);
15839 present = (present & 0x80000000) != 0;
15840 if (present) {
15841 /* mute internal speaker */
15842 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015843 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015844 } else {
15845 /* unmute internal speaker if necessary */
15846 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15847 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015848 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015849 }
15850}
15851
15852/* unsolicited event for HP jack sensing */
15853static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15854 unsigned int res)
15855{
15856 if ((res >> 26) == ALC880_HP_EVENT)
15857 alc662_eeepc_ep20_automute(codec);
15858}
15859
15860static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15861{
15862 alc662_eeepc_ep20_automute(codec);
15863}
15864
Kailang Yang6dda9f42008-05-27 12:05:31 +020015865static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15866{
15867 unsigned int present;
15868 unsigned char bits;
15869
15870 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015871 AC_VERB_GET_PIN_SENSE, 0)
15872 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015873 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015874 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15875 AMP_IN_MUTE(0), bits);
15876 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15877 AMP_IN_MUTE(0), bits);
15878}
15879
15880static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15881{
15882 unsigned int present;
15883 unsigned char bits;
15884
15885 present = snd_hda_codec_read(codec, 0x21, 0,
15886 AC_VERB_GET_PIN_SENSE, 0)
15887 & AC_PINSENSE_PRESENCE;
15888 bits = present ? HDA_AMP_MUTE : 0;
15889 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15890 AMP_IN_MUTE(0), bits);
15891 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15892 AMP_IN_MUTE(0), bits);
15893 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15894 AMP_IN_MUTE(0), bits);
15895 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15896 AMP_IN_MUTE(0), bits);
15897}
15898
15899static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15900{
15901 unsigned int present;
15902 unsigned char bits;
15903
15904 present = snd_hda_codec_read(codec, 0x15, 0,
15905 AC_VERB_GET_PIN_SENSE, 0)
15906 & AC_PINSENSE_PRESENCE;
15907 bits = present ? HDA_AMP_MUTE : 0;
15908 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15909 AMP_IN_MUTE(0), bits);
15910 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15911 AMP_IN_MUTE(0), bits);
15912 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15913 AMP_IN_MUTE(0), bits);
15914 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15915 AMP_IN_MUTE(0), bits);
15916}
15917
15918static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15919{
15920 unsigned int present;
15921 unsigned char bits;
15922
15923 present = snd_hda_codec_read(codec, 0x1b, 0,
15924 AC_VERB_GET_PIN_SENSE, 0)
15925 & AC_PINSENSE_PRESENCE;
15926 bits = present ? 0 : PIN_OUT;
15927 snd_hda_codec_write(codec, 0x14, 0,
15928 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15929}
15930
15931static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15932{
15933 unsigned int present1, present2;
15934
15935 present1 = snd_hda_codec_read(codec, 0x21, 0,
15936 AC_VERB_GET_PIN_SENSE, 0)
15937 & AC_PINSENSE_PRESENCE;
15938 present2 = snd_hda_codec_read(codec, 0x15, 0,
15939 AC_VERB_GET_PIN_SENSE, 0)
15940 & AC_PINSENSE_PRESENCE;
15941
15942 if (present1 || present2) {
15943 snd_hda_codec_write_cache(codec, 0x14, 0,
15944 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15945 } else {
15946 snd_hda_codec_write_cache(codec, 0x14, 0,
15947 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15948 }
15949}
15950
15951static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15952{
15953 unsigned int present1, present2;
15954
15955 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15956 AC_VERB_GET_PIN_SENSE, 0)
15957 & AC_PINSENSE_PRESENCE;
15958 present2 = snd_hda_codec_read(codec, 0x15, 0,
15959 AC_VERB_GET_PIN_SENSE, 0)
15960 & AC_PINSENSE_PRESENCE;
15961
15962 if (present1 || present2) {
15963 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15964 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15965 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15966 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15967 } else {
15968 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15969 AMP_IN_MUTE(0), 0);
15970 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15971 AMP_IN_MUTE(0), 0);
15972 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015973}
15974
15975static void alc663_m51va_mic_automute(struct hda_codec *codec)
15976{
15977 unsigned int present;
15978
15979 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015980 AC_VERB_GET_PIN_SENSE, 0)
15981 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015982 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015983 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015984 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015985 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015986 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015987 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015988 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015989 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015990}
15991
15992static void alc663_m51va_unsol_event(struct hda_codec *codec,
15993 unsigned int res)
15994{
15995 switch (res >> 26) {
15996 case ALC880_HP_EVENT:
15997 alc663_m51va_speaker_automute(codec);
15998 break;
15999 case ALC880_MIC_EVENT:
16000 alc663_m51va_mic_automute(codec);
16001 break;
16002 }
16003}
16004
16005static void alc663_m51va_inithook(struct hda_codec *codec)
16006{
16007 alc663_m51va_speaker_automute(codec);
16008 alc663_m51va_mic_automute(codec);
16009}
16010
Kailang Yangf1d4e282008-08-26 14:03:29 +020016011/* ***************** Mode1 ******************************/
16012static void alc663_mode1_unsol_event(struct hda_codec *codec,
16013 unsigned int res)
16014{
16015 switch (res >> 26) {
16016 case ALC880_HP_EVENT:
16017 alc663_m51va_speaker_automute(codec);
16018 break;
16019 case ALC880_MIC_EVENT:
16020 alc662_eeepc_mic_automute(codec);
16021 break;
16022 }
16023}
16024
16025static void alc663_mode1_inithook(struct hda_codec *codec)
16026{
16027 alc663_m51va_speaker_automute(codec);
16028 alc662_eeepc_mic_automute(codec);
16029}
16030/* ***************** Mode2 ******************************/
16031static void alc662_mode2_unsol_event(struct hda_codec *codec,
16032 unsigned int res)
16033{
16034 switch (res >> 26) {
16035 case ALC880_HP_EVENT:
16036 alc662_f5z_speaker_automute(codec);
16037 break;
16038 case ALC880_MIC_EVENT:
16039 alc662_eeepc_mic_automute(codec);
16040 break;
16041 }
16042}
16043
16044static void alc662_mode2_inithook(struct hda_codec *codec)
16045{
16046 alc662_f5z_speaker_automute(codec);
16047 alc662_eeepc_mic_automute(codec);
16048}
16049/* ***************** Mode3 ******************************/
16050static void alc663_mode3_unsol_event(struct hda_codec *codec,
16051 unsigned int res)
16052{
16053 switch (res >> 26) {
16054 case ALC880_HP_EVENT:
16055 alc663_two_hp_m1_speaker_automute(codec);
16056 break;
16057 case ALC880_MIC_EVENT:
16058 alc662_eeepc_mic_automute(codec);
16059 break;
16060 }
16061}
16062
16063static void alc663_mode3_inithook(struct hda_codec *codec)
16064{
16065 alc663_two_hp_m1_speaker_automute(codec);
16066 alc662_eeepc_mic_automute(codec);
16067}
16068/* ***************** Mode4 ******************************/
16069static void alc663_mode4_unsol_event(struct hda_codec *codec,
16070 unsigned int res)
16071{
16072 switch (res >> 26) {
16073 case ALC880_HP_EVENT:
16074 alc663_21jd_two_speaker_automute(codec);
16075 break;
16076 case ALC880_MIC_EVENT:
16077 alc662_eeepc_mic_automute(codec);
16078 break;
16079 }
16080}
16081
16082static void alc663_mode4_inithook(struct hda_codec *codec)
16083{
16084 alc663_21jd_two_speaker_automute(codec);
16085 alc662_eeepc_mic_automute(codec);
16086}
16087/* ***************** Mode5 ******************************/
16088static void alc663_mode5_unsol_event(struct hda_codec *codec,
16089 unsigned int res)
16090{
16091 switch (res >> 26) {
16092 case ALC880_HP_EVENT:
16093 alc663_15jd_two_speaker_automute(codec);
16094 break;
16095 case ALC880_MIC_EVENT:
16096 alc662_eeepc_mic_automute(codec);
16097 break;
16098 }
16099}
16100
16101static void alc663_mode5_inithook(struct hda_codec *codec)
16102{
16103 alc663_15jd_two_speaker_automute(codec);
16104 alc662_eeepc_mic_automute(codec);
16105}
16106/* ***************** Mode6 ******************************/
16107static void alc663_mode6_unsol_event(struct hda_codec *codec,
16108 unsigned int res)
16109{
16110 switch (res >> 26) {
16111 case ALC880_HP_EVENT:
16112 alc663_two_hp_m2_speaker_automute(codec);
16113 break;
16114 case ALC880_MIC_EVENT:
16115 alc662_eeepc_mic_automute(codec);
16116 break;
16117 }
16118}
16119
16120static void alc663_mode6_inithook(struct hda_codec *codec)
16121{
16122 alc663_two_hp_m2_speaker_automute(codec);
16123 alc662_eeepc_mic_automute(codec);
16124}
16125
Kailang Yang6dda9f42008-05-27 12:05:31 +020016126static void alc663_g71v_hp_automute(struct hda_codec *codec)
16127{
16128 unsigned int present;
16129 unsigned char bits;
16130
16131 present = snd_hda_codec_read(codec, 0x21, 0,
16132 AC_VERB_GET_PIN_SENSE, 0)
16133 & AC_PINSENSE_PRESENCE;
16134 bits = present ? HDA_AMP_MUTE : 0;
16135 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16136 HDA_AMP_MUTE, bits);
16137 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16138 HDA_AMP_MUTE, bits);
16139}
16140
16141static void alc663_g71v_front_automute(struct hda_codec *codec)
16142{
16143 unsigned int present;
16144 unsigned char bits;
16145
16146 present = snd_hda_codec_read(codec, 0x15, 0,
16147 AC_VERB_GET_PIN_SENSE, 0)
16148 & AC_PINSENSE_PRESENCE;
16149 bits = present ? HDA_AMP_MUTE : 0;
16150 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16151 HDA_AMP_MUTE, bits);
16152}
16153
16154static void alc663_g71v_unsol_event(struct hda_codec *codec,
16155 unsigned int res)
16156{
16157 switch (res >> 26) {
16158 case ALC880_HP_EVENT:
16159 alc663_g71v_hp_automute(codec);
16160 break;
16161 case ALC880_FRONT_EVENT:
16162 alc663_g71v_front_automute(codec);
16163 break;
16164 case ALC880_MIC_EVENT:
16165 alc662_eeepc_mic_automute(codec);
16166 break;
16167 }
16168}
16169
16170static void alc663_g71v_inithook(struct hda_codec *codec)
16171{
16172 alc663_g71v_front_automute(codec);
16173 alc663_g71v_hp_automute(codec);
16174 alc662_eeepc_mic_automute(codec);
16175}
16176
16177static void alc663_g50v_unsol_event(struct hda_codec *codec,
16178 unsigned int res)
16179{
16180 switch (res >> 26) {
16181 case ALC880_HP_EVENT:
16182 alc663_m51va_speaker_automute(codec);
16183 break;
16184 case ALC880_MIC_EVENT:
16185 alc662_eeepc_mic_automute(codec);
16186 break;
16187 }
16188}
16189
16190static void alc663_g50v_inithook(struct hda_codec *codec)
16191{
16192 alc663_m51va_speaker_automute(codec);
16193 alc662_eeepc_mic_automute(codec);
16194}
16195
Kailang Yangf1d4e282008-08-26 14:03:29 +020016196/* bind hp and internal speaker mute (with plug check) */
16197static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16198 struct snd_ctl_elem_value *ucontrol)
16199{
16200 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16201 long *valp = ucontrol->value.integer.value;
16202 int change;
16203
16204 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16205 HDA_AMP_MUTE,
16206 valp[0] ? 0 : HDA_AMP_MUTE);
16207 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16208 HDA_AMP_MUTE,
16209 valp[1] ? 0 : HDA_AMP_MUTE);
16210 if (change)
16211 alc262_hippo1_automute(codec);
16212 return change;
16213}
16214
16215static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16216 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16217 {
16218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16219 .name = "Master Playback Switch",
16220 .info = snd_hda_mixer_amp_switch_info,
16221 .get = snd_hda_mixer_amp_switch_get,
16222 .put = alc662_ecs_master_sw_put,
16223 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16224 },
16225
16226 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16227 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16228 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16229
16230 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16231 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16232 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16233 { } /* end */
16234};
16235
Takashi Iwaicb53c622007-08-10 17:21:45 +020016236#ifdef CONFIG_SND_HDA_POWER_SAVE
16237#define alc662_loopbacks alc880_loopbacks
16238#endif
16239
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016240
16241/* pcm configuration: identiacal with ALC880 */
16242#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16243#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16244#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16245#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16246
16247/*
16248 * configuration and preset
16249 */
16250static const char *alc662_models[ALC662_MODEL_LAST] = {
16251 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16252 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16253 [ALC662_3ST_6ch] = "3stack-6ch",
16254 [ALC662_5ST_DIG] = "6stack-dig",
16255 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016256 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016257 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016258 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016259 [ALC663_ASUS_M51VA] = "m51va",
16260 [ALC663_ASUS_G71V] = "g71v",
16261 [ALC663_ASUS_H13] = "h13",
16262 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016263 [ALC663_ASUS_MODE1] = "asus-mode1",
16264 [ALC662_ASUS_MODE2] = "asus-mode2",
16265 [ALC663_ASUS_MODE3] = "asus-mode3",
16266 [ALC663_ASUS_MODE4] = "asus-mode4",
16267 [ALC663_ASUS_MODE5] = "asus-mode5",
16268 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016269 [ALC662_AUTO] = "auto",
16270};
16271
16272static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016273 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16274 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16275 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16276 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16277 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16278 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16279 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16280 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16281 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16282 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16283 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16284 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16285 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16286 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16287 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16288 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16289 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16290 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16291 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016292 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016293 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16294 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16295 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16296 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16297 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16298 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16299 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16300 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16301 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016302 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016303 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16304 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16305 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16306 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16307 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016308 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016309 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016310 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016311 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016312 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16313 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016314 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16315 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016316 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016317 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016318 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016319 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016320 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16321 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016322 {}
16323};
16324
16325static struct alc_config_preset alc662_presets[] = {
16326 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016327 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016328 .init_verbs = { alc662_init_verbs },
16329 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16330 .dac_nids = alc662_dac_nids,
16331 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016332 .dig_in_nid = ALC662_DIGIN_NID,
16333 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16334 .channel_mode = alc662_3ST_2ch_modes,
16335 .input_mux = &alc662_capture_source,
16336 },
16337 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016338 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016339 .init_verbs = { alc662_init_verbs },
16340 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16341 .dac_nids = alc662_dac_nids,
16342 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016343 .dig_in_nid = ALC662_DIGIN_NID,
16344 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16345 .channel_mode = alc662_3ST_6ch_modes,
16346 .need_dac_fix = 1,
16347 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016348 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016349 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016350 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016351 .init_verbs = { alc662_init_verbs },
16352 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16353 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016354 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16355 .channel_mode = alc662_3ST_6ch_modes,
16356 .need_dac_fix = 1,
16357 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016358 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016359 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016360 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016361 .init_verbs = { alc662_init_verbs },
16362 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16363 .dac_nids = alc662_dac_nids,
16364 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016365 .dig_in_nid = ALC662_DIGIN_NID,
16366 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16367 .channel_mode = alc662_5stack_modes,
16368 .input_mux = &alc662_capture_source,
16369 },
16370 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016371 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016372 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16373 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16374 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016375 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16376 .channel_mode = alc662_3ST_2ch_modes,
16377 .input_mux = &alc662_lenovo_101e_capture_source,
16378 .unsol_event = alc662_lenovo_101e_unsol_event,
16379 .init_hook = alc662_lenovo_101e_all_automute,
16380 },
Kailang Yang291702f2007-10-16 14:28:03 +020016381 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016382 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016383 .init_verbs = { alc662_init_verbs,
16384 alc662_eeepc_sue_init_verbs },
16385 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16386 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016387 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16388 .channel_mode = alc662_3ST_2ch_modes,
16389 .input_mux = &alc662_eeepc_capture_source,
16390 .unsol_event = alc662_eeepc_unsol_event,
16391 .init_hook = alc662_eeepc_inithook,
16392 },
Kailang Yang8c427222008-01-10 13:03:59 +010016393 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016394 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016395 alc662_chmode_mixer },
16396 .init_verbs = { alc662_init_verbs,
16397 alc662_eeepc_ep20_sue_init_verbs },
16398 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16399 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016400 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16401 .channel_mode = alc662_3ST_6ch_modes,
16402 .input_mux = &alc662_lenovo_101e_capture_source,
16403 .unsol_event = alc662_eeepc_ep20_unsol_event,
16404 .init_hook = alc662_eeepc_ep20_inithook,
16405 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016406 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016407 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016408 .init_verbs = { alc662_init_verbs,
16409 alc662_ecs_init_verbs },
16410 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16411 .dac_nids = alc662_dac_nids,
16412 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16413 .channel_mode = alc662_3ST_2ch_modes,
16414 .input_mux = &alc662_eeepc_capture_source,
16415 .unsol_event = alc662_eeepc_unsol_event,
16416 .init_hook = alc662_eeepc_inithook,
16417 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016418 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016419 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016420 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16421 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16422 .dac_nids = alc662_dac_nids,
16423 .dig_out_nid = ALC662_DIGOUT_NID,
16424 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16425 .channel_mode = alc662_3ST_2ch_modes,
16426 .input_mux = &alc663_m51va_capture_source,
16427 .unsol_event = alc663_m51va_unsol_event,
16428 .init_hook = alc663_m51va_inithook,
16429 },
16430 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016431 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016432 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16433 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16434 .dac_nids = alc662_dac_nids,
16435 .dig_out_nid = ALC662_DIGOUT_NID,
16436 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16437 .channel_mode = alc662_3ST_2ch_modes,
16438 .input_mux = &alc662_eeepc_capture_source,
16439 .unsol_event = alc663_g71v_unsol_event,
16440 .init_hook = alc663_g71v_inithook,
16441 },
16442 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016443 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016444 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16445 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16446 .dac_nids = alc662_dac_nids,
16447 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16448 .channel_mode = alc662_3ST_2ch_modes,
16449 .input_mux = &alc663_m51va_capture_source,
16450 .unsol_event = alc663_m51va_unsol_event,
16451 .init_hook = alc663_m51va_inithook,
16452 },
16453 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016454 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016455 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16456 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16457 .dac_nids = alc662_dac_nids,
16458 .dig_out_nid = ALC662_DIGOUT_NID,
16459 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16460 .channel_mode = alc662_3ST_6ch_modes,
16461 .input_mux = &alc663_capture_source,
16462 .unsol_event = alc663_g50v_unsol_event,
16463 .init_hook = alc663_g50v_inithook,
16464 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016465 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016466 .mixers = { alc663_m51va_mixer },
16467 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016468 .init_verbs = { alc662_init_verbs,
16469 alc663_21jd_amic_init_verbs },
16470 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16471 .hp_nid = 0x03,
16472 .dac_nids = alc662_dac_nids,
16473 .dig_out_nid = ALC662_DIGOUT_NID,
16474 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16475 .channel_mode = alc662_3ST_2ch_modes,
16476 .input_mux = &alc662_eeepc_capture_source,
16477 .unsol_event = alc663_mode1_unsol_event,
16478 .init_hook = alc663_mode1_inithook,
16479 },
16480 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016481 .mixers = { alc662_1bjd_mixer },
16482 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016483 .init_verbs = { alc662_init_verbs,
16484 alc662_1bjd_amic_init_verbs },
16485 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16486 .dac_nids = alc662_dac_nids,
16487 .dig_out_nid = ALC662_DIGOUT_NID,
16488 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16489 .channel_mode = alc662_3ST_2ch_modes,
16490 .input_mux = &alc662_eeepc_capture_source,
16491 .unsol_event = alc662_mode2_unsol_event,
16492 .init_hook = alc662_mode2_inithook,
16493 },
16494 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016495 .mixers = { alc663_two_hp_m1_mixer },
16496 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016497 .init_verbs = { alc662_init_verbs,
16498 alc663_two_hp_amic_m1_init_verbs },
16499 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16500 .hp_nid = 0x03,
16501 .dac_nids = alc662_dac_nids,
16502 .dig_out_nid = ALC662_DIGOUT_NID,
16503 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16504 .channel_mode = alc662_3ST_2ch_modes,
16505 .input_mux = &alc662_eeepc_capture_source,
16506 .unsol_event = alc663_mode3_unsol_event,
16507 .init_hook = alc663_mode3_inithook,
16508 },
16509 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016510 .mixers = { alc663_asus_21jd_clfe_mixer },
16511 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016512 .init_verbs = { alc662_init_verbs,
16513 alc663_21jd_amic_init_verbs},
16514 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16515 .hp_nid = 0x03,
16516 .dac_nids = alc662_dac_nids,
16517 .dig_out_nid = ALC662_DIGOUT_NID,
16518 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16519 .channel_mode = alc662_3ST_2ch_modes,
16520 .input_mux = &alc662_eeepc_capture_source,
16521 .unsol_event = alc663_mode4_unsol_event,
16522 .init_hook = alc663_mode4_inithook,
16523 },
16524 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016525 .mixers = { alc663_asus_15jd_clfe_mixer },
16526 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016527 .init_verbs = { alc662_init_verbs,
16528 alc663_15jd_amic_init_verbs },
16529 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16530 .hp_nid = 0x03,
16531 .dac_nids = alc662_dac_nids,
16532 .dig_out_nid = ALC662_DIGOUT_NID,
16533 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16534 .channel_mode = alc662_3ST_2ch_modes,
16535 .input_mux = &alc662_eeepc_capture_source,
16536 .unsol_event = alc663_mode5_unsol_event,
16537 .init_hook = alc663_mode5_inithook,
16538 },
16539 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016540 .mixers = { alc663_two_hp_m2_mixer },
16541 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016542 .init_verbs = { alc662_init_verbs,
16543 alc663_two_hp_amic_m2_init_verbs },
16544 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16545 .hp_nid = 0x03,
16546 .dac_nids = alc662_dac_nids,
16547 .dig_out_nid = ALC662_DIGOUT_NID,
16548 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16549 .channel_mode = alc662_3ST_2ch_modes,
16550 .input_mux = &alc662_eeepc_capture_source,
16551 .unsol_event = alc663_mode6_unsol_event,
16552 .init_hook = alc663_mode6_inithook,
16553 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016554};
16555
16556
16557/*
16558 * BIOS auto configuration
16559 */
16560
16561/* add playback controls from the parsed DAC table */
16562static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16563 const struct auto_pin_cfg *cfg)
16564{
16565 char name[32];
16566 static const char *chname[4] = {
16567 "Front", "Surround", NULL /*CLFE*/, "Side"
16568 };
16569 hda_nid_t nid;
16570 int i, err;
16571
16572 for (i = 0; i < cfg->line_outs; i++) {
16573 if (!spec->multiout.dac_nids[i])
16574 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016575 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016576 if (i == 2) {
16577 /* Center/LFE */
16578 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16579 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016580 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16581 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016582 if (err < 0)
16583 return err;
16584 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16585 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016586 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16587 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016588 if (err < 0)
16589 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016590 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016591 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016592 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016593 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016594 if (err < 0)
16595 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016596 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016597 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016598 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016599 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016600 if (err < 0)
16601 return err;
16602 } else {
16603 sprintf(name, "%s Playback Volume", chname[i]);
16604 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016605 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16606 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016607 if (err < 0)
16608 return err;
16609 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016610 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16611 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16612 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016613 if (err < 0)
16614 return err;
16615 }
16616 }
16617 return 0;
16618}
16619
16620/* add playback controls for speaker and HP outputs */
16621static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16622 const char *pfx)
16623{
16624 hda_nid_t nid;
16625 int err;
16626 char name[32];
16627
16628 if (!pin)
16629 return 0;
16630
Takashi Iwai24fb9172008-09-02 14:48:20 +020016631 if (pin == 0x17) {
16632 /* ALC663 has a mono output pin on 0x17 */
16633 sprintf(name, "%s Playback Switch", pfx);
16634 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16635 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16636 return err;
16637 }
16638
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016639 if (alc880_is_fixed_pin(pin)) {
16640 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016641 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016642 /* specify the DAC as the extra output */
16643 if (!spec->multiout.hp_nid)
16644 spec->multiout.hp_nid = nid;
16645 else
16646 spec->multiout.extra_out_nid[0] = nid;
16647 /* control HP volume/switch on the output mixer amp */
16648 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16649 sprintf(name, "%s Playback Volume", pfx);
16650 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16651 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16652 if (err < 0)
16653 return err;
16654 sprintf(name, "%s Playback Switch", pfx);
16655 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16656 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16657 if (err < 0)
16658 return err;
16659 } else if (alc880_is_multi_pin(pin)) {
16660 /* set manual connection */
16661 /* we have only a switch on HP-out PIN */
16662 sprintf(name, "%s Playback Switch", pfx);
16663 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16664 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16665 if (err < 0)
16666 return err;
16667 }
16668 return 0;
16669}
16670
16671/* create playback/capture controls for input pins */
16672static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16673 const struct auto_pin_cfg *cfg)
16674{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016675 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016676 int i, err, idx;
16677
16678 for (i = 0; i < AUTO_PIN_LAST; i++) {
16679 if (alc880_is_input_pin(cfg->input_pins[i])) {
16680 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16681 err = new_analog_input(spec, cfg->input_pins[i],
16682 auto_pin_cfg_labels[i],
16683 idx, 0x0b);
16684 if (err < 0)
16685 return err;
16686 imux->items[imux->num_items].label =
16687 auto_pin_cfg_labels[i];
16688 imux->items[imux->num_items].index =
16689 alc880_input_pin_idx(cfg->input_pins[i]);
16690 imux->num_items++;
16691 }
16692 }
16693 return 0;
16694}
16695
16696static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16697 hda_nid_t nid, int pin_type,
16698 int dac_idx)
16699{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016700 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016701 /* need the manual connection? */
16702 if (alc880_is_multi_pin(nid)) {
16703 struct alc_spec *spec = codec->spec;
16704 int idx = alc880_multi_pin_idx(nid);
16705 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16706 AC_VERB_SET_CONNECT_SEL,
16707 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16708 }
16709}
16710
16711static void alc662_auto_init_multi_out(struct hda_codec *codec)
16712{
16713 struct alc_spec *spec = codec->spec;
16714 int i;
16715
Kailang Yang8c427222008-01-10 13:03:59 +010016716 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016717 for (i = 0; i <= HDA_SIDE; i++) {
16718 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016719 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016720 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016721 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016722 i);
16723 }
16724}
16725
16726static void alc662_auto_init_hp_out(struct hda_codec *codec)
16727{
16728 struct alc_spec *spec = codec->spec;
16729 hda_nid_t pin;
16730
16731 pin = spec->autocfg.hp_pins[0];
16732 if (pin) /* connect to front */
16733 /* use dac 0 */
16734 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016735 pin = spec->autocfg.speaker_pins[0];
16736 if (pin)
16737 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016738}
16739
16740#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16741#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16742
16743static void alc662_auto_init_analog_input(struct hda_codec *codec)
16744{
16745 struct alc_spec *spec = codec->spec;
16746 int i;
16747
16748 for (i = 0; i < AUTO_PIN_LAST; i++) {
16749 hda_nid_t nid = spec->autocfg.input_pins[i];
16750 if (alc662_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016751 alc_set_input_pin(codec, nid, i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016752 if (nid != ALC662_PIN_CD_NID)
16753 snd_hda_codec_write(codec, nid, 0,
16754 AC_VERB_SET_AMP_GAIN_MUTE,
16755 AMP_OUT_MUTE);
16756 }
16757 }
16758}
16759
Takashi Iwaif511b012008-08-15 16:46:42 +020016760#define alc662_auto_init_input_src alc882_auto_init_input_src
16761
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016762static int alc662_parse_auto_config(struct hda_codec *codec)
16763{
16764 struct alc_spec *spec = codec->spec;
16765 int err;
16766 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16767
16768 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16769 alc662_ignore);
16770 if (err < 0)
16771 return err;
16772 if (!spec->autocfg.line_outs)
16773 return 0; /* can't find valid BIOS pin config */
16774
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016775 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16776 if (err < 0)
16777 return err;
16778 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16779 if (err < 0)
16780 return err;
16781 err = alc662_auto_create_extra_out(spec,
16782 spec->autocfg.speaker_pins[0],
16783 "Speaker");
16784 if (err < 0)
16785 return err;
16786 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16787 "Headphone");
16788 if (err < 0)
16789 return err;
16790 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16791 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016792 return err;
16793
16794 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16795
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016796 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016797 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16798
Takashi Iwai603c4012008-07-30 15:01:44 +020016799 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016800 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016801
16802 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016803 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016804
Takashi Iwaid88897e2008-10-31 15:01:37 +010016805 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016806 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016807 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016808
16809 err = alc_auto_add_mic_boost(codec);
16810 if (err < 0)
16811 return err;
16812
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016813 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016814}
16815
16816/* additional initialization for auto-configuration model */
16817static void alc662_auto_init(struct hda_codec *codec)
16818{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016819 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016820 alc662_auto_init_multi_out(codec);
16821 alc662_auto_init_hp_out(codec);
16822 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016823 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016824 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016825 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016826}
16827
16828static int patch_alc662(struct hda_codec *codec)
16829{
16830 struct alc_spec *spec;
16831 int err, board_config;
16832
16833 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16834 if (!spec)
16835 return -ENOMEM;
16836
16837 codec->spec = spec;
16838
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016839 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16840
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016841 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16842 alc662_models,
16843 alc662_cfg_tbl);
16844 if (board_config < 0) {
16845 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16846 "trying auto-probe from BIOS...\n");
16847 board_config = ALC662_AUTO;
16848 }
16849
16850 if (board_config == ALC662_AUTO) {
16851 /* automatic parse from the BIOS config */
16852 err = alc662_parse_auto_config(codec);
16853 if (err < 0) {
16854 alc_free(codec);
16855 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016856 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016857 printk(KERN_INFO
16858 "hda_codec: Cannot set up configuration "
16859 "from BIOS. Using base mode...\n");
16860 board_config = ALC662_3ST_2ch_DIG;
16861 }
16862 }
16863
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016864 err = snd_hda_attach_beep_device(codec, 0x1);
16865 if (err < 0) {
16866 alc_free(codec);
16867 return err;
16868 }
16869
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016870 if (board_config != ALC662_AUTO)
16871 setup_preset(spec, &alc662_presets[board_config]);
16872
Kailang Yang6dda9f42008-05-27 12:05:31 +020016873 if (codec->vendor_id == 0x10ec0663) {
16874 spec->stream_name_analog = "ALC663 Analog";
16875 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016876 } else if (codec->vendor_id == 0x10ec0272) {
16877 spec->stream_name_analog = "ALC272 Analog";
16878 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016879 } else {
16880 spec->stream_name_analog = "ALC662 Analog";
16881 spec->stream_name_digital = "ALC662 Digital";
16882 }
16883
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016884 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16885 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16886
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016887 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16888 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16889
Takashi Iwaie1406342008-02-11 18:32:32 +010016890 spec->adc_nids = alc662_adc_nids;
16891 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16892 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016893 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016894
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016895 if (!spec->cap_mixer)
16896 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016897 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016898
Takashi Iwai2134ea42008-01-10 16:53:55 +010016899 spec->vmaster_nid = 0x02;
16900
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016901 codec->patch_ops = alc_patch_ops;
16902 if (board_config == ALC662_AUTO)
16903 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016904#ifdef CONFIG_SND_HDA_POWER_SAVE
16905 if (!spec->loopback.amplist)
16906 spec->loopback.amplist = alc662_loopbacks;
16907#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016908 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016909
16910 return 0;
16911}
16912
16913/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016914 * patch entries
16915 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016916static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016917 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016918 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016919 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016920 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016921 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016922 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016923 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016924 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016925 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16926 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16927 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016928 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16929 .patch = patch_alc883 },
16930 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16931 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016932 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016933 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016934 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016935 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016936 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16937 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016938 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016939 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016940 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016941 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016942 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16943 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016944 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016945 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016946 {} /* terminator */
16947};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016948
16949MODULE_ALIAS("snd-hda-codec-id:10ec*");
16950
16951MODULE_LICENSE("GPL");
16952MODULE_DESCRIPTION("Realtek HD-audio codec");
16953
16954static struct hda_codec_preset_list realtek_list = {
16955 .preset = snd_hda_preset_realtek,
16956 .owner = THIS_MODULE,
16957};
16958
16959static int __init patch_realtek_init(void)
16960{
16961 return snd_hda_add_codec_preset(&realtek_list);
16962}
16963
16964static void __exit patch_realtek_exit(void)
16965{
16966 snd_hda_delete_codec_preset(&realtek_list);
16967}
16968
16969module_init(patch_realtek_init)
16970module_exit(patch_realtek_exit)