blob: abddabc1efa80e29a066abf1f8cbbdf6ac84caf0 [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;
Takashi Iwaie044c392008-10-27 16:56:24 +0100333
334#ifdef SND_HDA_NEEDS_RESUME
335#define ALC_MAX_PINS 16
336 unsigned int num_pins;
337 hda_nid_t pin_nids[ALC_MAX_PINS];
338 unsigned int pin_cfgs[ALC_MAX_PINS];
339#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100340};
341
342/*
343 * configuration template - to be copied to the spec instance
344 */
345struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200346 struct snd_kcontrol_new *mixers[5]; /* should be identical size
347 * with spec
348 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100349 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100350 const struct hda_verb *init_verbs[5];
351 unsigned int num_dacs;
352 hda_nid_t *dac_nids;
353 hda_nid_t dig_out_nid; /* optional */
354 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800355 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100356 unsigned int num_adc_nids;
357 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100358 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100359 hda_nid_t dig_in_nid;
360 unsigned int num_channel_mode;
361 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200362 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200363 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100364 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100365 void (*unsol_event)(struct hda_codec *, unsigned int);
366 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200367#ifdef CONFIG_SND_HDA_POWER_SAVE
368 struct hda_amp_list *loopbacks;
369#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370};
371
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372
373/*
374 * input MUX handling
375 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200376static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
377 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378{
379 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
380 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200381 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
382 if (mux_idx >= spec->num_mux_defs)
383 mux_idx = 0;
384 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385}
386
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200387static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
388 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389{
390 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
391 struct alc_spec *spec = codec->spec;
392 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
393
394 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
395 return 0;
396}
397
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200398static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
399 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400{
401 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
402 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100403 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100405 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100406 hda_nid_t nid = spec->capsrc_nids ?
407 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408
Takashi Iwaicd896c32008-11-18 12:36:33 +0100409 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
410 imux = &spec->input_mux[mux_idx];
411
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200412 if (spec->capture_style &&
413 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100414 /* Matrix-mixer style (e.g. ALC882) */
415 unsigned int *cur_val = &spec->cur_mux[adc_idx];
416 unsigned int i, idx;
417
418 idx = ucontrol->value.enumerated.item[0];
419 if (idx >= imux->num_items)
420 idx = imux->num_items - 1;
421 if (*cur_val == idx)
422 return 0;
423 for (i = 0; i < imux->num_items; i++) {
424 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
425 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
426 imux->items[i].index,
427 HDA_AMP_MUTE, v);
428 }
429 *cur_val = idx;
430 return 1;
431 } else {
432 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100433 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100434 &spec->cur_mux[adc_idx]);
435 }
436}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200437
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438/*
439 * channel mode setting
440 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200441static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
442 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443{
444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
445 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100446 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
447 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448}
449
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200450static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
451 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452{
453 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
454 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100455 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200456 spec->num_channel_mode,
457 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458}
459
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200460static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
461 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462{
463 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
464 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200465 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
466 spec->num_channel_mode,
467 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200468 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200469 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
470 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471}
472
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100474 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200475 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100476 * being part of a format specifier. Maximum allowed length of a value is
477 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100478 *
479 * Note: some retasking pin complexes seem to ignore requests for input
480 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
481 * are requested. Therefore order this list so that this behaviour will not
482 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200483 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
484 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200485 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100486static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100487 "Mic 50pc bias", "Mic 80pc bias",
488 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100489};
490static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100491 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100492};
493/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200494 * in the pin being assumed to be exclusively an input or an output pin. In
495 * addition, "input" pins may or may not process the mic bias option
496 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
497 * accept requests for bias as of chip versions up to March 2006) and/or
498 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100499 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200500#define ALC_PIN_DIR_IN 0x00
501#define ALC_PIN_DIR_OUT 0x01
502#define ALC_PIN_DIR_INOUT 0x02
503#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
504#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100505
Kailang Yangea1fb292008-08-26 12:58:38 +0200506/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100507 * For each direction the minimum and maximum values are given.
508 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200509static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510 { 0, 2 }, /* ALC_PIN_DIR_IN */
511 { 3, 4 }, /* ALC_PIN_DIR_OUT */
512 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200513 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
514 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100515};
516#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
517#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
518#define alc_pin_mode_n_items(_dir) \
519 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
520
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200521static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
522 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200523{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100524 unsigned int item_num = uinfo->value.enumerated.item;
525 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
526
527 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200528 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100529 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
530
531 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
532 item_num = alc_pin_mode_min(dir);
533 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200534 return 0;
535}
536
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200537static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
538 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200539{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100540 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200541 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
542 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100543 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200544 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200545 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
546 AC_VERB_GET_PIN_WIDGET_CONTROL,
547 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200548
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100549 /* Find enumerated value for current pinctl setting */
550 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200553 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554 return 0;
555}
556
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200557static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
558 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100559{
560 signed int change;
561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
562 hda_nid_t nid = kcontrol->private_value & 0xffff;
563 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
564 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200565 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
566 AC_VERB_GET_PIN_WIDGET_CONTROL,
567 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100568
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200569 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570 val = alc_pin_mode_min(dir);
571
572 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100573 if (change) {
574 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200575 snd_hda_codec_write_cache(codec, nid, 0,
576 AC_VERB_SET_PIN_WIDGET_CONTROL,
577 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100578
Kailang Yangea1fb292008-08-26 12:58:38 +0200579 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100580 * for the requested pin mode. Enum values of 2 or less are
581 * input modes.
582 *
583 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200584 * reduces noise slightly (particularly on input) so we'll
585 * do it. However, having both input and output buffers
586 * enabled simultaneously doesn't seem to be problematic if
587 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100588 */
589 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200590 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
591 HDA_AMP_MUTE, HDA_AMP_MUTE);
592 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
593 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100594 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200595 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
596 HDA_AMP_MUTE, HDA_AMP_MUTE);
597 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
598 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100599 }
600 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200601 return change;
602}
603
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100604#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200605 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100606 .info = alc_pin_mode_info, \
607 .get = alc_pin_mode_get, \
608 .put = alc_pin_mode_put, \
609 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100610
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100611/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
612 * together using a mask with more than one bit set. This control is
613 * currently used only by the ALC260 test model. At this stage they are not
614 * needed for any "production" models.
615 */
616#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200617#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200618
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200619static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
620 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100621{
622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
623 hda_nid_t nid = kcontrol->private_value & 0xffff;
624 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
625 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200626 unsigned int val = snd_hda_codec_read(codec, nid, 0,
627 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100628
629 *valp = (val & mask) != 0;
630 return 0;
631}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200632static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100634{
635 signed int change;
636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
637 hda_nid_t nid = kcontrol->private_value & 0xffff;
638 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
639 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200640 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
641 AC_VERB_GET_GPIO_DATA,
642 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100643
644 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200645 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
646 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100647 gpio_data &= ~mask;
648 else
649 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200650 snd_hda_codec_write_cache(codec, nid, 0,
651 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100652
653 return change;
654}
655#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
656 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
657 .info = alc_gpio_data_info, \
658 .get = alc_gpio_data_get, \
659 .put = alc_gpio_data_put, \
660 .private_value = nid | (mask<<16) }
661#endif /* CONFIG_SND_DEBUG */
662
Jonathan Woithe92621f12006-02-28 11:47:47 +0100663/* A switch control to allow the enabling of the digital IO pins on the
664 * ALC260. This is incredibly simplistic; the intention of this control is
665 * to provide something in the test model allowing digital outputs to be
666 * identified if present. If models are found which can utilise these
667 * outputs a more complete mixer control can be devised for those models if
668 * necessary.
669 */
670#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200671#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200672
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200673static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
674 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100675{
676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
677 hda_nid_t nid = kcontrol->private_value & 0xffff;
678 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
679 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200680 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100681 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100682
683 *valp = (val & mask) != 0;
684 return 0;
685}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200686static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
687 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100688{
689 signed int change;
690 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
691 hda_nid_t nid = kcontrol->private_value & 0xffff;
692 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
693 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200694 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100695 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200696 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100697
698 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200699 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100700 if (val==0)
701 ctrl_data &= ~mask;
702 else
703 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200704 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
705 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100706
707 return change;
708}
709#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
710 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
711 .info = alc_spdif_ctrl_info, \
712 .get = alc_spdif_ctrl_get, \
713 .put = alc_spdif_ctrl_put, \
714 .private_value = nid | (mask<<16) }
715#endif /* CONFIG_SND_DEBUG */
716
Jonathan Woithef8225f62008-01-08 12:16:54 +0100717/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
718 * Again, this is only used in the ALC26x test models to help identify when
719 * the EAPD line must be asserted for features to work.
720 */
721#ifdef CONFIG_SND_DEBUG
722#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
723
724static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
725 struct snd_ctl_elem_value *ucontrol)
726{
727 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
728 hda_nid_t nid = kcontrol->private_value & 0xffff;
729 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
730 long *valp = ucontrol->value.integer.value;
731 unsigned int val = snd_hda_codec_read(codec, nid, 0,
732 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
733
734 *valp = (val & mask) != 0;
735 return 0;
736}
737
738static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
739 struct snd_ctl_elem_value *ucontrol)
740{
741 int change;
742 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
743 hda_nid_t nid = kcontrol->private_value & 0xffff;
744 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
745 long val = *ucontrol->value.integer.value;
746 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
747 AC_VERB_GET_EAPD_BTLENABLE,
748 0x00);
749
750 /* Set/unset the masked control bit(s) as needed */
751 change = (!val ? 0 : mask) != (ctrl_data & mask);
752 if (!val)
753 ctrl_data &= ~mask;
754 else
755 ctrl_data |= mask;
756 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
757 ctrl_data);
758
759 return change;
760}
761
762#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
763 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
764 .info = alc_eapd_ctrl_info, \
765 .get = alc_eapd_ctrl_get, \
766 .put = alc_eapd_ctrl_put, \
767 .private_value = nid | (mask<<16) }
768#endif /* CONFIG_SND_DEBUG */
769
Kailang Yangdf694da2005-12-05 19:42:22 +0100770/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100771 */
772static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
773{
774 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
775 return;
776 spec->mixers[spec->num_mixers++] = mix;
777}
778
779static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
780{
781 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
782 return;
783 spec->init_verbs[spec->num_init_verbs++] = verb;
784}
785
Takashi Iwaidaead532008-11-28 12:55:36 +0100786#ifdef CONFIG_PROC_FS
787/*
788 * hook for proc
789 */
790static void print_realtek_coef(struct snd_info_buffer *buffer,
791 struct hda_codec *codec, hda_nid_t nid)
792{
793 int coeff;
794
795 if (nid != 0x20)
796 return;
797 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
798 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
799 coeff = snd_hda_codec_read(codec, nid, 0,
800 AC_VERB_GET_COEF_INDEX, 0);
801 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
802}
803#else
804#define print_realtek_coef NULL
805#endif
806
Takashi Iwaid88897e2008-10-31 15:01:37 +0100807/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100808 * set up from the preset table
809 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200810static void setup_preset(struct alc_spec *spec,
811 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100812{
813 int i;
814
815 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100816 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100817 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200818 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
819 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100820 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200821
Kailang Yangdf694da2005-12-05 19:42:22 +0100822 spec->channel_mode = preset->channel_mode;
823 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200824 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100825
826 spec->multiout.max_channels = spec->channel_mode[0].channels;
827
828 spec->multiout.num_dacs = preset->num_dacs;
829 spec->multiout.dac_nids = preset->dac_nids;
830 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800831 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100832 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200833
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200834 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200835 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200836 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100837 spec->input_mux = preset->input_mux;
838
839 spec->num_adc_nids = preset->num_adc_nids;
840 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100841 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100842 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100843
844 spec->unsol_event = preset->unsol_event;
845 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200846#ifdef CONFIG_SND_HDA_POWER_SAVE
847 spec->loopback.amplist = preset->loopbacks;
848#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100849}
850
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200851/* Enable GPIO mask and set output */
852static struct hda_verb alc_gpio1_init_verbs[] = {
853 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
854 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
855 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
856 { }
857};
858
859static struct hda_verb alc_gpio2_init_verbs[] = {
860 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
861 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
862 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
863 { }
864};
865
Kailang Yangbdd148a2007-05-08 15:19:08 +0200866static struct hda_verb alc_gpio3_init_verbs[] = {
867 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
868 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
869 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
870 { }
871};
872
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200873/*
874 * Fix hardware PLL issue
875 * On some codecs, the analog PLL gating control must be off while
876 * the default value is 1.
877 */
878static void alc_fix_pll(struct hda_codec *codec)
879{
880 struct alc_spec *spec = codec->spec;
881 unsigned int val;
882
883 if (!spec->pll_nid)
884 return;
885 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
886 spec->pll_coef_idx);
887 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
888 AC_VERB_GET_PROC_COEF, 0);
889 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
890 spec->pll_coef_idx);
891 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
892 val & ~(1 << spec->pll_coef_bit));
893}
894
895static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
896 unsigned int coef_idx, unsigned int coef_bit)
897{
898 struct alc_spec *spec = codec->spec;
899 spec->pll_nid = nid;
900 spec->pll_coef_idx = coef_idx;
901 spec->pll_coef_bit = coef_bit;
902 alc_fix_pll(codec);
903}
904
Kailang Yangc9b58002007-10-16 14:30:01 +0200905static void alc_sku_automute(struct hda_codec *codec)
906{
907 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200908 unsigned int present;
909 unsigned int hp_nid = spec->autocfg.hp_pins[0];
910 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
911
912 /* need to execute and sync at first */
913 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
914 present = snd_hda_codec_read(codec, hp_nid, 0,
915 AC_VERB_GET_PIN_SENSE, 0);
916 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100917 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
918 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200919}
920
Takashi Iwai4605b712008-10-31 14:18:24 +0100921#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200922static void alc_mic_automute(struct hda_codec *codec)
923{
924 struct alc_spec *spec = codec->spec;
925 unsigned int present;
926 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
927 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
928 unsigned int mix_nid = spec->capsrc_nids[0];
929 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
930
931 capsrc_idx_mic = mic_nid - 0x18;
932 capsrc_idx_fmic = fmic_nid - 0x18;
933 present = snd_hda_codec_read(codec, mic_nid, 0,
934 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
935 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
936 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
937 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
938 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
939 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
940 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
941}
Takashi Iwai4605b712008-10-31 14:18:24 +0100942#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100943#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100944#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200945
Kailang Yangc9b58002007-10-16 14:30:01 +0200946/* unsolicited event for HP jack sensing */
947static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
948{
949 if (codec->vendor_id == 0x10ec0880)
950 res >>= 28;
951 else
952 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200953 if (res == ALC880_HP_EVENT)
954 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200955
Kailang Yang7fb0d782008-10-15 11:12:35 +0200956 if (res == ALC880_MIC_EVENT)
957 alc_mic_automute(codec);
958}
959
960static void alc_inithook(struct hda_codec *codec)
961{
Kailang Yangc9b58002007-10-16 14:30:01 +0200962 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200963 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200964}
965
Kailang Yangf9423e72008-05-27 12:32:25 +0200966/* additional initialization for ALC888 variants */
967static void alc888_coef_init(struct hda_codec *codec)
968{
969 unsigned int tmp;
970
971 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
972 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
973 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
974 if ((tmp & 0xf0) == 2)
975 /* alc888S-VC */
976 snd_hda_codec_read(codec, 0x20, 0,
977 AC_VERB_SET_PROC_COEF, 0x830);
978 else
979 /* alc888-VB */
980 snd_hda_codec_read(codec, 0x20, 0,
981 AC_VERB_SET_PROC_COEF, 0x3030);
982}
983
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200984/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
985 * 31 ~ 16 : Manufacture ID
986 * 15 ~ 8 : SKU ID
987 * 7 ~ 0 : Assembly ID
988 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
989 */
990static void alc_subsystem_id(struct hda_codec *codec,
991 unsigned int porta, unsigned int porte,
992 unsigned int portd)
993{
Kailang Yangc9b58002007-10-16 14:30:01 +0200994 unsigned int ass, tmp, i;
995 unsigned nid;
996 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200997
Kailang Yangc9b58002007-10-16 14:30:01 +0200998 ass = codec->subsystem_id & 0xffff;
999 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1000 goto do_sku;
1001
Kailang Yangea1fb292008-08-26 12:58:38 +02001002 /*
Kailang Yangc9b58002007-10-16 14:30:01 +02001003 * 31~30 : port conetcivity
1004 * 29~21 : reserve
1005 * 20 : PCBEEP input
1006 * 19~16 : Check sum (15:1)
1007 * 15~1 : Custom
1008 * 0 : override
1009 */
1010 nid = 0x1d;
1011 if (codec->vendor_id == 0x10ec0260)
1012 nid = 0x17;
1013 ass = snd_hda_codec_read(codec, nid, 0,
1014 AC_VERB_GET_CONFIG_DEFAULT, 0);
1015 if (!(ass & 1) && !(ass & 0x100000))
1016 return;
1017 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001018 return;
1019
Kailang Yangc9b58002007-10-16 14:30:01 +02001020 /* check sum */
1021 tmp = 0;
1022 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +01001023 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +02001024 tmp++;
1025 }
1026 if (((ass >> 16) & 0xf) != tmp)
1027 return;
1028do_sku:
1029 /*
1030 * 0 : override
1031 * 1 : Swap Jack
1032 * 2 : 0 --> Desktop, 1 --> Laptop
1033 * 3~5 : External Amplifier control
1034 * 7~6 : Reserved
1035 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001036 tmp = (ass & 0x38) >> 3; /* external Amp control */
1037 switch (tmp) {
1038 case 1:
1039 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1040 break;
1041 case 3:
1042 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1043 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001044 case 7:
1045 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1046 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001047 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001048 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001049 case 0x10ec0260:
1050 snd_hda_codec_write(codec, 0x0f, 0,
1051 AC_VERB_SET_EAPD_BTLENABLE, 2);
1052 snd_hda_codec_write(codec, 0x10, 0,
1053 AC_VERB_SET_EAPD_BTLENABLE, 2);
1054 break;
1055 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001056 case 0x10ec0267:
1057 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001058 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001059 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001060 case 0x10ec0660:
1061 case 0x10ec0662:
1062 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001063 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001064 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001065 snd_hda_codec_write(codec, 0x14, 0,
1066 AC_VERB_SET_EAPD_BTLENABLE, 2);
1067 snd_hda_codec_write(codec, 0x15, 0,
1068 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001069 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001070 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001071 switch (codec->vendor_id) {
1072 case 0x10ec0260:
1073 snd_hda_codec_write(codec, 0x1a, 0,
1074 AC_VERB_SET_COEF_INDEX, 7);
1075 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1076 AC_VERB_GET_PROC_COEF, 0);
1077 snd_hda_codec_write(codec, 0x1a, 0,
1078 AC_VERB_SET_COEF_INDEX, 7);
1079 snd_hda_codec_write(codec, 0x1a, 0,
1080 AC_VERB_SET_PROC_COEF,
1081 tmp | 0x2010);
1082 break;
1083 case 0x10ec0262:
1084 case 0x10ec0880:
1085 case 0x10ec0882:
1086 case 0x10ec0883:
1087 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001088 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001089 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001090 snd_hda_codec_write(codec, 0x20, 0,
1091 AC_VERB_SET_COEF_INDEX, 7);
1092 tmp = snd_hda_codec_read(codec, 0x20, 0,
1093 AC_VERB_GET_PROC_COEF, 0);
1094 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001095 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001096 snd_hda_codec_write(codec, 0x20, 0,
1097 AC_VERB_SET_PROC_COEF,
1098 tmp | 0x2010);
1099 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001100 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001101 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001102 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001103 case 0x10ec0267:
1104 case 0x10ec0268:
1105 snd_hda_codec_write(codec, 0x20, 0,
1106 AC_VERB_SET_COEF_INDEX, 7);
1107 tmp = snd_hda_codec_read(codec, 0x20, 0,
1108 AC_VERB_GET_PROC_COEF, 0);
1109 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001110 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001111 snd_hda_codec_write(codec, 0x20, 0,
1112 AC_VERB_SET_PROC_COEF,
1113 tmp | 0x3000);
1114 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001115 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001116 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001117 break;
1118 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001119
Kailang Yang8c427222008-01-10 13:03:59 +01001120 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001121 * when the external headphone out jack is plugged"
1122 */
Kailang Yang8c427222008-01-10 13:03:59 +01001123 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001124 return;
1125 /*
1126 * 10~8 : Jack location
1127 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1128 * 14~13: Resvered
1129 * 15 : 1 --> enable the function "Mute internal speaker
1130 * when the external headphone out jack is plugged"
1131 */
1132 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001133 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001134 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001135 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001136 else
1137 return;
1138 }
1139
1140 if (!spec->autocfg.hp_pins[0]) {
1141 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1142 if (tmp == 0)
1143 spec->autocfg.hp_pins[0] = porta;
1144 else if (tmp == 1)
1145 spec->autocfg.hp_pins[0] = porte;
1146 else if (tmp == 2)
1147 spec->autocfg.hp_pins[0] = portd;
1148 else
1149 return;
1150 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001151 if (spec->autocfg.hp_pins[0])
1152 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1153 AC_VERB_SET_UNSOLICITED_ENABLE,
1154 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001155
Takashi Iwai4605b712008-10-31 14:18:24 +01001156#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001157 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1158 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1159 snd_hda_codec_write(codec,
1160 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1161 AC_VERB_SET_UNSOLICITED_ENABLE,
1162 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001163#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001164
Kailang Yangc9b58002007-10-16 14:30:01 +02001165 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001166}
1167
Takashi Iwai41e41f12005-06-08 14:48:49 +02001168/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001169 * Fix-up pin default configurations
1170 */
1171
1172struct alc_pincfg {
1173 hda_nid_t nid;
1174 u32 val;
1175};
1176
1177static void alc_fix_pincfg(struct hda_codec *codec,
1178 const struct snd_pci_quirk *quirk,
1179 const struct alc_pincfg **pinfix)
1180{
1181 const struct alc_pincfg *cfg;
1182
1183 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1184 if (!quirk)
1185 return;
1186
1187 cfg = pinfix[quirk->value];
1188 for (; cfg->nid; cfg++) {
1189 int i;
1190 u32 val = cfg->val;
1191 for (i = 0; i < 4; i++) {
1192 snd_hda_codec_write(codec, cfg->nid, 0,
1193 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1194 val & 0xff);
1195 val >>= 8;
1196 }
1197 }
1198}
1199
1200/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001201 * ALC888
1202 */
1203
1204/*
1205 * 2ch mode
1206 */
1207static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1208/* Mic-in jack as mic in */
1209 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1210 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1211/* Line-in jack as Line in */
1212 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1213 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1214/* Line-Out as Front */
1215 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1216 { } /* end */
1217};
1218
1219/*
1220 * 4ch mode
1221 */
1222static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1223/* Mic-in jack as mic in */
1224 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1225 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1226/* Line-in jack as Surround */
1227 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1228 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1229/* Line-Out as Front */
1230 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1231 { } /* end */
1232};
1233
1234/*
1235 * 6ch mode
1236 */
1237static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1238/* Mic-in jack as CLFE */
1239 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1240 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1241/* Line-in jack as Surround */
1242 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1243 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1244/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1245 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1246 { } /* end */
1247};
1248
1249/*
1250 * 8ch mode
1251 */
1252static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1253/* Mic-in jack as CLFE */
1254 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1255 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1256/* Line-in jack as Surround */
1257 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1258 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1259/* Line-Out as Side */
1260 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1261 { } /* end */
1262};
1263
1264static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1265 { 2, alc888_4ST_ch2_intel_init },
1266 { 4, alc888_4ST_ch4_intel_init },
1267 { 6, alc888_4ST_ch6_intel_init },
1268 { 8, alc888_4ST_ch8_intel_init },
1269};
1270
1271/*
1272 * ALC888 Fujitsu Siemens Amillo xa3530
1273 */
1274
1275static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1276/* Front Mic: set to PIN_IN (empty by default) */
1277 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1278/* Connect Internal HP to Front */
1279 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1280 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1281 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1282/* Connect Bass HP to Front */
1283 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1285 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1286/* Connect Line-Out side jack (SPDIF) to Side */
1287 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1288 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1289 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1290/* Connect Mic jack to CLFE */
1291 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1292 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1293 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1294/* Connect Line-in jack to Surround */
1295 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1296 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1297 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1298/* Connect HP out jack to Front */
1299 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1300 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1301 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1302/* Enable unsolicited event for HP jack and Line-out jack */
1303 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1304 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1305 {}
1306};
1307
1308static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1309{
1310 unsigned int present;
1311 unsigned int bits;
1312 /* Line out presence */
1313 present = snd_hda_codec_read(codec, 0x17, 0,
1314 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1315 /* HP out presence */
1316 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1317 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1318 bits = present ? HDA_AMP_MUTE : 0;
1319 /* Toggle internal speakers muting */
1320 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1321 HDA_AMP_MUTE, bits);
1322 /* Toggle internal bass muting */
1323 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1324 HDA_AMP_MUTE, bits);
1325}
1326
1327static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1328 unsigned int res)
1329{
1330 if (res >> 26 == ALC880_HP_EVENT)
1331 alc888_fujitsu_xa3530_automute(codec);
1332}
1333
1334
1335/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001336 * ALC888 Acer Aspire 4930G model
1337 */
1338
1339static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1340/* Front Mic: set to PIN_IN (empty by default) */
1341 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1342/* Unselect Front Mic by default in input mixer 3 */
1343 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001344/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001345 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1346/* Connect Internal HP to front */
1347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1348 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1349 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1350/* Connect HP out to front */
1351 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1353 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1354 { }
1355};
1356
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001357static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001358 /* Front mic only available on one ADC */
1359 {
1360 .num_items = 4,
1361 .items = {
1362 { "Mic", 0x0 },
1363 { "Line", 0x2 },
1364 { "CD", 0x4 },
1365 { "Front Mic", 0xb },
1366 },
1367 },
1368 {
1369 .num_items = 3,
1370 .items = {
1371 { "Mic", 0x0 },
1372 { "Line", 0x2 },
1373 { "CD", 0x4 },
1374 },
1375 }
1376};
1377
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001378static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001379 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1380 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1381 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1382 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1383 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1384 HDA_OUTPUT),
1385 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1386 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1387 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1388 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1389 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1390 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1391 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1392 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1393 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1395 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1396 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001397 { } /* end */
1398};
1399
1400static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1401{
1402 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001403 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001404 present = snd_hda_codec_read(codec, 0x15, 0,
1405 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001406 bits = present ? HDA_AMP_MUTE : 0;
1407 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1408 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001409}
1410
1411static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1412 unsigned int res)
1413{
1414 if (res >> 26 == ALC880_HP_EVENT)
1415 alc888_acer_aspire_4930g_automute(codec);
1416}
1417
1418/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001419 * ALC880 3-stack model
1420 *
1421 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001422 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1423 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424 */
1425
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001426static hda_nid_t alc880_dac_nids[4] = {
1427 /* front, rear, clfe, rear_surr */
1428 0x02, 0x05, 0x04, 0x03
1429};
1430
1431static hda_nid_t alc880_adc_nids[3] = {
1432 /* ADC0-2 */
1433 0x07, 0x08, 0x09,
1434};
1435
1436/* The datasheet says the node 0x07 is connected from inputs,
1437 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001438 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001440static hda_nid_t alc880_adc_nids_alt[2] = {
1441 /* ADC1-2 */
1442 0x08, 0x09,
1443};
1444
1445#define ALC880_DIGOUT_NID 0x06
1446#define ALC880_DIGIN_NID 0x0a
1447
1448static struct hda_input_mux alc880_capture_source = {
1449 .num_items = 4,
1450 .items = {
1451 { "Mic", 0x0 },
1452 { "Front Mic", 0x3 },
1453 { "Line", 0x2 },
1454 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001456};
1457
1458/* channel source setting (2/6 channel selection for 3-stack) */
1459/* 2ch mode */
1460static struct hda_verb alc880_threestack_ch2_init[] = {
1461 /* set line-in to input, mute it */
1462 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1463 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1464 /* set mic-in to input vref 80%, mute it */
1465 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1466 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 { } /* end */
1468};
1469
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001470/* 6ch mode */
1471static struct hda_verb alc880_threestack_ch6_init[] = {
1472 /* set line-in to output, unmute it */
1473 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1474 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1475 /* set mic-in to output, unmute it */
1476 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1477 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1478 { } /* end */
1479};
1480
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001481static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001482 { 2, alc880_threestack_ch2_init },
1483 { 6, alc880_threestack_ch6_init },
1484};
1485
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001486static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001487 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001488 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001489 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001490 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001491 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1492 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001493 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1494 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1496 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1497 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1498 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1499 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1500 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1501 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1502 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001504 {
1505 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1506 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001507 .info = alc_ch_mode_info,
1508 .get = alc_ch_mode_get,
1509 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001510 },
1511 { } /* end */
1512};
1513
1514/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001515static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1516 struct snd_ctl_elem_info *uinfo)
1517{
1518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1519 struct alc_spec *spec = codec->spec;
1520 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001521
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001522 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001523 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1524 HDA_INPUT);
1525 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001526 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001527 return err;
1528}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001529
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001530static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1531 unsigned int size, unsigned int __user *tlv)
1532{
1533 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1534 struct alc_spec *spec = codec->spec;
1535 int err;
1536
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001537 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001538 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1539 HDA_INPUT);
1540 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001541 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001542 return err;
1543}
1544
1545typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1546 struct snd_ctl_elem_value *ucontrol);
1547
1548static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1549 struct snd_ctl_elem_value *ucontrol,
1550 getput_call_t func)
1551{
1552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1553 struct alc_spec *spec = codec->spec;
1554 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1555 int err;
1556
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001557 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001558 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1559 3, 0, HDA_INPUT);
1560 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001561 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001562 return err;
1563}
1564
1565static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1566 struct snd_ctl_elem_value *ucontrol)
1567{
1568 return alc_cap_getput_caller(kcontrol, ucontrol,
1569 snd_hda_mixer_amp_volume_get);
1570}
1571
1572static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1573 struct snd_ctl_elem_value *ucontrol)
1574{
1575 return alc_cap_getput_caller(kcontrol, ucontrol,
1576 snd_hda_mixer_amp_volume_put);
1577}
1578
1579/* capture mixer elements */
1580#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1581
1582static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1583 struct snd_ctl_elem_value *ucontrol)
1584{
1585 return alc_cap_getput_caller(kcontrol, ucontrol,
1586 snd_hda_mixer_amp_switch_get);
1587}
1588
1589static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1590 struct snd_ctl_elem_value *ucontrol)
1591{
1592 return alc_cap_getput_caller(kcontrol, ucontrol,
1593 snd_hda_mixer_amp_switch_put);
1594}
1595
1596#define DEFINE_CAPMIX(num) \
1597static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1598 { \
1599 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1600 .name = "Capture Switch", \
1601 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1602 .count = num, \
1603 .info = alc_cap_sw_info, \
1604 .get = alc_cap_sw_get, \
1605 .put = alc_cap_sw_put, \
1606 }, \
1607 { \
1608 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1609 .name = "Capture Volume", \
1610 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1611 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1612 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1613 .count = num, \
1614 .info = alc_cap_vol_info, \
1615 .get = alc_cap_vol_get, \
1616 .put = alc_cap_vol_put, \
1617 .tlv = { .c = alc_cap_vol_tlv }, \
1618 }, \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001619 { \
1620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1621 /* .name = "Capture Source", */ \
1622 .name = "Input Source", \
1623 .count = num, \
1624 .info = alc_mux_enum_info, \
1625 .get = alc_mux_enum_get, \
1626 .put = alc_mux_enum_put, \
1627 }, \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001628 { } /* end */ \
1629}
1630
1631/* up to three ADCs */
1632DEFINE_CAPMIX(1);
1633DEFINE_CAPMIX(2);
1634DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001635
1636
1637/*
1638 * ALC880 5-stack model
1639 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001640 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1641 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001642 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1643 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1644 */
1645
1646/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001647static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001648 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001649 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001650 { } /* end */
1651};
1652
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001653/* channel source setting (6/8 channel selection for 5-stack) */
1654/* 6ch mode */
1655static struct hda_verb alc880_fivestack_ch6_init[] = {
1656 /* set line-in to input, mute it */
1657 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1658 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001659 { } /* end */
1660};
1661
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001662/* 8ch mode */
1663static struct hda_verb alc880_fivestack_ch8_init[] = {
1664 /* set line-in to output, unmute it */
1665 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1666 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1667 { } /* end */
1668};
1669
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001670static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001671 { 6, alc880_fivestack_ch6_init },
1672 { 8, alc880_fivestack_ch8_init },
1673};
1674
1675
1676/*
1677 * ALC880 6-stack model
1678 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001679 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1680 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001681 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1682 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1683 */
1684
1685static hda_nid_t alc880_6st_dac_nids[4] = {
1686 /* front, rear, clfe, rear_surr */
1687 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001688};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001689
1690static struct hda_input_mux alc880_6stack_capture_source = {
1691 .num_items = 4,
1692 .items = {
1693 { "Mic", 0x0 },
1694 { "Front Mic", 0x1 },
1695 { "Line", 0x2 },
1696 { "CD", 0x4 },
1697 },
1698};
1699
1700/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001701static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001702 { 8, NULL },
1703};
1704
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001705static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001706 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001707 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001708 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001709 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001710 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1711 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001712 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1713 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001714 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001715 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001716 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1717 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1718 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1719 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1720 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1721 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1722 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1723 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001724 {
1725 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1726 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001727 .info = alc_ch_mode_info,
1728 .get = alc_ch_mode_get,
1729 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001730 },
1731 { } /* end */
1732};
1733
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001734
1735/*
1736 * ALC880 W810 model
1737 *
1738 * W810 has rear IO for:
1739 * Front (DAC 02)
1740 * Surround (DAC 03)
1741 * Center/LFE (DAC 04)
1742 * Digital out (06)
1743 *
1744 * The system also has a pair of internal speakers, and a headphone jack.
1745 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001746 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001747 * There is a variable resistor to control the speaker or headphone
1748 * volume. This is a hardware-only device without a software API.
1749 *
1750 * Plugging headphones in will disable the internal speakers. This is
1751 * implemented in hardware, not via the driver using jack sense. In
1752 * a similar fashion, plugging into the rear socket marked "front" will
1753 * disable both the speakers and headphones.
1754 *
1755 * For input, there's a microphone jack, and an "audio in" jack.
1756 * These may not do anything useful with this driver yet, because I
1757 * haven't setup any initialization verbs for these yet...
1758 */
1759
1760static hda_nid_t alc880_w810_dac_nids[3] = {
1761 /* front, rear/surround, clfe */
1762 0x02, 0x03, 0x04
1763};
1764
1765/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001766static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001767 { 6, NULL }
1768};
1769
1770/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001771static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001772 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001773 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001774 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001775 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001776 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1777 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001778 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1779 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001780 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1781 { } /* end */
1782};
1783
1784
1785/*
1786 * Z710V model
1787 *
1788 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001789 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1790 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001791 */
1792
1793static hda_nid_t alc880_z71v_dac_nids[1] = {
1794 0x02
1795};
1796#define ALC880_Z71V_HP_DAC 0x03
1797
1798/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001799static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001800 { 2, NULL }
1801};
1802
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001803static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001804 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001805 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001806 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001807 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001808 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1809 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1811 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1812 { } /* end */
1813};
1814
1815
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001816/*
1817 * ALC880 F1734 model
1818 *
1819 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1820 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1821 */
1822
1823static hda_nid_t alc880_f1734_dac_nids[1] = {
1824 0x03
1825};
1826#define ALC880_F1734_HP_DAC 0x02
1827
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001828static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001829 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001830 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001831 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1832 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001833 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1834 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001837 { } /* end */
1838};
1839
Takashi Iwai937b4162008-02-11 14:52:36 +01001840static struct hda_input_mux alc880_f1734_capture_source = {
1841 .num_items = 2,
1842 .items = {
1843 { "Mic", 0x1 },
1844 { "CD", 0x4 },
1845 },
1846};
1847
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001848
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001849/*
1850 * ALC880 ASUS model
1851 *
1852 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1853 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1854 * Mic = 0x18, Line = 0x1a
1855 */
1856
1857#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1858#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1859
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001860static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001861 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001862 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001863 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001864 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001865 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1866 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001867 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1868 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001869 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1870 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1871 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1872 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1873 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001875 {
1876 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1877 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001878 .info = alc_ch_mode_info,
1879 .get = alc_ch_mode_get,
1880 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001881 },
1882 { } /* end */
1883};
1884
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001885/*
1886 * ALC880 ASUS W1V model
1887 *
1888 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1889 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1890 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1891 */
1892
1893/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001894static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001895 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1896 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001897 { } /* end */
1898};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001899
Kailang Yangdf694da2005-12-05 19:42:22 +01001900/* TCL S700 */
1901static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1902 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1903 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1904 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1905 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1906 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1908 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1909 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1910 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001911 { } /* end */
1912};
1913
Kailang Yangccc656c2006-10-17 12:32:26 +02001914/* Uniwill */
1915static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001916 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1917 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1918 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1919 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001920 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1921 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1922 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1923 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1924 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1925 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1926 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1927 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1929 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1930 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1931 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001932 {
1933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1934 .name = "Channel Mode",
1935 .info = alc_ch_mode_info,
1936 .get = alc_ch_mode_get,
1937 .put = alc_ch_mode_put,
1938 },
1939 { } /* end */
1940};
1941
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001942static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1943 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1944 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1945 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1946 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1947 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1948 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1949 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1950 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1951 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1952 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1953 { } /* end */
1954};
1955
Kailang Yangccc656c2006-10-17 12:32:26 +02001956static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001957 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1958 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1959 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1960 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001961 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1962 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1963 { } /* end */
1964};
1965
Linus Torvalds1da177e2005-04-16 15:20:36 -07001966/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001967 * virtual master controls
1968 */
1969
1970/*
1971 * slave controls for virtual master
1972 */
1973static const char *alc_slave_vols[] = {
1974 "Front Playback Volume",
1975 "Surround Playback Volume",
1976 "Center Playback Volume",
1977 "LFE Playback Volume",
1978 "Side Playback Volume",
1979 "Headphone Playback Volume",
1980 "Speaker Playback Volume",
1981 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001982 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001983 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001984 NULL,
1985};
1986
1987static const char *alc_slave_sws[] = {
1988 "Front Playback Switch",
1989 "Surround Playback Switch",
1990 "Center Playback Switch",
1991 "LFE Playback Switch",
1992 "Side Playback Switch",
1993 "Headphone Playback Switch",
1994 "Speaker Playback Switch",
1995 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001996 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001997 NULL,
1998};
1999
2000/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002001 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002002 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002003
2004static void alc_free_kctls(struct hda_codec *codec);
2005
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002006/* additional beep mixers; the actual parameters are overwritten at build */
2007static struct snd_kcontrol_new alc_beep_mixer[] = {
2008 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2009 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2010 { } /* end */
2011};
2012
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013static int alc_build_controls(struct hda_codec *codec)
2014{
2015 struct alc_spec *spec = codec->spec;
2016 int err;
2017 int i;
2018
2019 for (i = 0; i < spec->num_mixers; i++) {
2020 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2021 if (err < 0)
2022 return err;
2023 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002024 if (spec->cap_mixer) {
2025 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2026 if (err < 0)
2027 return err;
2028 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002029 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002030 err = snd_hda_create_spdif_out_ctls(codec,
2031 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002032 if (err < 0)
2033 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002034 if (!spec->no_analog) {
2035 err = snd_hda_create_spdif_share_sw(codec,
2036 &spec->multiout);
2037 if (err < 0)
2038 return err;
2039 spec->multiout.share_spdif = 1;
2040 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002041 }
2042 if (spec->dig_in_nid) {
2043 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2044 if (err < 0)
2045 return err;
2046 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002047
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002048 /* create beep controls if needed */
2049 if (spec->beep_amp) {
2050 struct snd_kcontrol_new *knew;
2051 for (knew = alc_beep_mixer; knew->name; knew++) {
2052 struct snd_kcontrol *kctl;
2053 kctl = snd_ctl_new1(knew, codec);
2054 if (!kctl)
2055 return -ENOMEM;
2056 kctl->private_value = spec->beep_amp;
2057 err = snd_hda_ctl_add(codec, kctl);
2058 if (err < 0)
2059 return err;
2060 }
2061 }
2062
Takashi Iwai2134ea42008-01-10 16:53:55 +01002063 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002064 if (!spec->no_analog &&
2065 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002066 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002067 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002068 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002069 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002070 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002071 if (err < 0)
2072 return err;
2073 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002074 if (!spec->no_analog &&
2075 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002076 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2077 NULL, alc_slave_sws);
2078 if (err < 0)
2079 return err;
2080 }
2081
Takashi Iwai603c4012008-07-30 15:01:44 +02002082 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002083 return 0;
2084}
2085
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002086
Linus Torvalds1da177e2005-04-16 15:20:36 -07002087/*
2088 * initialize the codec volumes, etc
2089 */
2090
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002091/*
2092 * generic initialization of ADC, input mixers and output mixers
2093 */
2094static struct hda_verb alc880_volume_init_verbs[] = {
2095 /*
2096 * Unmute ADC0-2 and set the default input to mic-in
2097 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002098 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002099 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002100 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002101 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002102 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002103 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002105 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2106 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002107 * Note: PASD motherboards uses the Line In 2 as the input for front
2108 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002109 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002110 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002111 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002118
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002119 /*
2120 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002121 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002122 /* set vol=0 to output mixers */
2123 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2124 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2125 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2126 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2127 /* set up input amps for analog loopback */
2128 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002131 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2132 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002133 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2134 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002135 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2136 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137
2138 { }
2139};
2140
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002141/*
2142 * 3-stack pin configuration:
2143 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2144 */
2145static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2146 /*
2147 * preset connection lists of input pins
2148 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2149 */
2150 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2151 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2152 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2153
2154 /*
2155 * Set pin mode and muting
2156 */
2157 /* set front pin widgets 0x14 for output */
2158 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2159 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2160 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2161 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2162 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2163 /* Mic2 (as headphone out) for HP output */
2164 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2165 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2166 /* Line In pin widget for input */
2167 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2168 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2169 /* Line2 (as front mic) pin widget for input and vref at 80% */
2170 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2171 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2172 /* CD pin widget for input */
2173 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2174
2175 { }
2176};
2177
2178/*
2179 * 5-stack pin configuration:
2180 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2181 * line-in/side = 0x1a, f-mic = 0x1b
2182 */
2183static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2184 /*
2185 * preset connection lists of input pins
2186 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2187 */
2188 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2189 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2190
2191 /*
2192 * Set pin mode and muting
2193 */
2194 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002195 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2196 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2197 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2198 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002199 /* unmute pins for output (no gain on this amp) */
2200 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2201 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2202 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2203 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2204
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002206 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2208 /* Mic2 (as headphone out) for HP output */
2209 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002210 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002211 /* Line In pin widget for input */
2212 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2213 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2214 /* Line2 (as front mic) pin widget for input and vref at 80% */
2215 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2216 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2217 /* CD pin widget for input */
2218 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219
2220 { }
2221};
2222
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002223/*
2224 * W810 pin configuration:
2225 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2226 */
2227static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002228 /* hphone/speaker input selector: front DAC */
2229 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2230
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002231 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2233 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2234 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2235 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2236 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2237
2238 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002239 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002240
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241 { }
2242};
2243
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002244/*
2245 * Z71V pin configuration:
2246 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2247 */
2248static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002250 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002251 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002252 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002253
Takashi Iwai16ded522005-06-10 19:58:24 +02002254 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002255 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002256 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002257 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002258
2259 { }
2260};
2261
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002262/*
2263 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002264 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2265 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002266 */
2267static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2268 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2269
Takashi Iwai16ded522005-06-10 19:58:24 +02002270 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002271 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002274 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002275 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002276 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002277 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2278
Takashi Iwai16ded522005-06-10 19:58:24 +02002279 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002280 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002281 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002282 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002283 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002284 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002285 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002286 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002287 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002288
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002289 { }
2290};
Takashi Iwai16ded522005-06-10 19:58:24 +02002291
Kailang Yangccc656c2006-10-17 12:32:26 +02002292/*
2293 * Uniwill pin configuration:
2294 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2295 * line = 0x1a
2296 */
2297static struct hda_verb alc880_uniwill_init_verbs[] = {
2298 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2299
2300 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2301 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2302 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2303 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2304 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2306 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2307 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2311 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2312 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2313 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2314
2315 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2316 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2317 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2318 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2319 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2321 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2322 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2323 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2324
2325 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2326 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2327
2328 { }
2329};
2330
2331/*
2332* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002333* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002334 */
2335static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2336 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2337
2338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2339 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2340 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2342 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2343 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2350
2351 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2352 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2353 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2354 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2355 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2356 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2357
2358 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2359 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2360
2361 { }
2362};
2363
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002364static struct hda_verb alc880_beep_init_verbs[] = {
2365 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2366 { }
2367};
2368
Kailang Yangccc656c2006-10-17 12:32:26 +02002369/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002370static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002371{
2372 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002373 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002374
2375 present = snd_hda_codec_read(codec, 0x14, 0,
2376 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002377 bits = present ? HDA_AMP_MUTE : 0;
2378 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2379 HDA_AMP_MUTE, bits);
2380 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2381 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002382}
2383
2384/* auto-toggle front mic */
2385static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2386{
2387 unsigned int present;
2388 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002389
2390 present = snd_hda_codec_read(codec, 0x18, 0,
2391 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002392 bits = present ? HDA_AMP_MUTE : 0;
2393 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002394}
2395
2396static void alc880_uniwill_automute(struct hda_codec *codec)
2397{
2398 alc880_uniwill_hp_automute(codec);
2399 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002400}
2401
2402static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2403 unsigned int res)
2404{
2405 /* Looks like the unsol event is incompatible with the standard
2406 * definition. 4bit tag is placed at 28 bit!
2407 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002408 switch (res >> 28) {
2409 case ALC880_HP_EVENT:
2410 alc880_uniwill_hp_automute(codec);
2411 break;
2412 case ALC880_MIC_EVENT:
2413 alc880_uniwill_mic_automute(codec);
2414 break;
2415 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002416}
2417
2418static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2419{
2420 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002421 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002422
2423 present = snd_hda_codec_read(codec, 0x14, 0,
2424 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002425 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002426 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002427}
2428
2429static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2430{
2431 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002432
Kailang Yangccc656c2006-10-17 12:32:26 +02002433 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002434 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2435 present &= HDA_AMP_VOLMASK;
2436 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2437 HDA_AMP_VOLMASK, present);
2438 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2439 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002440}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002441
Kailang Yangccc656c2006-10-17 12:32:26 +02002442static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2443 unsigned int res)
2444{
2445 /* Looks like the unsol event is incompatible with the standard
2446 * definition. 4bit tag is placed at 28 bit!
2447 */
2448 if ((res >> 28) == ALC880_HP_EVENT)
2449 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002450 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002451 alc880_uniwill_p53_dcvol_automute(codec);
2452}
2453
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002454/*
2455 * F1734 pin configuration:
2456 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2457 */
2458static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002459 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002460 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2461 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2462 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2463 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2464
2465 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2466 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2469
2470 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2471 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002473 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2474 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2475 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2476 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2477 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2478 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002479
Takashi Iwai937b4162008-02-11 14:52:36 +01002480 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2481 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2482
Takashi Iwai16ded522005-06-10 19:58:24 +02002483 { }
2484};
2485
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002486/*
2487 * ASUS pin configuration:
2488 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2489 */
2490static struct hda_verb alc880_pin_asus_init_verbs[] = {
2491 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2492 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2493 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2494 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2495
2496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2498 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2500 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2502 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2503 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2504
2505 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2506 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2507 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2509 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2510 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2511 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2513 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002514
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002515 { }
2516};
2517
2518/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002519#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2520#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002521
Kailang Yangdf694da2005-12-05 19:42:22 +01002522/* Clevo m520g init */
2523static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2524 /* headphone output */
2525 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2526 /* line-out */
2527 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2528 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2529 /* Line-in */
2530 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2531 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2532 /* CD */
2533 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2534 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2535 /* Mic1 (rear panel) */
2536 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2537 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2538 /* Mic2 (front panel) */
2539 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2540 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2541 /* headphone */
2542 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2543 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2544 /* change to EAPD mode */
2545 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2546 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2547
2548 { }
2549};
2550
2551static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002552 /* change to EAPD mode */
2553 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2554 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2555
Kailang Yangdf694da2005-12-05 19:42:22 +01002556 /* Headphone output */
2557 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2558 /* Front output*/
2559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2560 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2561
2562 /* Line In pin widget for input */
2563 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2564 /* CD pin widget for input */
2565 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2566 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2567 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2568
2569 /* change to EAPD mode */
2570 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2571 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2572
2573 { }
2574};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002575
2576/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002577 * LG m1 express dual
2578 *
2579 * Pin assignment:
2580 * Rear Line-In/Out (blue): 0x14
2581 * Build-in Mic-In: 0x15
2582 * Speaker-out: 0x17
2583 * HP-Out (green): 0x1b
2584 * Mic-In/Out (red): 0x19
2585 * SPDIF-Out: 0x1e
2586 */
2587
2588/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2589static hda_nid_t alc880_lg_dac_nids[3] = {
2590 0x05, 0x02, 0x03
2591};
2592
2593/* seems analog CD is not working */
2594static struct hda_input_mux alc880_lg_capture_source = {
2595 .num_items = 3,
2596 .items = {
2597 { "Mic", 0x1 },
2598 { "Line", 0x5 },
2599 { "Internal Mic", 0x6 },
2600 },
2601};
2602
2603/* 2,4,6 channel modes */
2604static struct hda_verb alc880_lg_ch2_init[] = {
2605 /* set line-in and mic-in to input */
2606 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2607 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2608 { }
2609};
2610
2611static struct hda_verb alc880_lg_ch4_init[] = {
2612 /* set line-in to out and mic-in to input */
2613 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2614 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2615 { }
2616};
2617
2618static struct hda_verb alc880_lg_ch6_init[] = {
2619 /* set line-in and mic-in to output */
2620 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2621 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2622 { }
2623};
2624
2625static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2626 { 2, alc880_lg_ch2_init },
2627 { 4, alc880_lg_ch4_init },
2628 { 6, alc880_lg_ch6_init },
2629};
2630
2631static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002632 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2633 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002634 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2635 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2636 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2637 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2638 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2639 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2642 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2643 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2644 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2645 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2646 {
2647 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2648 .name = "Channel Mode",
2649 .info = alc_ch_mode_info,
2650 .get = alc_ch_mode_get,
2651 .put = alc_ch_mode_put,
2652 },
2653 { } /* end */
2654};
2655
2656static struct hda_verb alc880_lg_init_verbs[] = {
2657 /* set capture source to mic-in */
2658 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2659 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2660 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2661 /* mute all amp mixer inputs */
2662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002665 /* line-in to input */
2666 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2667 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2668 /* built-in mic */
2669 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2670 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2671 /* speaker-out */
2672 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2673 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2674 /* mic-in to input */
2675 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2676 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2677 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2678 /* HP-out */
2679 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2680 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2681 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2682 /* jack sense */
2683 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2684 { }
2685};
2686
2687/* toggle speaker-output according to the hp-jack state */
2688static void alc880_lg_automute(struct hda_codec *codec)
2689{
2690 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002691 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002692
2693 present = snd_hda_codec_read(codec, 0x1b, 0,
2694 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002695 bits = present ? HDA_AMP_MUTE : 0;
2696 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2697 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002698}
2699
2700static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2701{
2702 /* Looks like the unsol event is incompatible with the standard
2703 * definition. 4bit tag is placed at 28 bit!
2704 */
2705 if ((res >> 28) == 0x01)
2706 alc880_lg_automute(codec);
2707}
2708
2709/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002710 * LG LW20
2711 *
2712 * Pin assignment:
2713 * Speaker-out: 0x14
2714 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002715 * Built-in Mic-In: 0x19
2716 * Line-In: 0x1b
2717 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002718 * SPDIF-Out: 0x1e
2719 */
2720
Takashi Iwaid6815182006-03-23 16:06:23 +01002721static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002722 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002723 .items = {
2724 { "Mic", 0x0 },
2725 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002726 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002727 },
2728};
2729
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002730#define alc880_lg_lw_modes alc880_threestack_modes
2731
Takashi Iwaid6815182006-03-23 16:06:23 +01002732static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002733 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2734 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2735 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2736 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2737 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2738 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2739 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2740 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2741 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2742 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2744 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2745 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2746 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002747 {
2748 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2749 .name = "Channel Mode",
2750 .info = alc_ch_mode_info,
2751 .get = alc_ch_mode_get,
2752 .put = alc_ch_mode_put,
2753 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002754 { } /* end */
2755};
2756
2757static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002758 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2759 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2760 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2761
Takashi Iwaid6815182006-03-23 16:06:23 +01002762 /* set capture source to mic-in */
2763 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2764 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2765 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002766 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002767 /* speaker-out */
2768 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2770 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002771 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2772 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2773 /* mic-in to input */
2774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2776 /* built-in mic */
2777 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2778 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2779 /* jack sense */
2780 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2781 { }
2782};
2783
2784/* toggle speaker-output according to the hp-jack state */
2785static void alc880_lg_lw_automute(struct hda_codec *codec)
2786{
2787 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002788 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002789
2790 present = snd_hda_codec_read(codec, 0x1b, 0,
2791 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002792 bits = present ? HDA_AMP_MUTE : 0;
2793 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2794 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002795}
2796
2797static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2798{
2799 /* Looks like the unsol event is incompatible with the standard
2800 * definition. 4bit tag is placed at 28 bit!
2801 */
2802 if ((res >> 28) == 0x01)
2803 alc880_lg_lw_automute(codec);
2804}
2805
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002806static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2807 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2808 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2811 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2812 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2813 { } /* end */
2814};
2815
2816static struct hda_input_mux alc880_medion_rim_capture_source = {
2817 .num_items = 2,
2818 .items = {
2819 { "Mic", 0x0 },
2820 { "Internal Mic", 0x1 },
2821 },
2822};
2823
2824static struct hda_verb alc880_medion_rim_init_verbs[] = {
2825 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2826
2827 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2828 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2829
2830 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2831 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2832 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2833 /* Mic2 (as headphone out) for HP output */
2834 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2835 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2836 /* Internal Speaker */
2837 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2838 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2839
2840 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2841 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2842
2843 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2844 { }
2845};
2846
2847/* toggle speaker-output according to the hp-jack state */
2848static void alc880_medion_rim_automute(struct hda_codec *codec)
2849{
2850 unsigned int present;
2851 unsigned char bits;
2852
2853 present = snd_hda_codec_read(codec, 0x14, 0,
2854 AC_VERB_GET_PIN_SENSE, 0)
2855 & AC_PINSENSE_PRESENCE;
2856 bits = present ? HDA_AMP_MUTE : 0;
2857 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2858 HDA_AMP_MUTE, bits);
2859 if (present)
2860 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2861 else
2862 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2863}
2864
2865static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2866 unsigned int res)
2867{
2868 /* Looks like the unsol event is incompatible with the standard
2869 * definition. 4bit tag is placed at 28 bit!
2870 */
2871 if ((res >> 28) == ALC880_HP_EVENT)
2872 alc880_medion_rim_automute(codec);
2873}
2874
Takashi Iwaicb53c622007-08-10 17:21:45 +02002875#ifdef CONFIG_SND_HDA_POWER_SAVE
2876static struct hda_amp_list alc880_loopbacks[] = {
2877 { 0x0b, HDA_INPUT, 0 },
2878 { 0x0b, HDA_INPUT, 1 },
2879 { 0x0b, HDA_INPUT, 2 },
2880 { 0x0b, HDA_INPUT, 3 },
2881 { 0x0b, HDA_INPUT, 4 },
2882 { } /* end */
2883};
2884
2885static struct hda_amp_list alc880_lg_loopbacks[] = {
2886 { 0x0b, HDA_INPUT, 1 },
2887 { 0x0b, HDA_INPUT, 6 },
2888 { 0x0b, HDA_INPUT, 7 },
2889 { } /* end */
2890};
2891#endif
2892
Takashi Iwaid6815182006-03-23 16:06:23 +01002893/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002894 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002895 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002896
Linus Torvalds1da177e2005-04-16 15:20:36 -07002897static int alc_init(struct hda_codec *codec)
2898{
2899 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002900 unsigned int i;
2901
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002902 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002903 if (codec->vendor_id == 0x10ec0888)
2904 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002905
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002906 for (i = 0; i < spec->num_init_verbs; i++)
2907 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002908
2909 if (spec->init_hook)
2910 spec->init_hook(codec);
2911
Linus Torvalds1da177e2005-04-16 15:20:36 -07002912 return 0;
2913}
2914
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002915static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2916{
2917 struct alc_spec *spec = codec->spec;
2918
2919 if (spec->unsol_event)
2920 spec->unsol_event(codec, res);
2921}
2922
Takashi Iwaicb53c622007-08-10 17:21:45 +02002923#ifdef CONFIG_SND_HDA_POWER_SAVE
2924static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2925{
2926 struct alc_spec *spec = codec->spec;
2927 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2928}
2929#endif
2930
Linus Torvalds1da177e2005-04-16 15:20:36 -07002931/*
2932 * Analog playback callbacks
2933 */
2934static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2935 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002936 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002937{
2938 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002939 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2940 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941}
2942
2943static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2944 struct hda_codec *codec,
2945 unsigned int stream_tag,
2946 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002947 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002948{
2949 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002950 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2951 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002952}
2953
2954static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2955 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002956 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002957{
2958 struct alc_spec *spec = codec->spec;
2959 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2960}
2961
2962/*
2963 * Digital out
2964 */
2965static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2966 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002967 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002968{
2969 struct alc_spec *spec = codec->spec;
2970 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2971}
2972
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002973static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2974 struct hda_codec *codec,
2975 unsigned int stream_tag,
2976 unsigned int format,
2977 struct snd_pcm_substream *substream)
2978{
2979 struct alc_spec *spec = codec->spec;
2980 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2981 stream_tag, format, substream);
2982}
2983
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01002984static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2985 struct hda_codec *codec,
2986 struct snd_pcm_substream *substream)
2987{
2988 struct alc_spec *spec = codec->spec;
2989 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2990}
2991
Linus Torvalds1da177e2005-04-16 15:20:36 -07002992static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2993 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002994 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002995{
2996 struct alc_spec *spec = codec->spec;
2997 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2998}
2999
3000/*
3001 * Analog capture
3002 */
Takashi Iwai63300792008-01-24 15:31:36 +01003003static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003004 struct hda_codec *codec,
3005 unsigned int stream_tag,
3006 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003007 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003008{
3009 struct alc_spec *spec = codec->spec;
3010
Takashi Iwai63300792008-01-24 15:31:36 +01003011 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003012 stream_tag, 0, format);
3013 return 0;
3014}
3015
Takashi Iwai63300792008-01-24 15:31:36 +01003016static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003017 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003018 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003019{
3020 struct alc_spec *spec = codec->spec;
3021
Takashi Iwai888afa12008-03-18 09:57:50 +01003022 snd_hda_codec_cleanup_stream(codec,
3023 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003024 return 0;
3025}
3026
3027
3028/*
3029 */
3030static struct hda_pcm_stream alc880_pcm_analog_playback = {
3031 .substreams = 1,
3032 .channels_min = 2,
3033 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003034 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003035 .ops = {
3036 .open = alc880_playback_pcm_open,
3037 .prepare = alc880_playback_pcm_prepare,
3038 .cleanup = alc880_playback_pcm_cleanup
3039 },
3040};
3041
3042static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003043 .substreams = 1,
3044 .channels_min = 2,
3045 .channels_max = 2,
3046 /* NID is set in alc_build_pcms */
3047};
3048
3049static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3050 .substreams = 1,
3051 .channels_min = 2,
3052 .channels_max = 2,
3053 /* NID is set in alc_build_pcms */
3054};
3055
3056static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3057 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003058 .channels_min = 2,
3059 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003060 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003061 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003062 .prepare = alc880_alt_capture_pcm_prepare,
3063 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003064 },
3065};
3066
3067static struct hda_pcm_stream alc880_pcm_digital_playback = {
3068 .substreams = 1,
3069 .channels_min = 2,
3070 .channels_max = 2,
3071 /* NID is set in alc_build_pcms */
3072 .ops = {
3073 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003074 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003075 .prepare = alc880_dig_playback_pcm_prepare,
3076 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003077 },
3078};
3079
3080static struct hda_pcm_stream alc880_pcm_digital_capture = {
3081 .substreams = 1,
3082 .channels_min = 2,
3083 .channels_max = 2,
3084 /* NID is set in alc_build_pcms */
3085};
3086
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003087/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003088static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003089 .substreams = 0,
3090 .channels_min = 0,
3091 .channels_max = 0,
3092};
3093
Linus Torvalds1da177e2005-04-16 15:20:36 -07003094static int alc_build_pcms(struct hda_codec *codec)
3095{
3096 struct alc_spec *spec = codec->spec;
3097 struct hda_pcm *info = spec->pcm_rec;
3098 int i;
3099
3100 codec->num_pcms = 1;
3101 codec->pcm_info = info;
3102
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003103 if (spec->no_analog)
3104 goto skip_analog;
3105
Linus Torvalds1da177e2005-04-16 15:20:36 -07003106 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003107 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003108 if (snd_BUG_ON(!spec->multiout.dac_nids))
3109 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003110 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3111 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3112 }
3113 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003114 if (snd_BUG_ON(!spec->adc_nids))
3115 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003116 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3117 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3118 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003119
Takashi Iwai4a471b72005-12-07 13:56:29 +01003120 if (spec->channel_mode) {
3121 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3122 for (i = 0; i < spec->num_channel_mode; i++) {
3123 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3124 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3125 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003126 }
3127 }
3128
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003129 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003130 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003131 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003132 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003133 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003134 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003135 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003136 if (spec->dig_out_type)
3137 info->pcm_type = spec->dig_out_type;
3138 else
3139 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003140 if (spec->multiout.dig_out_nid &&
3141 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003142 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3143 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3144 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003145 if (spec->dig_in_nid &&
3146 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003147 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3148 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3149 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003150 /* FIXME: do we need this for all Realtek codec models? */
3151 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003152 }
3153
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003154 if (spec->no_analog)
3155 return 0;
3156
Takashi Iwaie08a0072006-09-07 17:52:14 +02003157 /* If the use of more than one ADC is requested for the current
3158 * model, configure a second analog capture-only PCM.
3159 */
3160 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003161 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3162 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003163 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003164 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003165 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003166 if (spec->alt_dac_nid) {
3167 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3168 *spec->stream_analog_alt_playback;
3169 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3170 spec->alt_dac_nid;
3171 } else {
3172 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3173 alc_pcm_null_stream;
3174 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3175 }
3176 if (spec->num_adc_nids > 1) {
3177 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3178 *spec->stream_analog_alt_capture;
3179 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3180 spec->adc_nids[1];
3181 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3182 spec->num_adc_nids - 1;
3183 } else {
3184 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3185 alc_pcm_null_stream;
3186 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003187 }
3188 }
3189
Linus Torvalds1da177e2005-04-16 15:20:36 -07003190 return 0;
3191}
3192
Takashi Iwai603c4012008-07-30 15:01:44 +02003193static void alc_free_kctls(struct hda_codec *codec)
3194{
3195 struct alc_spec *spec = codec->spec;
3196
3197 if (spec->kctls.list) {
3198 struct snd_kcontrol_new *kctl = spec->kctls.list;
3199 int i;
3200 for (i = 0; i < spec->kctls.used; i++)
3201 kfree(kctl[i].name);
3202 }
3203 snd_array_free(&spec->kctls);
3204}
3205
Linus Torvalds1da177e2005-04-16 15:20:36 -07003206static void alc_free(struct hda_codec *codec)
3207{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003208 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003209
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003210 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003211 return;
3212
Takashi Iwai603c4012008-07-30 15:01:44 +02003213 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003214 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003215 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003216}
3217
Takashi Iwaie044c392008-10-27 16:56:24 +01003218#ifdef SND_HDA_NEEDS_RESUME
3219static void store_pin_configs(struct hda_codec *codec)
3220{
3221 struct alc_spec *spec = codec->spec;
3222 hda_nid_t nid, end_nid;
3223
3224 end_nid = codec->start_nid + codec->num_nodes;
3225 for (nid = codec->start_nid; nid < end_nid; nid++) {
3226 unsigned int wid_caps = get_wcaps(codec, nid);
3227 unsigned int wid_type =
3228 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3229 if (wid_type != AC_WID_PIN)
3230 continue;
3231 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
3232 break;
3233 spec->pin_nids[spec->num_pins] = nid;
3234 spec->pin_cfgs[spec->num_pins] =
3235 snd_hda_codec_read(codec, nid, 0,
3236 AC_VERB_GET_CONFIG_DEFAULT, 0);
3237 spec->num_pins++;
3238 }
3239}
3240
3241static void resume_pin_configs(struct hda_codec *codec)
3242{
3243 struct alc_spec *spec = codec->spec;
3244 int i;
3245
3246 for (i = 0; i < spec->num_pins; i++) {
3247 hda_nid_t pin_nid = spec->pin_nids[i];
3248 unsigned int pin_config = spec->pin_cfgs[i];
3249 snd_hda_codec_write(codec, pin_nid, 0,
3250 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
3251 pin_config & 0x000000ff);
3252 snd_hda_codec_write(codec, pin_nid, 0,
3253 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
3254 (pin_config & 0x0000ff00) >> 8);
3255 snd_hda_codec_write(codec, pin_nid, 0,
3256 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
3257 (pin_config & 0x00ff0000) >> 16);
3258 snd_hda_codec_write(codec, pin_nid, 0,
3259 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
3260 pin_config >> 24);
3261 }
3262}
3263
3264static int alc_resume(struct hda_codec *codec)
3265{
3266 resume_pin_configs(codec);
3267 codec->patch_ops.init(codec);
3268 snd_hda_codec_resume_amp(codec);
3269 snd_hda_codec_resume_cache(codec);
3270 return 0;
3271}
3272#else
3273#define store_pin_configs(codec)
3274#endif
3275
Linus Torvalds1da177e2005-04-16 15:20:36 -07003276/*
3277 */
3278static struct hda_codec_ops alc_patch_ops = {
3279 .build_controls = alc_build_controls,
3280 .build_pcms = alc_build_pcms,
3281 .init = alc_init,
3282 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003283 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003284#ifdef SND_HDA_NEEDS_RESUME
3285 .resume = alc_resume,
3286#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003287#ifdef CONFIG_SND_HDA_POWER_SAVE
3288 .check_power_status = alc_check_power_status,
3289#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003290};
3291
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003292
3293/*
3294 * Test configuration for debugging
3295 *
3296 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3297 * enum controls.
3298 */
3299#ifdef CONFIG_SND_DEBUG
3300static hda_nid_t alc880_test_dac_nids[4] = {
3301 0x02, 0x03, 0x04, 0x05
3302};
3303
3304static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003305 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003306 .items = {
3307 { "In-1", 0x0 },
3308 { "In-2", 0x1 },
3309 { "In-3", 0x2 },
3310 { "In-4", 0x3 },
3311 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003312 { "Front", 0x5 },
3313 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003314 },
3315};
3316
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003317static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003318 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003319 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003320 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003321 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003322};
3323
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003324static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3325 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003326{
3327 static char *texts[] = {
3328 "N/A", "Line Out", "HP Out",
3329 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3330 };
3331 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3332 uinfo->count = 1;
3333 uinfo->value.enumerated.items = 8;
3334 if (uinfo->value.enumerated.item >= 8)
3335 uinfo->value.enumerated.item = 7;
3336 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3337 return 0;
3338}
3339
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003340static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3341 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003342{
3343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3344 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3345 unsigned int pin_ctl, item = 0;
3346
3347 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3348 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3349 if (pin_ctl & AC_PINCTL_OUT_EN) {
3350 if (pin_ctl & AC_PINCTL_HP_EN)
3351 item = 2;
3352 else
3353 item = 1;
3354 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3355 switch (pin_ctl & AC_PINCTL_VREFEN) {
3356 case AC_PINCTL_VREF_HIZ: item = 3; break;
3357 case AC_PINCTL_VREF_50: item = 4; break;
3358 case AC_PINCTL_VREF_GRD: item = 5; break;
3359 case AC_PINCTL_VREF_80: item = 6; break;
3360 case AC_PINCTL_VREF_100: item = 7; break;
3361 }
3362 }
3363 ucontrol->value.enumerated.item[0] = item;
3364 return 0;
3365}
3366
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003367static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3368 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003369{
3370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3371 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3372 static unsigned int ctls[] = {
3373 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3374 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3375 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3376 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3377 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3378 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3379 };
3380 unsigned int old_ctl, new_ctl;
3381
3382 old_ctl = snd_hda_codec_read(codec, nid, 0,
3383 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3384 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3385 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003386 int val;
3387 snd_hda_codec_write_cache(codec, nid, 0,
3388 AC_VERB_SET_PIN_WIDGET_CONTROL,
3389 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003390 val = ucontrol->value.enumerated.item[0] >= 3 ?
3391 HDA_AMP_MUTE : 0;
3392 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3393 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003394 return 1;
3395 }
3396 return 0;
3397}
3398
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003399static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3400 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003401{
3402 static char *texts[] = {
3403 "Front", "Surround", "CLFE", "Side"
3404 };
3405 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3406 uinfo->count = 1;
3407 uinfo->value.enumerated.items = 4;
3408 if (uinfo->value.enumerated.item >= 4)
3409 uinfo->value.enumerated.item = 3;
3410 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3411 return 0;
3412}
3413
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003414static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3415 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003416{
3417 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3418 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3419 unsigned int sel;
3420
3421 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3422 ucontrol->value.enumerated.item[0] = sel & 3;
3423 return 0;
3424}
3425
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003426static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3427 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003428{
3429 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3430 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3431 unsigned int sel;
3432
3433 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3434 if (ucontrol->value.enumerated.item[0] != sel) {
3435 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003436 snd_hda_codec_write_cache(codec, nid, 0,
3437 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003438 return 1;
3439 }
3440 return 0;
3441}
3442
3443#define PIN_CTL_TEST(xname,nid) { \
3444 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3445 .name = xname, \
3446 .info = alc_test_pin_ctl_info, \
3447 .get = alc_test_pin_ctl_get, \
3448 .put = alc_test_pin_ctl_put, \
3449 .private_value = nid \
3450 }
3451
3452#define PIN_SRC_TEST(xname,nid) { \
3453 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3454 .name = xname, \
3455 .info = alc_test_pin_src_info, \
3456 .get = alc_test_pin_src_get, \
3457 .put = alc_test_pin_src_put, \
3458 .private_value = nid \
3459 }
3460
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003461static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003462 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3463 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3464 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3465 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003466 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3467 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3468 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3469 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003470 PIN_CTL_TEST("Front Pin Mode", 0x14),
3471 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3472 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3473 PIN_CTL_TEST("Side Pin Mode", 0x17),
3474 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3475 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3476 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3477 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3478 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3479 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3480 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3481 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3482 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3483 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3484 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3485 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3486 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3487 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3488 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3489 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3490 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3491 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003492 {
3493 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3494 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003495 .info = alc_ch_mode_info,
3496 .get = alc_ch_mode_get,
3497 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003498 },
3499 { } /* end */
3500};
3501
3502static struct hda_verb alc880_test_init_verbs[] = {
3503 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3505 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3509 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3510 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3511 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003512 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3516 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003517 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003518 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3520 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3521 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003522 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003523 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3524 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3525 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3526 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003527 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003528 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3529 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003530 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3531 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3532 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003533 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003534 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3535 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3536 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3537 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003538 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003539 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003540 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003541 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003542 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003543 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003544 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003545 /* Analog input/passthru */
3546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003551 { }
3552};
3553#endif
3554
Linus Torvalds1da177e2005-04-16 15:20:36 -07003555/*
3556 */
3557
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003558static const char *alc880_models[ALC880_MODEL_LAST] = {
3559 [ALC880_3ST] = "3stack",
3560 [ALC880_TCL_S700] = "tcl",
3561 [ALC880_3ST_DIG] = "3stack-digout",
3562 [ALC880_CLEVO] = "clevo",
3563 [ALC880_5ST] = "5stack",
3564 [ALC880_5ST_DIG] = "5stack-digout",
3565 [ALC880_W810] = "w810",
3566 [ALC880_Z71V] = "z71v",
3567 [ALC880_6ST] = "6stack",
3568 [ALC880_6ST_DIG] = "6stack-digout",
3569 [ALC880_ASUS] = "asus",
3570 [ALC880_ASUS_W1V] = "asus-w1v",
3571 [ALC880_ASUS_DIG] = "asus-dig",
3572 [ALC880_ASUS_DIG2] = "asus-dig2",
3573 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003574 [ALC880_UNIWILL_P53] = "uniwill-p53",
3575 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003576 [ALC880_F1734] = "F1734",
3577 [ALC880_LG] = "lg",
3578 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003579 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003580#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003581 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003582#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003583 [ALC880_AUTO] = "auto",
3584};
3585
3586static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003587 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003588 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3589 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3590 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3591 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3592 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3593 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3594 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3595 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003596 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3597 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003598 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3599 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3600 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3601 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3602 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3603 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3604 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3605 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3606 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3607 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003608 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003609 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3610 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3611 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003612 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003613 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003614 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3615 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003616 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3617 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003618 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3619 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3620 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3621 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003622 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3623 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003624 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003625 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003626 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003627 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003628 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3629 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003630 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003631 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003632 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003633 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003634 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003635 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003636 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003637 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003638 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003639 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3640 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003641 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003642 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3643 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3644 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3645 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003646 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3647 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003648 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003649 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003650 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3651 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003652 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3653 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3654 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003655 /* default Intel */
3656 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003657 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3658 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003659 {}
3660};
3661
Takashi Iwai16ded522005-06-10 19:58:24 +02003662/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003663 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003664 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003665static struct alc_config_preset alc880_presets[] = {
3666 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003667 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003668 .init_verbs = { alc880_volume_init_verbs,
3669 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003670 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003671 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003672 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3673 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003674 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003675 .input_mux = &alc880_capture_source,
3676 },
3677 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003678 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003679 .init_verbs = { alc880_volume_init_verbs,
3680 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003681 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003682 .dac_nids = alc880_dac_nids,
3683 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003684 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3685 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003686 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003687 .input_mux = &alc880_capture_source,
3688 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003689 [ALC880_TCL_S700] = {
3690 .mixers = { alc880_tcl_s700_mixer },
3691 .init_verbs = { alc880_volume_init_verbs,
3692 alc880_pin_tcl_S700_init_verbs,
3693 alc880_gpio2_init_verbs },
3694 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3695 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003696 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3697 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003698 .hp_nid = 0x03,
3699 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3700 .channel_mode = alc880_2_jack_modes,
3701 .input_mux = &alc880_capture_source,
3702 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003703 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003704 .mixers = { alc880_three_stack_mixer,
3705 alc880_five_stack_mixer},
3706 .init_verbs = { alc880_volume_init_verbs,
3707 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003708 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3709 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003710 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3711 .channel_mode = alc880_fivestack_modes,
3712 .input_mux = &alc880_capture_source,
3713 },
3714 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003715 .mixers = { alc880_three_stack_mixer,
3716 alc880_five_stack_mixer },
3717 .init_verbs = { alc880_volume_init_verbs,
3718 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003719 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3720 .dac_nids = alc880_dac_nids,
3721 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003722 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3723 .channel_mode = alc880_fivestack_modes,
3724 .input_mux = &alc880_capture_source,
3725 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003726 [ALC880_6ST] = {
3727 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003728 .init_verbs = { alc880_volume_init_verbs,
3729 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003730 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3731 .dac_nids = alc880_6st_dac_nids,
3732 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3733 .channel_mode = alc880_sixstack_modes,
3734 .input_mux = &alc880_6stack_capture_source,
3735 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003736 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003737 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003738 .init_verbs = { alc880_volume_init_verbs,
3739 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003740 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3741 .dac_nids = alc880_6st_dac_nids,
3742 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003743 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3744 .channel_mode = alc880_sixstack_modes,
3745 .input_mux = &alc880_6stack_capture_source,
3746 },
3747 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003748 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003749 .init_verbs = { alc880_volume_init_verbs,
3750 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003751 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003752 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3753 .dac_nids = alc880_w810_dac_nids,
3754 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003755 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3756 .channel_mode = alc880_w810_modes,
3757 .input_mux = &alc880_capture_source,
3758 },
3759 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003760 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003761 .init_verbs = { alc880_volume_init_verbs,
3762 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003763 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3764 .dac_nids = alc880_z71v_dac_nids,
3765 .dig_out_nid = ALC880_DIGOUT_NID,
3766 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003767 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3768 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003769 .input_mux = &alc880_capture_source,
3770 },
3771 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003772 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003773 .init_verbs = { alc880_volume_init_verbs,
3774 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003775 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3776 .dac_nids = alc880_f1734_dac_nids,
3777 .hp_nid = 0x02,
3778 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3779 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003780 .input_mux = &alc880_f1734_capture_source,
3781 .unsol_event = alc880_uniwill_p53_unsol_event,
3782 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003783 },
3784 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003785 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003786 .init_verbs = { alc880_volume_init_verbs,
3787 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003788 alc880_gpio1_init_verbs },
3789 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3790 .dac_nids = alc880_asus_dac_nids,
3791 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3792 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003793 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003794 .input_mux = &alc880_capture_source,
3795 },
3796 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003797 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003798 .init_verbs = { alc880_volume_init_verbs,
3799 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003800 alc880_gpio1_init_verbs },
3801 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3802 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003803 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003804 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3805 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003806 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003807 .input_mux = &alc880_capture_source,
3808 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003809 [ALC880_ASUS_DIG2] = {
3810 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003811 .init_verbs = { alc880_volume_init_verbs,
3812 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003813 alc880_gpio2_init_verbs }, /* use GPIO2 */
3814 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3815 .dac_nids = alc880_asus_dac_nids,
3816 .dig_out_nid = ALC880_DIGOUT_NID,
3817 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3818 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003819 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003820 .input_mux = &alc880_capture_source,
3821 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003822 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003823 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003824 .init_verbs = { alc880_volume_init_verbs,
3825 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003826 alc880_gpio1_init_verbs },
3827 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3828 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003829 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003830 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3831 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003832 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003833 .input_mux = &alc880_capture_source,
3834 },
3835 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003836 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003837 .init_verbs = { alc880_volume_init_verbs,
3838 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003839 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3840 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003841 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003842 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3843 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003844 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003845 .input_mux = &alc880_capture_source,
3846 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003847 [ALC880_UNIWILL] = {
3848 .mixers = { alc880_uniwill_mixer },
3849 .init_verbs = { alc880_volume_init_verbs,
3850 alc880_uniwill_init_verbs },
3851 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3852 .dac_nids = alc880_asus_dac_nids,
3853 .dig_out_nid = ALC880_DIGOUT_NID,
3854 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3855 .channel_mode = alc880_threestack_modes,
3856 .need_dac_fix = 1,
3857 .input_mux = &alc880_capture_source,
3858 .unsol_event = alc880_uniwill_unsol_event,
3859 .init_hook = alc880_uniwill_automute,
3860 },
3861 [ALC880_UNIWILL_P53] = {
3862 .mixers = { alc880_uniwill_p53_mixer },
3863 .init_verbs = { alc880_volume_init_verbs,
3864 alc880_uniwill_p53_init_verbs },
3865 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3866 .dac_nids = alc880_asus_dac_nids,
3867 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003868 .channel_mode = alc880_threestack_modes,
3869 .input_mux = &alc880_capture_source,
3870 .unsol_event = alc880_uniwill_p53_unsol_event,
3871 .init_hook = alc880_uniwill_p53_hp_automute,
3872 },
3873 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003874 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003875 .init_verbs = { alc880_volume_init_verbs,
3876 alc880_uniwill_p53_init_verbs,
3877 alc880_beep_init_verbs },
3878 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3879 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003880 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003881 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3882 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003883 .input_mux = &alc880_capture_source,
3884 .unsol_event = alc880_uniwill_p53_unsol_event,
3885 .init_hook = alc880_uniwill_p53_hp_automute,
3886 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003887 [ALC880_CLEVO] = {
3888 .mixers = { alc880_three_stack_mixer },
3889 .init_verbs = { alc880_volume_init_verbs,
3890 alc880_pin_clevo_init_verbs },
3891 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3892 .dac_nids = alc880_dac_nids,
3893 .hp_nid = 0x03,
3894 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3895 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003896 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003897 .input_mux = &alc880_capture_source,
3898 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003899 [ALC880_LG] = {
3900 .mixers = { alc880_lg_mixer },
3901 .init_verbs = { alc880_volume_init_verbs,
3902 alc880_lg_init_verbs },
3903 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3904 .dac_nids = alc880_lg_dac_nids,
3905 .dig_out_nid = ALC880_DIGOUT_NID,
3906 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3907 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003908 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003909 .input_mux = &alc880_lg_capture_source,
3910 .unsol_event = alc880_lg_unsol_event,
3911 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003912#ifdef CONFIG_SND_HDA_POWER_SAVE
3913 .loopbacks = alc880_lg_loopbacks,
3914#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003915 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003916 [ALC880_LG_LW] = {
3917 .mixers = { alc880_lg_lw_mixer },
3918 .init_verbs = { alc880_volume_init_verbs,
3919 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003920 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003921 .dac_nids = alc880_dac_nids,
3922 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003923 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3924 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003925 .input_mux = &alc880_lg_lw_capture_source,
3926 .unsol_event = alc880_lg_lw_unsol_event,
3927 .init_hook = alc880_lg_lw_automute,
3928 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003929 [ALC880_MEDION_RIM] = {
3930 .mixers = { alc880_medion_rim_mixer },
3931 .init_verbs = { alc880_volume_init_verbs,
3932 alc880_medion_rim_init_verbs,
3933 alc_gpio2_init_verbs },
3934 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3935 .dac_nids = alc880_dac_nids,
3936 .dig_out_nid = ALC880_DIGOUT_NID,
3937 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3938 .channel_mode = alc880_2_jack_modes,
3939 .input_mux = &alc880_medion_rim_capture_source,
3940 .unsol_event = alc880_medion_rim_unsol_event,
3941 .init_hook = alc880_medion_rim_automute,
3942 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003943#ifdef CONFIG_SND_DEBUG
3944 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003945 .mixers = { alc880_test_mixer },
3946 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003947 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3948 .dac_nids = alc880_test_dac_nids,
3949 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003950 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3951 .channel_mode = alc880_test_modes,
3952 .input_mux = &alc880_test_capture_source,
3953 },
3954#endif
3955};
3956
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003957/*
3958 * Automatic parse of I/O pins from the BIOS configuration
3959 */
3960
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003961enum {
3962 ALC_CTL_WIDGET_VOL,
3963 ALC_CTL_WIDGET_MUTE,
3964 ALC_CTL_BIND_MUTE,
3965};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003966static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003967 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3968 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003969 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003970};
3971
3972/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003973static int add_control(struct alc_spec *spec, int type, const char *name,
3974 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003975{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003976 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003977
Takashi Iwai603c4012008-07-30 15:01:44 +02003978 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3979 knew = snd_array_new(&spec->kctls);
3980 if (!knew)
3981 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003982 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003983 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003984 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003985 return -ENOMEM;
3986 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003987 return 0;
3988}
3989
3990#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3991#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3992#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3993#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3994#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3995#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3996#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3997#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3998#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3999#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4000#define ALC880_PIN_CD_NID 0x1c
4001
4002/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004003static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4004 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004005{
4006 hda_nid_t nid;
4007 int assigned[4];
4008 int i, j;
4009
4010 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004011 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004012
4013 /* check the pins hardwired to audio widget */
4014 for (i = 0; i < cfg->line_outs; i++) {
4015 nid = cfg->line_out_pins[i];
4016 if (alc880_is_fixed_pin(nid)) {
4017 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004018 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004019 assigned[idx] = 1;
4020 }
4021 }
4022 /* left pins can be connect to any audio widget */
4023 for (i = 0; i < cfg->line_outs; i++) {
4024 nid = cfg->line_out_pins[i];
4025 if (alc880_is_fixed_pin(nid))
4026 continue;
4027 /* search for an empty channel */
4028 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004029 if (!assigned[j]) {
4030 spec->multiout.dac_nids[i] =
4031 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004032 assigned[j] = 1;
4033 break;
4034 }
4035 }
4036 }
4037 spec->multiout.num_dacs = cfg->line_outs;
4038 return 0;
4039}
4040
4041/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004042static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4043 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004044{
4045 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004046 static const char *chname[4] = {
4047 "Front", "Surround", NULL /*CLFE*/, "Side"
4048 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004049 hda_nid_t nid;
4050 int i, err;
4051
4052 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004053 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004054 continue;
4055 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4056 if (i == 2) {
4057 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004058 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4059 "Center Playback Volume",
4060 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4061 HDA_OUTPUT));
4062 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004063 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004064 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4065 "LFE Playback Volume",
4066 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4067 HDA_OUTPUT));
4068 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004069 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004070 err = add_control(spec, ALC_CTL_BIND_MUTE,
4071 "Center Playback Switch",
4072 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4073 HDA_INPUT));
4074 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004075 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004076 err = add_control(spec, ALC_CTL_BIND_MUTE,
4077 "LFE Playback Switch",
4078 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4079 HDA_INPUT));
4080 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004081 return err;
4082 } else {
4083 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004084 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4085 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4086 HDA_OUTPUT));
4087 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004088 return err;
4089 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004090 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4091 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4092 HDA_INPUT));
4093 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004094 return err;
4095 }
4096 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004097 return 0;
4098}
4099
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004100/* add playback controls for speaker and HP outputs */
4101static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4102 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004103{
4104 hda_nid_t nid;
4105 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004106 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004107
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004108 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004109 return 0;
4110
4111 if (alc880_is_fixed_pin(pin)) {
4112 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004113 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004114 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004115 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004116 else
4117 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004118 /* control HP volume/switch on the output mixer amp */
4119 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004120 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004121 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4122 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4123 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004124 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004125 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004126 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4127 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4128 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004129 return err;
4130 } else if (alc880_is_multi_pin(pin)) {
4131 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004132 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004133 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004134 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4135 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4136 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004137 return err;
4138 }
4139 return 0;
4140}
4141
4142/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004143static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4144 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004145 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004146{
4147 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004148 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004149
4150 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004151 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4152 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4153 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004154 return err;
4155 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004156 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4157 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4158 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004159 return err;
4160 return 0;
4161}
4162
4163/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004164static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4165 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004166{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004167 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004168 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004169
4170 for (i = 0; i < AUTO_PIN_LAST; i++) {
4171 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004172 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004173 err = new_analog_input(spec, cfg->input_pins[i],
4174 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004175 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004176 if (err < 0)
4177 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004178 imux->items[imux->num_items].label =
4179 auto_pin_cfg_labels[i];
4180 imux->items[imux->num_items].index =
4181 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004182 imux->num_items++;
4183 }
4184 }
4185 return 0;
4186}
4187
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004188static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4189 unsigned int pin_type)
4190{
4191 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4192 pin_type);
4193 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004194 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4195 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004196}
4197
Kailang Yangdf694da2005-12-05 19:42:22 +01004198static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4199 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004200 int dac_idx)
4201{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004202 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004203 /* need the manual connection? */
4204 if (alc880_is_multi_pin(nid)) {
4205 struct alc_spec *spec = codec->spec;
4206 int idx = alc880_multi_pin_idx(nid);
4207 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4208 AC_VERB_SET_CONNECT_SEL,
4209 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4210 }
4211}
4212
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004213static int get_pin_type(int line_out_type)
4214{
4215 if (line_out_type == AUTO_PIN_HP_OUT)
4216 return PIN_HP;
4217 else
4218 return PIN_OUT;
4219}
4220
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004221static void alc880_auto_init_multi_out(struct hda_codec *codec)
4222{
4223 struct alc_spec *spec = codec->spec;
4224 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004225
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004226 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004227 for (i = 0; i < spec->autocfg.line_outs; i++) {
4228 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004229 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4230 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004231 }
4232}
4233
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004234static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004235{
4236 struct alc_spec *spec = codec->spec;
4237 hda_nid_t pin;
4238
Takashi Iwai82bc9552006-03-21 11:24:42 +01004239 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004240 if (pin) /* connect to front */
4241 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004242 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004243 if (pin) /* connect to front */
4244 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4245}
4246
4247static void alc880_auto_init_analog_input(struct hda_codec *codec)
4248{
4249 struct alc_spec *spec = codec->spec;
4250 int i;
4251
4252 for (i = 0; i < AUTO_PIN_LAST; i++) {
4253 hda_nid_t nid = spec->autocfg.input_pins[i];
4254 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004255 snd_hda_codec_write(codec, nid, 0,
4256 AC_VERB_SET_PIN_WIDGET_CONTROL,
4257 i <= AUTO_PIN_FRONT_MIC ?
4258 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004259 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004260 snd_hda_codec_write(codec, nid, 0,
4261 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004262 AMP_OUT_MUTE);
4263 }
4264 }
4265}
4266
4267/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004268/* return 1 if successful, 0 if the proper config is not found,
4269 * or a negative error code
4270 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004271static int alc880_parse_auto_config(struct hda_codec *codec)
4272{
4273 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004274 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004275 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004276
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004277 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4278 alc880_ignore);
4279 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004280 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004281 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004282 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004283
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004284 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4285 if (err < 0)
4286 return err;
4287 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4288 if (err < 0)
4289 return err;
4290 err = alc880_auto_create_extra_out(spec,
4291 spec->autocfg.speaker_pins[0],
4292 "Speaker");
4293 if (err < 0)
4294 return err;
4295 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4296 "Headphone");
4297 if (err < 0)
4298 return err;
4299 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4300 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004301 return err;
4302
4303 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4304
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004305 /* check multiple SPDIF-out (for recent codecs) */
4306 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4307 hda_nid_t dig_nid;
4308 err = snd_hda_get_connections(codec,
4309 spec->autocfg.dig_out_pins[i],
4310 &dig_nid, 1);
4311 if (err < 0)
4312 continue;
4313 if (!i)
4314 spec->multiout.dig_out_nid = dig_nid;
4315 else {
4316 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4317 spec->slave_dig_outs[i - 1] = dig_nid;
4318 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4319 break;
4320 }
4321 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004322 if (spec->autocfg.dig_in_pin)
4323 spec->dig_in_nid = ALC880_DIGIN_NID;
4324
Takashi Iwai603c4012008-07-30 15:01:44 +02004325 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004326 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004327
Takashi Iwaid88897e2008-10-31 15:01:37 +01004328 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004329
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004330 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004331 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004332
Takashi Iwaie044c392008-10-27 16:56:24 +01004333 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004334 return 1;
4335}
4336
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004337/* additional initialization for auto-configuration model */
4338static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004339{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004340 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004341 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004342 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004343 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004344 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004345 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004346}
4347
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004348static void set_capture_mixer(struct alc_spec *spec)
4349{
4350 static struct snd_kcontrol_new *caps[3] = {
4351 alc_capture_mixer1,
4352 alc_capture_mixer2,
4353 alc_capture_mixer3,
4354 };
Takashi Iwai30d72e92008-11-27 15:25:34 +01004355 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004356 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4357}
4358
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004359#define set_beep_amp(spec, nid, idx, dir) \
4360 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4361
4362/*
4363 * OK, here we have finally the patch for ALC880
4364 */
4365
Linus Torvalds1da177e2005-04-16 15:20:36 -07004366static int patch_alc880(struct hda_codec *codec)
4367{
4368 struct alc_spec *spec;
4369 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004370 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004371
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004372 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004373 if (spec == NULL)
4374 return -ENOMEM;
4375
4376 codec->spec = spec;
4377
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004378 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4379 alc880_models,
4380 alc880_cfg_tbl);
4381 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004382 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4383 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004384 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004385 }
4386
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004387 if (board_config == ALC880_AUTO) {
4388 /* automatic parse from the BIOS config */
4389 err = alc880_parse_auto_config(codec);
4390 if (err < 0) {
4391 alc_free(codec);
4392 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004393 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004394 printk(KERN_INFO
4395 "hda_codec: Cannot set up configuration "
4396 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004397 board_config = ALC880_3ST;
4398 }
4399 }
4400
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004401 err = snd_hda_attach_beep_device(codec, 0x1);
4402 if (err < 0) {
4403 alc_free(codec);
4404 return err;
4405 }
4406
Kailang Yangdf694da2005-12-05 19:42:22 +01004407 if (board_config != ALC880_AUTO)
4408 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004409
4410 spec->stream_name_analog = "ALC880 Analog";
4411 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4412 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004413 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004414
4415 spec->stream_name_digital = "ALC880 Digital";
4416 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4417 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4418
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004419 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004420 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004421 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004422 /* get type */
4423 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004424 if (wcap != AC_WID_AUD_IN) {
4425 spec->adc_nids = alc880_adc_nids_alt;
4426 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004427 } else {
4428 spec->adc_nids = alc880_adc_nids;
4429 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004430 }
4431 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004432 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004433 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004434
Takashi Iwai2134ea42008-01-10 16:53:55 +01004435 spec->vmaster_nid = 0x0c;
4436
Linus Torvalds1da177e2005-04-16 15:20:36 -07004437 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004438 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004439 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004440#ifdef CONFIG_SND_HDA_POWER_SAVE
4441 if (!spec->loopback.amplist)
4442 spec->loopback.amplist = alc880_loopbacks;
4443#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004444 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004445
4446 return 0;
4447}
4448
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449
Linus Torvalds1da177e2005-04-16 15:20:36 -07004450/*
4451 * ALC260 support
4452 */
4453
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004454static hda_nid_t alc260_dac_nids[1] = {
4455 /* front */
4456 0x02,
4457};
4458
4459static hda_nid_t alc260_adc_nids[1] = {
4460 /* ADC0 */
4461 0x04,
4462};
4463
Kailang Yangdf694da2005-12-05 19:42:22 +01004464static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004465 /* ADC1 */
4466 0x05,
4467};
4468
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004469/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4470 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4471 */
4472static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004473 /* ADC0, ADC1 */
4474 0x04, 0x05
4475};
4476
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004477#define ALC260_DIGOUT_NID 0x03
4478#define ALC260_DIGIN_NID 0x06
4479
4480static struct hda_input_mux alc260_capture_source = {
4481 .num_items = 4,
4482 .items = {
4483 { "Mic", 0x0 },
4484 { "Front Mic", 0x1 },
4485 { "Line", 0x2 },
4486 { "CD", 0x4 },
4487 },
4488};
4489
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004490/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004491 * headphone jack and the internal CD lines since these are the only pins at
4492 * which audio can appear. For flexibility, also allow the option of
4493 * recording the mixer output on the second ADC (ADC0 doesn't have a
4494 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004495 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004496static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4497 {
4498 .num_items = 3,
4499 .items = {
4500 { "Mic/Line", 0x0 },
4501 { "CD", 0x4 },
4502 { "Headphone", 0x2 },
4503 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004504 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004505 {
4506 .num_items = 4,
4507 .items = {
4508 { "Mic/Line", 0x0 },
4509 { "CD", 0x4 },
4510 { "Headphone", 0x2 },
4511 { "Mixer", 0x5 },
4512 },
4513 },
4514
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004515};
4516
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004517/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4518 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004519 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004520static struct hda_input_mux alc260_acer_capture_sources[2] = {
4521 {
4522 .num_items = 4,
4523 .items = {
4524 { "Mic", 0x0 },
4525 { "Line", 0x2 },
4526 { "CD", 0x4 },
4527 { "Headphone", 0x5 },
4528 },
4529 },
4530 {
4531 .num_items = 5,
4532 .items = {
4533 { "Mic", 0x0 },
4534 { "Line", 0x2 },
4535 { "CD", 0x4 },
4536 { "Headphone", 0x6 },
4537 { "Mixer", 0x5 },
4538 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004539 },
4540};
Michael Schwingencc959482009-02-22 18:58:45 +01004541
4542/* Maxdata Favorit 100XS */
4543static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4544 {
4545 .num_items = 2,
4546 .items = {
4547 { "Line/Mic", 0x0 },
4548 { "CD", 0x4 },
4549 },
4550 },
4551 {
4552 .num_items = 3,
4553 .items = {
4554 { "Line/Mic", 0x0 },
4555 { "CD", 0x4 },
4556 { "Mixer", 0x5 },
4557 },
4558 },
4559};
4560
Linus Torvalds1da177e2005-04-16 15:20:36 -07004561/*
4562 * This is just place-holder, so there's something for alc_build_pcms to look
4563 * at when it calculates the maximum number of channels. ALC260 has no mixer
4564 * element which allows changing the channel mode, so the verb list is
4565 * never used.
4566 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004567static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004568 { 2, NULL },
4569};
4570
Kailang Yangdf694da2005-12-05 19:42:22 +01004571
4572/* Mixer combinations
4573 *
4574 * basic: base_output + input + pc_beep + capture
4575 * HP: base_output + input + capture_alt
4576 * HP_3013: hp_3013 + input + capture
4577 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004578 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004579 */
4580
4581static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004582 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004583 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004584 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4585 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4586 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4587 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4588 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004589};
Kailang Yangdf694da2005-12-05 19:42:22 +01004590
4591static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004592 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4593 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4594 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4595 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4596 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4597 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4598 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4599 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004600 { } /* end */
4601};
4602
Takashi Iwaibec15c32008-01-28 18:16:30 +01004603/* update HP, line and mono out pins according to the master switch */
4604static void alc260_hp_master_update(struct hda_codec *codec,
4605 hda_nid_t hp, hda_nid_t line,
4606 hda_nid_t mono)
4607{
4608 struct alc_spec *spec = codec->spec;
4609 unsigned int val = spec->master_sw ? PIN_HP : 0;
4610 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004611 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004612 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004613 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004614 val);
4615 /* mono (speaker) depending on the HP jack sense */
4616 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004617 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004618 val);
4619}
4620
4621static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4622 struct snd_ctl_elem_value *ucontrol)
4623{
4624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4625 struct alc_spec *spec = codec->spec;
4626 *ucontrol->value.integer.value = spec->master_sw;
4627 return 0;
4628}
4629
4630static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4631 struct snd_ctl_elem_value *ucontrol)
4632{
4633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4634 struct alc_spec *spec = codec->spec;
4635 int val = !!*ucontrol->value.integer.value;
4636 hda_nid_t hp, line, mono;
4637
4638 if (val == spec->master_sw)
4639 return 0;
4640 spec->master_sw = val;
4641 hp = (kcontrol->private_value >> 16) & 0xff;
4642 line = (kcontrol->private_value >> 8) & 0xff;
4643 mono = kcontrol->private_value & 0xff;
4644 alc260_hp_master_update(codec, hp, line, mono);
4645 return 1;
4646}
4647
4648static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4649 {
4650 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4651 .name = "Master Playback Switch",
4652 .info = snd_ctl_boolean_mono_info,
4653 .get = alc260_hp_master_sw_get,
4654 .put = alc260_hp_master_sw_put,
4655 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4656 },
4657 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4658 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4659 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4660 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4661 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4662 HDA_OUTPUT),
4663 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4664 { } /* end */
4665};
4666
4667static struct hda_verb alc260_hp_unsol_verbs[] = {
4668 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4669 {},
4670};
4671
4672static void alc260_hp_automute(struct hda_codec *codec)
4673{
4674 struct alc_spec *spec = codec->spec;
4675 unsigned int present;
4676
4677 present = snd_hda_codec_read(codec, 0x10, 0,
4678 AC_VERB_GET_PIN_SENSE, 0);
4679 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4680 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4681}
4682
4683static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4684{
4685 if ((res >> 26) == ALC880_HP_EVENT)
4686 alc260_hp_automute(codec);
4687}
4688
Kailang Yangdf694da2005-12-05 19:42:22 +01004689static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004690 {
4691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4692 .name = "Master Playback Switch",
4693 .info = snd_ctl_boolean_mono_info,
4694 .get = alc260_hp_master_sw_get,
4695 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004696 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004697 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004698 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4699 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4700 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4701 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4702 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4703 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004704 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4705 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004706 { } /* end */
4707};
4708
Kailang Yang3f878302008-08-26 13:02:23 +02004709static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4710 .ops = &snd_hda_bind_vol,
4711 .values = {
4712 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4713 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4714 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4715 0
4716 },
4717};
4718
4719static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4720 .ops = &snd_hda_bind_sw,
4721 .values = {
4722 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4723 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4724 0
4725 },
4726};
4727
4728static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4729 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4730 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4731 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4732 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4733 { } /* end */
4734};
4735
Takashi Iwaibec15c32008-01-28 18:16:30 +01004736static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4737 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4738 {},
4739};
4740
4741static void alc260_hp_3013_automute(struct hda_codec *codec)
4742{
4743 struct alc_spec *spec = codec->spec;
4744 unsigned int present;
4745
4746 present = snd_hda_codec_read(codec, 0x15, 0,
4747 AC_VERB_GET_PIN_SENSE, 0);
4748 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004749 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004750}
4751
4752static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4753 unsigned int res)
4754{
4755 if ((res >> 26) == ALC880_HP_EVENT)
4756 alc260_hp_3013_automute(codec);
4757}
4758
Kailang Yang3f878302008-08-26 13:02:23 +02004759static void alc260_hp_3012_automute(struct hda_codec *codec)
4760{
4761 unsigned int present, bits;
4762
4763 present = snd_hda_codec_read(codec, 0x10, 0,
4764 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4765
4766 bits = present ? 0 : PIN_OUT;
4767 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4768 bits);
4769 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4770 bits);
4771 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4772 bits);
4773}
4774
4775static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4776 unsigned int res)
4777{
4778 if ((res >> 26) == ALC880_HP_EVENT)
4779 alc260_hp_3012_automute(codec);
4780}
4781
4782/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004783 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4784 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004785static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004786 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004787 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004788 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004789 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4790 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4791 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4792 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004793 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004794 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4795 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004796 { } /* end */
4797};
4798
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004799/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4800 * versions of the ALC260 don't act on requests to enable mic bias from NID
4801 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4802 * datasheet doesn't mention this restriction. At this stage it's not clear
4803 * whether this behaviour is intentional or is a hardware bug in chip
4804 * revisions available in early 2006. Therefore for now allow the
4805 * "Headphone Jack Mode" control to span all choices, but if it turns out
4806 * that the lack of mic bias for this NID is intentional we could change the
4807 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4808 *
4809 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4810 * don't appear to make the mic bias available from the "line" jack, even
4811 * though the NID used for this jack (0x14) can supply it. The theory is
4812 * that perhaps Acer have included blocking capacitors between the ALC260
4813 * and the output jack. If this turns out to be the case for all such
4814 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4815 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004816 *
4817 * The C20x Tablet series have a mono internal speaker which is controlled
4818 * via the chip's Mono sum widget and pin complex, so include the necessary
4819 * controls for such models. On models without a "mono speaker" the control
4820 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004821 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004822static struct snd_kcontrol_new alc260_acer_mixer[] = {
4823 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4824 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004825 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004826 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004827 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004828 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004829 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004830 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4831 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4833 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4834 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4835 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4836 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4837 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004838 { } /* end */
4839};
4840
Michael Schwingencc959482009-02-22 18:58:45 +01004841/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4842 */
4843static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4844 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4845 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4846 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4847 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4848 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4849 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4850 { } /* end */
4851};
4852
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004853/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4854 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4855 */
4856static struct snd_kcontrol_new alc260_will_mixer[] = {
4857 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4858 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4860 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4861 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4862 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4863 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4864 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4865 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4866 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004867 { } /* end */
4868};
4869
4870/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4871 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4872 */
4873static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4874 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4875 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4876 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4877 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4878 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4879 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4880 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4881 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4882 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4883 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4884 { } /* end */
4885};
4886
Kailang Yangdf694da2005-12-05 19:42:22 +01004887/*
4888 * initialization verbs
4889 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004890static struct hda_verb alc260_init_verbs[] = {
4891 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004892 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004893 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004894 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004895 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004896 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004897 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004898 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004899 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004900 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004901 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004902 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004903 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004904 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004905 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004906 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004907 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004908 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4909 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004910 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004911 /* set connection select to line in (default select for this ADC) */
4912 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004913 /* mute capture amp left and right */
4914 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4915 /* set connection select to line in (default select for this ADC) */
4916 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004917 /* set vol=0 Line-Out mixer amp left and right */
4918 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4919 /* unmute pin widget amp left and right (no gain on this amp) */
4920 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4921 /* set vol=0 HP mixer amp left and right */
4922 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4923 /* unmute pin widget amp left and right (no gain on this amp) */
4924 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4925 /* set vol=0 Mono mixer amp left and right */
4926 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4927 /* unmute pin widget amp left and right (no gain on this amp) */
4928 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4929 /* unmute LINE-2 out pin */
4930 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
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)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004940 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004941 /* mute Front out path */
4942 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4943 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4944 /* mute Headphone out path */
4945 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4946 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4947 /* mute Mono out path */
4948 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4949 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004950 { }
4951};
4952
Takashi Iwai474167d2006-05-17 17:17:43 +02004953#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004954static struct hda_verb alc260_hp_init_verbs[] = {
4955 /* Headphone and output */
4956 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
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 /* Line-2 pin widget for output */
4966 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
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};
Takashi Iwai474167d2006-05-17 17:17:43 +02005002#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005003
5004static struct hda_verb alc260_hp_3013_init_verbs[] = {
5005 /* Line out and output */
5006 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5007 /* mono output */
5008 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5009 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5010 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5011 /* Mic2 (front panel) pin widget for input and vref at 80% */
5012 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5013 /* Line In pin widget for input */
5014 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5015 /* Headphone pin widget for output */
5016 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5017 /* CD pin widget for input */
5018 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5019 /* unmute amp left and right */
5020 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5021 /* set connection select to line in (default select for this ADC) */
5022 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5023 /* unmute Line-Out mixer amp left and right (volume = 0) */
5024 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5025 /* mute pin widget amp left and right (no gain on this amp) */
5026 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5027 /* unmute HP mixer amp left and right (volume = 0) */
5028 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5029 /* mute pin widget amp left and right (no gain on this amp) */
5030 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005031 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5032 * Line In 2 = 0x03
5033 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005034 /* mute analog inputs */
5035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5036 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5037 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5038 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5039 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005040 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5041 /* Unmute Front out path */
5042 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5043 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5044 /* Unmute Headphone out path */
5045 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5046 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5047 /* Unmute Mono out path */
5048 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5049 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5050 { }
5051};
5052
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005053/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005054 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5055 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005056 */
5057static struct hda_verb alc260_fujitsu_init_verbs[] = {
5058 /* Disable all GPIOs */
5059 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5060 /* Internal speaker is connected to headphone pin */
5061 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5062 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005064 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5065 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5066 /* Ensure all other unused pins are disabled and muted. */
5067 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5068 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005069 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005070 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005071 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005072 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5073 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005075
Jonathan Woithef7ace402006-02-28 11:46:14 +01005076 /* Disable digital (SPDIF) pins */
5077 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5078 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005079
Kailang Yangea1fb292008-08-26 12:58:38 +02005080 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005081 * when acting as an output.
5082 */
5083 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5084
5085 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005086 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5087 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5088 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5089 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5090 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5092 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5093 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5094 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005095
Jonathan Woithef7ace402006-02-28 11:46:14 +01005096 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5097 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5098 /* Unmute Line1 pin widget output buffer since it starts as an output.
5099 * If the pin mode is changed by the user the pin mode control will
5100 * take care of enabling the pin's input/output buffers as needed.
5101 * Therefore there's no need to enable the input buffer at this
5102 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005103 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005104 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005105 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005106 * mixer ctrl)
5107 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005108 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005109
Jonathan Woithef7ace402006-02-28 11:46:14 +01005110 /* Mute capture amp left and right */
5111 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005112 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005113 * in (on mic1 pin)
5114 */
5115 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005116
Jonathan Woithef7ace402006-02-28 11:46:14 +01005117 /* Do the same for the second ADC: mute capture input amp and
5118 * set ADC connection to line in (on mic1 pin)
5119 */
5120 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5121 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005122
Jonathan Woithef7ace402006-02-28 11:46:14 +01005123 /* Mute all inputs to mixer widget (even unconnected ones) */
5124 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5125 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5126 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5127 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005132
5133 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005134};
5135
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005136/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5137 * similar laptops (adapted from Fujitsu init verbs).
5138 */
5139static struct hda_verb alc260_acer_init_verbs[] = {
5140 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5141 * the headphone jack. Turn this on and rely on the standard mute
5142 * methods whenever the user wants to turn these outputs off.
5143 */
5144 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5145 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5146 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5147 /* Internal speaker/Headphone jack is connected to Line-out pin */
5148 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5149 /* Internal microphone/Mic jack is connected to Mic1 pin */
5150 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5151 /* Line In jack is connected to Line1 pin */
5152 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005153 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5154 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005155 /* Ensure all other unused pins are disabled and muted. */
5156 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5157 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005158 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5159 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5160 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5161 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5162 /* Disable digital (SPDIF) pins */
5163 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5164 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5165
Kailang Yangea1fb292008-08-26 12:58:38 +02005166 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005167 * bus when acting as outputs.
5168 */
5169 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5170 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5171
5172 /* Start with output sum widgets muted and their output gains at min */
5173 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5174 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5175 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5176 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5177 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5178 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5179 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5180 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5181 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5182
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005183 /* Unmute Line-out pin widget amp left and right
5184 * (no equiv mixer ctrl)
5185 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005186 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005187 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5188 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005189 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5190 * inputs. If the pin mode is changed by the user the pin mode control
5191 * will take care of enabling the pin's input/output buffers as needed.
5192 * Therefore there's no need to enable the input buffer at this
5193 * stage.
5194 */
5195 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5196 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5197
5198 /* Mute capture amp left and right */
5199 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5200 /* Set ADC connection select to match default mixer setting - mic
5201 * (on mic1 pin)
5202 */
5203 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5204
5205 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005206 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005207 */
5208 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005209 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005210
5211 /* Mute all inputs to mixer widget (even unconnected ones) */
5212 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5213 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5216 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5217 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5219 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5220
5221 { }
5222};
5223
Michael Schwingencc959482009-02-22 18:58:45 +01005224/* Initialisation sequence for Maxdata Favorit 100XS
5225 * (adapted from Acer init verbs).
5226 */
5227static struct hda_verb alc260_favorit100_init_verbs[] = {
5228 /* GPIO 0 enables the output jack.
5229 * Turn this on and rely on the standard mute
5230 * methods whenever the user wants to turn these outputs off.
5231 */
5232 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5233 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5234 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5235 /* Line/Mic input jack is connected to Mic1 pin */
5236 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5237 /* Ensure all other unused pins are disabled and muted. */
5238 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5239 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5240 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5241 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5242 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5243 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5245 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5246 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5248 /* Disable digital (SPDIF) pins */
5249 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5250 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5251
5252 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5253 * bus when acting as outputs.
5254 */
5255 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5256 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5257
5258 /* Start with output sum widgets muted and their output gains at min */
5259 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5260 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5261 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5262 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5263 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5264 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5265 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5266 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5267 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5268
5269 /* Unmute Line-out pin widget amp left and right
5270 * (no equiv mixer ctrl)
5271 */
5272 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5273 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5274 * inputs. If the pin mode is changed by the user the pin mode control
5275 * will take care of enabling the pin's input/output buffers as needed.
5276 * Therefore there's no need to enable the input buffer at this
5277 * stage.
5278 */
5279 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5280
5281 /* Mute capture amp left and right */
5282 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5283 /* Set ADC connection select to match default mixer setting - mic
5284 * (on mic1 pin)
5285 */
5286 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5287
5288 /* Do similar with the second ADC: mute capture input amp and
5289 * set ADC connection to mic to match ALSA's default state.
5290 */
5291 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5292 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5293
5294 /* Mute all inputs to mixer widget (even unconnected ones) */
5295 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5296 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5297 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5298 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5299 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5300 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5301 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5302 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5303
5304 { }
5305};
5306
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005307static struct hda_verb alc260_will_verbs[] = {
5308 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5309 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5310 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5311 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5312 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5313 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5314 {}
5315};
5316
5317static struct hda_verb alc260_replacer_672v_verbs[] = {
5318 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5319 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5320 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5321
5322 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5323 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5324 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5325
5326 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5327 {}
5328};
5329
5330/* toggle speaker-output according to the hp-jack state */
5331static void alc260_replacer_672v_automute(struct hda_codec *codec)
5332{
5333 unsigned int present;
5334
5335 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5336 present = snd_hda_codec_read(codec, 0x0f, 0,
5337 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5338 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005339 snd_hda_codec_write_cache(codec, 0x01, 0,
5340 AC_VERB_SET_GPIO_DATA, 1);
5341 snd_hda_codec_write_cache(codec, 0x0f, 0,
5342 AC_VERB_SET_PIN_WIDGET_CONTROL,
5343 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005344 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005345 snd_hda_codec_write_cache(codec, 0x01, 0,
5346 AC_VERB_SET_GPIO_DATA, 0);
5347 snd_hda_codec_write_cache(codec, 0x0f, 0,
5348 AC_VERB_SET_PIN_WIDGET_CONTROL,
5349 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005350 }
5351}
5352
5353static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5354 unsigned int res)
5355{
5356 if ((res >> 26) == ALC880_HP_EVENT)
5357 alc260_replacer_672v_automute(codec);
5358}
5359
Kailang Yang3f878302008-08-26 13:02:23 +02005360static struct hda_verb alc260_hp_dc7600_verbs[] = {
5361 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5362 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5363 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5364 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5365 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5367 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5368 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5369 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5370 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5371 {}
5372};
5373
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005374/* Test configuration for debugging, modelled after the ALC880 test
5375 * configuration.
5376 */
5377#ifdef CONFIG_SND_DEBUG
5378static hda_nid_t alc260_test_dac_nids[1] = {
5379 0x02,
5380};
5381static hda_nid_t alc260_test_adc_nids[2] = {
5382 0x04, 0x05,
5383};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005384/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005385 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005386 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005387 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005388static struct hda_input_mux alc260_test_capture_sources[2] = {
5389 {
5390 .num_items = 7,
5391 .items = {
5392 { "MIC1 pin", 0x0 },
5393 { "MIC2 pin", 0x1 },
5394 { "LINE1 pin", 0x2 },
5395 { "LINE2 pin", 0x3 },
5396 { "CD pin", 0x4 },
5397 { "LINE-OUT pin", 0x5 },
5398 { "HP-OUT pin", 0x6 },
5399 },
5400 },
5401 {
5402 .num_items = 8,
5403 .items = {
5404 { "MIC1 pin", 0x0 },
5405 { "MIC2 pin", 0x1 },
5406 { "LINE1 pin", 0x2 },
5407 { "LINE2 pin", 0x3 },
5408 { "CD pin", 0x4 },
5409 { "Mixer", 0x5 },
5410 { "LINE-OUT pin", 0x6 },
5411 { "HP-OUT pin", 0x7 },
5412 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005413 },
5414};
5415static struct snd_kcontrol_new alc260_test_mixer[] = {
5416 /* Output driver widgets */
5417 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5418 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5419 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5420 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5421 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5422 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5423
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005424 /* Modes for retasking pin widgets
5425 * Note: the ALC260 doesn't seem to act on requests to enable mic
5426 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5427 * mention this restriction. At this stage it's not clear whether
5428 * this behaviour is intentional or is a hardware bug in chip
5429 * revisions available at least up until early 2006. Therefore for
5430 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5431 * choices, but if it turns out that the lack of mic bias for these
5432 * NIDs is intentional we could change their modes from
5433 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5434 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005435 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5436 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5437 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5438 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5439 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5440 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5441
5442 /* Loopback mixer controls */
5443 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5444 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5445 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5446 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5447 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5448 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5449 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5450 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5451 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5452 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005453 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5454 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5455 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5456 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005457
5458 /* Controls for GPIO pins, assuming they are configured as outputs */
5459 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5460 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5461 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5462 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5463
Jonathan Woithe92621f12006-02-28 11:47:47 +01005464 /* Switches to allow the digital IO pins to be enabled. The datasheet
5465 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005466 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005467 */
5468 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5469 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5470
Jonathan Woithef8225f62008-01-08 12:16:54 +01005471 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5472 * this output to turn on an external amplifier.
5473 */
5474 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5475 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5476
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005477 { } /* end */
5478};
5479static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005480 /* Enable all GPIOs as outputs with an initial value of 0 */
5481 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5482 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5483 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5484
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005485 /* Enable retasking pins as output, initially without power amp */
5486 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5487 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5489 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5490 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5491 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5492
Jonathan Woithe92621f12006-02-28 11:47:47 +01005493 /* Disable digital (SPDIF) pins initially, but users can enable
5494 * them via a mixer switch. In the case of SPDIF-out, this initverb
5495 * payload also sets the generation to 0, output to be in "consumer"
5496 * PCM format, copyright asserted, no pre-emphasis and no validity
5497 * control.
5498 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005499 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5500 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5501
Kailang Yangea1fb292008-08-26 12:58:38 +02005502 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005503 * OUT1 sum bus when acting as an output.
5504 */
5505 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5506 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5507 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5508 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5509
5510 /* Start with output sum widgets muted and their output gains at min */
5511 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5512 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5513 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5514 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5515 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5516 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5517 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5518 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5519 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5520
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005521 /* Unmute retasking pin widget output buffers since the default
5522 * state appears to be output. As the pin mode is changed by the
5523 * user the pin mode control will take care of enabling the pin's
5524 * input/output buffers as needed.
5525 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005526 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5527 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5528 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5529 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5530 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5531 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5532 /* Also unmute the mono-out pin widget */
5533 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5534
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005535 /* Mute capture amp left and right */
5536 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005537 /* Set ADC connection select to match default mixer setting (mic1
5538 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005539 */
5540 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5541
5542 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005543 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005544 */
5545 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5546 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5547
5548 /* Mute all inputs to mixer widget (even unconnected ones) */
5549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5554 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5557
5558 { }
5559};
5560#endif
5561
Takashi Iwai63300792008-01-24 15:31:36 +01005562#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5563#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005564
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005565#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5566#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5567
Kailang Yangdf694da2005-12-05 19:42:22 +01005568/*
5569 * for BIOS auto-configuration
5570 */
5571
5572static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005573 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005574{
5575 hda_nid_t nid_vol;
5576 unsigned long vol_val, sw_val;
5577 char name[32];
5578 int err;
5579
5580 if (nid >= 0x0f && nid < 0x11) {
5581 nid_vol = nid - 0x7;
5582 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5583 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5584 } else if (nid == 0x11) {
5585 nid_vol = nid - 0x7;
5586 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5587 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5588 } else if (nid >= 0x12 && nid <= 0x15) {
5589 nid_vol = 0x08;
5590 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5591 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5592 } else
5593 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005594
Takashi Iwai863b4512008-10-21 17:01:47 +02005595 if (!(*vol_bits & (1 << nid_vol))) {
5596 /* first control for the volume widget */
5597 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5598 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5599 if (err < 0)
5600 return err;
5601 *vol_bits |= (1 << nid_vol);
5602 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005603 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005604 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5605 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005606 return err;
5607 return 1;
5608}
5609
5610/* add playback controls from the parsed DAC table */
5611static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5612 const struct auto_pin_cfg *cfg)
5613{
5614 hda_nid_t nid;
5615 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005616 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005617
5618 spec->multiout.num_dacs = 1;
5619 spec->multiout.dac_nids = spec->private_dac_nids;
5620 spec->multiout.dac_nids[0] = 0x02;
5621
5622 nid = cfg->line_out_pins[0];
5623 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005624 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005625 if (err < 0)
5626 return err;
5627 }
5628
Takashi Iwai82bc9552006-03-21 11:24:42 +01005629 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005630 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005631 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005632 if (err < 0)
5633 return err;
5634 }
5635
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005636 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005637 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005638 err = alc260_add_playback_controls(spec, nid, "Headphone",
5639 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005640 if (err < 0)
5641 return err;
5642 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005643 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005644}
5645
5646/* create playback/capture controls for input pins */
5647static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5648 const struct auto_pin_cfg *cfg)
5649{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005650 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005651 int i, err, idx;
5652
5653 for (i = 0; i < AUTO_PIN_LAST; i++) {
5654 if (cfg->input_pins[i] >= 0x12) {
5655 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005656 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005657 auto_pin_cfg_labels[i], idx,
5658 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005659 if (err < 0)
5660 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005661 imux->items[imux->num_items].label =
5662 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005663 imux->items[imux->num_items].index = idx;
5664 imux->num_items++;
5665 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005666 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005667 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005668 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005669 auto_pin_cfg_labels[i], idx,
5670 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005671 if (err < 0)
5672 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005673 imux->items[imux->num_items].label =
5674 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005675 imux->items[imux->num_items].index = idx;
5676 imux->num_items++;
5677 }
5678 }
5679 return 0;
5680}
5681
5682static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5683 hda_nid_t nid, int pin_type,
5684 int sel_idx)
5685{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005686 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005687 /* need the manual connection? */
5688 if (nid >= 0x12) {
5689 int idx = nid - 0x12;
5690 snd_hda_codec_write(codec, idx + 0x0b, 0,
5691 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005692 }
5693}
5694
5695static void alc260_auto_init_multi_out(struct hda_codec *codec)
5696{
5697 struct alc_spec *spec = codec->spec;
5698 hda_nid_t nid;
5699
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005700 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005701 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005702 if (nid) {
5703 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5704 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5705 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005706
Takashi Iwai82bc9552006-03-21 11:24:42 +01005707 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005708 if (nid)
5709 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5710
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005711 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005712 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005713 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005714}
Kailang Yangdf694da2005-12-05 19:42:22 +01005715
5716#define ALC260_PIN_CD_NID 0x16
5717static void alc260_auto_init_analog_input(struct hda_codec *codec)
5718{
5719 struct alc_spec *spec = codec->spec;
5720 int i;
5721
5722 for (i = 0; i < AUTO_PIN_LAST; i++) {
5723 hda_nid_t nid = spec->autocfg.input_pins[i];
5724 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005725 snd_hda_codec_write(codec, nid, 0,
5726 AC_VERB_SET_PIN_WIDGET_CONTROL,
5727 i <= AUTO_PIN_FRONT_MIC ?
5728 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005729 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005730 snd_hda_codec_write(codec, nid, 0,
5731 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005732 AMP_OUT_MUTE);
5733 }
5734 }
5735}
5736
5737/*
5738 * generic initialization of ADC, input mixers and output mixers
5739 */
5740static struct hda_verb alc260_volume_init_verbs[] = {
5741 /*
5742 * Unmute ADC0-1 and set the default input to mic-in
5743 */
5744 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5745 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5746 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5747 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005748
Kailang Yangdf694da2005-12-05 19:42:22 +01005749 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5750 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005751 * Note: PASD motherboards uses the Line In 2 as the input for
5752 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005753 */
5754 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005755 /* mute analog inputs */
5756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5757 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5760 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005761
5762 /*
5763 * Set up output mixers (0x08 - 0x0a)
5764 */
5765 /* set vol=0 to output mixers */
5766 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5767 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5768 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5769 /* set up input amps for analog loopback */
5770 /* Amp Indices: DAC = 0, mixer = 1 */
5771 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5772 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5773 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5774 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5775 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5776 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005777
Kailang Yangdf694da2005-12-05 19:42:22 +01005778 { }
5779};
5780
5781static int alc260_parse_auto_config(struct hda_codec *codec)
5782{
5783 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005784 int err;
5785 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5786
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005787 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5788 alc260_ignore);
5789 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005790 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005791 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5792 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005793 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005794 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005795 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005796 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5797 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005798 return err;
5799
5800 spec->multiout.max_channels = 2;
5801
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005802 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005803 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005804 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005805 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005806
Takashi Iwaid88897e2008-10-31 15:01:37 +01005807 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005808
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005809 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005810 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005811
Takashi Iwaie044c392008-10-27 16:56:24 +01005812 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005813 return 1;
5814}
5815
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005816/* additional initialization for auto-configuration model */
5817static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005818{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005819 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005820 alc260_auto_init_multi_out(codec);
5821 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005822 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005823 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005824}
5825
Takashi Iwaicb53c622007-08-10 17:21:45 +02005826#ifdef CONFIG_SND_HDA_POWER_SAVE
5827static struct hda_amp_list alc260_loopbacks[] = {
5828 { 0x07, HDA_INPUT, 0 },
5829 { 0x07, HDA_INPUT, 1 },
5830 { 0x07, HDA_INPUT, 2 },
5831 { 0x07, HDA_INPUT, 3 },
5832 { 0x07, HDA_INPUT, 4 },
5833 { } /* end */
5834};
5835#endif
5836
Kailang Yangdf694da2005-12-05 19:42:22 +01005837/*
5838 * ALC260 configurations
5839 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005840static const char *alc260_models[ALC260_MODEL_LAST] = {
5841 [ALC260_BASIC] = "basic",
5842 [ALC260_HP] = "hp",
5843 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005844 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005845 [ALC260_FUJITSU_S702X] = "fujitsu",
5846 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005847 [ALC260_WILL] = "will",
5848 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005849 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005850#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005851 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005852#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005853 [ALC260_AUTO] = "auto",
5854};
5855
5856static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005857 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005858 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01005859 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01005860 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005861 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005862 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005863 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005864 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005865 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5866 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5867 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5868 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5869 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5870 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5871 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5872 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5873 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005874 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005875 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005876 {}
5877};
5878
Kailang Yangdf694da2005-12-05 19:42:22 +01005879static struct alc_config_preset alc260_presets[] = {
5880 [ALC260_BASIC] = {
5881 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005882 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005883 .init_verbs = { alc260_init_verbs },
5884 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5885 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005886 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005887 .adc_nids = alc260_adc_nids,
5888 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5889 .channel_mode = alc260_modes,
5890 .input_mux = &alc260_capture_source,
5891 },
5892 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005893 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005894 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005895 .init_verbs = { alc260_init_verbs,
5896 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005897 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5898 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005899 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5900 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005901 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5902 .channel_mode = alc260_modes,
5903 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005904 .unsol_event = alc260_hp_unsol_event,
5905 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005906 },
Kailang Yang3f878302008-08-26 13:02:23 +02005907 [ALC260_HP_DC7600] = {
5908 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005909 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005910 .init_verbs = { alc260_init_verbs,
5911 alc260_hp_dc7600_verbs },
5912 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5913 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005914 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5915 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005916 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5917 .channel_mode = alc260_modes,
5918 .input_mux = &alc260_capture_source,
5919 .unsol_event = alc260_hp_3012_unsol_event,
5920 .init_hook = alc260_hp_3012_automute,
5921 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005922 [ALC260_HP_3013] = {
5923 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005924 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005925 .init_verbs = { alc260_hp_3013_init_verbs,
5926 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005927 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5928 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005929 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5930 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005931 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5932 .channel_mode = alc260_modes,
5933 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005934 .unsol_event = alc260_hp_3013_unsol_event,
5935 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005936 },
5937 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005938 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005939 .init_verbs = { alc260_fujitsu_init_verbs },
5940 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5941 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005942 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5943 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005944 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5945 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005946 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5947 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005948 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005949 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005950 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005951 .init_verbs = { alc260_acer_init_verbs },
5952 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5953 .dac_nids = alc260_dac_nids,
5954 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5955 .adc_nids = alc260_dual_adc_nids,
5956 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5957 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005958 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5959 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005960 },
Michael Schwingencc959482009-02-22 18:58:45 +01005961 [ALC260_FAVORIT100] = {
5962 .mixers = { alc260_favorit100_mixer },
5963 .init_verbs = { alc260_favorit100_init_verbs },
5964 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5965 .dac_nids = alc260_dac_nids,
5966 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5967 .adc_nids = alc260_dual_adc_nids,
5968 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5969 .channel_mode = alc260_modes,
5970 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
5971 .input_mux = alc260_favorit100_capture_sources,
5972 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005973 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005974 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005975 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5976 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5977 .dac_nids = alc260_dac_nids,
5978 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5979 .adc_nids = alc260_adc_nids,
5980 .dig_out_nid = ALC260_DIGOUT_NID,
5981 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5982 .channel_mode = alc260_modes,
5983 .input_mux = &alc260_capture_source,
5984 },
5985 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005986 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005987 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5988 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5989 .dac_nids = alc260_dac_nids,
5990 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5991 .adc_nids = alc260_adc_nids,
5992 .dig_out_nid = ALC260_DIGOUT_NID,
5993 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5994 .channel_mode = alc260_modes,
5995 .input_mux = &alc260_capture_source,
5996 .unsol_event = alc260_replacer_672v_unsol_event,
5997 .init_hook = alc260_replacer_672v_automute,
5998 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005999#ifdef CONFIG_SND_DEBUG
6000 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006001 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006002 .init_verbs = { alc260_test_init_verbs },
6003 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6004 .dac_nids = alc260_test_dac_nids,
6005 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6006 .adc_nids = alc260_test_adc_nids,
6007 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6008 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006009 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6010 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006011 },
6012#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006013};
6014
Linus Torvalds1da177e2005-04-16 15:20:36 -07006015static int patch_alc260(struct hda_codec *codec)
6016{
6017 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006018 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006019
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006020 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006021 if (spec == NULL)
6022 return -ENOMEM;
6023
6024 codec->spec = spec;
6025
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006026 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6027 alc260_models,
6028 alc260_cfg_tbl);
6029 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006030 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
6031 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006032 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006033 }
6034
Kailang Yangdf694da2005-12-05 19:42:22 +01006035 if (board_config == ALC260_AUTO) {
6036 /* automatic parse from the BIOS config */
6037 err = alc260_parse_auto_config(codec);
6038 if (err < 0) {
6039 alc_free(codec);
6040 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006041 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006042 printk(KERN_INFO
6043 "hda_codec: Cannot set up configuration "
6044 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006045 board_config = ALC260_BASIC;
6046 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006047 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006048
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006049 err = snd_hda_attach_beep_device(codec, 0x1);
6050 if (err < 0) {
6051 alc_free(codec);
6052 return err;
6053 }
6054
Kailang Yangdf694da2005-12-05 19:42:22 +01006055 if (board_config != ALC260_AUTO)
6056 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006057
6058 spec->stream_name_analog = "ALC260 Analog";
6059 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6060 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6061
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006062 spec->stream_name_digital = "ALC260 Digital";
6063 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6064 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6065
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006066 if (!spec->adc_nids && spec->input_mux) {
6067 /* check whether NID 0x04 is valid */
6068 unsigned int wcap = get_wcaps(codec, 0x04);
6069 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6070 /* get type */
6071 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6072 spec->adc_nids = alc260_adc_nids_alt;
6073 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6074 } else {
6075 spec->adc_nids = alc260_adc_nids;
6076 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6077 }
6078 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006079 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006080 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006081
Takashi Iwai2134ea42008-01-10 16:53:55 +01006082 spec->vmaster_nid = 0x08;
6083
Linus Torvalds1da177e2005-04-16 15:20:36 -07006084 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006085 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006086 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006087#ifdef CONFIG_SND_HDA_POWER_SAVE
6088 if (!spec->loopback.amplist)
6089 spec->loopback.amplist = alc260_loopbacks;
6090#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006091 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006092
6093 return 0;
6094}
6095
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006096
Linus Torvalds1da177e2005-04-16 15:20:36 -07006097/*
6098 * ALC882 support
6099 *
6100 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6101 * configuration. Each pin widget can choose any input DACs and a mixer.
6102 * Each ADC is connected from a mixer of all inputs. This makes possible
6103 * 6-channel independent captures.
6104 *
6105 * In addition, an independent DAC for the multi-playback (not used in this
6106 * driver yet).
6107 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006108#define ALC882_DIGOUT_NID 0x06
6109#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006110
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006111static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006112 { 8, NULL }
6113};
6114
6115static hda_nid_t alc882_dac_nids[4] = {
6116 /* front, rear, clfe, rear_surr */
6117 0x02, 0x03, 0x04, 0x05
6118};
6119
Kailang Yangdf694da2005-12-05 19:42:22 +01006120/* identical with ALC880 */
6121#define alc882_adc_nids alc880_adc_nids
6122#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006123
Takashi Iwaie1406342008-02-11 18:32:32 +01006124static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6125static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6126
Linus Torvalds1da177e2005-04-16 15:20:36 -07006127/* input MUX */
6128/* FIXME: should be a matrix-type input source selection */
6129
6130static struct hda_input_mux alc882_capture_source = {
6131 .num_items = 4,
6132 .items = {
6133 { "Mic", 0x0 },
6134 { "Front Mic", 0x1 },
6135 { "Line", 0x2 },
6136 { "CD", 0x4 },
6137 },
6138};
Kailang Yangdf694da2005-12-05 19:42:22 +01006139/*
Kailang Yang272a5272007-05-14 11:00:38 +02006140 * 2ch mode
6141 */
6142static struct hda_verb alc882_3ST_ch2_init[] = {
6143 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6144 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6145 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6146 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6147 { } /* end */
6148};
6149
6150/*
6151 * 6ch mode
6152 */
6153static struct hda_verb alc882_3ST_ch6_init[] = {
6154 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6155 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6156 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6157 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6158 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6159 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6160 { } /* end */
6161};
6162
6163static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6164 { 2, alc882_3ST_ch2_init },
6165 { 6, alc882_3ST_ch6_init },
6166};
6167
6168/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006169 * 6ch mode
6170 */
6171static struct hda_verb alc882_sixstack_ch6_init[] = {
6172 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6173 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6174 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6175 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6176 { } /* end */
6177};
6178
6179/*
6180 * 8ch mode
6181 */
6182static struct hda_verb alc882_sixstack_ch8_init[] = {
6183 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6184 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6185 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6186 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6187 { } /* end */
6188};
6189
6190static struct hda_channel_mode alc882_sixstack_modes[2] = {
6191 { 6, alc882_sixstack_ch6_init },
6192 { 8, alc882_sixstack_ch8_init },
6193};
6194
Takashi Iwai87350ad2007-08-16 18:19:38 +02006195/*
6196 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6197 */
6198
6199/*
6200 * 2ch mode
6201 */
6202static struct hda_verb alc885_mbp_ch2_init[] = {
6203 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6204 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6205 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6206 { } /* end */
6207};
6208
6209/*
6210 * 6ch mode
6211 */
6212static struct hda_verb alc885_mbp_ch6_init[] = {
6213 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6214 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6215 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6216 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6217 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6218 { } /* end */
6219};
6220
6221static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6222 { 2, alc885_mbp_ch2_init },
6223 { 6, alc885_mbp_ch6_init },
6224};
6225
6226
Linus Torvalds1da177e2005-04-16 15:20:36 -07006227/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6228 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6229 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006230static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006231 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006232 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006233 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006234 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006235 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6236 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006237 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6238 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006239 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006240 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006241 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6242 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6243 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6244 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6245 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006247 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6249 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006250 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006251 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006252 { } /* end */
6253};
6254
Takashi Iwai87350ad2007-08-16 18:19:38 +02006255static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006256 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6257 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6258 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6259 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6260 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6261 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6263 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006264 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6266 { } /* end */
6267};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006268static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6269 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6270 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6271 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6272 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6273 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6274 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6275 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6276 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6277 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006278 { } /* end */
6279};
6280
Kailang Yang272a5272007-05-14 11:00:38 +02006281static struct snd_kcontrol_new alc882_targa_mixer[] = {
6282 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6283 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6284 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6285 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6286 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6287 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6288 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6289 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6290 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006291 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006292 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6293 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006294 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006295 { } /* end */
6296};
6297
6298/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6299 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6300 */
6301static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6302 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6303 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6304 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6305 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6306 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6307 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6308 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6309 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6310 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6311 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6312 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6313 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006314 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006315 { } /* end */
6316};
6317
Takashi Iwai914759b2007-09-06 14:52:04 +02006318static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6319 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6320 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6321 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6322 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6323 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6324 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6325 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6327 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6328 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006329 { } /* end */
6330};
6331
Kailang Yangdf694da2005-12-05 19:42:22 +01006332static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6333 {
6334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6335 .name = "Channel Mode",
6336 .info = alc_ch_mode_info,
6337 .get = alc_ch_mode_get,
6338 .put = alc_ch_mode_put,
6339 },
6340 { } /* end */
6341};
6342
Linus Torvalds1da177e2005-04-16 15:20:36 -07006343static struct hda_verb alc882_init_verbs[] = {
6344 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006348 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006349 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6350 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6351 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006352 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006353 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6354 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6355 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006356 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006357 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6358 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6359 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006360
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006361 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006362 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006363 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006364 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006365 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006367 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006368 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006369 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006370 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006371 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006372 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006373 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006374 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006375 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006376 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006377 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006378 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006379 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6380 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006381 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006382 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6383 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006384 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006385 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6386 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6387 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6388 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6389 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006390 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006391 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006392
6393 /* FIXME: use matrix-type input source selection */
6394 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6395 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006396 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6397 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6399 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006400 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006401 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6402 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6403 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6404 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006405 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006406 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6407 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6408 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6409 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6410 /* ADC1: mute amp left and right */
6411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006412 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006413 /* ADC2: mute amp left and right */
6414 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006415 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006416 /* ADC3: mute amp left and right */
6417 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006418 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006419
6420 { }
6421};
6422
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006423static struct hda_verb alc882_eapd_verbs[] = {
6424 /* change to EAPD mode */
6425 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006426 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006427 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006428};
6429
Tobin Davis9102cd12006-12-15 10:02:12 +01006430/* Mac Pro test */
6431static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6432 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6433 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6434 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6435 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6436 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006437 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006438 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6439 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006440 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006441 { } /* end */
6442};
6443
6444static struct hda_verb alc882_macpro_init_verbs[] = {
6445 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6447 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6449 /* Front Pin: output 0 (0x0c) */
6450 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6453 /* Front Mic pin: input vref at 80% */
6454 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6455 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6456 /* Speaker: output */
6457 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6458 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6459 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6460 /* Headphone output (output 0 - 0x0c) */
6461 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6462 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6463 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6464
6465 /* FIXME: use matrix-type input source selection */
6466 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6467 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6468 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6469 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6470 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6471 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6472 /* Input mixer2 */
6473 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6474 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6475 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6477 /* Input mixer3 */
6478 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6482 /* ADC1: mute amp left and right */
6483 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6484 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6485 /* ADC2: mute amp left and right */
6486 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6487 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6488 /* ADC3: mute amp left and right */
6489 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6490 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6491
6492 { }
6493};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006494
Takashi Iwai87350ad2007-08-16 18:19:38 +02006495/* Macbook Pro rev3 */
6496static struct hda_verb alc885_mbp3_init_verbs[] = {
6497 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6498 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6499 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6501 /* Rear mixer */
6502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6505 /* Front Pin: output 0 (0x0c) */
6506 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6507 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6508 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6509 /* HP Pin: output 0 (0x0d) */
6510 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6511 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6512 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6513 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6514 /* Mic (rear) pin: input vref at 80% */
6515 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6516 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6517 /* Front Mic pin: input vref at 80% */
6518 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6519 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6520 /* Line In pin: use output 1 when in LineOut mode */
6521 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6522 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6523 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6524
6525 /* FIXME: use matrix-type input source selection */
6526 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6527 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6528 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6529 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6530 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6531 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6532 /* Input mixer2 */
6533 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6534 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6535 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6536 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6537 /* Input mixer3 */
6538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6539 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6542 /* ADC1: mute amp left and right */
6543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6544 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6545 /* ADC2: mute amp left and right */
6546 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6547 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6548 /* ADC3: mute amp left and right */
6549 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6550 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6551
6552 { }
6553};
6554
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006555/* iMac 24 mixer. */
6556static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6557 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6558 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6559 { } /* end */
6560};
6561
6562/* iMac 24 init verbs. */
6563static struct hda_verb alc885_imac24_init_verbs[] = {
6564 /* Internal speakers: output 0 (0x0c) */
6565 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6566 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6567 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6568 /* Internal speakers: output 0 (0x0c) */
6569 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6570 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6571 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6572 /* Headphone: output 0 (0x0c) */
6573 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6574 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6575 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6576 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6577 /* Front Mic: input vref at 80% */
6578 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6579 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6580 { }
6581};
6582
6583/* Toggle speaker-output according to the hp-jack state */
6584static void alc885_imac24_automute(struct hda_codec *codec)
6585{
6586 unsigned int present;
6587
6588 present = snd_hda_codec_read(codec, 0x14, 0,
6589 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006590 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6591 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6592 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6593 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006594}
6595
6596/* Processes unsolicited events. */
6597static void alc885_imac24_unsol_event(struct hda_codec *codec,
6598 unsigned int res)
6599{
6600 /* Headphone insertion or removal. */
6601 if ((res >> 26) == ALC880_HP_EVENT)
6602 alc885_imac24_automute(codec);
6603}
6604
Takashi Iwai87350ad2007-08-16 18:19:38 +02006605static void alc885_mbp3_automute(struct hda_codec *codec)
6606{
6607 unsigned int present;
6608
6609 present = snd_hda_codec_read(codec, 0x15, 0,
6610 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6611 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6612 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6613 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6614 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6615
6616}
6617static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6618 unsigned int res)
6619{
6620 /* Headphone insertion or removal. */
6621 if ((res >> 26) == ALC880_HP_EVENT)
6622 alc885_mbp3_automute(codec);
6623}
6624
6625
Kailang Yang272a5272007-05-14 11:00:38 +02006626static struct hda_verb alc882_targa_verbs[] = {
6627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6629
6630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006632
Kailang Yang272a5272007-05-14 11:00:38 +02006633 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6634 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6635 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6636
6637 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6638 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6639 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6640 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6641 { } /* end */
6642};
6643
6644/* toggle speaker-output according to the hp-jack state */
6645static void alc882_targa_automute(struct hda_codec *codec)
6646{
6647 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006648
Kailang Yang272a5272007-05-14 11:00:38 +02006649 present = snd_hda_codec_read(codec, 0x14, 0,
6650 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006651 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6652 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006653 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6654 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006655}
6656
6657static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6658{
6659 /* Looks like the unsol event is incompatible with the standard
6660 * definition. 4bit tag is placed at 26 bit!
6661 */
6662 if (((res >> 26) == ALC880_HP_EVENT)) {
6663 alc882_targa_automute(codec);
6664 }
6665}
6666
6667static struct hda_verb alc882_asus_a7j_verbs[] = {
6668 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6669 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6670
6671 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6672 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6673 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006674
Kailang Yang272a5272007-05-14 11:00:38 +02006675 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6676 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6677 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6678
6679 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6680 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6681 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6682 { } /* end */
6683};
6684
Takashi Iwai914759b2007-09-06 14:52:04 +02006685static struct hda_verb alc882_asus_a7m_verbs[] = {
6686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6688
6689 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6691 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006692
Takashi Iwai914759b2007-09-06 14:52:04 +02006693 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6694 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6695 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6696
6697 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6698 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6699 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6700 { } /* end */
6701};
6702
Tobin Davis9102cd12006-12-15 10:02:12 +01006703static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6704{
6705 unsigned int gpiostate, gpiomask, gpiodir;
6706
6707 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6708 AC_VERB_GET_GPIO_DATA, 0);
6709
6710 if (!muted)
6711 gpiostate |= (1 << pin);
6712 else
6713 gpiostate &= ~(1 << pin);
6714
6715 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6716 AC_VERB_GET_GPIO_MASK, 0);
6717 gpiomask |= (1 << pin);
6718
6719 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6720 AC_VERB_GET_GPIO_DIRECTION, 0);
6721 gpiodir |= (1 << pin);
6722
6723
6724 snd_hda_codec_write(codec, codec->afg, 0,
6725 AC_VERB_SET_GPIO_MASK, gpiomask);
6726 snd_hda_codec_write(codec, codec->afg, 0,
6727 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6728
6729 msleep(1);
6730
6731 snd_hda_codec_write(codec, codec->afg, 0,
6732 AC_VERB_SET_GPIO_DATA, gpiostate);
6733}
6734
Takashi Iwai7debbe52007-08-16 15:01:03 +02006735/* set up GPIO at initialization */
6736static void alc885_macpro_init_hook(struct hda_codec *codec)
6737{
6738 alc882_gpio_mute(codec, 0, 0);
6739 alc882_gpio_mute(codec, 1, 0);
6740}
6741
6742/* set up GPIO and update auto-muting at initialization */
6743static void alc885_imac24_init_hook(struct hda_codec *codec)
6744{
6745 alc885_macpro_init_hook(codec);
6746 alc885_imac24_automute(codec);
6747}
6748
Kailang Yangdf694da2005-12-05 19:42:22 +01006749/*
6750 * generic initialization of ADC, input mixers and output mixers
6751 */
6752static struct hda_verb alc882_auto_init_verbs[] = {
6753 /*
6754 * Unmute ADC0-2 and set the default input to mic-in
6755 */
6756 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6757 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6758 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6759 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6760 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6761 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6762
Takashi Iwaicb53c622007-08-10 17:21:45 +02006763 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006764 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006765 * Note: PASD motherboards uses the Line In 2 as the input for
6766 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006767 */
6768 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006769 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6771 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6772 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6773 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006774
6775 /*
6776 * Set up output mixers (0x0c - 0x0f)
6777 */
6778 /* set vol=0 to output mixers */
6779 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6780 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6781 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6782 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6783 /* set up input amps for analog loopback */
6784 /* Amp Indices: DAC = 0, mixer = 1 */
6785 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6787 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6788 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6789 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6790 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6791 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6792 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6793 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6794 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6795
6796 /* FIXME: use matrix-type input source selection */
6797 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6798 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6799 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6800 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6801 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6802 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6803 /* Input mixer2 */
6804 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6805 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6806 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6807 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6808 /* Input mixer3 */
6809 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6810 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6811 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6812 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6813
6814 { }
6815};
6816
Takashi Iwaicb53c622007-08-10 17:21:45 +02006817#ifdef CONFIG_SND_HDA_POWER_SAVE
6818#define alc882_loopbacks alc880_loopbacks
6819#endif
6820
Kailang Yangdf694da2005-12-05 19:42:22 +01006821/* pcm configuration: identiacal with ALC880 */
6822#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6823#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6824#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6825#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6826
6827/*
6828 * configuration and preset
6829 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006830static const char *alc882_models[ALC882_MODEL_LAST] = {
6831 [ALC882_3ST_DIG] = "3stack-dig",
6832 [ALC882_6ST_DIG] = "6stack-dig",
6833 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006834 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006835 [ALC882_TARGA] = "targa",
6836 [ALC882_ASUS_A7J] = "asus-a7j",
6837 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006838 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006839 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006840 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006841 [ALC882_AUTO] = "auto",
6842};
6843
6844static struct snd_pci_quirk alc882_cfg_tbl[] = {
6845 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006846 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006847 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006848 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006849 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006850 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006851 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006852 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006853 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006854 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6855 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6856 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006857 {}
6858};
6859
6860static struct alc_config_preset alc882_presets[] = {
6861 [ALC882_3ST_DIG] = {
6862 .mixers = { alc882_base_mixer },
6863 .init_verbs = { alc882_init_verbs },
6864 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6865 .dac_nids = alc882_dac_nids,
6866 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006867 .dig_in_nid = ALC882_DIGIN_NID,
6868 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6869 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006870 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006871 .input_mux = &alc882_capture_source,
6872 },
6873 [ALC882_6ST_DIG] = {
6874 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6875 .init_verbs = { alc882_init_verbs },
6876 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6877 .dac_nids = alc882_dac_nids,
6878 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006879 .dig_in_nid = ALC882_DIGIN_NID,
6880 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6881 .channel_mode = alc882_sixstack_modes,
6882 .input_mux = &alc882_capture_source,
6883 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006884 [ALC882_ARIMA] = {
6885 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6886 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6887 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6888 .dac_nids = alc882_dac_nids,
6889 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6890 .channel_mode = alc882_sixstack_modes,
6891 .input_mux = &alc882_capture_source,
6892 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006893 [ALC882_W2JC] = {
6894 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6895 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6896 alc880_gpio1_init_verbs },
6897 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6898 .dac_nids = alc882_dac_nids,
6899 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6900 .channel_mode = alc880_threestack_modes,
6901 .need_dac_fix = 1,
6902 .input_mux = &alc882_capture_source,
6903 .dig_out_nid = ALC882_DIGOUT_NID,
6904 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006905 [ALC885_MBP3] = {
6906 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6907 .init_verbs = { alc885_mbp3_init_verbs,
6908 alc880_gpio1_init_verbs },
6909 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6910 .dac_nids = alc882_dac_nids,
6911 .channel_mode = alc885_mbp_6ch_modes,
6912 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6913 .input_mux = &alc882_capture_source,
6914 .dig_out_nid = ALC882_DIGOUT_NID,
6915 .dig_in_nid = ALC882_DIGIN_NID,
6916 .unsol_event = alc885_mbp3_unsol_event,
6917 .init_hook = alc885_mbp3_automute,
6918 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006919 [ALC885_MACPRO] = {
6920 .mixers = { alc882_macpro_mixer },
6921 .init_verbs = { alc882_macpro_init_verbs },
6922 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6923 .dac_nids = alc882_dac_nids,
6924 .dig_out_nid = ALC882_DIGOUT_NID,
6925 .dig_in_nid = ALC882_DIGIN_NID,
6926 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6927 .channel_mode = alc882_ch_modes,
6928 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006929 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006930 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006931 [ALC885_IMAC24] = {
6932 .mixers = { alc885_imac24_mixer },
6933 .init_verbs = { alc885_imac24_init_verbs },
6934 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6935 .dac_nids = alc882_dac_nids,
6936 .dig_out_nid = ALC882_DIGOUT_NID,
6937 .dig_in_nid = ALC882_DIGIN_NID,
6938 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6939 .channel_mode = alc882_ch_modes,
6940 .input_mux = &alc882_capture_source,
6941 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006942 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006943 },
Kailang Yang272a5272007-05-14 11:00:38 +02006944 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006945 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006946 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6947 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6948 .dac_nids = alc882_dac_nids,
6949 .dig_out_nid = ALC882_DIGOUT_NID,
6950 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6951 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006952 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006953 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6954 .channel_mode = alc882_3ST_6ch_modes,
6955 .need_dac_fix = 1,
6956 .input_mux = &alc882_capture_source,
6957 .unsol_event = alc882_targa_unsol_event,
6958 .init_hook = alc882_targa_automute,
6959 },
6960 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006961 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006962 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6963 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6964 .dac_nids = alc882_dac_nids,
6965 .dig_out_nid = ALC882_DIGOUT_NID,
6966 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6967 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006968 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006969 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6970 .channel_mode = alc882_3ST_6ch_modes,
6971 .need_dac_fix = 1,
6972 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006973 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006974 [ALC882_ASUS_A7M] = {
6975 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6976 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6977 alc880_gpio1_init_verbs,
6978 alc882_asus_a7m_verbs },
6979 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6980 .dac_nids = alc882_dac_nids,
6981 .dig_out_nid = ALC882_DIGOUT_NID,
6982 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6983 .channel_mode = alc880_threestack_modes,
6984 .need_dac_fix = 1,
6985 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006986 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006987};
6988
6989
6990/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006991 * Pin config fixes
6992 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006993enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006994 PINFIX_ABIT_AW9D_MAX
6995};
6996
6997static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6998 { 0x15, 0x01080104 }, /* side */
6999 { 0x16, 0x01011012 }, /* rear */
7000 { 0x17, 0x01016011 }, /* clfe */
7001 { }
7002};
7003
7004static const struct alc_pincfg *alc882_pin_fixes[] = {
7005 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7006};
7007
7008static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7009 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7010 {}
7011};
7012
7013/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007014 * BIOS auto configuration
7015 */
7016static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7017 hda_nid_t nid, int pin_type,
7018 int dac_idx)
7019{
7020 /* set as output */
7021 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007022 int idx;
7023
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007024 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007025 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7026 idx = 4;
7027 else
7028 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007029 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7030
7031}
7032
7033static void alc882_auto_init_multi_out(struct hda_codec *codec)
7034{
7035 struct alc_spec *spec = codec->spec;
7036 int i;
7037
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007038 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01007039 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007040 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007041 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007042 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007043 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007044 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007045 }
7046}
7047
7048static void alc882_auto_init_hp_out(struct hda_codec *codec)
7049{
7050 struct alc_spec *spec = codec->spec;
7051 hda_nid_t pin;
7052
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007053 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007054 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007055 /* use dac 0 */
7056 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007057 pin = spec->autocfg.speaker_pins[0];
7058 if (pin)
7059 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007060}
7061
7062#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7063#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7064
7065static void alc882_auto_init_analog_input(struct hda_codec *codec)
7066{
7067 struct alc_spec *spec = codec->spec;
7068 int i;
7069
7070 for (i = 0; i < AUTO_PIN_LAST; i++) {
7071 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007072 unsigned int vref;
7073 if (!nid)
7074 continue;
7075 vref = PIN_IN;
7076 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02007077 unsigned int pincap;
7078 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
7079 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01007080 AC_PINCAP_VREF_80)
7081 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01007082 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01007083 snd_hda_codec_write(codec, nid, 0,
7084 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
7085 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7086 snd_hda_codec_write(codec, nid, 0,
7087 AC_VERB_SET_AMP_GAIN_MUTE,
7088 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007089 }
7090}
7091
Takashi Iwaif511b012008-08-15 16:46:42 +02007092static void alc882_auto_init_input_src(struct hda_codec *codec)
7093{
7094 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007095 int c;
7096
7097 for (c = 0; c < spec->num_adc_nids; c++) {
7098 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7099 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007100 unsigned int mux_idx;
7101 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007102 int conns, mute, idx, item;
7103
7104 conns = snd_hda_get_connections(codec, nid, conn_list,
7105 ARRAY_SIZE(conn_list));
7106 if (conns < 0)
7107 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007108 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7109 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007110 for (idx = 0; idx < conns; idx++) {
7111 /* if the current connection is the selected one,
7112 * unmute it as default - otherwise mute it
7113 */
7114 mute = AMP_IN_MUTE(idx);
7115 for (item = 0; item < imux->num_items; item++) {
7116 if (imux->items[item].index == idx) {
7117 if (spec->cur_mux[c] == item)
7118 mute = AMP_IN_UNMUTE(idx);
7119 break;
7120 }
7121 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007122 /* check if we have a selector or mixer
7123 * we could check for the widget type instead, but
7124 * just check for Amp-In presence (in case of mixer
7125 * without amp-in there is something wrong, this
7126 * function shouldn't be used or capsrc nid is wrong)
7127 */
7128 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7129 snd_hda_codec_write(codec, nid, 0,
7130 AC_VERB_SET_AMP_GAIN_MUTE,
7131 mute);
7132 else if (mute != AMP_IN_MUTE(idx))
7133 snd_hda_codec_write(codec, nid, 0,
7134 AC_VERB_SET_CONNECT_SEL,
7135 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007136 }
7137 }
7138}
7139
Takashi Iwai776e1842007-08-29 15:07:11 +02007140/* add mic boosts if needed */
7141static int alc_auto_add_mic_boost(struct hda_codec *codec)
7142{
7143 struct alc_spec *spec = codec->spec;
7144 int err;
7145 hda_nid_t nid;
7146
7147 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007148 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007149 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7150 "Mic Boost",
7151 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7152 if (err < 0)
7153 return err;
7154 }
7155 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007156 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007157 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7158 "Front Mic Boost",
7159 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7160 if (err < 0)
7161 return err;
7162 }
7163 return 0;
7164}
7165
Kailang Yangdf694da2005-12-05 19:42:22 +01007166/* almost identical with ALC880 parser... */
7167static int alc882_parse_auto_config(struct hda_codec *codec)
7168{
7169 struct alc_spec *spec = codec->spec;
7170 int err = alc880_parse_auto_config(codec);
7171
7172 if (err < 0)
7173 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007174 else if (!err)
7175 return 0; /* no config found */
7176
7177 err = alc_auto_add_mic_boost(codec);
7178 if (err < 0)
7179 return err;
7180
7181 /* hack - override the init verbs */
7182 spec->init_verbs[0] = alc882_auto_init_verbs;
7183
7184 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007185}
7186
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007187/* additional initialization for auto-configuration model */
7188static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007189{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007190 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007191 alc882_auto_init_multi_out(codec);
7192 alc882_auto_init_hp_out(codec);
7193 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007194 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007195 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007196 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007197}
7198
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007199static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7200
Linus Torvalds1da177e2005-04-16 15:20:36 -07007201static int patch_alc882(struct hda_codec *codec)
7202{
7203 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007204 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007205
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007206 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007207 if (spec == NULL)
7208 return -ENOMEM;
7209
Linus Torvalds1da177e2005-04-16 15:20:36 -07007210 codec->spec = spec;
7211
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007212 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7213 alc882_models,
7214 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007215
Kailang Yangdf694da2005-12-05 19:42:22 +01007216 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007217 /* Pick up systems that don't supply PCI SSID */
7218 switch (codec->subsystem_id) {
7219 case 0x106b0c00: /* Mac Pro */
7220 board_config = ALC885_MACPRO;
7221 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007222 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007223 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007224 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007225 board_config = ALC885_IMAC24;
7226 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02007227 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007228 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007229 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007230 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007231 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007232 board_config = ALC885_MBP3;
7233 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007234 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007235 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007236 if (codec->revision_id == 0x100101 ||
7237 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007238 alc_free(codec);
7239 return patch_alc883(codec);
7240 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007241 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7242 "trying auto-probe from BIOS...\n");
7243 board_config = ALC882_AUTO;
7244 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007245 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007246
Takashi Iwaif95474e2007-07-10 00:47:43 +02007247 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7248
Kailang Yangdf694da2005-12-05 19:42:22 +01007249 if (board_config == ALC882_AUTO) {
7250 /* automatic parse from the BIOS config */
7251 err = alc882_parse_auto_config(codec);
7252 if (err < 0) {
7253 alc_free(codec);
7254 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007255 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007256 printk(KERN_INFO
7257 "hda_codec: Cannot set up configuration "
7258 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007259 board_config = ALC882_3ST_DIG;
7260 }
7261 }
7262
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007263 err = snd_hda_attach_beep_device(codec, 0x1);
7264 if (err < 0) {
7265 alc_free(codec);
7266 return err;
7267 }
7268
Kailang Yangdf694da2005-12-05 19:42:22 +01007269 if (board_config != ALC882_AUTO)
7270 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007271
Kailang Yang2f893282008-05-27 12:14:47 +02007272 if (codec->vendor_id == 0x10ec0885) {
7273 spec->stream_name_analog = "ALC885 Analog";
7274 spec->stream_name_digital = "ALC885 Digital";
7275 } else {
7276 spec->stream_name_analog = "ALC882 Analog";
7277 spec->stream_name_digital = "ALC882 Digital";
7278 }
7279
Kailang Yangdf694da2005-12-05 19:42:22 +01007280 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7281 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007282 /* FIXME: setup DAC5 */
7283 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7284 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007285
Kailang Yangdf694da2005-12-05 19:42:22 +01007286 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7287 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007288
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007289 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007290 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007291 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007292 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007293 /* get type */
7294 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007295 if (wcap != AC_WID_AUD_IN) {
7296 spec->adc_nids = alc882_adc_nids_alt;
7297 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007298 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007299 } else {
7300 spec->adc_nids = alc882_adc_nids;
7301 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007302 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007303 }
7304 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007305 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007306 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007307
Takashi Iwai2134ea42008-01-10 16:53:55 +01007308 spec->vmaster_nid = 0x0c;
7309
Linus Torvalds1da177e2005-04-16 15:20:36 -07007310 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007311 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007312 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007313#ifdef CONFIG_SND_HDA_POWER_SAVE
7314 if (!spec->loopback.amplist)
7315 spec->loopback.amplist = alc882_loopbacks;
7316#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007317 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007318
7319 return 0;
7320}
7321
7322/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007323 * ALC883 support
7324 *
7325 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7326 * configuration. Each pin widget can choose any input DACs and a mixer.
7327 * Each ADC is connected from a mixer of all inputs. This makes possible
7328 * 6-channel independent captures.
7329 *
7330 * In addition, an independent DAC for the multi-playback (not used in this
7331 * driver yet).
7332 */
7333#define ALC883_DIGOUT_NID 0x06
7334#define ALC883_DIGIN_NID 0x0a
7335
Wu Fengguang3ab90932008-11-17 09:51:09 +01007336#define ALC1200_DIGOUT_NID 0x10
7337
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007338static hda_nid_t alc883_dac_nids[4] = {
7339 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007340 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007341};
7342
7343static hda_nid_t alc883_adc_nids[2] = {
7344 /* ADC1-2 */
7345 0x08, 0x09,
7346};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007347
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007348static hda_nid_t alc883_adc_nids_alt[1] = {
7349 /* ADC1 */
7350 0x08,
7351};
7352
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007353static hda_nid_t alc883_adc_nids_rev[2] = {
7354 /* ADC2-1 */
7355 0x09, 0x08
7356};
7357
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007358#define alc889_adc_nids alc880_adc_nids
7359
Takashi Iwaie1406342008-02-11 18:32:32 +01007360static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7361
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007362static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7363
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007364#define alc889_capsrc_nids alc882_capsrc_nids
7365
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007366/* input MUX */
7367/* FIXME: should be a matrix-type input source selection */
7368
7369static struct hda_input_mux alc883_capture_source = {
7370 .num_items = 4,
7371 .items = {
7372 { "Mic", 0x0 },
7373 { "Front Mic", 0x1 },
7374 { "Line", 0x2 },
7375 { "CD", 0x4 },
7376 },
7377};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007378
Jiang zhe17bba1b2008-06-04 12:11:07 +02007379static struct hda_input_mux alc883_3stack_6ch_intel = {
7380 .num_items = 4,
7381 .items = {
7382 { "Mic", 0x1 },
7383 { "Front Mic", 0x0 },
7384 { "Line", 0x2 },
7385 { "CD", 0x4 },
7386 },
7387};
7388
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007389static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7390 .num_items = 2,
7391 .items = {
7392 { "Mic", 0x1 },
7393 { "Line", 0x2 },
7394 },
7395};
7396
Kailang Yang272a5272007-05-14 11:00:38 +02007397static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7398 .num_items = 4,
7399 .items = {
7400 { "Mic", 0x0 },
7401 { "iMic", 0x1 },
7402 { "Line", 0x2 },
7403 { "CD", 0x4 },
7404 },
7405};
7406
Jiang zhefb97dc62008-03-06 11:07:11 +01007407static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7408 .num_items = 2,
7409 .items = {
7410 { "Mic", 0x0 },
7411 { "Int Mic", 0x1 },
7412 },
7413};
7414
Kailang Yange2757d52008-08-26 13:17:46 +02007415static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7416 .num_items = 3,
7417 .items = {
7418 { "Mic", 0x0 },
7419 { "Front Mic", 0x1 },
7420 { "Line", 0x4 },
7421 },
7422};
7423
7424static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7425 .num_items = 2,
7426 .items = {
7427 { "Mic", 0x0 },
7428 { "Line", 0x2 },
7429 },
7430};
7431
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007432/*
7433 * 2ch mode
7434 */
7435static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7436 { 2, NULL }
7437};
7438
7439/*
7440 * 2ch mode
7441 */
7442static struct hda_verb alc883_3ST_ch2_init[] = {
7443 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7444 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7445 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7446 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7447 { } /* end */
7448};
7449
7450/*
Tobin Davisb2011312007-09-17 12:45:11 +02007451 * 4ch mode
7452 */
7453static struct hda_verb alc883_3ST_ch4_init[] = {
7454 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7455 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7456 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7457 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7458 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7459 { } /* end */
7460};
7461
7462/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007463 * 6ch mode
7464 */
7465static struct hda_verb alc883_3ST_ch6_init[] = {
7466 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7467 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7468 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7469 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7470 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7471 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7472 { } /* end */
7473};
7474
Tobin Davisb2011312007-09-17 12:45:11 +02007475static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007476 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007477 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007478 { 6, alc883_3ST_ch6_init },
7479};
7480
7481/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007482 * 2ch mode
7483 */
7484static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7485 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7486 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7487 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7488 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7489 { } /* end */
7490};
7491
7492/*
7493 * 4ch mode
7494 */
7495static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7496 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7497 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7498 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7499 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7500 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7501 { } /* end */
7502};
7503
7504/*
7505 * 6ch mode
7506 */
7507static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7508 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7509 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7510 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7511 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7512 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7513 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7514 { } /* end */
7515};
7516
7517static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7518 { 2, alc883_3ST_ch2_intel_init },
7519 { 4, alc883_3ST_ch4_intel_init },
7520 { 6, alc883_3ST_ch6_intel_init },
7521};
7522
7523/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007524 * 6ch mode
7525 */
7526static struct hda_verb alc883_sixstack_ch6_init[] = {
7527 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7528 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7529 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7530 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7531 { } /* end */
7532};
7533
7534/*
7535 * 8ch mode
7536 */
7537static struct hda_verb alc883_sixstack_ch8_init[] = {
7538 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7539 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7540 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7541 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7542 { } /* end */
7543};
7544
7545static struct hda_channel_mode alc883_sixstack_modes[2] = {
7546 { 6, alc883_sixstack_ch6_init },
7547 { 8, alc883_sixstack_ch8_init },
7548};
7549
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007550static struct hda_verb alc883_medion_eapd_verbs[] = {
7551 /* eanable EAPD on medion laptop */
7552 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7553 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7554 { }
7555};
7556
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007557/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7558 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7559 */
7560
7561static struct snd_kcontrol_new alc883_base_mixer[] = {
7562 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7563 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7564 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7565 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7566 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7567 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7568 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7569 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7570 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7571 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7572 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7573 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7574 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7575 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7576 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7577 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007578 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007579 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7580 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007581 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007582 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007583 { } /* end */
7584};
7585
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007586static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7587 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7588 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7589 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7590 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7591 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7592 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7593 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7594 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7595 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7596 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7597 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7598 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7599 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007600 { } /* end */
7601};
7602
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007603static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007604 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7605 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7606 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7607 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7609 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7610 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7611 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7612 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7613 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007614 { } /* end */
7615};
7616
Jiang zhefb97dc62008-03-06 11:07:11 +01007617static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7618 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7619 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7620 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7621 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7622 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7623 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7624 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7625 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7626 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7627 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007628 { } /* end */
7629};
7630
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007631static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7632 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7633 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7634 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7635 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7636 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7637 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7638 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007640 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7642 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007643 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007644 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007645 { } /* end */
7646};
7647
7648static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7649 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7650 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7651 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7652 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7653 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7654 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7655 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7656 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7657 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7658 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7659 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7660 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7661 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7662 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007663 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007664 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7665 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007666 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007667 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007668 { } /* end */
7669};
7670
Jiang zhe17bba1b2008-06-04 12:11:07 +02007671static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7672 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7673 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7674 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7675 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7676 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7677 HDA_OUTPUT),
7678 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7679 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7680 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7681 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7682 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7683 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7684 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7685 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7686 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7687 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7688 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7689 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7690 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7691 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007692 { } /* end */
7693};
7694
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007695static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007696 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007697 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007698 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007699 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007700 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7701 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007702 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7703 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007704 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7705 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7706 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7707 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7708 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007710 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007711 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7712 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007713 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007714 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007715 { } /* end */
7716};
7717
Kailang Yangccc656c2006-10-17 12:32:26 +02007718static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7719 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7720 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7721 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7722 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7723 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7724 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7725 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7726 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7727 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7728 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7729 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7730 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7731 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007733 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007734 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007735 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007736};
Kailang Yangccc656c2006-10-17 12:32:26 +02007737
7738static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7739 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7740 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7741 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7742 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7743 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7744 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007745 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007747 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7748 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7749 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007750 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007751};
Kailang Yangccc656c2006-10-17 12:32:26 +02007752
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007753static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7754 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7755 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007756 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7757 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7760 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007762 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007763};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007764
Kailang Yang272a5272007-05-14 11:00:38 +02007765static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7766 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7767 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7768 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7769 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7770 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7773 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7774 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007775 { } /* end */
7776};
7777
7778static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7779 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7780 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7781 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7782 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7783 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7785 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7786 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7787 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007788 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007789};
Kailang Yang272a5272007-05-14 11:00:38 +02007790
Tobin Davis2880a862007-08-07 11:50:26 +02007791static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007792 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7793 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007794 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7798 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007800 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007801};
Tobin Davis2880a862007-08-07 11:50:26 +02007802
Kailang Yange2757d52008-08-26 13:17:46 +02007803static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7804 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7805 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7806 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7807 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7808 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7809 0x0d, 1, 0x0, HDA_OUTPUT),
7810 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7811 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7812 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7813 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7814 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7816 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7817 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7818 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7819 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7820 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7822 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7823 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7824 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7825 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7826 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007827 { } /* end */
7828};
7829
7830static struct hda_bind_ctls alc883_bind_cap_vol = {
7831 .ops = &snd_hda_bind_vol,
7832 .values = {
7833 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7834 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7835 0
7836 },
7837};
7838
7839static struct hda_bind_ctls alc883_bind_cap_switch = {
7840 .ops = &snd_hda_bind_sw,
7841 .values = {
7842 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7843 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7844 0
7845 },
7846};
7847
7848static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7849 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7850 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7851 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7852 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7853 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7854 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7855 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7856 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007857 { } /* end */
7858};
7859
7860static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007861 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7862 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7863 {
7864 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7865 /* .name = "Capture Source", */
7866 .name = "Input Source",
7867 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007868 .info = alc_mux_enum_info,
7869 .get = alc_mux_enum_get,
7870 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007871 },
7872 { } /* end */
7873};
7874
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007875static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7876 {
7877 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7878 .name = "Channel Mode",
7879 .info = alc_ch_mode_info,
7880 .get = alc_ch_mode_get,
7881 .put = alc_ch_mode_put,
7882 },
7883 { } /* end */
7884};
7885
7886static struct hda_verb alc883_init_verbs[] = {
7887 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007888 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007889 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7890 /* ADC2: mute amp left and right */
7891 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7892 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7893 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7894 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7895 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7896 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7897 /* Rear mixer */
7898 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7899 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7900 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7901 /* CLFE mixer */
7902 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7903 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7905 /* Side mixer */
7906 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7908 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7909
Takashi Iwaicb53c622007-08-10 17:21:45 +02007910 /* mute analog input loopbacks */
7911 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7912 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7913 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7914 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7915 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007916
7917 /* Front Pin: output 0 (0x0c) */
7918 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7919 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7920 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7921 /* Rear Pin: output 1 (0x0d) */
7922 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7923 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7924 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7925 /* CLFE Pin: output 2 (0x0e) */
7926 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7927 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7928 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7929 /* Side Pin: output 3 (0x0f) */
7930 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7931 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7932 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7933 /* Mic (rear) pin: input vref at 80% */
7934 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7935 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7936 /* Front Mic pin: input vref at 80% */
7937 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7938 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7939 /* Line In pin: input */
7940 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7941 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7942 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7944 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7945 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7946 /* CD pin widget for input */
7947 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7948
7949 /* FIXME: use matrix-type input source selection */
7950 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7951 /* Input mixer2 */
7952 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007953 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7954 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7955 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007956 /* Input mixer3 */
7957 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007958 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7959 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7960 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007961 { }
7962};
7963
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007964/* toggle speaker-output according to the hp-jack state */
7965static void alc883_mitac_hp_automute(struct hda_codec *codec)
7966{
7967 unsigned int present;
7968
7969 present = snd_hda_codec_read(codec, 0x15, 0,
7970 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7971 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7972 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7973 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7974 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7975}
7976
7977/* auto-toggle front mic */
7978/*
7979static void alc883_mitac_mic_automute(struct hda_codec *codec)
7980{
7981 unsigned int present;
7982 unsigned char bits;
7983
7984 present = snd_hda_codec_read(codec, 0x18, 0,
7985 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7986 bits = present ? HDA_AMP_MUTE : 0;
7987 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7988}
7989*/
7990
7991static void alc883_mitac_automute(struct hda_codec *codec)
7992{
7993 alc883_mitac_hp_automute(codec);
7994 /* alc883_mitac_mic_automute(codec); */
7995}
7996
7997static void alc883_mitac_unsol_event(struct hda_codec *codec,
7998 unsigned int res)
7999{
8000 switch (res >> 26) {
8001 case ALC880_HP_EVENT:
8002 alc883_mitac_hp_automute(codec);
8003 break;
8004 case ALC880_MIC_EVENT:
8005 /* alc883_mitac_mic_automute(codec); */
8006 break;
8007 }
8008}
8009
8010static struct hda_verb alc883_mitac_verbs[] = {
8011 /* HP */
8012 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8013 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8014 /* Subwoofer */
8015 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8016 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8017
8018 /* enable unsolicited event */
8019 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8020 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8021
8022 { } /* end */
8023};
8024
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008025static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008026 /* HP */
8027 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8029 /* Int speaker */
8030 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8032
8033 /* enable unsolicited event */
8034 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008035 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008036
8037 { } /* end */
8038};
8039
Jiang zhefb97dc62008-03-06 11:07:11 +01008040static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8041 /* HP */
8042 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8043 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8044 /* Subwoofer */
8045 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8046 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8047
8048 /* enable unsolicited event */
8049 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8050
8051 { } /* end */
8052};
8053
Kailang Yangccc656c2006-10-17 12:32:26 +02008054static struct hda_verb alc883_tagra_verbs[] = {
8055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8056 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8057
8058 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8059 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008060
Kailang Yangccc656c2006-10-17 12:32:26 +02008061 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8062 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8063 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8064
8065 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008066 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8067 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8068 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02008069
8070 { } /* end */
8071};
8072
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008073static struct hda_verb alc883_lenovo_101e_verbs[] = {
8074 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8075 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8076 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8077 { } /* end */
8078};
8079
Kailang Yang272a5272007-05-14 11:00:38 +02008080static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8081 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8082 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8083 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8085 { } /* end */
8086};
8087
8088static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8091 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8092 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8093 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8094 { } /* end */
8095};
8096
Kailang Yang189609a2007-08-20 11:31:23 +02008097static struct hda_verb alc883_haier_w66_verbs[] = {
8098 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8100
8101 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8102
8103 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8104 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8105 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8106 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8107 { } /* end */
8108};
8109
Kailang Yange2757d52008-08-26 13:17:46 +02008110static struct hda_verb alc888_lenovo_sky_verbs[] = {
8111 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8112 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8113 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8114 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8115 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8116 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8117 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8118 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8119 { } /* end */
8120};
8121
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008122static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008123 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008124 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8125 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008126 { }
8127};
8128
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008129static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008130 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8131 { }
8132};
8133
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008134static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008135 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8136 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8137 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8138 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8139 { }
8140};
8141
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008142static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008143 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8144 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8145 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8146 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8147 { }
8148};
8149
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008150static struct hda_channel_mode alc888_3st_hp_modes[2] = {
8151 { 2, alc888_3st_hp_2ch_init },
8152 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008153};
8154
Kailang Yang272a5272007-05-14 11:00:38 +02008155/* toggle front-jack and RCA according to the hp-jack state */
8156static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8157{
8158 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008159
Kailang Yang272a5272007-05-14 11:00:38 +02008160 present = snd_hda_codec_read(codec, 0x1b, 0,
8161 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008162 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8163 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8164 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8165 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008166}
8167
8168/* toggle RCA according to the front-jack state */
8169static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8170{
8171 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008172
Kailang Yang272a5272007-05-14 11:00:38 +02008173 present = snd_hda_codec_read(codec, 0x14, 0,
8174 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008175 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8176 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008177}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008178
Kailang Yang272a5272007-05-14 11:00:38 +02008179static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8180 unsigned int res)
8181{
8182 if ((res >> 26) == ALC880_HP_EVENT)
8183 alc888_lenovo_ms7195_front_automute(codec);
8184 if ((res >> 26) == ALC880_FRONT_EVENT)
8185 alc888_lenovo_ms7195_rca_automute(codec);
8186}
8187
8188static struct hda_verb alc883_medion_md2_verbs[] = {
8189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8191
8192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8193
8194 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8195 { } /* end */
8196};
8197
8198/* toggle speaker-output according to the hp-jack state */
8199static void alc883_medion_md2_automute(struct hda_codec *codec)
8200{
8201 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008202
Kailang Yang272a5272007-05-14 11:00:38 +02008203 present = snd_hda_codec_read(codec, 0x14, 0,
8204 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008205 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8206 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008207}
8208
8209static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8210 unsigned int res)
8211{
8212 if ((res >> 26) == ALC880_HP_EVENT)
8213 alc883_medion_md2_automute(codec);
8214}
8215
Kailang Yangccc656c2006-10-17 12:32:26 +02008216/* toggle speaker-output according to the hp-jack state */
8217static void alc883_tagra_automute(struct hda_codec *codec)
8218{
8219 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008220 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008221
8222 present = snd_hda_codec_read(codec, 0x14, 0,
8223 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008224 bits = present ? HDA_AMP_MUTE : 0;
8225 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8226 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008227 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8228 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008229}
8230
8231static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8232{
8233 if ((res >> 26) == ALC880_HP_EVENT)
8234 alc883_tagra_automute(codec);
8235}
8236
Jiang zhe368c7a92008-03-04 11:20:33 +01008237/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008238static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008239{
8240 unsigned int present;
8241 unsigned char bits;
8242
8243 present = snd_hda_codec_read(codec, 0x15, 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, 0x14, HDA_OUTPUT, 0,
8247 HDA_AMP_MUTE, bits);
8248}
8249
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008250static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8251{
8252 unsigned int present;
8253
8254 present = snd_hda_codec_read(codec, 0x18, 0,
8255 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8256 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8257 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8258}
8259
8260static void alc883_clevo_m720_automute(struct hda_codec *codec)
8261{
8262 alc883_clevo_m720_hp_automute(codec);
8263 alc883_clevo_m720_mic_automute(codec);
8264}
8265
8266static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008267 unsigned int res)
8268{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008269 switch (res >> 26) {
8270 case ALC880_HP_EVENT:
8271 alc883_clevo_m720_hp_automute(codec);
8272 break;
8273 case ALC880_MIC_EVENT:
8274 alc883_clevo_m720_mic_automute(codec);
8275 break;
8276 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008277}
8278
Jiang zhefb97dc62008-03-06 11:07:11 +01008279/* toggle speaker-output according to the hp-jack state */
8280static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8281{
8282 unsigned int present;
8283 unsigned char bits;
8284
8285 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8286 & AC_PINSENSE_PRESENCE;
8287 bits = present ? HDA_AMP_MUTE : 0;
8288 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8289 HDA_AMP_MUTE, bits);
8290}
8291
8292static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8293 unsigned int res)
8294{
8295 if ((res >> 26) == ALC880_HP_EVENT)
8296 alc883_2ch_fujitsu_pi2515_automute(codec);
8297}
8298
Kailang Yang189609a2007-08-20 11:31:23 +02008299static void alc883_haier_w66_automute(struct hda_codec *codec)
8300{
8301 unsigned int present;
8302 unsigned char bits;
8303
8304 present = snd_hda_codec_read(codec, 0x1b, 0,
8305 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8306 bits = present ? 0x80 : 0;
8307 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8308 0x80, bits);
8309}
8310
8311static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8312 unsigned int res)
8313{
8314 if ((res >> 26) == ALC880_HP_EVENT)
8315 alc883_haier_w66_automute(codec);
8316}
8317
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008318static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8319{
8320 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008321 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008322
8323 present = snd_hda_codec_read(codec, 0x14, 0,
8324 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008325 bits = present ? HDA_AMP_MUTE : 0;
8326 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8327 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008328}
8329
8330static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8331{
8332 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008333 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008334
8335 present = snd_hda_codec_read(codec, 0x1b, 0,
8336 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008337 bits = present ? HDA_AMP_MUTE : 0;
8338 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8339 HDA_AMP_MUTE, bits);
8340 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8341 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008342}
8343
8344static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8345 unsigned int res)
8346{
8347 if ((res >> 26) == ALC880_HP_EVENT)
8348 alc883_lenovo_101e_all_automute(codec);
8349 if ((res >> 26) == ALC880_FRONT_EVENT)
8350 alc883_lenovo_101e_ispeaker_automute(codec);
8351}
8352
Takashi Iwai676a9b52007-08-16 15:23:35 +02008353/* toggle speaker-output according to the hp-jack state */
8354static void alc883_acer_aspire_automute(struct hda_codec *codec)
8355{
8356 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008357
Takashi Iwai676a9b52007-08-16 15:23:35 +02008358 present = snd_hda_codec_read(codec, 0x14, 0,
8359 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8360 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8361 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8362 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8363 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8364}
8365
8366static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8367 unsigned int res)
8368{
8369 if ((res >> 26) == ALC880_HP_EVENT)
8370 alc883_acer_aspire_automute(codec);
8371}
8372
Kailang Yangd1a991a2007-08-15 16:21:59 +02008373static struct hda_verb alc883_acer_eapd_verbs[] = {
8374 /* HP Pin: output 0 (0x0c) */
8375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8376 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8377 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8378 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8380 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008381 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008382 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8383 /* eanable EAPD on medion laptop */
8384 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8385 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008386 /* enable unsolicited event */
8387 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008388 { }
8389};
8390
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008391static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8392{
8393 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008394
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008395 present = snd_hda_codec_read(codec, 0x1b, 0,
8396 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8397 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8398 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8399 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8400 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8401 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8402 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8403 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8404 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8405}
8406
8407static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8408 unsigned int res)
8409{
8410 switch (res >> 26) {
8411 case ALC880_HP_EVENT:
Takashi Iwai939778a2009-02-05 15:57:55 +01008412 /* printk(KERN_DEBUG "hp_event\n"); */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008413 alc888_6st_dell_front_automute(codec);
8414 break;
8415 }
8416}
8417
Kailang Yange2757d52008-08-26 13:17:46 +02008418static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8419{
8420 unsigned int mute;
8421 unsigned int present;
8422
8423 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8424 present = snd_hda_codec_read(codec, 0x1b, 0,
8425 AC_VERB_GET_PIN_SENSE, 0);
8426 present = (present & 0x80000000) != 0;
8427 if (present) {
8428 /* mute internal speaker */
8429 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8430 HDA_AMP_MUTE, HDA_AMP_MUTE);
8431 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8432 HDA_AMP_MUTE, HDA_AMP_MUTE);
8433 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8434 HDA_AMP_MUTE, HDA_AMP_MUTE);
8435 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8436 HDA_AMP_MUTE, HDA_AMP_MUTE);
8437 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8438 HDA_AMP_MUTE, HDA_AMP_MUTE);
8439 } else {
8440 /* unmute internal speaker if necessary */
8441 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8442 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8443 HDA_AMP_MUTE, mute);
8444 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8445 HDA_AMP_MUTE, mute);
8446 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8447 HDA_AMP_MUTE, mute);
8448 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8449 HDA_AMP_MUTE, mute);
8450 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8451 HDA_AMP_MUTE, mute);
8452 }
8453}
8454
8455static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8456 unsigned int res)
8457{
8458 if ((res >> 26) == ALC880_HP_EVENT)
8459 alc888_lenovo_sky_front_automute(codec);
8460}
8461
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008462/*
8463 * generic initialization of ADC, input mixers and output mixers
8464 */
8465static struct hda_verb alc883_auto_init_verbs[] = {
8466 /*
8467 * Unmute ADC0-2 and set the default input to mic-in
8468 */
8469 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8470 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8471 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8472 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8473
Takashi Iwaicb53c622007-08-10 17:21:45 +02008474 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008475 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008476 * Note: PASD motherboards uses the Line In 2 as the input for
8477 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008478 */
8479 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008480 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8481 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8482 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8483 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8484 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008485
8486 /*
8487 * Set up output mixers (0x0c - 0x0f)
8488 */
8489 /* set vol=0 to output mixers */
8490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8491 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8492 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8493 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8494 /* set up input amps for analog loopback */
8495 /* Amp Indices: DAC = 0, mixer = 1 */
8496 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8498 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8499 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8500 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8501 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8502 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8503 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8504 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8505 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8506
8507 /* FIXME: use matrix-type input source selection */
8508 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8509 /* Input mixer1 */
8510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8511 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8512 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008513 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008514 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8515 /* Input mixer2 */
8516 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8517 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8518 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008519 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008521
8522 { }
8523};
8524
Kailang Yange2757d52008-08-26 13:17:46 +02008525static struct hda_verb alc888_asus_m90v_verbs[] = {
8526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8527 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8528 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8529 /* enable unsolicited event */
8530 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8531 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8532 { } /* end */
8533};
8534
8535static void alc883_nb_mic_automute(struct hda_codec *codec)
8536{
8537 unsigned int present;
8538
8539 present = snd_hda_codec_read(codec, 0x18, 0,
8540 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8541 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8542 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8543 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8544 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8545}
8546
8547static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8548{
8549 unsigned int present;
8550 unsigned char bits;
8551
8552 present = snd_hda_codec_read(codec, 0x1b, 0,
8553 AC_VERB_GET_PIN_SENSE, 0)
8554 & AC_PINSENSE_PRESENCE;
8555 bits = present ? 0 : PIN_OUT;
8556 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8557 bits);
8558 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8559 bits);
8560 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8561 bits);
8562}
8563
8564static void alc883_mode2_unsol_event(struct hda_codec *codec,
8565 unsigned int res)
8566{
8567 switch (res >> 26) {
8568 case ALC880_HP_EVENT:
8569 alc883_M90V_speaker_automute(codec);
8570 break;
8571 case ALC880_MIC_EVENT:
8572 alc883_nb_mic_automute(codec);
8573 break;
8574 }
8575}
8576
8577static void alc883_mode2_inithook(struct hda_codec *codec)
8578{
8579 alc883_M90V_speaker_automute(codec);
8580 alc883_nb_mic_automute(codec);
8581}
8582
8583static struct hda_verb alc888_asus_eee1601_verbs[] = {
8584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8585 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8586 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8588 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8589 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8590 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8591 /* enable unsolicited event */
8592 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8593 { } /* end */
8594};
8595
8596static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8597{
8598 unsigned int present;
8599 unsigned char bits;
8600
8601 present = snd_hda_codec_read(codec, 0x14, 0,
8602 AC_VERB_GET_PIN_SENSE, 0)
8603 & AC_PINSENSE_PRESENCE;
8604 bits = present ? 0 : PIN_OUT;
8605 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8606 bits);
8607}
8608
8609static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8610 unsigned int res)
8611{
8612 switch (res >> 26) {
8613 case ALC880_HP_EVENT:
8614 alc883_eee1601_speaker_automute(codec);
8615 break;
8616 }
8617}
8618
8619static void alc883_eee1601_inithook(struct hda_codec *codec)
8620{
8621 alc883_eee1601_speaker_automute(codec);
8622}
8623
Takashi Iwaicb53c622007-08-10 17:21:45 +02008624#ifdef CONFIG_SND_HDA_POWER_SAVE
8625#define alc883_loopbacks alc880_loopbacks
8626#endif
8627
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008628/* pcm configuration: identiacal with ALC880 */
8629#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8630#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008631#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008632#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8633#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8634
8635/*
8636 * configuration and preset
8637 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008638static const char *alc883_models[ALC883_MODEL_LAST] = {
8639 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8640 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8641 [ALC883_3ST_6ch] = "3stack-6ch",
8642 [ALC883_6ST_DIG] = "6stack-dig",
8643 [ALC883_TARGA_DIG] = "targa-dig",
8644 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008645 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008646 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008647 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008648 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008649 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008650 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008651 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008652 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8653 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008654 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008655 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008656 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008657 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008658 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008659 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008660 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008661 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008662 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008663 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008664 [ALC883_AUTO] = "auto",
8665};
8666
8667static struct snd_pci_quirk alc883_cfg_tbl[] = {
8668 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008669 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008670 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008671 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8672 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008673 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008674 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8675 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008676 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8677 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01008678 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008679 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008680 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8681 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008682 /* default Acer */
8683 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008684 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008685 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008686 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8687 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008688 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008689 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008690 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008691 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008692 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008693 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008694 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008695 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008696 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008697 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008698 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8699 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008700 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008701 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008702 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008703 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8704 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8705 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008706 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008707 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008708 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008709 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8710 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8711 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8712 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8713 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8714 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8715 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8716 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8717 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008718 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8719 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008720 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008721 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008722 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008723 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008724 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008725 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008726 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008727 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8728 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008729 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008730 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008731 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaif67d8172009-02-04 23:30:19 +01008732 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8733 ALC883_FUJITSU_PI2515),
Jiang zhefb97dc62008-03-06 11:07:11 +01008734 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008735 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8736 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008737 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008738 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008739 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8740 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008741 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008742 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008743 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008744 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008745 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008746 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8747 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008748 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008749 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008750 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008751 {}
8752};
8753
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008754static hda_nid_t alc1200_slave_dig_outs[] = {
8755 ALC883_DIGOUT_NID, 0,
8756};
8757
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008758static struct alc_config_preset alc883_presets[] = {
8759 [ALC883_3ST_2ch_DIG] = {
8760 .mixers = { alc883_3ST_2ch_mixer },
8761 .init_verbs = { alc883_init_verbs },
8762 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8763 .dac_nids = alc883_dac_nids,
8764 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008765 .dig_in_nid = ALC883_DIGIN_NID,
8766 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8767 .channel_mode = alc883_3ST_2ch_modes,
8768 .input_mux = &alc883_capture_source,
8769 },
8770 [ALC883_3ST_6ch_DIG] = {
8771 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8772 .init_verbs = { alc883_init_verbs },
8773 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8774 .dac_nids = alc883_dac_nids,
8775 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008776 .dig_in_nid = ALC883_DIGIN_NID,
8777 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8778 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008779 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008780 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008781 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008782 [ALC883_3ST_6ch] = {
8783 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8784 .init_verbs = { alc883_init_verbs },
8785 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8786 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008787 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8788 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008789 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008790 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008791 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008792 [ALC883_3ST_6ch_INTEL] = {
8793 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8794 .init_verbs = { alc883_init_verbs },
8795 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8796 .dac_nids = alc883_dac_nids,
8797 .dig_out_nid = ALC883_DIGOUT_NID,
8798 .dig_in_nid = ALC883_DIGIN_NID,
8799 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8800 .channel_mode = alc883_3ST_6ch_intel_modes,
8801 .need_dac_fix = 1,
8802 .input_mux = &alc883_3stack_6ch_intel,
8803 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008804 [ALC883_6ST_DIG] = {
8805 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8806 .init_verbs = { alc883_init_verbs },
8807 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8808 .dac_nids = alc883_dac_nids,
8809 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008810 .dig_in_nid = ALC883_DIGIN_NID,
8811 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8812 .channel_mode = alc883_sixstack_modes,
8813 .input_mux = &alc883_capture_source,
8814 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008815 [ALC883_TARGA_DIG] = {
8816 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8817 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8818 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8819 .dac_nids = alc883_dac_nids,
8820 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008821 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8822 .channel_mode = alc883_3ST_6ch_modes,
8823 .need_dac_fix = 1,
8824 .input_mux = &alc883_capture_source,
8825 .unsol_event = alc883_tagra_unsol_event,
8826 .init_hook = alc883_tagra_automute,
8827 },
8828 [ALC883_TARGA_2ch_DIG] = {
8829 .mixers = { alc883_tagra_2ch_mixer},
8830 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8831 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8832 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008833 .adc_nids = alc883_adc_nids_alt,
8834 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008835 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008836 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8837 .channel_mode = alc883_3ST_2ch_modes,
8838 .input_mux = &alc883_capture_source,
8839 .unsol_event = alc883_tagra_unsol_event,
8840 .init_hook = alc883_tagra_automute,
8841 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008842 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008843 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008844 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8845 * and the headphone jack. Turn this on and rely on the
8846 * standard mute methods whenever the user wants to turn
8847 * these outputs off.
8848 */
8849 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8850 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8851 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008852 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8853 .channel_mode = alc883_3ST_2ch_modes,
8854 .input_mux = &alc883_capture_source,
8855 },
Tobin Davis2880a862007-08-07 11:50:26 +02008856 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008857 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008858 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008859 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8860 .dac_nids = alc883_dac_nids,
8861 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008862 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8863 .channel_mode = alc883_3ST_2ch_modes,
8864 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008865 .unsol_event = alc883_acer_aspire_unsol_event,
8866 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008867 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008868 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008869 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008870 alc883_chmode_mixer },
8871 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8872 alc888_acer_aspire_4930g_verbs },
8873 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8874 .dac_nids = alc883_dac_nids,
8875 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8876 .adc_nids = alc883_adc_nids_rev,
8877 .capsrc_nids = alc883_capsrc_nids_rev,
8878 .dig_out_nid = ALC883_DIGOUT_NID,
8879 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8880 .channel_mode = alc883_3ST_6ch_modes,
8881 .need_dac_fix = 1,
8882 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008883 ARRAY_SIZE(alc888_2_capture_sources),
8884 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008885 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8886 .init_hook = alc888_acer_aspire_4930g_automute,
8887 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008888 [ALC883_MEDION] = {
8889 .mixers = { alc883_fivestack_mixer,
8890 alc883_chmode_mixer },
8891 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008892 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008893 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8894 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008895 .adc_nids = alc883_adc_nids_alt,
8896 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008897 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8898 .channel_mode = alc883_sixstack_modes,
8899 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008900 },
Kailang Yang272a5272007-05-14 11:00:38 +02008901 [ALC883_MEDION_MD2] = {
8902 .mixers = { alc883_medion_md2_mixer},
8903 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8904 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8905 .dac_nids = alc883_dac_nids,
8906 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008907 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8908 .channel_mode = alc883_3ST_2ch_modes,
8909 .input_mux = &alc883_capture_source,
8910 .unsol_event = alc883_medion_md2_unsol_event,
8911 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008912 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008913 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008914 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008915 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8916 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8917 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008918 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8919 .channel_mode = alc883_3ST_2ch_modes,
8920 .input_mux = &alc883_capture_source,
8921 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008922 [ALC883_CLEVO_M720] = {
8923 .mixers = { alc883_clevo_m720_mixer },
8924 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008925 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8926 .dac_nids = alc883_dac_nids,
8927 .dig_out_nid = ALC883_DIGOUT_NID,
8928 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8929 .channel_mode = alc883_3ST_2ch_modes,
8930 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008931 .unsol_event = alc883_clevo_m720_unsol_event,
8932 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008933 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008934 [ALC883_LENOVO_101E_2ch] = {
8935 .mixers = { alc883_lenovo_101e_2ch_mixer},
8936 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8937 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8938 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008939 .adc_nids = alc883_adc_nids_alt,
8940 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008941 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8942 .channel_mode = alc883_3ST_2ch_modes,
8943 .input_mux = &alc883_lenovo_101e_capture_source,
8944 .unsol_event = alc883_lenovo_101e_unsol_event,
8945 .init_hook = alc883_lenovo_101e_all_automute,
8946 },
Kailang Yang272a5272007-05-14 11:00:38 +02008947 [ALC883_LENOVO_NB0763] = {
8948 .mixers = { alc883_lenovo_nb0763_mixer },
8949 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8950 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8951 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008952 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8953 .channel_mode = alc883_3ST_2ch_modes,
8954 .need_dac_fix = 1,
8955 .input_mux = &alc883_lenovo_nb0763_capture_source,
8956 .unsol_event = alc883_medion_md2_unsol_event,
8957 .init_hook = alc883_medion_md2_automute,
8958 },
8959 [ALC888_LENOVO_MS7195_DIG] = {
8960 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8961 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8962 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8963 .dac_nids = alc883_dac_nids,
8964 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008965 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8966 .channel_mode = alc883_3ST_6ch_modes,
8967 .need_dac_fix = 1,
8968 .input_mux = &alc883_capture_source,
8969 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8970 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008971 },
8972 [ALC883_HAIER_W66] = {
8973 .mixers = { alc883_tagra_2ch_mixer},
8974 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8975 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8976 .dac_nids = alc883_dac_nids,
8977 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008978 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8979 .channel_mode = alc883_3ST_2ch_modes,
8980 .input_mux = &alc883_capture_source,
8981 .unsol_event = alc883_haier_w66_unsol_event,
8982 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008983 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008984 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008985 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008986 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008987 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8988 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008989 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8990 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008991 .need_dac_fix = 1,
8992 .input_mux = &alc883_capture_source,
8993 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008994 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008995 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008996 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8997 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8998 .dac_nids = alc883_dac_nids,
8999 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009000 .dig_in_nid = ALC883_DIGIN_NID,
9001 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9002 .channel_mode = alc883_sixstack_modes,
9003 .input_mux = &alc883_capture_source,
9004 .unsol_event = alc888_6st_dell_unsol_event,
9005 .init_hook = alc888_6st_dell_front_automute,
9006 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009007 [ALC883_MITAC] = {
9008 .mixers = { alc883_mitac_mixer },
9009 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9010 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9011 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009012 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9013 .channel_mode = alc883_3ST_2ch_modes,
9014 .input_mux = &alc883_capture_source,
9015 .unsol_event = alc883_mitac_unsol_event,
9016 .init_hook = alc883_mitac_automute,
9017 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009018 [ALC883_FUJITSU_PI2515] = {
9019 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9020 .init_verbs = { alc883_init_verbs,
9021 alc883_2ch_fujitsu_pi2515_verbs},
9022 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9023 .dac_nids = alc883_dac_nids,
9024 .dig_out_nid = ALC883_DIGOUT_NID,
9025 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9026 .channel_mode = alc883_3ST_2ch_modes,
9027 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9028 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
9029 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
9030 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009031 [ALC888_FUJITSU_XA3530] = {
9032 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9033 .init_verbs = { alc883_init_verbs,
9034 alc888_fujitsu_xa3530_verbs },
9035 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9036 .dac_nids = alc883_dac_nids,
9037 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9038 .adc_nids = alc883_adc_nids_rev,
9039 .capsrc_nids = alc883_capsrc_nids_rev,
9040 .dig_out_nid = ALC883_DIGOUT_NID,
9041 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9042 .channel_mode = alc888_4ST_8ch_intel_modes,
9043 .num_mux_defs =
9044 ARRAY_SIZE(alc888_2_capture_sources),
9045 .input_mux = alc888_2_capture_sources,
9046 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
9047 .init_hook = alc888_fujitsu_xa3530_automute,
9048 },
Kailang Yange2757d52008-08-26 13:17:46 +02009049 [ALC888_LENOVO_SKY] = {
9050 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9051 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9052 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9053 .dac_nids = alc883_dac_nids,
9054 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009055 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9056 .channel_mode = alc883_sixstack_modes,
9057 .need_dac_fix = 1,
9058 .input_mux = &alc883_lenovo_sky_capture_source,
9059 .unsol_event = alc883_lenovo_sky_unsol_event,
9060 .init_hook = alc888_lenovo_sky_front_automute,
9061 },
9062 [ALC888_ASUS_M90V] = {
9063 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9064 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9065 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9066 .dac_nids = alc883_dac_nids,
9067 .dig_out_nid = ALC883_DIGOUT_NID,
9068 .dig_in_nid = ALC883_DIGIN_NID,
9069 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9070 .channel_mode = alc883_3ST_6ch_modes,
9071 .need_dac_fix = 1,
9072 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9073 .unsol_event = alc883_mode2_unsol_event,
9074 .init_hook = alc883_mode2_inithook,
9075 },
9076 [ALC888_ASUS_EEE1601] = {
9077 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009078 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009079 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9080 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9081 .dac_nids = alc883_dac_nids,
9082 .dig_out_nid = ALC883_DIGOUT_NID,
9083 .dig_in_nid = ALC883_DIGIN_NID,
9084 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9085 .channel_mode = alc883_3ST_2ch_modes,
9086 .need_dac_fix = 1,
9087 .input_mux = &alc883_asus_eee1601_capture_source,
9088 .unsol_event = alc883_eee1601_unsol_event,
9089 .init_hook = alc883_eee1601_inithook,
9090 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009091 [ALC1200_ASUS_P5Q] = {
9092 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9093 .init_verbs = { alc883_init_verbs },
9094 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9095 .dac_nids = alc883_dac_nids,
9096 .dig_out_nid = ALC1200_DIGOUT_NID,
9097 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009098 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009099 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9100 .channel_mode = alc883_sixstack_modes,
9101 .input_mux = &alc883_capture_source,
9102 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009103};
9104
9105
9106/*
9107 * BIOS auto configuration
9108 */
9109static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9110 hda_nid_t nid, int pin_type,
9111 int dac_idx)
9112{
9113 /* set as output */
9114 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009115 int idx;
9116
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009117 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009118 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9119 idx = 4;
9120 else
9121 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009122 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9123
9124}
9125
9126static void alc883_auto_init_multi_out(struct hda_codec *codec)
9127{
9128 struct alc_spec *spec = codec->spec;
9129 int i;
9130
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009131 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009132 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009133 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009134 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009135 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009136 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009137 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009138 }
9139}
9140
9141static void alc883_auto_init_hp_out(struct hda_codec *codec)
9142{
9143 struct alc_spec *spec = codec->spec;
9144 hda_nid_t pin;
9145
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009146 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009147 if (pin) /* connect to front */
9148 /* use dac 0 */
9149 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009150 pin = spec->autocfg.speaker_pins[0];
9151 if (pin)
9152 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009153}
9154
9155#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9156#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9157
9158static void alc883_auto_init_analog_input(struct hda_codec *codec)
9159{
9160 struct alc_spec *spec = codec->spec;
9161 int i;
9162
9163 for (i = 0; i < AUTO_PIN_LAST; i++) {
9164 hda_nid_t nid = spec->autocfg.input_pins[i];
9165 if (alc883_is_input_pin(nid)) {
9166 snd_hda_codec_write(codec, nid, 0,
9167 AC_VERB_SET_PIN_WIDGET_CONTROL,
9168 (i <= AUTO_PIN_FRONT_MIC ?
9169 PIN_VREF80 : PIN_IN));
9170 if (nid != ALC883_PIN_CD_NID)
9171 snd_hda_codec_write(codec, nid, 0,
9172 AC_VERB_SET_AMP_GAIN_MUTE,
9173 AMP_OUT_MUTE);
9174 }
9175 }
9176}
9177
Takashi Iwaif511b012008-08-15 16:46:42 +02009178#define alc883_auto_init_input_src alc882_auto_init_input_src
9179
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009180/* almost identical with ALC880 parser... */
9181static int alc883_parse_auto_config(struct hda_codec *codec)
9182{
9183 struct alc_spec *spec = codec->spec;
9184 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009185 struct auto_pin_cfg *cfg = &spec->autocfg;
9186 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009187
9188 if (err < 0)
9189 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009190 else if (!err)
9191 return 0; /* no config found */
9192
9193 err = alc_auto_add_mic_boost(codec);
9194 if (err < 0)
9195 return err;
9196
9197 /* hack - override the init verbs */
9198 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009199
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009200 /* setup input_mux for ALC889 */
9201 if (codec->vendor_id == 0x10ec0889) {
9202 /* digital-mic input pin is excluded in alc880_auto_create..()
9203 * because it's under 0x18
9204 */
9205 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9206 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9207 struct hda_input_mux *imux = &spec->private_imux[0];
9208 for (i = 1; i < 3; i++)
9209 memcpy(&spec->private_imux[i],
9210 &spec->private_imux[0],
9211 sizeof(spec->private_imux[0]));
9212 imux->items[imux->num_items].label = "Int DMic";
9213 imux->items[imux->num_items].index = 0x0b;
9214 imux->num_items++;
9215 spec->num_mux_defs = 3;
9216 spec->input_mux = spec->private_imux;
9217 }
9218 }
9219
Takashi Iwai776e1842007-08-29 15:07:11 +02009220 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009221}
9222
9223/* additional initialization for auto-configuration model */
9224static void alc883_auto_init(struct hda_codec *codec)
9225{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009226 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009227 alc883_auto_init_multi_out(codec);
9228 alc883_auto_init_hp_out(codec);
9229 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009230 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009231 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009232 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009233}
9234
9235static int patch_alc883(struct hda_codec *codec)
9236{
9237 struct alc_spec *spec;
9238 int err, board_config;
9239
9240 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9241 if (spec == NULL)
9242 return -ENOMEM;
9243
9244 codec->spec = spec;
9245
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009246 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9247
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009248 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9249 alc883_models,
9250 alc883_cfg_tbl);
9251 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009252 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9253 "trying auto-probe from BIOS...\n");
9254 board_config = ALC883_AUTO;
9255 }
9256
9257 if (board_config == ALC883_AUTO) {
9258 /* automatic parse from the BIOS config */
9259 err = alc883_parse_auto_config(codec);
9260 if (err < 0) {
9261 alc_free(codec);
9262 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009263 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009264 printk(KERN_INFO
9265 "hda_codec: Cannot set up configuration "
9266 "from BIOS. Using base mode...\n");
9267 board_config = ALC883_3ST_2ch_DIG;
9268 }
9269 }
9270
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009271 err = snd_hda_attach_beep_device(codec, 0x1);
9272 if (err < 0) {
9273 alc_free(codec);
9274 return err;
9275 }
9276
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009277 if (board_config != ALC883_AUTO)
9278 setup_preset(spec, &alc883_presets[board_config]);
9279
Kailang Yang2f893282008-05-27 12:14:47 +02009280 switch (codec->vendor_id) {
9281 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009282 if (codec->revision_id == 0x100101) {
9283 spec->stream_name_analog = "ALC1200 Analog";
9284 spec->stream_name_digital = "ALC1200 Digital";
9285 } else {
9286 spec->stream_name_analog = "ALC888 Analog";
9287 spec->stream_name_digital = "ALC888 Digital";
9288 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009289 if (!spec->num_adc_nids) {
9290 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9291 spec->adc_nids = alc883_adc_nids;
9292 }
9293 if (!spec->capsrc_nids)
9294 spec->capsrc_nids = alc883_capsrc_nids;
9295 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009296 break;
9297 case 0x10ec0889:
9298 spec->stream_name_analog = "ALC889 Analog";
9299 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009300 if (!spec->num_adc_nids) {
9301 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9302 spec->adc_nids = alc889_adc_nids;
9303 }
9304 if (!spec->capsrc_nids)
9305 spec->capsrc_nids = alc889_capsrc_nids;
9306 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9307 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009308 break;
9309 default:
9310 spec->stream_name_analog = "ALC883 Analog";
9311 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009312 if (!spec->num_adc_nids) {
9313 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9314 spec->adc_nids = alc883_adc_nids;
9315 }
9316 if (!spec->capsrc_nids)
9317 spec->capsrc_nids = alc883_capsrc_nids;
9318 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009319 break;
9320 }
9321
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009322 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9323 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009324 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009325
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009326 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9327 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9328
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009329 if (!spec->cap_mixer)
9330 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009331 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009332
Takashi Iwai2134ea42008-01-10 16:53:55 +01009333 spec->vmaster_nid = 0x0c;
9334
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009335 codec->patch_ops = alc_patch_ops;
9336 if (board_config == ALC883_AUTO)
9337 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009338
Takashi Iwaicb53c622007-08-10 17:21:45 +02009339#ifdef CONFIG_SND_HDA_POWER_SAVE
9340 if (!spec->loopback.amplist)
9341 spec->loopback.amplist = alc883_loopbacks;
9342#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009343 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009344
9345 return 0;
9346}
9347
9348/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009349 * ALC262 support
9350 */
9351
9352#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9353#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9354
9355#define alc262_dac_nids alc260_dac_nids
9356#define alc262_adc_nids alc882_adc_nids
9357#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009358#define alc262_capsrc_nids alc882_capsrc_nids
9359#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009360
9361#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009362#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009363
Kailang Yang4e555fe2008-08-26 13:05:55 +02009364static hda_nid_t alc262_dmic_adc_nids[1] = {
9365 /* ADC0 */
9366 0x09
9367};
9368
9369static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9370
Kailang Yangdf694da2005-12-05 19:42:22 +01009371static struct snd_kcontrol_new alc262_base_mixer[] = {
9372 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9373 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9374 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9375 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9376 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9377 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9379 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009380 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009381 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9382 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009383 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009384 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9386 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9387 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009388 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009389};
9390
Kailang Yangccc656c2006-10-17 12:32:26 +02009391static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9392 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9393 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9394 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9395 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9396 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9397 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9398 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9399 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009400 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009401 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9402 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009403 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009404 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9405 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9406 { } /* end */
9407};
9408
Takashi Iwaice875f02008-01-28 18:17:43 +01009409/* update HP, line and mono-out pins according to the master switch */
9410static void alc262_hp_master_update(struct hda_codec *codec)
9411{
9412 struct alc_spec *spec = codec->spec;
9413 int val = spec->master_sw;
9414
9415 /* HP & line-out */
9416 snd_hda_codec_write_cache(codec, 0x1b, 0,
9417 AC_VERB_SET_PIN_WIDGET_CONTROL,
9418 val ? PIN_HP : 0);
9419 snd_hda_codec_write_cache(codec, 0x15, 0,
9420 AC_VERB_SET_PIN_WIDGET_CONTROL,
9421 val ? PIN_HP : 0);
9422 /* mono (speaker) depending on the HP jack sense */
9423 val = val && !spec->jack_present;
9424 snd_hda_codec_write_cache(codec, 0x16, 0,
9425 AC_VERB_SET_PIN_WIDGET_CONTROL,
9426 val ? PIN_OUT : 0);
9427}
9428
9429static void alc262_hp_bpc_automute(struct hda_codec *codec)
9430{
9431 struct alc_spec *spec = codec->spec;
9432 unsigned int presence;
9433 presence = snd_hda_codec_read(codec, 0x1b, 0,
9434 AC_VERB_GET_PIN_SENSE, 0);
9435 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9436 alc262_hp_master_update(codec);
9437}
9438
9439static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9440{
9441 if ((res >> 26) != ALC880_HP_EVENT)
9442 return;
9443 alc262_hp_bpc_automute(codec);
9444}
9445
9446static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9447{
9448 struct alc_spec *spec = codec->spec;
9449 unsigned int presence;
9450 presence = snd_hda_codec_read(codec, 0x15, 0,
9451 AC_VERB_GET_PIN_SENSE, 0);
9452 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9453 alc262_hp_master_update(codec);
9454}
9455
9456static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9457 unsigned int res)
9458{
9459 if ((res >> 26) != ALC880_HP_EVENT)
9460 return;
9461 alc262_hp_wildwest_automute(codec);
9462}
9463
9464static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9465 struct snd_ctl_elem_value *ucontrol)
9466{
9467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9468 struct alc_spec *spec = codec->spec;
9469 *ucontrol->value.integer.value = spec->master_sw;
9470 return 0;
9471}
9472
9473static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9474 struct snd_ctl_elem_value *ucontrol)
9475{
9476 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9477 struct alc_spec *spec = codec->spec;
9478 int val = !!*ucontrol->value.integer.value;
9479
9480 if (val == spec->master_sw)
9481 return 0;
9482 spec->master_sw = val;
9483 alc262_hp_master_update(codec);
9484 return 1;
9485}
9486
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009487static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009488 {
9489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9490 .name = "Master Playback Switch",
9491 .info = snd_ctl_boolean_mono_info,
9492 .get = alc262_hp_master_sw_get,
9493 .put = alc262_hp_master_sw_put,
9494 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009495 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9496 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9497 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009498 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9499 HDA_OUTPUT),
9500 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9501 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009502 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9503 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009504 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009505 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9506 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009507 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009508 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9509 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9510 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9511 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009512 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9513 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9514 { } /* end */
9515};
9516
Kailang Yangcd7509a2007-01-26 18:33:17 +01009517static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009518 {
9519 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9520 .name = "Master Playback Switch",
9521 .info = snd_ctl_boolean_mono_info,
9522 .get = alc262_hp_master_sw_get,
9523 .put = alc262_hp_master_sw_put,
9524 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009525 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9526 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9527 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9528 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009529 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9530 HDA_OUTPUT),
9531 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9532 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009533 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9534 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009535 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009536 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9537 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9538 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9539 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009540 { } /* end */
9541};
9542
9543static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9544 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9545 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009546 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009547 { } /* end */
9548};
9549
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009550/* mute/unmute internal speaker according to the hp jack and mute state */
9551static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9552{
9553 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009554
9555 if (force || !spec->sense_updated) {
9556 unsigned int present;
9557 present = snd_hda_codec_read(codec, 0x15, 0,
9558 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009559 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009560 spec->sense_updated = 1;
9561 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009562 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9563 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009564}
9565
9566static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9567 unsigned int res)
9568{
9569 if ((res >> 26) != ALC880_HP_EVENT)
9570 return;
9571 alc262_hp_t5735_automute(codec, 1);
9572}
9573
9574static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9575{
9576 alc262_hp_t5735_automute(codec, 1);
9577}
9578
9579static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009580 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9581 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009582 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9583 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9584 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9585 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9586 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9587 { } /* end */
9588};
9589
9590static struct hda_verb alc262_hp_t5735_verbs[] = {
9591 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9593
9594 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9595 { }
9596};
9597
Kailang Yang8c427222008-01-10 13:03:59 +01009598static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009599 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9600 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009601 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9602 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009603 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9604 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9605 { } /* end */
9606};
9607
9608static struct hda_verb alc262_hp_rp5700_verbs[] = {
9609 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9610 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9611 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9612 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9613 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9614 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9616 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9618 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9619 {}
9620};
9621
9622static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9623 .num_items = 1,
9624 .items = {
9625 { "Line", 0x1 },
9626 },
9627};
9628
Takashi Iwai0724ea22007-08-23 00:31:43 +02009629/* bind hp and internal speaker mute (with plug check) */
9630static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9631 struct snd_ctl_elem_value *ucontrol)
9632{
9633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9634 long *valp = ucontrol->value.integer.value;
9635 int change;
9636
9637 /* change hp mute */
9638 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9639 HDA_AMP_MUTE,
9640 valp[0] ? 0 : HDA_AMP_MUTE);
9641 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9642 HDA_AMP_MUTE,
9643 valp[1] ? 0 : HDA_AMP_MUTE);
9644 if (change) {
9645 /* change speaker according to HP jack state */
9646 struct alc_spec *spec = codec->spec;
9647 unsigned int mute;
9648 if (spec->jack_present)
9649 mute = HDA_AMP_MUTE;
9650 else
9651 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9652 HDA_OUTPUT, 0);
9653 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9654 HDA_AMP_MUTE, mute);
9655 }
9656 return change;
9657}
Takashi Iwai5b319542007-07-26 11:49:22 +02009658
Kailang Yang272a5272007-05-14 11:00:38 +02009659static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009660 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9661 {
9662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9663 .name = "Master Playback Switch",
9664 .info = snd_hda_mixer_amp_switch_info,
9665 .get = snd_hda_mixer_amp_switch_get,
9666 .put = alc262_sony_master_sw_put,
9667 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9668 },
Kailang Yang272a5272007-05-14 11:00:38 +02009669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9671 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9672 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9673 { } /* end */
9674};
9675
Kailang Yang83c34212007-07-05 11:43:05 +02009676static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9677 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9678 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9679 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9682 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9683 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9684 { } /* end */
9685};
Kailang Yang272a5272007-05-14 11:00:38 +02009686
Tony Vroonba340e82009-02-02 19:01:30 +00009687static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9688 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9689 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9690 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9691 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9692 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9693 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9694 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9695 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9696 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9697 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9698 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9699 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9700 { } /* end */
9701};
9702
9703static struct hda_verb alc262_tyan_verbs[] = {
9704 /* Headphone automute */
9705 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9706 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9707 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9708
9709 /* P11 AUX_IN, white 4-pin connector */
9710 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9711 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9712 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9713 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9714
9715 {}
9716};
9717
9718/* unsolicited event for HP jack sensing */
9719static void alc262_tyan_automute(struct hda_codec *codec)
9720{
9721 unsigned int mute;
9722 unsigned int present;
9723
9724 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9725 present = snd_hda_codec_read(codec, 0x1b, 0,
9726 AC_VERB_GET_PIN_SENSE, 0);
9727 present = (present & 0x80000000) != 0;
9728 if (present) {
9729 /* mute line output on ATX panel */
9730 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9731 HDA_AMP_MUTE, HDA_AMP_MUTE);
9732 } else {
9733 /* unmute line output if necessary */
9734 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9735 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9736 HDA_AMP_MUTE, mute);
9737 }
9738}
9739
9740static void alc262_tyan_unsol_event(struct hda_codec *codec,
9741 unsigned int res)
9742{
9743 if ((res >> 26) != ALC880_HP_EVENT)
9744 return;
9745 alc262_tyan_automute(codec);
9746}
9747
Kailang Yangdf694da2005-12-05 19:42:22 +01009748#define alc262_capture_mixer alc882_capture_mixer
9749#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9750
9751/*
9752 * generic initialization of ADC, input mixers and output mixers
9753 */
9754static struct hda_verb alc262_init_verbs[] = {
9755 /*
9756 * Unmute ADC0-2 and set the default input to mic-in
9757 */
9758 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9760 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9761 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9762 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9763 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9764
Takashi Iwaicb53c622007-08-10 17:21:45 +02009765 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009766 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009767 * Note: PASD motherboards uses the Line In 2 as the input for
9768 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009769 */
9770 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009771 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9772 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9773 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9774 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9775 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009776
9777 /*
9778 * Set up output mixers (0x0c - 0x0e)
9779 */
9780 /* set vol=0 to output mixers */
9781 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9782 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9783 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9784 /* set up input amps for analog loopback */
9785 /* Amp Indices: DAC = 0, mixer = 1 */
9786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9788 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9789 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9790 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9791 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9792
9793 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9794 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9795 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9796 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9797 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9798 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9799
9800 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9803 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9804 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009805
Kailang Yangdf694da2005-12-05 19:42:22 +01009806 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9807 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009808
Kailang Yangdf694da2005-12-05 19:42:22 +01009809 /* FIXME: use matrix-type input source selection */
9810 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9811 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9812 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9813 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9814 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9815 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9816 /* Input mixer2 */
9817 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9818 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9819 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9820 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9821 /* Input mixer3 */
9822 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9823 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9824 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009825 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009826
9827 { }
9828};
9829
Kailang Yang4e555fe2008-08-26 13:05:55 +02009830static struct hda_verb alc262_eapd_verbs[] = {
9831 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9832 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9833 { }
9834};
9835
Kailang Yangccc656c2006-10-17 12:32:26 +02009836static struct hda_verb alc262_hippo_unsol_verbs[] = {
9837 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9838 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9839 {}
9840};
9841
9842static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9843 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9844 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9845 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9846
9847 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9848 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9849 {}
9850};
9851
Kailang Yang272a5272007-05-14 11:00:38 +02009852static struct hda_verb alc262_sony_unsol_verbs[] = {
9853 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9854 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9855 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9856
9857 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9858 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009859 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009860};
9861
Kailang Yang4e555fe2008-08-26 13:05:55 +02009862static struct hda_input_mux alc262_dmic_capture_source = {
9863 .num_items = 2,
9864 .items = {
9865 { "Int DMic", 0x9 },
9866 { "Mic", 0x0 },
9867 },
9868};
9869
9870static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9871 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9872 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9873 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9874 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9875 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009876 { } /* end */
9877};
9878
9879static struct hda_verb alc262_toshiba_s06_verbs[] = {
9880 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9882 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9883 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9884 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9885 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9886 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9887 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9888 {}
9889};
9890
9891static void alc262_dmic_automute(struct hda_codec *codec)
9892{
9893 unsigned int present;
9894
9895 present = snd_hda_codec_read(codec, 0x18, 0,
9896 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9897 snd_hda_codec_write(codec, 0x22, 0,
9898 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9899}
9900
9901/* toggle speaker-output according to the hp-jack state */
9902static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9903{
9904 unsigned int present;
9905 unsigned char bits;
9906
9907 present = snd_hda_codec_read(codec, 0x15, 0,
9908 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9909 bits = present ? 0 : PIN_OUT;
9910 snd_hda_codec_write(codec, 0x14, 0,
9911 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9912}
9913
9914
9915
9916/* unsolicited event for HP jack sensing */
9917static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9918 unsigned int res)
9919{
9920 if ((res >> 26) == ALC880_HP_EVENT)
9921 alc262_toshiba_s06_speaker_automute(codec);
9922 if ((res >> 26) == ALC880_MIC_EVENT)
9923 alc262_dmic_automute(codec);
9924
9925}
9926
9927static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9928{
9929 alc262_toshiba_s06_speaker_automute(codec);
9930 alc262_dmic_automute(codec);
9931}
9932
Kailang Yangccc656c2006-10-17 12:32:26 +02009933/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009934static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009935{
9936 struct alc_spec *spec = codec->spec;
9937 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009938 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009939
Takashi Iwai5b319542007-07-26 11:49:22 +02009940 /* need to execute and sync at first */
9941 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9942 present = snd_hda_codec_read(codec, 0x15, 0,
9943 AC_VERB_GET_PIN_SENSE, 0);
9944 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009945 if (spec->jack_present) {
9946 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009947 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9948 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009949 } else {
9950 /* unmute internal speaker if necessary */
9951 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009952 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9953 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009954 }
9955}
9956
9957/* unsolicited event for HP jack sensing */
9958static void alc262_hippo_unsol_event(struct hda_codec *codec,
9959 unsigned int res)
9960{
9961 if ((res >> 26) != ALC880_HP_EVENT)
9962 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009963 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009964}
9965
Takashi Iwai5b319542007-07-26 11:49:22 +02009966static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009967{
Kailang Yangccc656c2006-10-17 12:32:26 +02009968 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009969 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009970
Takashi Iwai5b319542007-07-26 11:49:22 +02009971 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9972 present = snd_hda_codec_read(codec, 0x1b, 0,
9973 AC_VERB_GET_PIN_SENSE, 0);
9974 present = (present & 0x80000000) != 0;
9975 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009976 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009977 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9978 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009979 } else {
9980 /* unmute internal speaker if necessary */
9981 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009982 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9983 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009984 }
9985}
9986
9987/* unsolicited event for HP jack sensing */
9988static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9989 unsigned int res)
9990{
9991 if ((res >> 26) != ALC880_HP_EVENT)
9992 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009993 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009994}
9995
Takashi Iwai834be882006-03-01 14:16:17 +01009996/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009997 * nec model
9998 * 0x15 = headphone
9999 * 0x16 = internal speaker
10000 * 0x18 = external mic
10001 */
10002
10003static struct snd_kcontrol_new alc262_nec_mixer[] = {
10004 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10005 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10006
10007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10009 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10010
10011 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10013 { } /* end */
10014};
10015
10016static struct hda_verb alc262_nec_verbs[] = {
10017 /* Unmute Speaker */
10018 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10019
10020 /* Headphone */
10021 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10022 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10023
10024 /* External mic to headphone */
10025 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10026 /* External mic to speaker */
10027 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10028 {}
10029};
10030
10031/*
Takashi Iwai834be882006-03-01 14:16:17 +010010032 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010033 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10034 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010035 */
10036
10037#define ALC_HP_EVENT 0x37
10038
10039static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10040 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10041 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010042 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10043 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010044 {}
10045};
10046
Jiang zhe0e31daf2008-03-20 12:12:39 +010010047static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10048 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10049 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10050 {}
10051};
10052
Takashi Iwai834be882006-03-01 14:16:17 +010010053static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010054 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010055 .items = {
10056 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010057 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010058 { "CD", 0x4 },
10059 },
10060};
10061
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010062static struct hda_input_mux alc262_HP_capture_source = {
10063 .num_items = 5,
10064 .items = {
10065 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010066 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010067 { "Line", 0x2 },
10068 { "CD", 0x4 },
10069 { "AUX IN", 0x6 },
10070 },
10071};
10072
zhejiangaccbe492007-08-31 12:36:05 +020010073static struct hda_input_mux alc262_HP_D7000_capture_source = {
10074 .num_items = 4,
10075 .items = {
10076 { "Mic", 0x0 },
10077 { "Front Mic", 0x2 },
10078 { "Line", 0x1 },
10079 { "CD", 0x4 },
10080 },
10081};
10082
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010083/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010084static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10085{
10086 struct alc_spec *spec = codec->spec;
10087 unsigned int mute;
10088
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010089 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010090 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010091 /* need to execute and sync at first */
10092 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010093 /* check laptop HP jack */
10094 present = snd_hda_codec_read(codec, 0x14, 0,
10095 AC_VERB_GET_PIN_SENSE, 0);
10096 /* need to execute and sync at first */
10097 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10098 /* check docking HP jack */
10099 present |= snd_hda_codec_read(codec, 0x1b, 0,
10100 AC_VERB_GET_PIN_SENSE, 0);
10101 if (present & AC_PINSENSE_PRESENCE)
10102 spec->jack_present = 1;
10103 else
10104 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010105 spec->sense_updated = 1;
10106 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010107 /* unmute internal speaker only if both HPs are unplugged and
10108 * master switch is on
10109 */
10110 if (spec->jack_present)
10111 mute = HDA_AMP_MUTE;
10112 else
Takashi Iwai834be882006-03-01 14:16:17 +010010113 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010114 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10115 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010116}
10117
10118/* unsolicited event for HP jack sensing */
10119static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10120 unsigned int res)
10121{
10122 if ((res >> 26) != ALC_HP_EVENT)
10123 return;
10124 alc262_fujitsu_automute(codec, 1);
10125}
10126
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010127static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10128{
10129 alc262_fujitsu_automute(codec, 1);
10130}
10131
Takashi Iwai834be882006-03-01 14:16:17 +010010132/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010133static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10134 .ops = &snd_hda_bind_vol,
10135 .values = {
10136 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10137 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10138 0
10139 },
10140};
Takashi Iwai834be882006-03-01 14:16:17 +010010141
Jiang zhe0e31daf2008-03-20 12:12:39 +010010142/* mute/unmute internal speaker according to the hp jack and mute state */
10143static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10144{
10145 struct alc_spec *spec = codec->spec;
10146 unsigned int mute;
10147
10148 if (force || !spec->sense_updated) {
10149 unsigned int present_int_hp;
10150 /* need to execute and sync at first */
10151 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10152 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10153 AC_VERB_GET_PIN_SENSE, 0);
10154 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10155 spec->sense_updated = 1;
10156 }
10157 if (spec->jack_present) {
10158 /* mute internal speaker */
10159 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10160 HDA_AMP_MUTE, HDA_AMP_MUTE);
10161 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10162 HDA_AMP_MUTE, HDA_AMP_MUTE);
10163 } else {
10164 /* unmute internal speaker if necessary */
10165 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10166 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10167 HDA_AMP_MUTE, mute);
10168 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10169 HDA_AMP_MUTE, mute);
10170 }
10171}
10172
10173/* unsolicited event for HP jack sensing */
10174static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10175 unsigned int res)
10176{
10177 if ((res >> 26) != ALC_HP_EVENT)
10178 return;
10179 alc262_lenovo_3000_automute(codec, 1);
10180}
10181
Takashi Iwai834be882006-03-01 14:16:17 +010010182/* bind hp and internal speaker mute (with plug check) */
10183static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10184 struct snd_ctl_elem_value *ucontrol)
10185{
10186 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10187 long *valp = ucontrol->value.integer.value;
10188 int change;
10189
Tony Vroon5d9fab22008-03-14 17:09:18 +010010190 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10191 HDA_AMP_MUTE,
10192 valp ? 0 : HDA_AMP_MUTE);
10193 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10194 HDA_AMP_MUTE,
10195 valp ? 0 : HDA_AMP_MUTE);
10196
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010197 if (change)
10198 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010199 return change;
10200}
10201
10202static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010203 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010204 {
10205 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10206 .name = "Master Playback Switch",
10207 .info = snd_hda_mixer_amp_switch_info,
10208 .get = snd_hda_mixer_amp_switch_get,
10209 .put = alc262_fujitsu_master_sw_put,
10210 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10211 },
10212 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10213 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10214 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010217 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10218 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10219 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010220 { } /* end */
10221};
10222
Jiang zhe0e31daf2008-03-20 12:12:39 +010010223/* bind hp and internal speaker mute (with plug check) */
10224static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10225 struct snd_ctl_elem_value *ucontrol)
10226{
10227 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10228 long *valp = ucontrol->value.integer.value;
10229 int change;
10230
10231 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10232 HDA_AMP_MUTE,
10233 valp ? 0 : HDA_AMP_MUTE);
10234
10235 if (change)
10236 alc262_lenovo_3000_automute(codec, 0);
10237 return change;
10238}
10239
10240static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10241 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10242 {
10243 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10244 .name = "Master Playback Switch",
10245 .info = snd_hda_mixer_amp_switch_info,
10246 .get = snd_hda_mixer_amp_switch_get,
10247 .put = alc262_lenovo_3000_master_sw_put,
10248 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10249 },
10250 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10251 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10252 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10255 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10256 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10257 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10258 { } /* end */
10259};
10260
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010261static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10262 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10263 {
10264 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10265 .name = "Master Playback Switch",
10266 .info = snd_hda_mixer_amp_switch_info,
10267 .get = snd_hda_mixer_amp_switch_get,
10268 .put = alc262_sony_master_sw_put,
10269 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10270 },
10271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10272 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10273 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10274 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10275 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10276 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10277 { } /* end */
10278};
10279
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010280/* additional init verbs for Benq laptops */
10281static struct hda_verb alc262_EAPD_verbs[] = {
10282 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10283 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10284 {}
10285};
10286
Kailang Yang83c34212007-07-05 11:43:05 +020010287static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10288 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10289 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10290
10291 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10292 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10293 {}
10294};
10295
Tobin Davisf651b502007-10-26 12:40:47 +020010296/* Samsung Q1 Ultra Vista model setup */
10297static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010298 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10299 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010300 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10301 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10302 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010303 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010304 { } /* end */
10305};
10306
10307static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010308 /* output mixer */
10309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10312 /* speaker */
10313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10314 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10315 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10316 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10317 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010318 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010319 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10320 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10321 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10322 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10323 /* internal mic */
10324 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10326 /* ADC, choose mic */
10327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10328 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10329 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10335 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10336 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010337 {}
10338};
10339
Tobin Davisf651b502007-10-26 12:40:47 +020010340/* mute/unmute internal speaker according to the hp jack and mute state */
10341static void alc262_ultra_automute(struct hda_codec *codec)
10342{
10343 struct alc_spec *spec = codec->spec;
10344 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010345
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010346 mute = 0;
10347 /* auto-mute only when HP is used as HP */
10348 if (!spec->cur_mux[0]) {
10349 unsigned int present;
10350 /* need to execute and sync at first */
10351 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10352 present = snd_hda_codec_read(codec, 0x15, 0,
10353 AC_VERB_GET_PIN_SENSE, 0);
10354 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10355 if (spec->jack_present)
10356 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010357 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010358 /* mute/unmute internal speaker */
10359 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10360 HDA_AMP_MUTE, mute);
10361 /* mute/unmute HP */
10362 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10363 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010364}
10365
10366/* unsolicited event for HP jack sensing */
10367static void alc262_ultra_unsol_event(struct hda_codec *codec,
10368 unsigned int res)
10369{
10370 if ((res >> 26) != ALC880_HP_EVENT)
10371 return;
10372 alc262_ultra_automute(codec);
10373}
10374
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010375static struct hda_input_mux alc262_ultra_capture_source = {
10376 .num_items = 2,
10377 .items = {
10378 { "Mic", 0x1 },
10379 { "Headphone", 0x7 },
10380 },
10381};
10382
10383static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10384 struct snd_ctl_elem_value *ucontrol)
10385{
10386 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10387 struct alc_spec *spec = codec->spec;
10388 int ret;
10389
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010390 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010391 if (!ret)
10392 return 0;
10393 /* reprogram the HP pin as mic or HP according to the input source */
10394 snd_hda_codec_write_cache(codec, 0x15, 0,
10395 AC_VERB_SET_PIN_WIDGET_CONTROL,
10396 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10397 alc262_ultra_automute(codec); /* mute/unmute HP */
10398 return ret;
10399}
10400
10401static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10402 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10403 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10404 {
10405 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10406 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010407 .info = alc_mux_enum_info,
10408 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010409 .put = alc262_ultra_mux_enum_put,
10410 },
10411 { } /* end */
10412};
10413
Kailang Yangdf694da2005-12-05 19:42:22 +010010414/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010415static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10416 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010417{
10418 hda_nid_t nid;
10419 int err;
10420
10421 spec->multiout.num_dacs = 1; /* only use one dac */
10422 spec->multiout.dac_nids = spec->private_dac_nids;
10423 spec->multiout.dac_nids[0] = 2;
10424
10425 nid = cfg->line_out_pins[0];
10426 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010427 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10428 "Front Playback Volume",
10429 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10430 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010431 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010432 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10433 "Front Playback Switch",
10434 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10435 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010436 return err;
10437 }
10438
Takashi Iwai82bc9552006-03-21 11:24:42 +010010439 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010440 if (nid) {
10441 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010442 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10443 "Speaker Playback Volume",
10444 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10445 HDA_OUTPUT));
10446 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010447 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010448 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10449 "Speaker Playback Switch",
10450 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10451 HDA_OUTPUT));
10452 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010453 return err;
10454 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010455 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10456 "Speaker Playback Switch",
10457 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10458 HDA_OUTPUT));
10459 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010460 return err;
10461 }
10462 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010463 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010464 if (nid) {
10465 /* spec->multiout.hp_nid = 2; */
10466 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010467 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10468 "Headphone Playback Volume",
10469 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10470 HDA_OUTPUT));
10471 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010472 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010473 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10474 "Headphone Playback Switch",
10475 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10476 HDA_OUTPUT));
10477 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010478 return err;
10479 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010480 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10481 "Headphone Playback Switch",
10482 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10483 HDA_OUTPUT));
10484 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010485 return err;
10486 }
10487 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010488 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010489}
10490
10491/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010492#define alc262_auto_create_analog_input_ctls \
10493 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010494
10495/*
10496 * generic initialization of ADC, input mixers and output mixers
10497 */
10498static struct hda_verb alc262_volume_init_verbs[] = {
10499 /*
10500 * Unmute ADC0-2 and set the default input to mic-in
10501 */
10502 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10504 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10505 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10506 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10507 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10508
Takashi Iwaicb53c622007-08-10 17:21:45 +020010509 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010510 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010511 * Note: PASD motherboards uses the Line In 2 as the input for
10512 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010513 */
10514 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010520
10521 /*
10522 * Set up output mixers (0x0c - 0x0f)
10523 */
10524 /* set vol=0 to output mixers */
10525 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10526 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10527 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010528
Kailang Yangdf694da2005-12-05 19:42:22 +010010529 /* set up input amps for analog loopback */
10530 /* Amp Indices: DAC = 0, mixer = 1 */
10531 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10532 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10533 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10534 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10535 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10536 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10537
10538 /* FIXME: use matrix-type input source selection */
10539 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10540 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10541 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10542 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10543 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10544 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10545 /* Input mixer2 */
10546 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10547 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10548 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10549 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10550 /* Input mixer3 */
10551 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10552 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10553 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10555
10556 { }
10557};
10558
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010559static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10560 /*
10561 * Unmute ADC0-2 and set the default input to mic-in
10562 */
10563 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10564 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10565 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10566 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10567 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10568 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10569
Takashi Iwaicb53c622007-08-10 17:21:45 +020010570 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010571 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010572 * Note: PASD motherboards uses the Line In 2 as the input for
10573 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010574 */
10575 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010576 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10577 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10578 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10579 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010583
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010584 /*
10585 * Set up output mixers (0x0c - 0x0e)
10586 */
10587 /* set vol=0 to output mixers */
10588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10589 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10590 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10591
10592 /* set up input amps for analog loopback */
10593 /* Amp Indices: DAC = 0, mixer = 1 */
10594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10596 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10597 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10598 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10600
Takashi Iwaice875f02008-01-28 18:17:43 +010010601 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010602 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10603 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10604
10605 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10606 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10607
10608 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10609 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10610
10611 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10612 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10613 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10614 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10615 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10616
10617 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10618 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10619 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10620 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10621 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10622 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10623
10624
10625 /* FIXME: use matrix-type input source selection */
10626 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10627 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10628 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10629 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10630 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10631 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10632 /* Input mixer2 */
10633 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10635 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10636 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10637 /* Input mixer3 */
10638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10641 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10642
Takashi Iwaice875f02008-01-28 18:17:43 +010010643 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10644
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010645 { }
10646};
10647
Kailang Yangcd7509a2007-01-26 18:33:17 +010010648static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10649 /*
10650 * Unmute ADC0-2 and set the default input to mic-in
10651 */
10652 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10653 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10654 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10655 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10656 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10657 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10658
Takashi Iwaicb53c622007-08-10 17:21:45 +020010659 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010660 * mixer widget
10661 * Note: PASD motherboards uses the Line In 2 as the input for front
10662 * panel mic (mic 2)
10663 */
10664 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10666 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10667 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10668 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10669 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10670 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10671 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10672 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010673 /*
10674 * Set up output mixers (0x0c - 0x0e)
10675 */
10676 /* set vol=0 to output mixers */
10677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10678 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10679 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10680
10681 /* set up input amps for analog loopback */
10682 /* Amp Indices: DAC = 0, mixer = 1 */
10683 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10684 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10685 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10686 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10687 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10688 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10689
10690
10691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10692 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10693 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10694 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10695 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10696 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10697 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10698
10699 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10701
10702 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10703 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10704
10705 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10706 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10707 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10708 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10709 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10710 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10711
10712 /* FIXME: use matrix-type input source selection */
10713 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10714 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10715 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10716 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10717 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10718 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10719 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10720 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10721 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10722 /* Input mixer2 */
10723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10726 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10727 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10728 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10729 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10730 /* Input mixer3 */
10731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10732 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10733 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10734 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10736 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10738
Takashi Iwaice875f02008-01-28 18:17:43 +010010739 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10740
Kailang Yangcd7509a2007-01-26 18:33:17 +010010741 { }
10742};
10743
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010744static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10745
10746 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10747 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10748 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10749
10750 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10751 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10752 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10753 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10754
10755 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10756 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10757 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10758 {}
10759};
10760
10761
Takashi Iwaicb53c622007-08-10 17:21:45 +020010762#ifdef CONFIG_SND_HDA_POWER_SAVE
10763#define alc262_loopbacks alc880_loopbacks
10764#endif
10765
Kailang Yangdf694da2005-12-05 19:42:22 +010010766/* pcm configuration: identiacal with ALC880 */
10767#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10768#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10769#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10770#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10771
10772/*
10773 * BIOS auto configuration
10774 */
10775static int alc262_parse_auto_config(struct hda_codec *codec)
10776{
10777 struct alc_spec *spec = codec->spec;
10778 int err;
10779 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10780
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010781 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10782 alc262_ignore);
10783 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010784 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010785 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010786 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010787 spec->multiout.max_channels = 2;
10788 spec->no_analog = 1;
10789 goto dig_only;
10790 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010791 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010792 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010793 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10794 if (err < 0)
10795 return err;
10796 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10797 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010798 return err;
10799
10800 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10801
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010802 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010803 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010804 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010805 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010806 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010807 if (spec->autocfg.dig_in_pin)
10808 spec->dig_in_nid = ALC262_DIGIN_NID;
10809
Takashi Iwai603c4012008-07-30 15:01:44 +020010810 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010811 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010812
Takashi Iwaid88897e2008-10-31 15:01:37 +010010813 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010814 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010815 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010816
Takashi Iwai776e1842007-08-29 15:07:11 +020010817 err = alc_auto_add_mic_boost(codec);
10818 if (err < 0)
10819 return err;
10820
Takashi Iwaie044c392008-10-27 16:56:24 +010010821 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010822 return 1;
10823}
10824
10825#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10826#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10827#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010828#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010829
10830
10831/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010832static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010833{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010834 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010835 alc262_auto_init_multi_out(codec);
10836 alc262_auto_init_hp_out(codec);
10837 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010838 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010839 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010840 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010841}
10842
10843/*
10844 * configuration and preset
10845 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010846static const char *alc262_models[ALC262_MODEL_LAST] = {
10847 [ALC262_BASIC] = "basic",
10848 [ALC262_HIPPO] = "hippo",
10849 [ALC262_HIPPO_1] = "hippo_1",
10850 [ALC262_FUJITSU] = "fujitsu",
10851 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010852 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010853 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010854 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010855 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010856 [ALC262_BENQ_T31] = "benq-t31",
10857 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010858 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010859 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010860 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010861 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010862 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010863 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010864 [ALC262_AUTO] = "auto",
10865};
10866
10867static struct snd_pci_quirk alc262_cfg_tbl[] = {
10868 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010869 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010870 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10871 ALC262_HP_BPC),
10872 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10873 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010874 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010875 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010876 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010877 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010878 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010879 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010880 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010881 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010882 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10883 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10884 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010885 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10886 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010887 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010888 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010889 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010890 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10891 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10892 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwai57a5ef42008-11-28 14:46:28 +010010893 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
10894 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010895 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010896 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010897 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010898 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010899 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010900 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010901 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10902 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010903 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010904 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010905 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010906 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010907 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010908 {}
10909};
10910
10911static struct alc_config_preset alc262_presets[] = {
10912 [ALC262_BASIC] = {
10913 .mixers = { alc262_base_mixer },
10914 .init_verbs = { alc262_init_verbs },
10915 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10916 .dac_nids = alc262_dac_nids,
10917 .hp_nid = 0x03,
10918 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10919 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010920 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010921 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010922 [ALC262_HIPPO] = {
10923 .mixers = { alc262_base_mixer },
10924 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10925 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10926 .dac_nids = alc262_dac_nids,
10927 .hp_nid = 0x03,
10928 .dig_out_nid = ALC262_DIGOUT_NID,
10929 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10930 .channel_mode = alc262_modes,
10931 .input_mux = &alc262_capture_source,
10932 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010933 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010934 },
10935 [ALC262_HIPPO_1] = {
10936 .mixers = { alc262_hippo1_mixer },
10937 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10938 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10939 .dac_nids = alc262_dac_nids,
10940 .hp_nid = 0x02,
10941 .dig_out_nid = ALC262_DIGOUT_NID,
10942 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10943 .channel_mode = alc262_modes,
10944 .input_mux = &alc262_capture_source,
10945 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010946 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010947 },
Takashi Iwai834be882006-03-01 14:16:17 +010010948 [ALC262_FUJITSU] = {
10949 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010950 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10951 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010952 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10953 .dac_nids = alc262_dac_nids,
10954 .hp_nid = 0x03,
10955 .dig_out_nid = ALC262_DIGOUT_NID,
10956 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10957 .channel_mode = alc262_modes,
10958 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010959 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010960 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010961 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010962 [ALC262_HP_BPC] = {
10963 .mixers = { alc262_HP_BPC_mixer },
10964 .init_verbs = { alc262_HP_BPC_init_verbs },
10965 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10966 .dac_nids = alc262_dac_nids,
10967 .hp_nid = 0x03,
10968 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10969 .channel_mode = alc262_modes,
10970 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010971 .unsol_event = alc262_hp_bpc_unsol_event,
10972 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010973 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010974 [ALC262_HP_BPC_D7000_WF] = {
10975 .mixers = { alc262_HP_BPC_WildWest_mixer },
10976 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10977 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10978 .dac_nids = alc262_dac_nids,
10979 .hp_nid = 0x03,
10980 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10981 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010982 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010983 .unsol_event = alc262_hp_wildwest_unsol_event,
10984 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010985 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010986 [ALC262_HP_BPC_D7000_WL] = {
10987 .mixers = { alc262_HP_BPC_WildWest_mixer,
10988 alc262_HP_BPC_WildWest_option_mixer },
10989 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10990 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10991 .dac_nids = alc262_dac_nids,
10992 .hp_nid = 0x03,
10993 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10994 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010995 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010996 .unsol_event = alc262_hp_wildwest_unsol_event,
10997 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010998 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010999 [ALC262_HP_TC_T5735] = {
11000 .mixers = { alc262_hp_t5735_mixer },
11001 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_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_hp_t5735_unsol_event,
11009 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011010 },
11011 [ALC262_HP_RP5700] = {
11012 .mixers = { alc262_hp_rp5700_mixer },
11013 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11014 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11015 .dac_nids = alc262_dac_nids,
11016 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11017 .channel_mode = alc262_modes,
11018 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011019 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011020 [ALC262_BENQ_ED8] = {
11021 .mixers = { alc262_base_mixer },
11022 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11023 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11024 .dac_nids = alc262_dac_nids,
11025 .hp_nid = 0x03,
11026 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11027 .channel_mode = alc262_modes,
11028 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011029 },
Kailang Yang272a5272007-05-14 11:00:38 +020011030 [ALC262_SONY_ASSAMD] = {
11031 .mixers = { alc262_sony_mixer },
11032 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11033 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11034 .dac_nids = alc262_dac_nids,
11035 .hp_nid = 0x02,
11036 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11037 .channel_mode = alc262_modes,
11038 .input_mux = &alc262_capture_source,
11039 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011040 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011041 },
11042 [ALC262_BENQ_T31] = {
11043 .mixers = { alc262_benq_t31_mixer },
11044 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11045 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11046 .dac_nids = alc262_dac_nids,
11047 .hp_nid = 0x03,
11048 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11049 .channel_mode = alc262_modes,
11050 .input_mux = &alc262_capture_source,
11051 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011052 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011053 },
Tobin Davisf651b502007-10-26 12:40:47 +020011054 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011055 .mixers = { alc262_ultra_mixer },
11056 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011057 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011058 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11059 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011060 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11061 .channel_mode = alc262_modes,
11062 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011063 .adc_nids = alc262_adc_nids, /* ADC0 */
11064 .capsrc_nids = alc262_capsrc_nids,
11065 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011066 .unsol_event = alc262_ultra_unsol_event,
11067 .init_hook = alc262_ultra_automute,
11068 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011069 [ALC262_LENOVO_3000] = {
11070 .mixers = { alc262_lenovo_3000_mixer },
11071 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11072 alc262_lenovo_3000_unsol_verbs },
11073 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11074 .dac_nids = alc262_dac_nids,
11075 .hp_nid = 0x03,
11076 .dig_out_nid = ALC262_DIGOUT_NID,
11077 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11078 .channel_mode = alc262_modes,
11079 .input_mux = &alc262_fujitsu_capture_source,
11080 .unsol_event = alc262_lenovo_3000_unsol_event,
11081 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011082 [ALC262_NEC] = {
11083 .mixers = { alc262_nec_mixer },
11084 .init_verbs = { alc262_nec_verbs },
11085 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11086 .dac_nids = alc262_dac_nids,
11087 .hp_nid = 0x03,
11088 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11089 .channel_mode = alc262_modes,
11090 .input_mux = &alc262_capture_source,
11091 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011092 [ALC262_TOSHIBA_S06] = {
11093 .mixers = { alc262_toshiba_s06_mixer },
11094 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11095 alc262_eapd_verbs },
11096 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11097 .capsrc_nids = alc262_dmic_capsrc_nids,
11098 .dac_nids = alc262_dac_nids,
11099 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11100 .dig_out_nid = ALC262_DIGOUT_NID,
11101 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11102 .channel_mode = alc262_modes,
11103 .input_mux = &alc262_dmic_capture_source,
11104 .unsol_event = alc262_toshiba_s06_unsol_event,
11105 .init_hook = alc262_toshiba_s06_init_hook,
11106 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011107 [ALC262_TOSHIBA_RX1] = {
11108 .mixers = { alc262_toshiba_rx1_mixer },
11109 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11110 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11111 .dac_nids = alc262_dac_nids,
11112 .hp_nid = 0x03,
11113 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11114 .channel_mode = alc262_modes,
11115 .input_mux = &alc262_capture_source,
11116 .unsol_event = alc262_hippo_unsol_event,
11117 .init_hook = alc262_hippo_automute,
11118 },
Tony Vroonba340e82009-02-02 19:01:30 +000011119 [ALC262_TYAN] = {
11120 .mixers = { alc262_tyan_mixer },
11121 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11122 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11123 .dac_nids = alc262_dac_nids,
11124 .hp_nid = 0x02,
11125 .dig_out_nid = ALC262_DIGOUT_NID,
11126 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11127 .channel_mode = alc262_modes,
11128 .input_mux = &alc262_capture_source,
11129 .unsol_event = alc262_tyan_unsol_event,
11130 .init_hook = alc262_tyan_automute,
11131 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011132};
11133
11134static int patch_alc262(struct hda_codec *codec)
11135{
11136 struct alc_spec *spec;
11137 int board_config;
11138 int err;
11139
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011140 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011141 if (spec == NULL)
11142 return -ENOMEM;
11143
11144 codec->spec = spec;
11145#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011146 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11147 * under-run
11148 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011149 {
11150 int tmp;
11151 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11152 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11153 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11154 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11155 }
11156#endif
11157
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011158 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11159
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011160 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11161 alc262_models,
11162 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011163
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011164 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011165 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11166 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011167 board_config = ALC262_AUTO;
11168 }
11169
11170 if (board_config == ALC262_AUTO) {
11171 /* automatic parse from the BIOS config */
11172 err = alc262_parse_auto_config(codec);
11173 if (err < 0) {
11174 alc_free(codec);
11175 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011176 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011177 printk(KERN_INFO
11178 "hda_codec: Cannot set up configuration "
11179 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011180 board_config = ALC262_BASIC;
11181 }
11182 }
11183
Takashi Iwai07eba612009-02-19 08:06:35 +010011184 if (!spec->no_analog) {
11185 err = snd_hda_attach_beep_device(codec, 0x1);
11186 if (err < 0) {
11187 alc_free(codec);
11188 return err;
11189 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011190 }
11191
Kailang Yangdf694da2005-12-05 19:42:22 +010011192 if (board_config != ALC262_AUTO)
11193 setup_preset(spec, &alc262_presets[board_config]);
11194
11195 spec->stream_name_analog = "ALC262 Analog";
11196 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11197 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011198
Kailang Yangdf694da2005-12-05 19:42:22 +010011199 spec->stream_name_digital = "ALC262 Digital";
11200 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11201 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11202
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011203 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011204 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011205 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011206 unsigned int wcap = get_wcaps(codec, 0x07);
11207
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011208 /* get type */
11209 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011210 if (wcap != AC_WID_AUD_IN) {
11211 spec->adc_nids = alc262_adc_nids_alt;
11212 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011213 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011214 } else {
11215 spec->adc_nids = alc262_adc_nids;
11216 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011217 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011218 }
11219 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011220 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011221 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011222 if (!spec->no_analog)
11223 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011224
Takashi Iwai2134ea42008-01-10 16:53:55 +010011225 spec->vmaster_nid = 0x0c;
11226
Kailang Yangdf694da2005-12-05 19:42:22 +010011227 codec->patch_ops = alc_patch_ops;
11228 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011229 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011230#ifdef CONFIG_SND_HDA_POWER_SAVE
11231 if (!spec->loopback.amplist)
11232 spec->loopback.amplist = alc262_loopbacks;
11233#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011234 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011235
Kailang Yangdf694da2005-12-05 19:42:22 +010011236 return 0;
11237}
11238
Kailang Yangdf694da2005-12-05 19:42:22 +010011239/*
Kailang Yanga361d842007-06-05 12:30:55 +020011240 * ALC268 channel source setting (2 channel)
11241 */
11242#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11243#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011244
Kailang Yanga361d842007-06-05 12:30:55 +020011245static hda_nid_t alc268_dac_nids[2] = {
11246 /* front, hp */
11247 0x02, 0x03
11248};
11249
11250static hda_nid_t alc268_adc_nids[2] = {
11251 /* ADC0-1 */
11252 0x08, 0x07
11253};
11254
11255static hda_nid_t alc268_adc_nids_alt[1] = {
11256 /* ADC0 */
11257 0x08
11258};
11259
Takashi Iwaie1406342008-02-11 18:32:32 +010011260static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11261
Kailang Yanga361d842007-06-05 12:30:55 +020011262static struct snd_kcontrol_new alc268_base_mixer[] = {
11263 /* output mixer control */
11264 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11265 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11266 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011268 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11269 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11270 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011271 { }
11272};
11273
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011274/* bind Beep switches of both NID 0x0f and 0x10 */
11275static struct hda_bind_ctls alc268_bind_beep_sw = {
11276 .ops = &snd_hda_bind_sw,
11277 .values = {
11278 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11279 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11280 0
11281 },
11282};
11283
11284static struct snd_kcontrol_new alc268_beep_mixer[] = {
11285 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11286 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11287 { }
11288};
11289
Kailang Yangd1a991a2007-08-15 16:21:59 +020011290static struct hda_verb alc268_eapd_verbs[] = {
11291 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11292 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11293 { }
11294};
11295
Takashi Iwaid2738092007-08-16 14:59:45 +020011296/* Toshiba specific */
11297#define alc268_toshiba_automute alc262_hippo_automute
11298
11299static struct hda_verb alc268_toshiba_verbs[] = {
11300 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11301 { } /* end */
11302};
11303
Kailang Yang8ef355d2008-08-26 13:10:22 +020011304static struct hda_input_mux alc268_acer_lc_capture_source = {
11305 .num_items = 2,
11306 .items = {
11307 { "i-Mic", 0x6 },
11308 { "E-Mic", 0x0 },
11309 },
11310};
11311
Takashi Iwaid2738092007-08-16 14:59:45 +020011312/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011313/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011314static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11315 .ops = &snd_hda_bind_vol,
11316 .values = {
11317 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11318 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11319 0
11320 },
11321};
11322
Takashi Iwai889c4392007-08-23 18:56:52 +020011323/* mute/unmute internal speaker according to the hp jack and mute state */
11324static void alc268_acer_automute(struct hda_codec *codec, int force)
11325{
11326 struct alc_spec *spec = codec->spec;
11327 unsigned int mute;
11328
11329 if (force || !spec->sense_updated) {
11330 unsigned int present;
11331 present = snd_hda_codec_read(codec, 0x14, 0,
11332 AC_VERB_GET_PIN_SENSE, 0);
11333 spec->jack_present = (present & 0x80000000) != 0;
11334 spec->sense_updated = 1;
11335 }
11336 if (spec->jack_present)
11337 mute = HDA_AMP_MUTE; /* mute internal speaker */
11338 else /* unmute internal speaker if necessary */
11339 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11340 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11341 HDA_AMP_MUTE, mute);
11342}
11343
11344
11345/* bind hp and internal speaker mute (with plug check) */
11346static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11347 struct snd_ctl_elem_value *ucontrol)
11348{
11349 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11350 long *valp = ucontrol->value.integer.value;
11351 int change;
11352
11353 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11354 HDA_AMP_MUTE,
11355 valp[0] ? 0 : HDA_AMP_MUTE);
11356 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11357 HDA_AMP_MUTE,
11358 valp[1] ? 0 : HDA_AMP_MUTE);
11359 if (change)
11360 alc268_acer_automute(codec, 0);
11361 return change;
11362}
Takashi Iwaid2738092007-08-16 14:59:45 +020011363
Kailang Yang8ef355d2008-08-26 13:10:22 +020011364static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11365 /* output mixer control */
11366 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11367 {
11368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11369 .name = "Master Playback Switch",
11370 .info = snd_hda_mixer_amp_switch_info,
11371 .get = snd_hda_mixer_amp_switch_get,
11372 .put = alc268_acer_master_sw_put,
11373 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11374 },
11375 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11376 { }
11377};
11378
Takashi Iwaid2738092007-08-16 14:59:45 +020011379static struct snd_kcontrol_new alc268_acer_mixer[] = {
11380 /* output mixer control */
11381 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11382 {
11383 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11384 .name = "Master Playback Switch",
11385 .info = snd_hda_mixer_amp_switch_info,
11386 .get = snd_hda_mixer_amp_switch_get,
11387 .put = alc268_acer_master_sw_put,
11388 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11389 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011390 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11391 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11392 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011393 { }
11394};
11395
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011396static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11397 /* output mixer control */
11398 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11399 {
11400 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11401 .name = "Master Playback Switch",
11402 .info = snd_hda_mixer_amp_switch_info,
11403 .get = snd_hda_mixer_amp_switch_get,
11404 .put = alc268_acer_master_sw_put,
11405 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11406 },
11407 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11408 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11409 { }
11410};
11411
Kailang Yang8ef355d2008-08-26 13:10:22 +020011412static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11413 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11414 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11415 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11416 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11417 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11418 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11419 { }
11420};
11421
Takashi Iwaid2738092007-08-16 14:59:45 +020011422static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011423 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11424 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11426 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011427 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11428 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011429 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11430 { }
11431};
11432
11433/* unsolicited event for HP jack sensing */
11434static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11435 unsigned int res)
11436{
Takashi Iwai889c4392007-08-23 18:56:52 +020011437 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011438 return;
11439 alc268_toshiba_automute(codec);
11440}
11441
11442static void alc268_acer_unsol_event(struct hda_codec *codec,
11443 unsigned int res)
11444{
Takashi Iwai889c4392007-08-23 18:56:52 +020011445 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011446 return;
11447 alc268_acer_automute(codec, 1);
11448}
11449
Takashi Iwai889c4392007-08-23 18:56:52 +020011450static void alc268_acer_init_hook(struct hda_codec *codec)
11451{
11452 alc268_acer_automute(codec, 1);
11453}
11454
Kailang Yang8ef355d2008-08-26 13:10:22 +020011455/* toggle speaker-output according to the hp-jack state */
11456static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11457{
11458 unsigned int present;
11459 unsigned char bits;
11460
11461 present = snd_hda_codec_read(codec, 0x15, 0,
11462 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11463 bits = present ? AMP_IN_MUTE(0) : 0;
11464 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11465 AMP_IN_MUTE(0), bits);
11466 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11467 AMP_IN_MUTE(0), bits);
11468}
11469
11470
11471static void alc268_acer_mic_automute(struct hda_codec *codec)
11472{
11473 unsigned int present;
11474
11475 present = snd_hda_codec_read(codec, 0x18, 0,
11476 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11477 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11478 present ? 0x0 : 0x6);
11479}
11480
11481static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11482 unsigned int res)
11483{
11484 if ((res >> 26) == ALC880_HP_EVENT)
11485 alc268_aspire_one_speaker_automute(codec);
11486 if ((res >> 26) == ALC880_MIC_EVENT)
11487 alc268_acer_mic_automute(codec);
11488}
11489
11490static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11491{
11492 alc268_aspire_one_speaker_automute(codec);
11493 alc268_acer_mic_automute(codec);
11494}
11495
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011496static struct snd_kcontrol_new alc268_dell_mixer[] = {
11497 /* output mixer control */
11498 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11499 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11500 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11501 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11502 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11503 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11504 { }
11505};
11506
11507static struct hda_verb alc268_dell_verbs[] = {
11508 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11509 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11510 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11511 { }
11512};
11513
11514/* mute/unmute internal speaker according to the hp jack and mute state */
11515static void alc268_dell_automute(struct hda_codec *codec)
11516{
11517 unsigned int present;
11518 unsigned int mute;
11519
11520 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11521 if (present & 0x80000000)
11522 mute = HDA_AMP_MUTE;
11523 else
11524 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11525 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11526 HDA_AMP_MUTE, mute);
11527}
11528
11529static void alc268_dell_unsol_event(struct hda_codec *codec,
11530 unsigned int res)
11531{
11532 if ((res >> 26) != ALC880_HP_EVENT)
11533 return;
11534 alc268_dell_automute(codec);
11535}
11536
11537#define alc268_dell_init_hook alc268_dell_automute
11538
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011539static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11540 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11541 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11542 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11543 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11544 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11545 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11546 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11547 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11548 { }
11549};
11550
11551static struct hda_verb alc267_quanta_il1_verbs[] = {
11552 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11553 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11554 { }
11555};
11556
11557static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11558{
11559 unsigned int present;
11560
11561 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11562 & AC_PINSENSE_PRESENCE;
11563 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11564 present ? 0 : PIN_OUT);
11565}
11566
11567static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11568{
11569 unsigned int present;
11570
11571 present = snd_hda_codec_read(codec, 0x18, 0,
11572 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11573 snd_hda_codec_write(codec, 0x23, 0,
11574 AC_VERB_SET_CONNECT_SEL,
11575 present ? 0x00 : 0x01);
11576}
11577
11578static void alc267_quanta_il1_automute(struct hda_codec *codec)
11579{
11580 alc267_quanta_il1_hp_automute(codec);
11581 alc267_quanta_il1_mic_automute(codec);
11582}
11583
11584static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11585 unsigned int res)
11586{
11587 switch (res >> 26) {
11588 case ALC880_HP_EVENT:
11589 alc267_quanta_il1_hp_automute(codec);
11590 break;
11591 case ALC880_MIC_EVENT:
11592 alc267_quanta_il1_mic_automute(codec);
11593 break;
11594 }
11595}
11596
Kailang Yanga361d842007-06-05 12:30:55 +020011597/*
11598 * generic initialization of ADC, input mixers and output mixers
11599 */
11600static struct hda_verb alc268_base_init_verbs[] = {
11601 /* Unmute DAC0-1 and set vol = 0 */
11602 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011603 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011604
11605 /*
11606 * Set up output mixers (0x0c - 0x0e)
11607 */
11608 /* set vol=0 to output mixers */
11609 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011610 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11611
11612 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11613 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11614
11615 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11616 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11617 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11618 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11619 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11620 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11621 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11622 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11623
11624 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11626 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11627 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011628 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011629
11630 /* set PCBEEP vol = 0, mute connections */
11631 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11632 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11633 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011634
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011635 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011636
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011637 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11638 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11639 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11640 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011641
Kailang Yanga361d842007-06-05 12:30:55 +020011642 { }
11643};
11644
11645/*
11646 * generic initialization of ADC, input mixers and output mixers
11647 */
11648static struct hda_verb alc268_volume_init_verbs[] = {
11649 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011650 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11651 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011652
11653 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11654 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11655 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11656 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11657 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11658
Kailang Yanga361d842007-06-05 12:30:55 +020011659 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011660 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11661 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11662
11663 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011664 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011665
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011666 /* set PCBEEP vol = 0, mute connections */
11667 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11668 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11669 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011670
11671 { }
11672};
11673
Kailang Yanga361d842007-06-05 12:30:55 +020011674static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11675 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11676 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11677 {
11678 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11679 /* The multiple "Capture Source" controls confuse alsamixer
11680 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011681 */
11682 /* .name = "Capture Source", */
11683 .name = "Input Source",
11684 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011685 .info = alc_mux_enum_info,
11686 .get = alc_mux_enum_get,
11687 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011688 },
11689 { } /* end */
11690};
11691
11692static struct snd_kcontrol_new alc268_capture_mixer[] = {
11693 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11694 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11695 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11696 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11697 {
11698 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11699 /* The multiple "Capture Source" controls confuse alsamixer
11700 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011701 */
11702 /* .name = "Capture Source", */
11703 .name = "Input Source",
11704 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011705 .info = alc_mux_enum_info,
11706 .get = alc_mux_enum_get,
11707 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011708 },
11709 { } /* end */
11710};
11711
11712static struct hda_input_mux alc268_capture_source = {
11713 .num_items = 4,
11714 .items = {
11715 { "Mic", 0x0 },
11716 { "Front Mic", 0x1 },
11717 { "Line", 0x2 },
11718 { "CD", 0x3 },
11719 },
11720};
11721
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011722static struct hda_input_mux alc268_acer_capture_source = {
11723 .num_items = 3,
11724 .items = {
11725 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011726 { "Internal Mic", 0x1 },
11727 { "Line", 0x2 },
11728 },
11729};
11730
11731static struct hda_input_mux alc268_acer_dmic_capture_source = {
11732 .num_items = 3,
11733 .items = {
11734 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011735 { "Internal Mic", 0x6 },
11736 { "Line", 0x2 },
11737 },
11738};
11739
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011740#ifdef CONFIG_SND_DEBUG
11741static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011742 /* Volume widgets */
11743 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11744 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11745 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11746 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11747 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11748 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11749 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11750 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11751 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11752 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11753 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11754 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11755 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011756 /* The below appears problematic on some hardwares */
11757 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011758 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11759 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11760 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11761 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11762
11763 /* Modes for retasking pin widgets */
11764 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11765 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11766 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11767 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11768
11769 /* Controls for GPIO pins, assuming they are configured as outputs */
11770 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11771 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11772 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11773 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11774
11775 /* Switches to allow the digital SPDIF output pin to be enabled.
11776 * The ALC268 does not have an SPDIF input.
11777 */
11778 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11779
11780 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11781 * this output to turn on an external amplifier.
11782 */
11783 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11784 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11785
11786 { } /* end */
11787};
11788#endif
11789
Kailang Yanga361d842007-06-05 12:30:55 +020011790/* create input playback/capture controls for the given pin */
11791static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11792 const char *ctlname, int idx)
11793{
11794 char name[32];
11795 int err;
11796
11797 sprintf(name, "%s Playback Volume", ctlname);
11798 if (nid == 0x14) {
11799 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11800 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11801 HDA_OUTPUT));
11802 if (err < 0)
11803 return err;
11804 } else if (nid == 0x15) {
11805 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11806 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11807 HDA_OUTPUT));
11808 if (err < 0)
11809 return err;
11810 } else
11811 return -1;
11812 sprintf(name, "%s Playback Switch", ctlname);
11813 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11814 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11815 if (err < 0)
11816 return err;
11817 return 0;
11818}
11819
11820/* add playback controls from the parsed DAC table */
11821static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11822 const struct auto_pin_cfg *cfg)
11823{
11824 hda_nid_t nid;
11825 int err;
11826
11827 spec->multiout.num_dacs = 2; /* only use one dac */
11828 spec->multiout.dac_nids = spec->private_dac_nids;
11829 spec->multiout.dac_nids[0] = 2;
11830 spec->multiout.dac_nids[1] = 3;
11831
11832 nid = cfg->line_out_pins[0];
11833 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011834 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011835
11836 nid = cfg->speaker_pins[0];
11837 if (nid == 0x1d) {
11838 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11839 "Speaker Playback Volume",
11840 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11841 if (err < 0)
11842 return err;
11843 }
11844 nid = cfg->hp_pins[0];
11845 if (nid)
11846 alc268_new_analog_output(spec, nid, "Headphone", 0);
11847
11848 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11849 if (nid == 0x16) {
11850 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11851 "Mono Playback Switch",
11852 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11853 if (err < 0)
11854 return err;
11855 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011856 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011857}
11858
11859/* create playback/capture controls for input pins */
11860static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11861 const struct auto_pin_cfg *cfg)
11862{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011863 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011864 int i, idx1;
11865
11866 for (i = 0; i < AUTO_PIN_LAST; i++) {
11867 switch(cfg->input_pins[i]) {
11868 case 0x18:
11869 idx1 = 0; /* Mic 1 */
11870 break;
11871 case 0x19:
11872 idx1 = 1; /* Mic 2 */
11873 break;
11874 case 0x1a:
11875 idx1 = 2; /* Line In */
11876 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011877 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011878 idx1 = 3; /* CD */
11879 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011880 case 0x12:
11881 case 0x13:
11882 idx1 = 6; /* digital mics */
11883 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011884 default:
11885 continue;
11886 }
11887 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11888 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011889 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011890 }
11891 return 0;
11892}
11893
11894static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11895{
11896 struct alc_spec *spec = codec->spec;
11897 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11898 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11899 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11900 unsigned int dac_vol1, dac_vol2;
11901
11902 if (speaker_nid) {
11903 snd_hda_codec_write(codec, speaker_nid, 0,
11904 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11905 snd_hda_codec_write(codec, 0x0f, 0,
11906 AC_VERB_SET_AMP_GAIN_MUTE,
11907 AMP_IN_UNMUTE(1));
11908 snd_hda_codec_write(codec, 0x10, 0,
11909 AC_VERB_SET_AMP_GAIN_MUTE,
11910 AMP_IN_UNMUTE(1));
11911 } else {
11912 snd_hda_codec_write(codec, 0x0f, 0,
11913 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11914 snd_hda_codec_write(codec, 0x10, 0,
11915 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11916 }
11917
11918 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011919 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011920 dac_vol2 = AMP_OUT_ZERO;
11921 else if (line_nid == 0x15)
11922 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011923 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011924 dac_vol2 = AMP_OUT_ZERO;
11925 else if (hp_nid == 0x15)
11926 dac_vol1 = AMP_OUT_ZERO;
11927 if (line_nid != 0x16 || hp_nid != 0x16 ||
11928 spec->autocfg.line_out_pins[1] != 0x16 ||
11929 spec->autocfg.line_out_pins[2] != 0x16)
11930 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11931
11932 snd_hda_codec_write(codec, 0x02, 0,
11933 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11934 snd_hda_codec_write(codec, 0x03, 0,
11935 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11936}
11937
11938/* pcm configuration: identiacal with ALC880 */
11939#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11940#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011941#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011942#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11943
11944/*
11945 * BIOS auto configuration
11946 */
11947static int alc268_parse_auto_config(struct hda_codec *codec)
11948{
11949 struct alc_spec *spec = codec->spec;
11950 int err;
11951 static hda_nid_t alc268_ignore[] = { 0 };
11952
11953 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11954 alc268_ignore);
11955 if (err < 0)
11956 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011957 if (!spec->autocfg.line_outs) {
11958 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11959 spec->multiout.max_channels = 2;
11960 spec->no_analog = 1;
11961 goto dig_only;
11962 }
Kailang Yanga361d842007-06-05 12:30:55 +020011963 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011964 }
Kailang Yanga361d842007-06-05 12:30:55 +020011965 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11966 if (err < 0)
11967 return err;
11968 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11969 if (err < 0)
11970 return err;
11971
11972 spec->multiout.max_channels = 2;
11973
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011974 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020011975 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011976 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020011977 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011978 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11979 }
Takashi Iwai603c4012008-07-30 15:01:44 +020011980 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011981 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011982
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011983 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011984 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011985
Takashi Iwaid88897e2008-10-31 15:01:37 +010011986 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011987 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011988 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011989
Takashi Iwai776e1842007-08-29 15:07:11 +020011990 err = alc_auto_add_mic_boost(codec);
11991 if (err < 0)
11992 return err;
11993
Takashi Iwaie044c392008-10-27 16:56:24 +010011994 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011995 return 1;
11996}
11997
11998#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11999#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12000#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12001
12002/* init callback for auto-configuration model -- overriding the default init */
12003static void alc268_auto_init(struct hda_codec *codec)
12004{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012005 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012006 alc268_auto_init_multi_out(codec);
12007 alc268_auto_init_hp_out(codec);
12008 alc268_auto_init_mono_speaker_out(codec);
12009 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012010 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012011 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012012}
12013
12014/*
12015 * configuration and preset
12016 */
12017static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012018 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012019 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012020 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012021 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012022 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012023 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012024 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012025 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012026#ifdef CONFIG_SND_DEBUG
12027 [ALC268_TEST] = "test",
12028#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012029 [ALC268_AUTO] = "auto",
12030};
12031
12032static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012033 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012034 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012035 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012036 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012037 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012038 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12039 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012040 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012041 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012042 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012043 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020012044 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020012045 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020012046 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012047 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012048 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012049 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012050 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012051 {}
12052};
12053
12054static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012055 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012056 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012057 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12058 alc267_quanta_il1_verbs },
12059 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12060 .dac_nids = alc268_dac_nids,
12061 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12062 .adc_nids = alc268_adc_nids_alt,
12063 .hp_nid = 0x03,
12064 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12065 .channel_mode = alc268_modes,
12066 .input_mux = &alc268_capture_source,
12067 .unsol_event = alc267_quanta_il1_unsol_event,
12068 .init_hook = alc267_quanta_il1_automute,
12069 },
Kailang Yanga361d842007-06-05 12:30:55 +020012070 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012071 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12072 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012073 .init_verbs = { alc268_base_init_verbs },
12074 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12075 .dac_nids = alc268_dac_nids,
12076 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12077 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012078 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012079 .hp_nid = 0x03,
12080 .dig_out_nid = ALC268_DIGOUT_NID,
12081 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12082 .channel_mode = alc268_modes,
12083 .input_mux = &alc268_capture_source,
12084 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012085 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012086 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12087 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012088 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12089 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012090 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12091 .dac_nids = alc268_dac_nids,
12092 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12093 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012094 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012095 .hp_nid = 0x03,
12096 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12097 .channel_mode = alc268_modes,
12098 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012099 .unsol_event = alc268_toshiba_unsol_event,
12100 .init_hook = alc268_toshiba_automute,
12101 },
12102 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012103 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12104 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012105 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12106 alc268_acer_verbs },
12107 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12108 .dac_nids = alc268_dac_nids,
12109 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12110 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012111 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012112 .hp_nid = 0x02,
12113 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12114 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012115 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012116 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012117 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012118 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012119 [ALC268_ACER_DMIC] = {
12120 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12121 alc268_beep_mixer },
12122 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12123 alc268_acer_verbs },
12124 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12125 .dac_nids = alc268_dac_nids,
12126 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12127 .adc_nids = alc268_adc_nids_alt,
12128 .capsrc_nids = alc268_capsrc_nids,
12129 .hp_nid = 0x02,
12130 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12131 .channel_mode = alc268_modes,
12132 .input_mux = &alc268_acer_dmic_capture_source,
12133 .unsol_event = alc268_acer_unsol_event,
12134 .init_hook = alc268_acer_init_hook,
12135 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012136 [ALC268_ACER_ASPIRE_ONE] = {
12137 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012138 alc268_beep_mixer,
12139 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012140 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12141 alc268_acer_aspire_one_verbs },
12142 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12143 .dac_nids = alc268_dac_nids,
12144 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12145 .adc_nids = alc268_adc_nids_alt,
12146 .capsrc_nids = alc268_capsrc_nids,
12147 .hp_nid = 0x03,
12148 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12149 .channel_mode = alc268_modes,
12150 .input_mux = &alc268_acer_lc_capture_source,
12151 .unsol_event = alc268_acer_lc_unsol_event,
12152 .init_hook = alc268_acer_lc_init_hook,
12153 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012154 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012155 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012156 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12157 alc268_dell_verbs },
12158 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12159 .dac_nids = alc268_dac_nids,
12160 .hp_nid = 0x02,
12161 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12162 .channel_mode = alc268_modes,
12163 .unsol_event = alc268_dell_unsol_event,
12164 .init_hook = alc268_dell_init_hook,
12165 .input_mux = &alc268_capture_source,
12166 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012167 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012168 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12169 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012170 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12171 alc268_toshiba_verbs },
12172 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12173 .dac_nids = alc268_dac_nids,
12174 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12175 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012176 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012177 .hp_nid = 0x03,
12178 .dig_out_nid = ALC268_DIGOUT_NID,
12179 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12180 .channel_mode = alc268_modes,
12181 .input_mux = &alc268_capture_source,
12182 .unsol_event = alc268_toshiba_unsol_event,
12183 .init_hook = alc268_toshiba_automute
12184 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012185#ifdef CONFIG_SND_DEBUG
12186 [ALC268_TEST] = {
12187 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12188 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12189 alc268_volume_init_verbs },
12190 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12191 .dac_nids = alc268_dac_nids,
12192 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12193 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012194 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012195 .hp_nid = 0x03,
12196 .dig_out_nid = ALC268_DIGOUT_NID,
12197 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12198 .channel_mode = alc268_modes,
12199 .input_mux = &alc268_capture_source,
12200 },
12201#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012202};
12203
12204static int patch_alc268(struct hda_codec *codec)
12205{
12206 struct alc_spec *spec;
12207 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012208 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012209
12210 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12211 if (spec == NULL)
12212 return -ENOMEM;
12213
12214 codec->spec = spec;
12215
12216 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12217 alc268_models,
12218 alc268_cfg_tbl);
12219
12220 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12221 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12222 "trying auto-probe from BIOS...\n");
12223 board_config = ALC268_AUTO;
12224 }
12225
12226 if (board_config == ALC268_AUTO) {
12227 /* automatic parse from the BIOS config */
12228 err = alc268_parse_auto_config(codec);
12229 if (err < 0) {
12230 alc_free(codec);
12231 return err;
12232 } else if (!err) {
12233 printk(KERN_INFO
12234 "hda_codec: Cannot set up configuration "
12235 "from BIOS. Using base mode...\n");
12236 board_config = ALC268_3ST;
12237 }
12238 }
12239
12240 if (board_config != ALC268_AUTO)
12241 setup_preset(spec, &alc268_presets[board_config]);
12242
Kailang Yang2f893282008-05-27 12:14:47 +020012243 if (codec->vendor_id == 0x10ec0267) {
12244 spec->stream_name_analog = "ALC267 Analog";
12245 spec->stream_name_digital = "ALC267 Digital";
12246 } else {
12247 spec->stream_name_analog = "ALC268 Analog";
12248 spec->stream_name_digital = "ALC268 Digital";
12249 }
12250
Kailang Yanga361d842007-06-05 12:30:55 +020012251 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12252 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012253 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012254
Kailang Yanga361d842007-06-05 12:30:55 +020012255 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12256
Takashi Iwai22971e32009-02-10 11:56:44 +010012257 has_beep = 0;
12258 for (i = 0; i < spec->num_mixers; i++) {
12259 if (spec->mixers[i] == alc268_beep_mixer) {
12260 has_beep = 1;
12261 break;
12262 }
12263 }
12264
12265 if (has_beep) {
12266 err = snd_hda_attach_beep_device(codec, 0x1);
12267 if (err < 0) {
12268 alc_free(codec);
12269 return err;
12270 }
12271 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12272 /* override the amp caps for beep generator */
12273 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012274 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12275 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12276 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12277 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012278 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012279
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012280 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012281 /* check whether NID 0x07 is valid */
12282 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012283 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012284
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012285 /* get type */
12286 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012287 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012288 spec->adc_nids = alc268_adc_nids_alt;
12289 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012290 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012291 } else {
12292 spec->adc_nids = alc268_adc_nids;
12293 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012294 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012295 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012296 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012297 /* set default input source */
12298 for (i = 0; i < spec->num_adc_nids; i++)
12299 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12300 0, AC_VERB_SET_CONNECT_SEL,
12301 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012302 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012303
12304 spec->vmaster_nid = 0x02;
12305
Kailang Yanga361d842007-06-05 12:30:55 +020012306 codec->patch_ops = alc_patch_ops;
12307 if (board_config == ALC268_AUTO)
12308 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012309
Takashi Iwaidaead532008-11-28 12:55:36 +010012310 codec->proc_widget_hook = print_realtek_coef;
12311
Kailang Yanga361d842007-06-05 12:30:55 +020012312 return 0;
12313}
12314
12315/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012316 * ALC269 channel source setting (2 channel)
12317 */
12318#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12319
12320#define alc269_dac_nids alc260_dac_nids
12321
12322static hda_nid_t alc269_adc_nids[1] = {
12323 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012324 0x08,
12325};
12326
Takashi Iwaie01bf502008-08-21 16:25:07 +020012327static hda_nid_t alc269_capsrc_nids[1] = {
12328 0x23,
12329};
12330
12331/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12332 * not a mux!
12333 */
12334
Kailang Yangf53281e2008-07-18 12:36:43 +020012335static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12336 .num_items = 2,
12337 .items = {
12338 { "i-Mic", 0x5 },
12339 { "e-Mic", 0x0 },
12340 },
12341};
12342
12343static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12344 .num_items = 2,
12345 .items = {
12346 { "i-Mic", 0x1 },
12347 { "e-Mic", 0x0 },
12348 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012349};
12350
12351#define alc269_modes alc260_modes
12352#define alc269_capture_source alc880_lg_lw_capture_source
12353
12354static struct snd_kcontrol_new alc269_base_mixer[] = {
12355 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12356 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12357 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12358 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12359 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12360 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12361 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12362 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12363 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12364 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12365 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12366 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12367 { } /* end */
12368};
12369
Kailang Yang60db6b52008-08-26 13:13:00 +020012370static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12371 /* output mixer control */
12372 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12373 {
12374 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12375 .name = "Master Playback Switch",
12376 .info = snd_hda_mixer_amp_switch_info,
12377 .get = snd_hda_mixer_amp_switch_get,
12378 .put = alc268_acer_master_sw_put,
12379 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12380 },
12381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12382 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12383 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12384 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12385 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12386 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012387 { }
12388};
12389
Tony Vroon64154832008-11-06 15:08:49 +000012390static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12391 /* output mixer control */
12392 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12393 {
12394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12395 .name = "Master Playback Switch",
12396 .info = snd_hda_mixer_amp_switch_info,
12397 .get = snd_hda_mixer_amp_switch_get,
12398 .put = alc268_acer_master_sw_put,
12399 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12400 },
12401 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12402 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12403 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12404 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12405 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12406 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12407 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12408 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12409 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012410 { }
12411};
12412
Kailang Yangf53281e2008-07-18 12:36:43 +020012413/* bind volumes of both NID 0x0c and 0x0d */
12414static struct hda_bind_ctls alc269_epc_bind_vol = {
12415 .ops = &snd_hda_bind_vol,
12416 .values = {
12417 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12418 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12419 0
12420 },
12421};
12422
12423static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12424 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12425 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12426 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12427 { } /* end */
12428};
12429
Kailang Yangf6a92242007-12-13 16:52:54 +010012430/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012431static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12432 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12433 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012434 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12435 { } /* end */
12436};
12437
12438/* FSC amilo */
12439static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12440 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12441 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12442 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012443 { } /* end */
12444};
12445
Kailang Yang60db6b52008-08-26 13:13:00 +020012446static struct hda_verb alc269_quanta_fl1_verbs[] = {
12447 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12448 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12449 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12450 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12451 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12452 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12453 { }
12454};
12455
Tony Vroon64154832008-11-06 15:08:49 +000012456static struct hda_verb alc269_lifebook_verbs[] = {
12457 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12458 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12459 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12460 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12461 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12463 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12464 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12465 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12466 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12467 { }
12468};
12469
Kailang Yang60db6b52008-08-26 13:13:00 +020012470/* toggle speaker-output according to the hp-jack state */
12471static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12472{
12473 unsigned int present;
12474 unsigned char bits;
12475
12476 present = snd_hda_codec_read(codec, 0x15, 0,
12477 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12478 bits = present ? AMP_IN_MUTE(0) : 0;
12479 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12480 AMP_IN_MUTE(0), bits);
12481 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12482 AMP_IN_MUTE(0), bits);
12483
12484 snd_hda_codec_write(codec, 0x20, 0,
12485 AC_VERB_SET_COEF_INDEX, 0x0c);
12486 snd_hda_codec_write(codec, 0x20, 0,
12487 AC_VERB_SET_PROC_COEF, 0x680);
12488
12489 snd_hda_codec_write(codec, 0x20, 0,
12490 AC_VERB_SET_COEF_INDEX, 0x0c);
12491 snd_hda_codec_write(codec, 0x20, 0,
12492 AC_VERB_SET_PROC_COEF, 0x480);
12493}
12494
Tony Vroon64154832008-11-06 15:08:49 +000012495/* toggle speaker-output according to the hp-jacks state */
12496static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12497{
12498 unsigned int present;
12499 unsigned char bits;
12500
12501 /* Check laptop headphone socket */
12502 present = snd_hda_codec_read(codec, 0x15, 0,
12503 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12504
12505 /* Check port replicator headphone socket */
12506 present |= snd_hda_codec_read(codec, 0x1a, 0,
12507 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12508
12509 bits = present ? AMP_IN_MUTE(0) : 0;
12510 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12511 AMP_IN_MUTE(0), bits);
12512 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12513 AMP_IN_MUTE(0), bits);
12514
12515 snd_hda_codec_write(codec, 0x20, 0,
12516 AC_VERB_SET_COEF_INDEX, 0x0c);
12517 snd_hda_codec_write(codec, 0x20, 0,
12518 AC_VERB_SET_PROC_COEF, 0x680);
12519
12520 snd_hda_codec_write(codec, 0x20, 0,
12521 AC_VERB_SET_COEF_INDEX, 0x0c);
12522 snd_hda_codec_write(codec, 0x20, 0,
12523 AC_VERB_SET_PROC_COEF, 0x480);
12524}
12525
Kailang Yang60db6b52008-08-26 13:13:00 +020012526static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12527{
12528 unsigned int present;
12529
12530 present = snd_hda_codec_read(codec, 0x18, 0,
12531 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12532 snd_hda_codec_write(codec, 0x23, 0,
12533 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12534}
12535
Tony Vroon64154832008-11-06 15:08:49 +000012536static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12537{
12538 unsigned int present_laptop;
12539 unsigned int present_dock;
12540
12541 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12542 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12543
12544 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12545 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12546
12547 /* Laptop mic port overrides dock mic port, design decision */
12548 if (present_dock)
12549 snd_hda_codec_write(codec, 0x23, 0,
12550 AC_VERB_SET_CONNECT_SEL, 0x3);
12551 if (present_laptop)
12552 snd_hda_codec_write(codec, 0x23, 0,
12553 AC_VERB_SET_CONNECT_SEL, 0x0);
12554 if (!present_dock && !present_laptop)
12555 snd_hda_codec_write(codec, 0x23, 0,
12556 AC_VERB_SET_CONNECT_SEL, 0x1);
12557}
12558
Kailang Yang60db6b52008-08-26 13:13:00 +020012559static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12560 unsigned int res)
12561{
12562 if ((res >> 26) == ALC880_HP_EVENT)
12563 alc269_quanta_fl1_speaker_automute(codec);
12564 if ((res >> 26) == ALC880_MIC_EVENT)
12565 alc269_quanta_fl1_mic_automute(codec);
12566}
12567
Tony Vroon64154832008-11-06 15:08:49 +000012568static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12569 unsigned int res)
12570{
12571 if ((res >> 26) == ALC880_HP_EVENT)
12572 alc269_lifebook_speaker_automute(codec);
12573 if ((res >> 26) == ALC880_MIC_EVENT)
12574 alc269_lifebook_mic_autoswitch(codec);
12575}
12576
Kailang Yang60db6b52008-08-26 13:13:00 +020012577static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12578{
12579 alc269_quanta_fl1_speaker_automute(codec);
12580 alc269_quanta_fl1_mic_automute(codec);
12581}
12582
Tony Vroon64154832008-11-06 15:08:49 +000012583static void alc269_lifebook_init_hook(struct hda_codec *codec)
12584{
12585 alc269_lifebook_speaker_automute(codec);
12586 alc269_lifebook_mic_autoswitch(codec);
12587}
12588
Kailang Yang60db6b52008-08-26 13:13:00 +020012589static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12590 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12591 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12592 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12593 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12594 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12595 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12596 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12597 {}
12598};
12599
12600static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12601 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12602 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12603 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12604 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12605 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12606 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12607 {}
12608};
12609
12610/* toggle speaker-output according to the hp-jack state */
12611static void alc269_speaker_automute(struct hda_codec *codec)
12612{
12613 unsigned int present;
12614 unsigned char bits;
12615
12616 present = snd_hda_codec_read(codec, 0x15, 0,
12617 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12618 bits = present ? AMP_IN_MUTE(0) : 0;
12619 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12620 AMP_IN_MUTE(0), bits);
12621 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12622 AMP_IN_MUTE(0), bits);
12623}
12624
12625static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12626{
12627 unsigned int present;
12628
12629 present = snd_hda_codec_read(codec, 0x18, 0,
12630 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12631 snd_hda_codec_write(codec, 0x23, 0,
12632 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12633}
12634
12635static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12636{
12637 unsigned int present;
12638
12639 present = snd_hda_codec_read(codec, 0x18, 0,
12640 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12641 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12642 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12643 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12644 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12645}
12646
12647/* unsolicited event for HP jack sensing */
12648static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12649 unsigned int res)
12650{
12651 if ((res >> 26) == ALC880_HP_EVENT)
12652 alc269_speaker_automute(codec);
12653
12654 if ((res >> 26) == ALC880_MIC_EVENT)
12655 alc269_eeepc_dmic_automute(codec);
12656}
12657
12658static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12659{
12660 alc269_speaker_automute(codec);
12661 alc269_eeepc_dmic_automute(codec);
12662}
12663
12664/* unsolicited event for HP jack sensing */
12665static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12666 unsigned int res)
12667{
12668 if ((res >> 26) == ALC880_HP_EVENT)
12669 alc269_speaker_automute(codec);
12670
12671 if ((res >> 26) == ALC880_MIC_EVENT)
12672 alc269_eeepc_amic_automute(codec);
12673}
12674
12675static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12676{
12677 alc269_speaker_automute(codec);
12678 alc269_eeepc_amic_automute(codec);
12679}
12680
Kailang Yangf6a92242007-12-13 16:52:54 +010012681/*
12682 * generic initialization of ADC, input mixers and output mixers
12683 */
12684static struct hda_verb alc269_init_verbs[] = {
12685 /*
12686 * Unmute ADC0 and set the default input to mic-in
12687 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012688 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012689
12690 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12691 * analog-loopback mixer widget
12692 * Note: PASD motherboards uses the Line In 2 as the input for
12693 * front panel mic (mic 2)
12694 */
12695 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12697 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12698 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12699 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12700 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12701
12702 /*
12703 * Set up output mixers (0x0c - 0x0e)
12704 */
12705 /* set vol=0 to output mixers */
12706 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12707 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12708
12709 /* set up input amps for analog loopback */
12710 /* Amp Indices: DAC = 0, mixer = 1 */
12711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12712 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12713 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12714 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12715 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12716 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12717
12718 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12719 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12720 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12721 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12722 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12723 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12724 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12725
12726 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12727 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12728 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12729 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12730 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12731 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12732 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12733
12734 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12735 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12736
12737 /* FIXME: use matrix-type input source selection */
12738 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12739 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012740 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12741 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012742 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12743 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12744
12745 /* set EAPD */
12746 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12747 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12748 { }
12749};
12750
12751/* add playback controls from the parsed DAC table */
12752static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12753 const struct auto_pin_cfg *cfg)
12754{
12755 hda_nid_t nid;
12756 int err;
12757
12758 spec->multiout.num_dacs = 1; /* only use one dac */
12759 spec->multiout.dac_nids = spec->private_dac_nids;
12760 spec->multiout.dac_nids[0] = 2;
12761
12762 nid = cfg->line_out_pins[0];
12763 if (nid) {
12764 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12765 "Front Playback Volume",
12766 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12767 if (err < 0)
12768 return err;
12769 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12770 "Front Playback Switch",
12771 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12772 if (err < 0)
12773 return err;
12774 }
12775
12776 nid = cfg->speaker_pins[0];
12777 if (nid) {
12778 if (!cfg->line_out_pins[0]) {
12779 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12780 "Speaker Playback Volume",
12781 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12782 HDA_OUTPUT));
12783 if (err < 0)
12784 return err;
12785 }
12786 if (nid == 0x16) {
12787 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12788 "Speaker Playback Switch",
12789 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12790 HDA_OUTPUT));
12791 if (err < 0)
12792 return err;
12793 } else {
12794 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12795 "Speaker Playback Switch",
12796 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12797 HDA_OUTPUT));
12798 if (err < 0)
12799 return err;
12800 }
12801 }
12802 nid = cfg->hp_pins[0];
12803 if (nid) {
12804 /* spec->multiout.hp_nid = 2; */
12805 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12806 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12807 "Headphone Playback Volume",
12808 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12809 HDA_OUTPUT));
12810 if (err < 0)
12811 return err;
12812 }
12813 if (nid == 0x16) {
12814 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12815 "Headphone Playback Switch",
12816 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12817 HDA_OUTPUT));
12818 if (err < 0)
12819 return err;
12820 } else {
12821 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12822 "Headphone Playback Switch",
12823 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12824 HDA_OUTPUT));
12825 if (err < 0)
12826 return err;
12827 }
12828 }
12829 return 0;
12830}
12831
Takashi Iwaiee956e02008-10-31 17:16:31 +010012832static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12833 const struct auto_pin_cfg *cfg)
12834{
12835 int err;
12836
12837 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12838 if (err < 0)
12839 return err;
12840 /* digital-mic input pin is excluded in alc880_auto_create..()
12841 * because it's under 0x18
12842 */
12843 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12844 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012845 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012846 imux->items[imux->num_items].label = "Int Mic";
12847 imux->items[imux->num_items].index = 0x05;
12848 imux->num_items++;
12849 }
12850 return 0;
12851}
Kailang Yangf6a92242007-12-13 16:52:54 +010012852
12853#ifdef CONFIG_SND_HDA_POWER_SAVE
12854#define alc269_loopbacks alc880_loopbacks
12855#endif
12856
12857/* pcm configuration: identiacal with ALC880 */
12858#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12859#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12860#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12861#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12862
12863/*
12864 * BIOS auto configuration
12865 */
12866static int alc269_parse_auto_config(struct hda_codec *codec)
12867{
12868 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012869 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012870 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12871
12872 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12873 alc269_ignore);
12874 if (err < 0)
12875 return err;
12876
12877 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12878 if (err < 0)
12879 return err;
12880 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12881 if (err < 0)
12882 return err;
12883
12884 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12885
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012886 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012887 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12888
Takashi Iwai603c4012008-07-30 15:01:44 +020012889 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012890 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012891
Takashi Iwaid88897e2008-10-31 15:01:37 +010012892 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012893 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012894 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012895 /* set default input source */
12896 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12897 0, AC_VERB_SET_CONNECT_SEL,
12898 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012899
12900 err = alc_auto_add_mic_boost(codec);
12901 if (err < 0)
12902 return err;
12903
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012904 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012905 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012906
Takashi Iwaie044c392008-10-27 16:56:24 +010012907 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012908 return 1;
12909}
12910
12911#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12912#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12913#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12914
12915
12916/* init callback for auto-configuration model -- overriding the default init */
12917static void alc269_auto_init(struct hda_codec *codec)
12918{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012919 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012920 alc269_auto_init_multi_out(codec);
12921 alc269_auto_init_hp_out(codec);
12922 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012923 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012924 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012925}
12926
12927/*
12928 * configuration and preset
12929 */
12930static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012931 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012932 [ALC269_QUANTA_FL1] = "quanta",
12933 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012934 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012935 [ALC269_FUJITSU] = "fujitsu",
12936 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012937};
12938
12939static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012940 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012941 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12942 ALC269_ASUS_EEEPC_P703),
12943 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12944 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012945 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12946 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012947 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012948 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012949 {}
12950};
12951
12952static struct alc_config_preset alc269_presets[] = {
12953 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012954 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012955 .init_verbs = { alc269_init_verbs },
12956 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12957 .dac_nids = alc269_dac_nids,
12958 .hp_nid = 0x03,
12959 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12960 .channel_mode = alc269_modes,
12961 .input_mux = &alc269_capture_source,
12962 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012963 [ALC269_QUANTA_FL1] = {
12964 .mixers = { alc269_quanta_fl1_mixer },
12965 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12966 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12967 .dac_nids = alc269_dac_nids,
12968 .hp_nid = 0x03,
12969 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12970 .channel_mode = alc269_modes,
12971 .input_mux = &alc269_capture_source,
12972 .unsol_event = alc269_quanta_fl1_unsol_event,
12973 .init_hook = alc269_quanta_fl1_init_hook,
12974 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012975 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012976 .mixers = { alc269_eeepc_mixer },
12977 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012978 .init_verbs = { alc269_init_verbs,
12979 alc269_eeepc_amic_init_verbs },
12980 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12981 .dac_nids = alc269_dac_nids,
12982 .hp_nid = 0x03,
12983 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12984 .channel_mode = alc269_modes,
12985 .input_mux = &alc269_eeepc_amic_capture_source,
12986 .unsol_event = alc269_eeepc_amic_unsol_event,
12987 .init_hook = alc269_eeepc_amic_inithook,
12988 },
12989 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012990 .mixers = { alc269_eeepc_mixer },
12991 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012992 .init_verbs = { alc269_init_verbs,
12993 alc269_eeepc_dmic_init_verbs },
12994 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12995 .dac_nids = alc269_dac_nids,
12996 .hp_nid = 0x03,
12997 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12998 .channel_mode = alc269_modes,
12999 .input_mux = &alc269_eeepc_dmic_capture_source,
13000 .unsol_event = alc269_eeepc_dmic_unsol_event,
13001 .init_hook = alc269_eeepc_dmic_inithook,
13002 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013003 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013004 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013005 .cap_mixer = alc269_epc_capture_mixer,
13006 .init_verbs = { alc269_init_verbs,
13007 alc269_eeepc_dmic_init_verbs },
13008 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13009 .dac_nids = alc269_dac_nids,
13010 .hp_nid = 0x03,
13011 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13012 .channel_mode = alc269_modes,
13013 .input_mux = &alc269_eeepc_dmic_capture_source,
13014 .unsol_event = alc269_eeepc_dmic_unsol_event,
13015 .init_hook = alc269_eeepc_dmic_inithook,
13016 },
Tony Vroon64154832008-11-06 15:08:49 +000013017 [ALC269_LIFEBOOK] = {
13018 .mixers = { alc269_lifebook_mixer },
13019 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13020 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13021 .dac_nids = alc269_dac_nids,
13022 .hp_nid = 0x03,
13023 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13024 .channel_mode = alc269_modes,
13025 .input_mux = &alc269_capture_source,
13026 .unsol_event = alc269_lifebook_unsol_event,
13027 .init_hook = alc269_lifebook_init_hook,
13028 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013029};
13030
13031static int patch_alc269(struct hda_codec *codec)
13032{
13033 struct alc_spec *spec;
13034 int board_config;
13035 int err;
13036
13037 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13038 if (spec == NULL)
13039 return -ENOMEM;
13040
13041 codec->spec = spec;
13042
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013043 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13044
Kailang Yangf6a92242007-12-13 16:52:54 +010013045 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13046 alc269_models,
13047 alc269_cfg_tbl);
13048
13049 if (board_config < 0) {
13050 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
13051 "trying auto-probe from BIOS...\n");
13052 board_config = ALC269_AUTO;
13053 }
13054
13055 if (board_config == ALC269_AUTO) {
13056 /* automatic parse from the BIOS config */
13057 err = alc269_parse_auto_config(codec);
13058 if (err < 0) {
13059 alc_free(codec);
13060 return err;
13061 } else if (!err) {
13062 printk(KERN_INFO
13063 "hda_codec: Cannot set up configuration "
13064 "from BIOS. Using base mode...\n");
13065 board_config = ALC269_BASIC;
13066 }
13067 }
13068
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013069 err = snd_hda_attach_beep_device(codec, 0x1);
13070 if (err < 0) {
13071 alc_free(codec);
13072 return err;
13073 }
13074
Kailang Yangf6a92242007-12-13 16:52:54 +010013075 if (board_config != ALC269_AUTO)
13076 setup_preset(spec, &alc269_presets[board_config]);
13077
13078 spec->stream_name_analog = "ALC269 Analog";
13079 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13080 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13081
13082 spec->stream_name_digital = "ALC269 Digital";
13083 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13084 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13085
13086 spec->adc_nids = alc269_adc_nids;
13087 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013088 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013089 if (!spec->cap_mixer)
13090 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013091 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013092
13093 codec->patch_ops = alc_patch_ops;
13094 if (board_config == ALC269_AUTO)
13095 spec->init_hook = alc269_auto_init;
13096#ifdef CONFIG_SND_HDA_POWER_SAVE
13097 if (!spec->loopback.amplist)
13098 spec->loopback.amplist = alc269_loopbacks;
13099#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013100 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013101
13102 return 0;
13103}
13104
13105/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013106 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13107 */
13108
13109/*
13110 * set the path ways for 2 channel output
13111 * need to set the codec line out and mic 1 pin widgets to inputs
13112 */
13113static struct hda_verb alc861_threestack_ch2_init[] = {
13114 /* set pin widget 1Ah (line in) for input */
13115 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013116 /* set pin widget 18h (mic1/2) for input, for mic also enable
13117 * the vref
13118 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013119 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13120
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013121 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13122#if 0
13123 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13124 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13125#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013126 { } /* end */
13127};
13128/*
13129 * 6ch mode
13130 * need to set the codec line out and mic 1 pin widgets to outputs
13131 */
13132static struct hda_verb alc861_threestack_ch6_init[] = {
13133 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13134 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13135 /* set pin widget 18h (mic1) for output (CLFE)*/
13136 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13137
13138 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013139 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013140
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013141 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13142#if 0
13143 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13144 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13145#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013146 { } /* end */
13147};
13148
13149static struct hda_channel_mode alc861_threestack_modes[2] = {
13150 { 2, alc861_threestack_ch2_init },
13151 { 6, alc861_threestack_ch6_init },
13152};
Takashi Iwai22309c32006-08-09 16:57:28 +020013153/* Set mic1 as input and unmute the mixer */
13154static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13155 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13156 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13157 { } /* end */
13158};
13159/* Set mic1 as output and mute mixer */
13160static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13161 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13162 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13163 { } /* end */
13164};
13165
13166static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13167 { 2, alc861_uniwill_m31_ch2_init },
13168 { 4, alc861_uniwill_m31_ch4_init },
13169};
Kailang Yangdf694da2005-12-05 19:42:22 +010013170
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013171/* Set mic1 and line-in as input and unmute the mixer */
13172static struct hda_verb alc861_asus_ch2_init[] = {
13173 /* set pin widget 1Ah (line in) for input */
13174 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013175 /* set pin widget 18h (mic1/2) for input, for mic also enable
13176 * the vref
13177 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013178 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13179
13180 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13181#if 0
13182 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13183 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13184#endif
13185 { } /* end */
13186};
13187/* Set mic1 nad line-in as output and mute mixer */
13188static struct hda_verb alc861_asus_ch6_init[] = {
13189 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13190 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13191 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13192 /* set pin widget 18h (mic1) for output (CLFE)*/
13193 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13194 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13195 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13196 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13197
13198 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13199#if 0
13200 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13201 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13202#endif
13203 { } /* end */
13204};
13205
13206static struct hda_channel_mode alc861_asus_modes[2] = {
13207 { 2, alc861_asus_ch2_init },
13208 { 6, alc861_asus_ch6_init },
13209};
13210
Kailang Yangdf694da2005-12-05 19:42:22 +010013211/* patch-ALC861 */
13212
13213static struct snd_kcontrol_new alc861_base_mixer[] = {
13214 /* output mixer control */
13215 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13216 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13217 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13218 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13219 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13220
13221 /*Input mixer control */
13222 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13223 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13224 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13225 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13226 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13227 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13229 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13230 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13231 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013232
Kailang Yangdf694da2005-12-05 19:42:22 +010013233 { } /* end */
13234};
13235
13236static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13237 /* output mixer control */
13238 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13239 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13240 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13241 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13242 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13243
13244 /* Input mixer control */
13245 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13246 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13247 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13248 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13249 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13250 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13252 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13253 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13254 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013255
Kailang Yangdf694da2005-12-05 19:42:22 +010013256 {
13257 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13258 .name = "Channel Mode",
13259 .info = alc_ch_mode_info,
13260 .get = alc_ch_mode_get,
13261 .put = alc_ch_mode_put,
13262 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13263 },
13264 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013265};
13266
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013267static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013268 /* output mixer control */
13269 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13271 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013272
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013273 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013274};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013275
Takashi Iwai22309c32006-08-09 16:57:28 +020013276static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13277 /* output mixer control */
13278 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13279 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13280 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13281 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13282 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13283
13284 /* Input mixer control */
13285 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13286 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13287 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13288 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13289 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13290 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13292 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13293 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13294 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013295
Takashi Iwai22309c32006-08-09 16:57:28 +020013296 {
13297 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13298 .name = "Channel Mode",
13299 .info = alc_ch_mode_info,
13300 .get = alc_ch_mode_get,
13301 .put = alc_ch_mode_put,
13302 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13303 },
13304 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013305};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013306
13307static struct snd_kcontrol_new alc861_asus_mixer[] = {
13308 /* output mixer control */
13309 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13310 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13311 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13312 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13313 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13314
13315 /* Input mixer control */
13316 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13317 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13318 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13319 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13320 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13321 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13322 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13323 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13324 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013325 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13326
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013327 {
13328 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13329 .name = "Channel Mode",
13330 .info = alc_ch_mode_info,
13331 .get = alc_ch_mode_get,
13332 .put = alc_ch_mode_put,
13333 .private_value = ARRAY_SIZE(alc861_asus_modes),
13334 },
13335 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013336};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013337
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013338/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013339static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013340 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13341 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013342 { }
13343};
13344
Kailang Yangdf694da2005-12-05 19:42:22 +010013345/*
13346 * generic initialization of ADC, input mixers and output mixers
13347 */
13348static struct hda_verb alc861_base_init_verbs[] = {
13349 /*
13350 * Unmute ADC0 and set the default input to mic-in
13351 */
13352 /* port-A for surround (rear panel) */
13353 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13354 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13355 /* port-B for mic-in (rear panel) with vref */
13356 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13357 /* port-C for line-in (rear panel) */
13358 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13359 /* port-D for Front */
13360 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13361 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13362 /* port-E for HP out (front panel) */
13363 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13364 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013365 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013366 /* port-F for mic-in (front panel) with vref */
13367 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13368 /* port-G for CLFE (rear panel) */
13369 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13370 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13371 /* port-H for side (rear panel) */
13372 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13373 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13374 /* CD-in */
13375 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13376 /* route front mic to ADC1*/
13377 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13378 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013379
Kailang Yangdf694da2005-12-05 19:42:22 +010013380 /* Unmute DAC0~3 & spdif out*/
13381 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13382 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13383 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13384 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013386
Kailang Yangdf694da2005-12-05 19:42:22 +010013387 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13388 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13389 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13390 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13391 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013392
Kailang Yangdf694da2005-12-05 19:42:22 +010013393 /* Unmute Stereo Mixer 15 */
13394 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13396 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013397 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013398
13399 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13400 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13401 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13402 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13403 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13404 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13405 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13406 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013407 /* hp used DAC 3 (Front) */
13408 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013409 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13410
13411 { }
13412};
13413
13414static struct hda_verb alc861_threestack_init_verbs[] = {
13415 /*
13416 * Unmute ADC0 and set the default input to mic-in
13417 */
13418 /* port-A for surround (rear panel) */
13419 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13420 /* port-B for mic-in (rear panel) with vref */
13421 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13422 /* port-C for line-in (rear panel) */
13423 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13424 /* port-D for Front */
13425 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13426 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13427 /* port-E for HP out (front panel) */
13428 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13429 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013430 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013431 /* port-F for mic-in (front panel) with vref */
13432 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13433 /* port-G for CLFE (rear panel) */
13434 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13435 /* port-H for side (rear panel) */
13436 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13437 /* CD-in */
13438 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13439 /* route front mic to ADC1*/
13440 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13441 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13442 /* Unmute DAC0~3 & spdif out*/
13443 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13444 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13445 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13446 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13447 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013448
Kailang Yangdf694da2005-12-05 19:42:22 +010013449 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13450 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13451 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13452 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13453 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013454
Kailang Yangdf694da2005-12-05 19:42:22 +010013455 /* Unmute Stereo Mixer 15 */
13456 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13457 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13458 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013459 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013460
13461 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13462 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13463 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13464 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13465 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13466 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13467 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13468 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013469 /* hp used DAC 3 (Front) */
13470 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013471 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13472 { }
13473};
Takashi Iwai22309c32006-08-09 16:57:28 +020013474
13475static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13476 /*
13477 * Unmute ADC0 and set the default input to mic-in
13478 */
13479 /* port-A for surround (rear panel) */
13480 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13481 /* port-B for mic-in (rear panel) with vref */
13482 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13483 /* port-C for line-in (rear panel) */
13484 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13485 /* port-D for Front */
13486 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13487 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13488 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013489 /* this has to be set to VREF80 */
13490 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013491 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013492 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013493 /* port-F for mic-in (front panel) with vref */
13494 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13495 /* port-G for CLFE (rear panel) */
13496 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13497 /* port-H for side (rear panel) */
13498 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13499 /* CD-in */
13500 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13501 /* route front mic to ADC1*/
13502 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13504 /* Unmute DAC0~3 & spdif out*/
13505 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13506 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13507 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13508 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013510
Takashi Iwai22309c32006-08-09 16:57:28 +020013511 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13512 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13513 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13514 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13515 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013516
Takashi Iwai22309c32006-08-09 16:57:28 +020013517 /* Unmute Stereo Mixer 15 */
13518 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013521 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013522
13523 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13524 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13525 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13526 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13527 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13528 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13529 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13530 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013531 /* hp used DAC 3 (Front) */
13532 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013533 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13534 { }
13535};
13536
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013537static struct hda_verb alc861_asus_init_verbs[] = {
13538 /*
13539 * Unmute ADC0 and set the default input to mic-in
13540 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013541 /* port-A for surround (rear panel)
13542 * according to codec#0 this is the HP jack
13543 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013544 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13545 /* route front PCM to HP */
13546 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13547 /* port-B for mic-in (rear panel) with vref */
13548 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13549 /* port-C for line-in (rear panel) */
13550 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13551 /* port-D for Front */
13552 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13553 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13554 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013555 /* this has to be set to VREF80 */
13556 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013557 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013558 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013559 /* port-F for mic-in (front panel) with vref */
13560 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13561 /* port-G for CLFE (rear panel) */
13562 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13563 /* port-H for side (rear panel) */
13564 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13565 /* CD-in */
13566 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13567 /* route front mic to ADC1*/
13568 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13570 /* Unmute DAC0~3 & spdif out*/
13571 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13572 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13573 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13574 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13576 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13577 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13578 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13579 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13580 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013581
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013582 /* Unmute Stereo Mixer 15 */
13583 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13584 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13585 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013586 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013587
13588 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13589 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13590 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13591 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13592 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13593 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13594 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13595 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013596 /* hp used DAC 3 (Front) */
13597 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013598 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13599 { }
13600};
13601
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013602/* additional init verbs for ASUS laptops */
13603static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13604 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13605 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13606 { }
13607};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013608
Kailang Yangdf694da2005-12-05 19:42:22 +010013609/*
13610 * generic initialization of ADC, input mixers and output mixers
13611 */
13612static struct hda_verb alc861_auto_init_verbs[] = {
13613 /*
13614 * Unmute ADC0 and set the default input to mic-in
13615 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013616 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013617 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013618
Kailang Yangdf694da2005-12-05 19:42:22 +010013619 /* Unmute DAC0~3 & spdif out*/
13620 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13621 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13622 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13623 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13624 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013625
Kailang Yangdf694da2005-12-05 19:42:22 +010013626 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13627 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13628 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13629 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13630 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013631
Kailang Yangdf694da2005-12-05 19:42:22 +010013632 /* Unmute Stereo Mixer 15 */
13633 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13634 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13635 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13636 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13637
13638 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13639 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13640 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13641 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13642 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13644 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13645 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13646
13647 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013649 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13650 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013651 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13652 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013653 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13654 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013655
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013656 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013657
13658 { }
13659};
13660
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013661static struct hda_verb alc861_toshiba_init_verbs[] = {
13662 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013663
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013664 { }
13665};
13666
13667/* toggle speaker-output according to the hp-jack state */
13668static void alc861_toshiba_automute(struct hda_codec *codec)
13669{
13670 unsigned int present;
13671
13672 present = snd_hda_codec_read(codec, 0x0f, 0,
13673 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013674 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13675 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13676 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13677 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013678}
13679
13680static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13681 unsigned int res)
13682{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013683 if ((res >> 26) == ALC880_HP_EVENT)
13684 alc861_toshiba_automute(codec);
13685}
13686
Kailang Yangdf694da2005-12-05 19:42:22 +010013687/* pcm configuration: identiacal with ALC880 */
13688#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13689#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13690#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13691#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13692
13693
13694#define ALC861_DIGOUT_NID 0x07
13695
13696static struct hda_channel_mode alc861_8ch_modes[1] = {
13697 { 8, NULL }
13698};
13699
13700static hda_nid_t alc861_dac_nids[4] = {
13701 /* front, surround, clfe, side */
13702 0x03, 0x06, 0x05, 0x04
13703};
13704
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013705static hda_nid_t alc660_dac_nids[3] = {
13706 /* front, clfe, surround */
13707 0x03, 0x05, 0x06
13708};
13709
Kailang Yangdf694da2005-12-05 19:42:22 +010013710static hda_nid_t alc861_adc_nids[1] = {
13711 /* ADC0-2 */
13712 0x08,
13713};
13714
13715static struct hda_input_mux alc861_capture_source = {
13716 .num_items = 5,
13717 .items = {
13718 { "Mic", 0x0 },
13719 { "Front Mic", 0x3 },
13720 { "Line", 0x1 },
13721 { "CD", 0x4 },
13722 { "Mixer", 0x5 },
13723 },
13724};
13725
13726/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013727static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13728 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013729{
13730 int i;
13731 hda_nid_t nid;
13732
13733 spec->multiout.dac_nids = spec->private_dac_nids;
13734 for (i = 0; i < cfg->line_outs; i++) {
13735 nid = cfg->line_out_pins[i];
13736 if (nid) {
13737 if (i >= ARRAY_SIZE(alc861_dac_nids))
13738 continue;
13739 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13740 }
13741 }
13742 spec->multiout.num_dacs = cfg->line_outs;
13743 return 0;
13744}
13745
13746/* add playback controls from the parsed DAC table */
13747static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13748 const struct auto_pin_cfg *cfg)
13749{
13750 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013751 static const char *chname[4] = {
13752 "Front", "Surround", NULL /*CLFE*/, "Side"
13753 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013754 hda_nid_t nid;
13755 int i, idx, err;
13756
13757 for (i = 0; i < cfg->line_outs; i++) {
13758 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013759 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013760 continue;
13761 if (nid == 0x05) {
13762 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013763 err = add_control(spec, ALC_CTL_BIND_MUTE,
13764 "Center Playback Switch",
13765 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13766 HDA_OUTPUT));
13767 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013768 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013769 err = add_control(spec, ALC_CTL_BIND_MUTE,
13770 "LFE Playback Switch",
13771 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13772 HDA_OUTPUT));
13773 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013774 return err;
13775 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013776 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13777 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013778 if (nid == alc861_dac_nids[idx])
13779 break;
13780 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013781 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13782 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13783 HDA_OUTPUT));
13784 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013785 return err;
13786 }
13787 }
13788 return 0;
13789}
13790
13791static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13792{
13793 int err;
13794 hda_nid_t nid;
13795
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013796 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013797 return 0;
13798
13799 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13800 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013801 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13802 "Headphone Playback Switch",
13803 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13804 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013805 return err;
13806 spec->multiout.hp_nid = nid;
13807 }
13808 return 0;
13809}
13810
13811/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013812static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13813 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013814{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013815 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013816 int i, err, idx, idx1;
13817
13818 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013819 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013820 case 0x0c:
13821 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013822 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013823 break;
13824 case 0x0f:
13825 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013826 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013827 break;
13828 case 0x0d:
13829 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013830 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013831 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013832 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013833 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013834 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013835 break;
13836 case 0x11:
13837 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013838 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013839 break;
13840 default:
13841 continue;
13842 }
13843
Takashi Iwai4a471b72005-12-07 13:56:29 +010013844 err = new_analog_input(spec, cfg->input_pins[i],
13845 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013846 if (err < 0)
13847 return err;
13848
Takashi Iwai4a471b72005-12-07 13:56:29 +010013849 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013850 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013851 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013852 }
13853 return 0;
13854}
13855
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013856static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13857 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013858 int pin_type, int dac_idx)
13859{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013860 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13861 pin_type);
13862 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13863 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013864}
13865
13866static void alc861_auto_init_multi_out(struct hda_codec *codec)
13867{
13868 struct alc_spec *spec = codec->spec;
13869 int i;
13870
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013871 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013872 for (i = 0; i < spec->autocfg.line_outs; i++) {
13873 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013874 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013875 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013876 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013877 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013878 }
13879}
13880
13881static void alc861_auto_init_hp_out(struct hda_codec *codec)
13882{
13883 struct alc_spec *spec = codec->spec;
13884 hda_nid_t pin;
13885
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013886 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013887 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013888 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13889 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013890 pin = spec->autocfg.speaker_pins[0];
13891 if (pin)
13892 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013893}
13894
13895static void alc861_auto_init_analog_input(struct hda_codec *codec)
13896{
13897 struct alc_spec *spec = codec->spec;
13898 int i;
13899
13900 for (i = 0; i < AUTO_PIN_LAST; i++) {
13901 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013902 if (nid >= 0x0c && nid <= 0x11) {
13903 snd_hda_codec_write(codec, nid, 0,
13904 AC_VERB_SET_PIN_WIDGET_CONTROL,
13905 i <= AUTO_PIN_FRONT_MIC ?
13906 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013907 }
13908 }
13909}
13910
13911/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013912/* return 1 if successful, 0 if the proper config is not found,
13913 * or a negative error code
13914 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013915static int alc861_parse_auto_config(struct hda_codec *codec)
13916{
13917 struct alc_spec *spec = codec->spec;
13918 int err;
13919 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13920
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013921 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13922 alc861_ignore);
13923 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013924 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013925 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013926 return 0; /* can't find valid BIOS pin config */
13927
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013928 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13929 if (err < 0)
13930 return err;
13931 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13932 if (err < 0)
13933 return err;
13934 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13935 if (err < 0)
13936 return err;
13937 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13938 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013939 return err;
13940
13941 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13942
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013943 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013944 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13945
Takashi Iwai603c4012008-07-30 15:01:44 +020013946 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013947 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013948
Takashi Iwaid88897e2008-10-31 15:01:37 +010013949 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013950
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013951 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013952 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013953
13954 spec->adc_nids = alc861_adc_nids;
13955 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013956 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013957
Takashi Iwaie044c392008-10-27 16:56:24 +010013958 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013959 return 1;
13960}
13961
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013962/* additional initialization for auto-configuration model */
13963static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013964{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013965 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013966 alc861_auto_init_multi_out(codec);
13967 alc861_auto_init_hp_out(codec);
13968 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013969 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013970 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013971}
13972
Takashi Iwaicb53c622007-08-10 17:21:45 +020013973#ifdef CONFIG_SND_HDA_POWER_SAVE
13974static struct hda_amp_list alc861_loopbacks[] = {
13975 { 0x15, HDA_INPUT, 0 },
13976 { 0x15, HDA_INPUT, 1 },
13977 { 0x15, HDA_INPUT, 2 },
13978 { 0x15, HDA_INPUT, 3 },
13979 { } /* end */
13980};
13981#endif
13982
Kailang Yangdf694da2005-12-05 19:42:22 +010013983
13984/*
13985 * configuration and preset
13986 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013987static const char *alc861_models[ALC861_MODEL_LAST] = {
13988 [ALC861_3ST] = "3stack",
13989 [ALC660_3ST] = "3stack-660",
13990 [ALC861_3ST_DIG] = "3stack-dig",
13991 [ALC861_6ST_DIG] = "6stack-dig",
13992 [ALC861_UNIWILL_M31] = "uniwill-m31",
13993 [ALC861_TOSHIBA] = "toshiba",
13994 [ALC861_ASUS] = "asus",
13995 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13996 [ALC861_AUTO] = "auto",
13997};
13998
13999static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014000 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014001 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14002 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14003 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014004 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014005 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014006 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014007 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14008 * Any other models that need this preset?
14009 */
14010 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014011 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14012 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014013 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14014 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14015 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14016 /* FIXME: the below seems conflict */
14017 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14018 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14019 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014020 {}
14021};
14022
14023static struct alc_config_preset alc861_presets[] = {
14024 [ALC861_3ST] = {
14025 .mixers = { alc861_3ST_mixer },
14026 .init_verbs = { alc861_threestack_init_verbs },
14027 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14028 .dac_nids = alc861_dac_nids,
14029 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14030 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014031 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014032 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14033 .adc_nids = alc861_adc_nids,
14034 .input_mux = &alc861_capture_source,
14035 },
14036 [ALC861_3ST_DIG] = {
14037 .mixers = { alc861_base_mixer },
14038 .init_verbs = { alc861_threestack_init_verbs },
14039 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14040 .dac_nids = alc861_dac_nids,
14041 .dig_out_nid = ALC861_DIGOUT_NID,
14042 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14043 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014044 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014045 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14046 .adc_nids = alc861_adc_nids,
14047 .input_mux = &alc861_capture_source,
14048 },
14049 [ALC861_6ST_DIG] = {
14050 .mixers = { alc861_base_mixer },
14051 .init_verbs = { alc861_base_init_verbs },
14052 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14053 .dac_nids = alc861_dac_nids,
14054 .dig_out_nid = ALC861_DIGOUT_NID,
14055 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14056 .channel_mode = alc861_8ch_modes,
14057 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14058 .adc_nids = alc861_adc_nids,
14059 .input_mux = &alc861_capture_source,
14060 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014061 [ALC660_3ST] = {
14062 .mixers = { alc861_3ST_mixer },
14063 .init_verbs = { alc861_threestack_init_verbs },
14064 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14065 .dac_nids = alc660_dac_nids,
14066 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14067 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014068 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014069 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14070 .adc_nids = alc861_adc_nids,
14071 .input_mux = &alc861_capture_source,
14072 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014073 [ALC861_UNIWILL_M31] = {
14074 .mixers = { alc861_uniwill_m31_mixer },
14075 .init_verbs = { alc861_uniwill_m31_init_verbs },
14076 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14077 .dac_nids = alc861_dac_nids,
14078 .dig_out_nid = ALC861_DIGOUT_NID,
14079 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14080 .channel_mode = alc861_uniwill_m31_modes,
14081 .need_dac_fix = 1,
14082 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14083 .adc_nids = alc861_adc_nids,
14084 .input_mux = &alc861_capture_source,
14085 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014086 [ALC861_TOSHIBA] = {
14087 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014088 .init_verbs = { alc861_base_init_verbs,
14089 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014090 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14091 .dac_nids = alc861_dac_nids,
14092 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14093 .channel_mode = alc883_3ST_2ch_modes,
14094 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14095 .adc_nids = alc861_adc_nids,
14096 .input_mux = &alc861_capture_source,
14097 .unsol_event = alc861_toshiba_unsol_event,
14098 .init_hook = alc861_toshiba_automute,
14099 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014100 [ALC861_ASUS] = {
14101 .mixers = { alc861_asus_mixer },
14102 .init_verbs = { alc861_asus_init_verbs },
14103 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14104 .dac_nids = alc861_dac_nids,
14105 .dig_out_nid = ALC861_DIGOUT_NID,
14106 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14107 .channel_mode = alc861_asus_modes,
14108 .need_dac_fix = 1,
14109 .hp_nid = 0x06,
14110 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14111 .adc_nids = alc861_adc_nids,
14112 .input_mux = &alc861_capture_source,
14113 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014114 [ALC861_ASUS_LAPTOP] = {
14115 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14116 .init_verbs = { alc861_asus_init_verbs,
14117 alc861_asus_laptop_init_verbs },
14118 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14119 .dac_nids = alc861_dac_nids,
14120 .dig_out_nid = ALC861_DIGOUT_NID,
14121 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14122 .channel_mode = alc883_3ST_2ch_modes,
14123 .need_dac_fix = 1,
14124 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14125 .adc_nids = alc861_adc_nids,
14126 .input_mux = &alc861_capture_source,
14127 },
14128};
Kailang Yangdf694da2005-12-05 19:42:22 +010014129
14130
14131static int patch_alc861(struct hda_codec *codec)
14132{
14133 struct alc_spec *spec;
14134 int board_config;
14135 int err;
14136
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014137 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014138 if (spec == NULL)
14139 return -ENOMEM;
14140
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014141 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014142
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014143 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14144 alc861_models,
14145 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014146
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014147 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014148 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14149 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014150 board_config = ALC861_AUTO;
14151 }
14152
14153 if (board_config == ALC861_AUTO) {
14154 /* automatic parse from the BIOS config */
14155 err = alc861_parse_auto_config(codec);
14156 if (err < 0) {
14157 alc_free(codec);
14158 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014159 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014160 printk(KERN_INFO
14161 "hda_codec: Cannot set up configuration "
14162 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014163 board_config = ALC861_3ST_DIG;
14164 }
14165 }
14166
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014167 err = snd_hda_attach_beep_device(codec, 0x23);
14168 if (err < 0) {
14169 alc_free(codec);
14170 return err;
14171 }
14172
Kailang Yangdf694da2005-12-05 19:42:22 +010014173 if (board_config != ALC861_AUTO)
14174 setup_preset(spec, &alc861_presets[board_config]);
14175
14176 spec->stream_name_analog = "ALC861 Analog";
14177 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14178 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14179
14180 spec->stream_name_digital = "ALC861 Digital";
14181 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14182 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14183
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014184 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14185
Takashi Iwai2134ea42008-01-10 16:53:55 +010014186 spec->vmaster_nid = 0x03;
14187
Kailang Yangdf694da2005-12-05 19:42:22 +010014188 codec->patch_ops = alc_patch_ops;
14189 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014190 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014191#ifdef CONFIG_SND_HDA_POWER_SAVE
14192 if (!spec->loopback.amplist)
14193 spec->loopback.amplist = alc861_loopbacks;
14194#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014195 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014196
Kailang Yangdf694da2005-12-05 19:42:22 +010014197 return 0;
14198}
14199
14200/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014201 * ALC861-VD support
14202 *
14203 * Based on ALC882
14204 *
14205 * In addition, an independent DAC
14206 */
14207#define ALC861VD_DIGOUT_NID 0x06
14208
14209static hda_nid_t alc861vd_dac_nids[4] = {
14210 /* front, surr, clfe, side surr */
14211 0x02, 0x03, 0x04, 0x05
14212};
14213
14214/* dac_nids for ALC660vd are in a different order - according to
14215 * Realtek's driver.
14216 * This should probably tesult in a different mixer for 6stack models
14217 * of ALC660vd codecs, but for now there is only 3stack mixer
14218 * - and it is the same as in 861vd.
14219 * adc_nids in ALC660vd are (is) the same as in 861vd
14220 */
14221static hda_nid_t alc660vd_dac_nids[3] = {
14222 /* front, rear, clfe, rear_surr */
14223 0x02, 0x04, 0x03
14224};
14225
14226static hda_nid_t alc861vd_adc_nids[1] = {
14227 /* ADC0 */
14228 0x09,
14229};
14230
Takashi Iwaie1406342008-02-11 18:32:32 +010014231static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14232
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014233/* input MUX */
14234/* FIXME: should be a matrix-type input source selection */
14235static struct hda_input_mux alc861vd_capture_source = {
14236 .num_items = 4,
14237 .items = {
14238 { "Mic", 0x0 },
14239 { "Front Mic", 0x1 },
14240 { "Line", 0x2 },
14241 { "CD", 0x4 },
14242 },
14243};
14244
Kailang Yang272a5272007-05-14 11:00:38 +020014245static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014246 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014247 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014248 { "Ext Mic", 0x0 },
14249 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014250 },
14251};
14252
Kailang Yangd1a991a2007-08-15 16:21:59 +020014253static struct hda_input_mux alc861vd_hp_capture_source = {
14254 .num_items = 2,
14255 .items = {
14256 { "Front Mic", 0x0 },
14257 { "ATAPI Mic", 0x1 },
14258 },
14259};
14260
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014261/*
14262 * 2ch mode
14263 */
14264static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14265 { 2, NULL }
14266};
14267
14268/*
14269 * 6ch mode
14270 */
14271static struct hda_verb alc861vd_6stack_ch6_init[] = {
14272 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14273 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14274 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14275 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14276 { } /* end */
14277};
14278
14279/*
14280 * 8ch mode
14281 */
14282static struct hda_verb alc861vd_6stack_ch8_init[] = {
14283 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14284 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14285 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14286 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14287 { } /* end */
14288};
14289
14290static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14291 { 6, alc861vd_6stack_ch6_init },
14292 { 8, alc861vd_6stack_ch8_init },
14293};
14294
14295static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14296 {
14297 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14298 .name = "Channel Mode",
14299 .info = alc_ch_mode_info,
14300 .get = alc_ch_mode_get,
14301 .put = alc_ch_mode_put,
14302 },
14303 { } /* end */
14304};
14305
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014306/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14307 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14308 */
14309static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14310 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14311 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14312
14313 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14314 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14315
14316 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14317 HDA_OUTPUT),
14318 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14319 HDA_OUTPUT),
14320 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14321 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14322
14323 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14324 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14325
14326 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14327
14328 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14329 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14330 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14331
14332 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14333 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14334 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14335
14336 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14337 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14338
14339 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14340 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14341
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014342 { } /* end */
14343};
14344
14345static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14346 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14347 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14348
14349 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14350
14351 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14354
14355 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14356 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14357 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14358
14359 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14360 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14361
14362 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14363 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14364
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014365 { } /* end */
14366};
14367
Kailang Yangbdd148a2007-05-08 15:19:08 +020014368static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14369 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14370 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14371 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14372
14373 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14374
14375 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14376 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14377 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14378
14379 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14380 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14381 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14382
14383 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14384 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14385
14386 { } /* end */
14387};
14388
Tobin Davisb419f342008-03-07 11:57:51 +010014389/* Pin assignment: Speaker=0x14, HP = 0x15,
14390 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014391 */
14392static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014393 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14394 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014395 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14396 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014397 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14398 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14399 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14400 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14401 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14402 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014403 { } /* end */
14404};
14405
Kailang Yangd1a991a2007-08-15 16:21:59 +020014406/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14407 * Front Mic=0x18, ATAPI Mic = 0x19,
14408 */
14409static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14410 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14411 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14412 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14413 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14414 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14415 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14416 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14417 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014418
Kailang Yangd1a991a2007-08-15 16:21:59 +020014419 { } /* end */
14420};
14421
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014422/*
14423 * generic initialization of ADC, input mixers and output mixers
14424 */
14425static struct hda_verb alc861vd_volume_init_verbs[] = {
14426 /*
14427 * Unmute ADC0 and set the default input to mic-in
14428 */
14429 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14430 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14431
14432 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14433 * the analog-loopback mixer widget
14434 */
14435 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014436 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14437 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14438 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14439 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14440 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014441
14442 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014443 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14444 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14445 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014446 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014447
14448 /*
14449 * Set up output mixers (0x02 - 0x05)
14450 */
14451 /* set vol=0 to output mixers */
14452 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14453 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14454 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14455 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14456
14457 /* set up input amps for analog loopback */
14458 /* Amp Indices: DAC = 0, mixer = 1 */
14459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14461 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14462 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14464 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14466 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14467
14468 { }
14469};
14470
14471/*
14472 * 3-stack pin configuration:
14473 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14474 */
14475static struct hda_verb alc861vd_3stack_init_verbs[] = {
14476 /*
14477 * Set pin mode and muting
14478 */
14479 /* set front pin widgets 0x14 for output */
14480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14481 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14482 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14483
14484 /* Mic (rear) pin: input vref at 80% */
14485 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14486 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14487 /* Front Mic pin: input vref at 80% */
14488 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14489 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14490 /* Line In pin: input */
14491 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14492 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14493 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14494 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14495 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14496 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14497 /* CD pin widget for input */
14498 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14499
14500 { }
14501};
14502
14503/*
14504 * 6-stack pin configuration:
14505 */
14506static struct hda_verb alc861vd_6stack_init_verbs[] = {
14507 /*
14508 * Set pin mode and muting
14509 */
14510 /* set front pin widgets 0x14 for output */
14511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14513 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14514
14515 /* Rear Pin: output 1 (0x0d) */
14516 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14517 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14518 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14519 /* CLFE Pin: output 2 (0x0e) */
14520 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14521 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14522 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14523 /* Side Pin: output 3 (0x0f) */
14524 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14525 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14526 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14527
14528 /* Mic (rear) pin: input vref at 80% */
14529 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14530 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14531 /* Front Mic pin: input vref at 80% */
14532 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14533 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14534 /* Line In pin: input */
14535 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14536 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14537 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14539 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14540 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14541 /* CD pin widget for input */
14542 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14543
14544 { }
14545};
14546
Kailang Yangbdd148a2007-05-08 15:19:08 +020014547static struct hda_verb alc861vd_eapd_verbs[] = {
14548 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14549 { }
14550};
14551
Kailang Yangf9423e72008-05-27 12:32:25 +020014552static struct hda_verb alc660vd_eapd_verbs[] = {
14553 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14554 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14555 { }
14556};
14557
Kailang Yangbdd148a2007-05-08 15:19:08 +020014558static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14559 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14560 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14562 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014563 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014564 {}
14565};
14566
14567/* toggle speaker-output according to the hp-jack state */
14568static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14569{
14570 unsigned int present;
14571 unsigned char bits;
14572
14573 present = snd_hda_codec_read(codec, 0x1b, 0,
14574 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014575 bits = present ? HDA_AMP_MUTE : 0;
14576 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14577 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014578}
14579
14580static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14581{
14582 unsigned int present;
14583 unsigned char bits;
14584
14585 present = snd_hda_codec_read(codec, 0x18, 0,
14586 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014587 bits = present ? HDA_AMP_MUTE : 0;
14588 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14589 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014590}
14591
14592static void alc861vd_lenovo_automute(struct hda_codec *codec)
14593{
14594 alc861vd_lenovo_hp_automute(codec);
14595 alc861vd_lenovo_mic_automute(codec);
14596}
14597
14598static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14599 unsigned int res)
14600{
14601 switch (res >> 26) {
14602 case ALC880_HP_EVENT:
14603 alc861vd_lenovo_hp_automute(codec);
14604 break;
14605 case ALC880_MIC_EVENT:
14606 alc861vd_lenovo_mic_automute(codec);
14607 break;
14608 }
14609}
14610
Kailang Yang272a5272007-05-14 11:00:38 +020014611static struct hda_verb alc861vd_dallas_verbs[] = {
14612 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14613 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14614 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14615 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14616
14617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14619 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14620 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14621 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14622 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14623 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14624 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014625
Kailang Yang272a5272007-05-14 11:00:38 +020014626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14627 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14628 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14630 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14631 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14632 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14633 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14634
14635 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14636 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14637 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14638 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14639 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14640 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14641 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14642 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14643
14644 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14645 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14646 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14647 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14648
14649 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014650 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014651 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14652
14653 { } /* end */
14654};
14655
14656/* toggle speaker-output according to the hp-jack state */
14657static void alc861vd_dallas_automute(struct hda_codec *codec)
14658{
14659 unsigned int present;
14660
14661 present = snd_hda_codec_read(codec, 0x15, 0,
14662 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014663 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14664 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014665}
14666
14667static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14668{
14669 if ((res >> 26) == ALC880_HP_EVENT)
14670 alc861vd_dallas_automute(codec);
14671}
14672
Takashi Iwaicb53c622007-08-10 17:21:45 +020014673#ifdef CONFIG_SND_HDA_POWER_SAVE
14674#define alc861vd_loopbacks alc880_loopbacks
14675#endif
14676
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014677/* pcm configuration: identiacal with ALC880 */
14678#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14679#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14680#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14681#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14682
14683/*
14684 * configuration and preset
14685 */
14686static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14687 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014688 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014689 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014690 [ALC861VD_3ST] = "3stack",
14691 [ALC861VD_3ST_DIG] = "3stack-digout",
14692 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014693 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014694 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014695 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014696 [ALC861VD_AUTO] = "auto",
14697};
14698
14699static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014700 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14701 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014702 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014703 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014704 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014705 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014706 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014707 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014708 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014709 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014710 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014711 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014712 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014713 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014714 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014715 {}
14716};
14717
14718static struct alc_config_preset alc861vd_presets[] = {
14719 [ALC660VD_3ST] = {
14720 .mixers = { alc861vd_3st_mixer },
14721 .init_verbs = { alc861vd_volume_init_verbs,
14722 alc861vd_3stack_init_verbs },
14723 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14724 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014725 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14726 .channel_mode = alc861vd_3stack_2ch_modes,
14727 .input_mux = &alc861vd_capture_source,
14728 },
Mike Crash6963f842007-06-25 12:12:51 +020014729 [ALC660VD_3ST_DIG] = {
14730 .mixers = { alc861vd_3st_mixer },
14731 .init_verbs = { alc861vd_volume_init_verbs,
14732 alc861vd_3stack_init_verbs },
14733 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14734 .dac_nids = alc660vd_dac_nids,
14735 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014736 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14737 .channel_mode = alc861vd_3stack_2ch_modes,
14738 .input_mux = &alc861vd_capture_source,
14739 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014740 [ALC861VD_3ST] = {
14741 .mixers = { alc861vd_3st_mixer },
14742 .init_verbs = { alc861vd_volume_init_verbs,
14743 alc861vd_3stack_init_verbs },
14744 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14745 .dac_nids = alc861vd_dac_nids,
14746 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14747 .channel_mode = alc861vd_3stack_2ch_modes,
14748 .input_mux = &alc861vd_capture_source,
14749 },
14750 [ALC861VD_3ST_DIG] = {
14751 .mixers = { alc861vd_3st_mixer },
14752 .init_verbs = { alc861vd_volume_init_verbs,
14753 alc861vd_3stack_init_verbs },
14754 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14755 .dac_nids = alc861vd_dac_nids,
14756 .dig_out_nid = ALC861VD_DIGOUT_NID,
14757 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14758 .channel_mode = alc861vd_3stack_2ch_modes,
14759 .input_mux = &alc861vd_capture_source,
14760 },
14761 [ALC861VD_6ST_DIG] = {
14762 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14763 .init_verbs = { alc861vd_volume_init_verbs,
14764 alc861vd_6stack_init_verbs },
14765 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14766 .dac_nids = alc861vd_dac_nids,
14767 .dig_out_nid = ALC861VD_DIGOUT_NID,
14768 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14769 .channel_mode = alc861vd_6stack_modes,
14770 .input_mux = &alc861vd_capture_source,
14771 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014772 [ALC861VD_LENOVO] = {
14773 .mixers = { alc861vd_lenovo_mixer },
14774 .init_verbs = { alc861vd_volume_init_verbs,
14775 alc861vd_3stack_init_verbs,
14776 alc861vd_eapd_verbs,
14777 alc861vd_lenovo_unsol_verbs },
14778 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14779 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014780 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14781 .channel_mode = alc861vd_3stack_2ch_modes,
14782 .input_mux = &alc861vd_capture_source,
14783 .unsol_event = alc861vd_lenovo_unsol_event,
14784 .init_hook = alc861vd_lenovo_automute,
14785 },
Kailang Yang272a5272007-05-14 11:00:38 +020014786 [ALC861VD_DALLAS] = {
14787 .mixers = { alc861vd_dallas_mixer },
14788 .init_verbs = { alc861vd_dallas_verbs },
14789 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14790 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014791 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14792 .channel_mode = alc861vd_3stack_2ch_modes,
14793 .input_mux = &alc861vd_dallas_capture_source,
14794 .unsol_event = alc861vd_dallas_unsol_event,
14795 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014796 },
14797 [ALC861VD_HP] = {
14798 .mixers = { alc861vd_hp_mixer },
14799 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14800 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14801 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014802 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014803 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14804 .channel_mode = alc861vd_3stack_2ch_modes,
14805 .input_mux = &alc861vd_hp_capture_source,
14806 .unsol_event = alc861vd_dallas_unsol_event,
14807 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014808 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014809 [ALC660VD_ASUS_V1S] = {
14810 .mixers = { alc861vd_lenovo_mixer },
14811 .init_verbs = { alc861vd_volume_init_verbs,
14812 alc861vd_3stack_init_verbs,
14813 alc861vd_eapd_verbs,
14814 alc861vd_lenovo_unsol_verbs },
14815 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14816 .dac_nids = alc660vd_dac_nids,
14817 .dig_out_nid = ALC861VD_DIGOUT_NID,
14818 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14819 .channel_mode = alc861vd_3stack_2ch_modes,
14820 .input_mux = &alc861vd_capture_source,
14821 .unsol_event = alc861vd_lenovo_unsol_event,
14822 .init_hook = alc861vd_lenovo_automute,
14823 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014824};
14825
14826/*
14827 * BIOS auto configuration
14828 */
14829static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14830 hda_nid_t nid, int pin_type, int dac_idx)
14831{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014832 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014833}
14834
14835static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14836{
14837 struct alc_spec *spec = codec->spec;
14838 int i;
14839
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014840 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014841 for (i = 0; i <= HDA_SIDE; i++) {
14842 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014843 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014844 if (nid)
14845 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014846 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014847 }
14848}
14849
14850
14851static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14852{
14853 struct alc_spec *spec = codec->spec;
14854 hda_nid_t pin;
14855
14856 pin = spec->autocfg.hp_pins[0];
14857 if (pin) /* connect to front and use dac 0 */
14858 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014859 pin = spec->autocfg.speaker_pins[0];
14860 if (pin)
14861 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014862}
14863
14864#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14865#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14866
14867static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14868{
14869 struct alc_spec *spec = codec->spec;
14870 int i;
14871
14872 for (i = 0; i < AUTO_PIN_LAST; i++) {
14873 hda_nid_t nid = spec->autocfg.input_pins[i];
14874 if (alc861vd_is_input_pin(nid)) {
14875 snd_hda_codec_write(codec, nid, 0,
14876 AC_VERB_SET_PIN_WIDGET_CONTROL,
14877 i <= AUTO_PIN_FRONT_MIC ?
14878 PIN_VREF80 : PIN_IN);
14879 if (nid != ALC861VD_PIN_CD_NID)
14880 snd_hda_codec_write(codec, nid, 0,
14881 AC_VERB_SET_AMP_GAIN_MUTE,
14882 AMP_OUT_MUTE);
14883 }
14884 }
14885}
14886
Takashi Iwaif511b012008-08-15 16:46:42 +020014887#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14888
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014889#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14890#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14891
14892/* add playback controls from the parsed DAC table */
14893/* Based on ALC880 version. But ALC861VD has separate,
14894 * different NIDs for mute/unmute switch and volume control */
14895static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14896 const struct auto_pin_cfg *cfg)
14897{
14898 char name[32];
14899 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14900 hda_nid_t nid_v, nid_s;
14901 int i, err;
14902
14903 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014904 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014905 continue;
14906 nid_v = alc861vd_idx_to_mixer_vol(
14907 alc880_dac_to_idx(
14908 spec->multiout.dac_nids[i]));
14909 nid_s = alc861vd_idx_to_mixer_switch(
14910 alc880_dac_to_idx(
14911 spec->multiout.dac_nids[i]));
14912
14913 if (i == 2) {
14914 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014915 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14916 "Center Playback Volume",
14917 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14918 HDA_OUTPUT));
14919 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014920 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014921 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14922 "LFE Playback Volume",
14923 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14924 HDA_OUTPUT));
14925 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014926 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014927 err = add_control(spec, ALC_CTL_BIND_MUTE,
14928 "Center Playback Switch",
14929 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14930 HDA_INPUT));
14931 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014932 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014933 err = add_control(spec, ALC_CTL_BIND_MUTE,
14934 "LFE Playback Switch",
14935 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14936 HDA_INPUT));
14937 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014938 return err;
14939 } else {
14940 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014941 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14942 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14943 HDA_OUTPUT));
14944 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014945 return err;
14946 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014947 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014948 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014949 HDA_INPUT));
14950 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014951 return err;
14952 }
14953 }
14954 return 0;
14955}
14956
14957/* add playback controls for speaker and HP outputs */
14958/* Based on ALC880 version. But ALC861VD has separate,
14959 * different NIDs for mute/unmute switch and volume control */
14960static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14961 hda_nid_t pin, const char *pfx)
14962{
14963 hda_nid_t nid_v, nid_s;
14964 int err;
14965 char name[32];
14966
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014967 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014968 return 0;
14969
14970 if (alc880_is_fixed_pin(pin)) {
14971 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14972 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014973 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014974 spec->multiout.hp_nid = nid_v;
14975 else
14976 spec->multiout.extra_out_nid[0] = nid_v;
14977 /* control HP volume/switch on the output mixer amp */
14978 nid_v = alc861vd_idx_to_mixer_vol(
14979 alc880_fixed_pin_idx(pin));
14980 nid_s = alc861vd_idx_to_mixer_switch(
14981 alc880_fixed_pin_idx(pin));
14982
14983 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014984 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14985 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14986 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014987 return err;
14988 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014989 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14990 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14991 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014992 return err;
14993 } else if (alc880_is_multi_pin(pin)) {
14994 /* set manual connection */
14995 /* we have only a switch on HP-out PIN */
14996 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014997 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14998 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14999 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015000 return err;
15001 }
15002 return 0;
15003}
15004
15005/* parse the BIOS configuration and set up the alc_spec
15006 * return 1 if successful, 0 if the proper config is not found,
15007 * or a negative error code
15008 * Based on ALC880 version - had to change it to override
15009 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15010static int alc861vd_parse_auto_config(struct hda_codec *codec)
15011{
15012 struct alc_spec *spec = codec->spec;
15013 int err;
15014 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15015
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015016 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15017 alc861vd_ignore);
15018 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015019 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015020 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015021 return 0; /* can't find valid BIOS pin config */
15022
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015023 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15024 if (err < 0)
15025 return err;
15026 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15027 if (err < 0)
15028 return err;
15029 err = alc861vd_auto_create_extra_out(spec,
15030 spec->autocfg.speaker_pins[0],
15031 "Speaker");
15032 if (err < 0)
15033 return err;
15034 err = alc861vd_auto_create_extra_out(spec,
15035 spec->autocfg.hp_pins[0],
15036 "Headphone");
15037 if (err < 0)
15038 return err;
15039 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15040 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015041 return err;
15042
15043 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15044
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015045 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015046 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15047
Takashi Iwai603c4012008-07-30 15:01:44 +020015048 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015049 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015050
Takashi Iwaid88897e2008-10-31 15:01:37 +010015051 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015052
15053 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015054 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015055
Takashi Iwai776e1842007-08-29 15:07:11 +020015056 err = alc_auto_add_mic_boost(codec);
15057 if (err < 0)
15058 return err;
15059
Takashi Iwaie044c392008-10-27 16:56:24 +010015060 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015061 return 1;
15062}
15063
15064/* additional initialization for auto-configuration model */
15065static void alc861vd_auto_init(struct hda_codec *codec)
15066{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015067 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015068 alc861vd_auto_init_multi_out(codec);
15069 alc861vd_auto_init_hp_out(codec);
15070 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015071 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015072 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015073 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015074}
15075
15076static int patch_alc861vd(struct hda_codec *codec)
15077{
15078 struct alc_spec *spec;
15079 int err, board_config;
15080
15081 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15082 if (spec == NULL)
15083 return -ENOMEM;
15084
15085 codec->spec = spec;
15086
15087 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15088 alc861vd_models,
15089 alc861vd_cfg_tbl);
15090
15091 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15092 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
15093 "ALC861VD, trying auto-probe from BIOS...\n");
15094 board_config = ALC861VD_AUTO;
15095 }
15096
15097 if (board_config == ALC861VD_AUTO) {
15098 /* automatic parse from the BIOS config */
15099 err = alc861vd_parse_auto_config(codec);
15100 if (err < 0) {
15101 alc_free(codec);
15102 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015103 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015104 printk(KERN_INFO
15105 "hda_codec: Cannot set up configuration "
15106 "from BIOS. Using base mode...\n");
15107 board_config = ALC861VD_3ST;
15108 }
15109 }
15110
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015111 err = snd_hda_attach_beep_device(codec, 0x23);
15112 if (err < 0) {
15113 alc_free(codec);
15114 return err;
15115 }
15116
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015117 if (board_config != ALC861VD_AUTO)
15118 setup_preset(spec, &alc861vd_presets[board_config]);
15119
Kailang Yang2f893282008-05-27 12:14:47 +020015120 if (codec->vendor_id == 0x10ec0660) {
15121 spec->stream_name_analog = "ALC660-VD Analog";
15122 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020015123 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015124 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015125 } else {
15126 spec->stream_name_analog = "ALC861VD Analog";
15127 spec->stream_name_digital = "ALC861VD Digital";
15128 }
15129
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015130 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15131 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15132
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015133 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15134 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15135
15136 spec->adc_nids = alc861vd_adc_nids;
15137 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015138 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015139 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015140
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015141 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015142 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015143
Takashi Iwai2134ea42008-01-10 16:53:55 +010015144 spec->vmaster_nid = 0x02;
15145
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015146 codec->patch_ops = alc_patch_ops;
15147
15148 if (board_config == ALC861VD_AUTO)
15149 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015150#ifdef CONFIG_SND_HDA_POWER_SAVE
15151 if (!spec->loopback.amplist)
15152 spec->loopback.amplist = alc861vd_loopbacks;
15153#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015154 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015155
15156 return 0;
15157}
15158
15159/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015160 * ALC662 support
15161 *
15162 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15163 * configuration. Each pin widget can choose any input DACs and a mixer.
15164 * Each ADC is connected from a mixer of all inputs. This makes possible
15165 * 6-channel independent captures.
15166 *
15167 * In addition, an independent DAC for the multi-playback (not used in this
15168 * driver yet).
15169 */
15170#define ALC662_DIGOUT_NID 0x06
15171#define ALC662_DIGIN_NID 0x0a
15172
15173static hda_nid_t alc662_dac_nids[4] = {
15174 /* front, rear, clfe, rear_surr */
15175 0x02, 0x03, 0x04
15176};
15177
15178static hda_nid_t alc662_adc_nids[1] = {
15179 /* ADC1-2 */
15180 0x09,
15181};
Takashi Iwaie1406342008-02-11 18:32:32 +010015182
Kailang Yang77a261b2008-02-19 11:38:05 +010015183static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010015184
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015185/* input MUX */
15186/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015187static struct hda_input_mux alc662_capture_source = {
15188 .num_items = 4,
15189 .items = {
15190 { "Mic", 0x0 },
15191 { "Front Mic", 0x1 },
15192 { "Line", 0x2 },
15193 { "CD", 0x4 },
15194 },
15195};
15196
15197static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15198 .num_items = 2,
15199 .items = {
15200 { "Mic", 0x1 },
15201 { "Line", 0x2 },
15202 },
15203};
Kailang Yang291702f2007-10-16 14:28:03 +020015204
15205static struct hda_input_mux alc662_eeepc_capture_source = {
15206 .num_items = 2,
15207 .items = {
15208 { "i-Mic", 0x1 },
15209 { "e-Mic", 0x0 },
15210 },
15211};
15212
Kailang Yang6dda9f42008-05-27 12:05:31 +020015213static struct hda_input_mux alc663_capture_source = {
15214 .num_items = 3,
15215 .items = {
15216 { "Mic", 0x0 },
15217 { "Front Mic", 0x1 },
15218 { "Line", 0x2 },
15219 },
15220};
15221
15222static struct hda_input_mux alc663_m51va_capture_source = {
15223 .num_items = 2,
15224 .items = {
15225 { "Ext-Mic", 0x0 },
15226 { "D-Mic", 0x9 },
15227 },
15228};
15229
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015230/*
15231 * 2ch mode
15232 */
15233static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15234 { 2, NULL }
15235};
15236
15237/*
15238 * 2ch mode
15239 */
15240static struct hda_verb alc662_3ST_ch2_init[] = {
15241 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15242 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15243 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15244 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15245 { } /* end */
15246};
15247
15248/*
15249 * 6ch mode
15250 */
15251static struct hda_verb alc662_3ST_ch6_init[] = {
15252 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15253 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15254 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15255 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15256 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15257 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15258 { } /* end */
15259};
15260
15261static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15262 { 2, alc662_3ST_ch2_init },
15263 { 6, alc662_3ST_ch6_init },
15264};
15265
15266/*
15267 * 2ch mode
15268 */
15269static struct hda_verb alc662_sixstack_ch6_init[] = {
15270 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15271 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15272 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15273 { } /* end */
15274};
15275
15276/*
15277 * 6ch mode
15278 */
15279static struct hda_verb alc662_sixstack_ch8_init[] = {
15280 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15281 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15282 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15283 { } /* end */
15284};
15285
15286static struct hda_channel_mode alc662_5stack_modes[2] = {
15287 { 2, alc662_sixstack_ch6_init },
15288 { 6, alc662_sixstack_ch8_init },
15289};
15290
15291/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15292 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15293 */
15294
15295static struct snd_kcontrol_new alc662_base_mixer[] = {
15296 /* output mixer control */
15297 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015298 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015299 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015300 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015301 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15302 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015303 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15304 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015305 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15306
15307 /*Input mixer control */
15308 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15309 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15310 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15311 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15312 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15313 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15314 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15315 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015316 { } /* end */
15317};
15318
15319static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15320 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015321 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015322 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15323 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15324 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15325 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15326 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15327 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15328 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15329 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15330 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015331 { } /* end */
15332};
15333
15334static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15335 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015336 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015337 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015338 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015339 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15340 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015341 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15342 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015343 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15344 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15345 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15346 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15347 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15349 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15350 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15351 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015352 { } /* end */
15353};
15354
15355static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15356 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15357 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015358 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15359 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015360 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15361 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15362 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15363 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15364 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015365 { } /* end */
15366};
15367
Kailang Yang291702f2007-10-16 14:28:03 +020015368static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015369 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015370
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015371 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15372 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015373
15374 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15375 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15376 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15377
15378 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15379 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15380 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15381 { } /* end */
15382};
15383
Kailang Yang8c427222008-01-10 13:03:59 +010015384static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015385 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15386 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015387 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15388 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15389 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15390 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15391 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15392 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015393 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015394 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15395 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15396 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15397 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15398 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15399 { } /* end */
15400};
15401
Kailang Yangf1d4e282008-08-26 14:03:29 +020015402static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15403 .ops = &snd_hda_bind_vol,
15404 .values = {
15405 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15406 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15407 0
15408 },
15409};
15410
15411static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15412 .ops = &snd_hda_bind_sw,
15413 .values = {
15414 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15415 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15416 0
15417 },
15418};
15419
Kailang Yang6dda9f42008-05-27 12:05:31 +020015420static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015421 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15422 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15423 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15424 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15425 { } /* end */
15426};
15427
15428static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15429 .ops = &snd_hda_bind_sw,
15430 .values = {
15431 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15432 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15433 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15434 0
15435 },
15436};
15437
15438static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15439 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15440 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15441 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15442 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15443 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15444 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15445
15446 { } /* end */
15447};
15448
15449static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15450 .ops = &snd_hda_bind_sw,
15451 .values = {
15452 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15453 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15454 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15455 0
15456 },
15457};
15458
15459static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15460 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15461 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15464 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15465 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15466 { } /* end */
15467};
15468
15469static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015470 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15471 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015472 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15473 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15474 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15475 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15476 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15477 { } /* end */
15478};
15479
15480static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15481 .ops = &snd_hda_bind_vol,
15482 .values = {
15483 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15484 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15485 0
15486 },
15487};
15488
15489static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15490 .ops = &snd_hda_bind_sw,
15491 .values = {
15492 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15493 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15494 0
15495 },
15496};
15497
15498static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15499 HDA_BIND_VOL("Master Playback Volume",
15500 &alc663_asus_two_bind_master_vol),
15501 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15502 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015503 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15504 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15505 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015506 { } /* end */
15507};
15508
15509static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15510 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15511 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15512 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15513 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15515 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015516 { } /* end */
15517};
15518
15519static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15520 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15521 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15522 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15523 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15524 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15525
15526 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15527 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15528 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15529 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15530 { } /* end */
15531};
15532
15533static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15534 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15535 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15536 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15537
15538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15540 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15541 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15542 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15543 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15544 { } /* end */
15545};
15546
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015547static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15548 {
15549 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15550 .name = "Channel Mode",
15551 .info = alc_ch_mode_info,
15552 .get = alc_ch_mode_get,
15553 .put = alc_ch_mode_put,
15554 },
15555 { } /* end */
15556};
15557
15558static struct hda_verb alc662_init_verbs[] = {
15559 /* ADC: mute amp left and right */
15560 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15561 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15562 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15563
Takashi Iwaicb53c622007-08-10 17:21:45 +020015564 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15565 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15566 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15567 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015569
Kailang Yangb60dd392007-09-20 12:50:29 +020015570 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15571 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15572 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15573 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15574 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15575 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015576
15577 /* Front Pin: output 0 (0x0c) */
15578 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15579 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15580
15581 /* Rear Pin: output 1 (0x0d) */
15582 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15583 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15584
15585 /* CLFE Pin: output 2 (0x0e) */
15586 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15587 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15588
15589 /* Mic (rear) pin: input vref at 80% */
15590 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15591 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15592 /* Front Mic pin: input vref at 80% */
15593 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15594 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15595 /* Line In pin: input */
15596 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15597 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15598 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15599 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15600 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15601 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15602 /* CD pin widget for input */
15603 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15604
15605 /* FIXME: use matrix-type input source selection */
15606 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15607 /* Input mixer */
15608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15611 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015612
15613 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15614 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015617
15618 /* always trun on EAPD */
15619 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15620 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15621
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015622 { }
15623};
15624
15625static struct hda_verb alc662_sue_init_verbs[] = {
15626 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15627 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015628 {}
15629};
15630
15631static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15632 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15633 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15634 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015635};
15636
Kailang Yang8c427222008-01-10 13:03:59 +010015637/* Set Unsolicited Event*/
15638static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15639 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15640 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15641 {}
15642};
15643
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015644/*
15645 * generic initialization of ADC, input mixers and output mixers
15646 */
15647static struct hda_verb alc662_auto_init_verbs[] = {
15648 /*
15649 * Unmute ADC and set the default input to mic-in
15650 */
15651 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15652 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15653
15654 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15655 * mixer widget
15656 * Note: PASD motherboards uses the Line In 2 as the input for front
15657 * panel mic (mic 2)
15658 */
15659 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015660 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015665
15666 /*
15667 * Set up output mixers (0x0c - 0x0f)
15668 */
15669 /* set vol=0 to output mixers */
15670 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15671 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15672 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15673
15674 /* set up input amps for analog loopback */
15675 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015676 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15678 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15679 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15680 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15681 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015682
15683
15684 /* FIXME: use matrix-type input source selection */
15685 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15686 /* Input mixer */
15687 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015688 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015689 { }
15690};
15691
Takashi Iwai24fb9172008-09-02 14:48:20 +020015692/* additional verbs for ALC663 */
15693static struct hda_verb alc663_auto_init_verbs[] = {
15694 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15695 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15696 { }
15697};
15698
Kailang Yang6dda9f42008-05-27 12:05:31 +020015699static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15701 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015702 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15703 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015704 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15705 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15706 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015707 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15708 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15709 {}
15710};
15711
Kailang Yangf1d4e282008-08-26 14:03:29 +020015712static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15713 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15714 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15715 {0x21, 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 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15720 {}
15721};
15722
15723static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15724 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15725 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15726 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15727 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15730 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15731 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15732 {}
15733};
15734
15735static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15736 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15738 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15739 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15740 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15741 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15742 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15743 {}
15744};
15745
15746static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15747 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15748 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15749 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15750 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15753 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15754 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15755 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15756 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15757 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15758 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15759 {}
15760};
15761
15762static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15763 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15764 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15765 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15766 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15767 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15769 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15772 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15773 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15774 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15775 {}
15776};
15777
Kailang Yang6dda9f42008-05-27 12:05:31 +020015778static struct hda_verb alc663_g71v_init_verbs[] = {
15779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15780 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15781 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15782
15783 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15784 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15785 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15786
15787 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15788 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15789 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15790 {}
15791};
15792
15793static struct hda_verb alc663_g50v_init_verbs[] = {
15794 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15795 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15796 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15797
15798 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15799 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15800 {}
15801};
15802
Kailang Yangf1d4e282008-08-26 14:03:29 +020015803static struct hda_verb alc662_ecs_init_verbs[] = {
15804 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15805 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15806 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15807 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15808 {}
15809};
15810
Kailang Yangf1d4e282008-08-26 14:03:29 +020015811static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15812 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15813 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15814 { } /* end */
15815};
15816
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015817static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15818{
15819 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015820 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015821
15822 present = snd_hda_codec_read(codec, 0x14, 0,
15823 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015824 bits = present ? HDA_AMP_MUTE : 0;
15825 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15826 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015827}
15828
15829static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15830{
15831 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015832 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015833
15834 present = snd_hda_codec_read(codec, 0x1b, 0,
15835 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015836 bits = present ? HDA_AMP_MUTE : 0;
15837 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15838 HDA_AMP_MUTE, bits);
15839 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15840 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015841}
15842
15843static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15844 unsigned int res)
15845{
15846 if ((res >> 26) == ALC880_HP_EVENT)
15847 alc662_lenovo_101e_all_automute(codec);
15848 if ((res >> 26) == ALC880_FRONT_EVENT)
15849 alc662_lenovo_101e_ispeaker_automute(codec);
15850}
15851
Kailang Yang291702f2007-10-16 14:28:03 +020015852static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15853{
15854 unsigned int present;
15855
15856 present = snd_hda_codec_read(codec, 0x18, 0,
15857 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15858 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15859 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15860 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15861 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15862 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15863 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15864 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15865 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15866}
15867
15868/* unsolicited event for HP jack sensing */
15869static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15870 unsigned int res)
15871{
15872 if ((res >> 26) == ALC880_HP_EVENT)
15873 alc262_hippo1_automute( codec );
15874
15875 if ((res >> 26) == ALC880_MIC_EVENT)
15876 alc662_eeepc_mic_automute(codec);
15877}
15878
15879static void alc662_eeepc_inithook(struct hda_codec *codec)
15880{
15881 alc262_hippo1_automute( codec );
15882 alc662_eeepc_mic_automute(codec);
15883}
15884
Kailang Yang8c427222008-01-10 13:03:59 +010015885static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15886{
15887 unsigned int mute;
15888 unsigned int present;
15889
15890 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15891 present = snd_hda_codec_read(codec, 0x14, 0,
15892 AC_VERB_GET_PIN_SENSE, 0);
15893 present = (present & 0x80000000) != 0;
15894 if (present) {
15895 /* mute internal speaker */
15896 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015897 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015898 } else {
15899 /* unmute internal speaker if necessary */
15900 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15901 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015902 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015903 }
15904}
15905
15906/* unsolicited event for HP jack sensing */
15907static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15908 unsigned int res)
15909{
15910 if ((res >> 26) == ALC880_HP_EVENT)
15911 alc662_eeepc_ep20_automute(codec);
15912}
15913
15914static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15915{
15916 alc662_eeepc_ep20_automute(codec);
15917}
15918
Kailang Yang6dda9f42008-05-27 12:05:31 +020015919static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15920{
15921 unsigned int present;
15922 unsigned char bits;
15923
15924 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015925 AC_VERB_GET_PIN_SENSE, 0)
15926 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015927 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015928 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15929 AMP_IN_MUTE(0), bits);
15930 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15931 AMP_IN_MUTE(0), bits);
15932}
15933
15934static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15935{
15936 unsigned int present;
15937 unsigned char bits;
15938
15939 present = snd_hda_codec_read(codec, 0x21, 0,
15940 AC_VERB_GET_PIN_SENSE, 0)
15941 & AC_PINSENSE_PRESENCE;
15942 bits = present ? HDA_AMP_MUTE : 0;
15943 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15944 AMP_IN_MUTE(0), bits);
15945 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15946 AMP_IN_MUTE(0), bits);
15947 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15948 AMP_IN_MUTE(0), bits);
15949 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15950 AMP_IN_MUTE(0), bits);
15951}
15952
15953static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15954{
15955 unsigned int present;
15956 unsigned char bits;
15957
15958 present = snd_hda_codec_read(codec, 0x15, 0,
15959 AC_VERB_GET_PIN_SENSE, 0)
15960 & AC_PINSENSE_PRESENCE;
15961 bits = present ? HDA_AMP_MUTE : 0;
15962 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15963 AMP_IN_MUTE(0), bits);
15964 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15965 AMP_IN_MUTE(0), bits);
15966 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15967 AMP_IN_MUTE(0), bits);
15968 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15969 AMP_IN_MUTE(0), bits);
15970}
15971
15972static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15973{
15974 unsigned int present;
15975 unsigned char bits;
15976
15977 present = snd_hda_codec_read(codec, 0x1b, 0,
15978 AC_VERB_GET_PIN_SENSE, 0)
15979 & AC_PINSENSE_PRESENCE;
15980 bits = present ? 0 : PIN_OUT;
15981 snd_hda_codec_write(codec, 0x14, 0,
15982 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15983}
15984
15985static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15986{
15987 unsigned int present1, present2;
15988
15989 present1 = snd_hda_codec_read(codec, 0x21, 0,
15990 AC_VERB_GET_PIN_SENSE, 0)
15991 & AC_PINSENSE_PRESENCE;
15992 present2 = snd_hda_codec_read(codec, 0x15, 0,
15993 AC_VERB_GET_PIN_SENSE, 0)
15994 & AC_PINSENSE_PRESENCE;
15995
15996 if (present1 || present2) {
15997 snd_hda_codec_write_cache(codec, 0x14, 0,
15998 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15999 } else {
16000 snd_hda_codec_write_cache(codec, 0x14, 0,
16001 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16002 }
16003}
16004
16005static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16006{
16007 unsigned int present1, present2;
16008
16009 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16010 AC_VERB_GET_PIN_SENSE, 0)
16011 & AC_PINSENSE_PRESENCE;
16012 present2 = snd_hda_codec_read(codec, 0x15, 0,
16013 AC_VERB_GET_PIN_SENSE, 0)
16014 & AC_PINSENSE_PRESENCE;
16015
16016 if (present1 || present2) {
16017 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16018 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16019 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16020 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16021 } else {
16022 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16023 AMP_IN_MUTE(0), 0);
16024 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16025 AMP_IN_MUTE(0), 0);
16026 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016027}
16028
16029static void alc663_m51va_mic_automute(struct hda_codec *codec)
16030{
16031 unsigned int present;
16032
16033 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016034 AC_VERB_GET_PIN_SENSE, 0)
16035 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016036 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016037 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016038 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016039 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016040 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016041 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016042 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016043 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016044}
16045
16046static void alc663_m51va_unsol_event(struct hda_codec *codec,
16047 unsigned int res)
16048{
16049 switch (res >> 26) {
16050 case ALC880_HP_EVENT:
16051 alc663_m51va_speaker_automute(codec);
16052 break;
16053 case ALC880_MIC_EVENT:
16054 alc663_m51va_mic_automute(codec);
16055 break;
16056 }
16057}
16058
16059static void alc663_m51va_inithook(struct hda_codec *codec)
16060{
16061 alc663_m51va_speaker_automute(codec);
16062 alc663_m51va_mic_automute(codec);
16063}
16064
Kailang Yangf1d4e282008-08-26 14:03:29 +020016065/* ***************** Mode1 ******************************/
16066static void alc663_mode1_unsol_event(struct hda_codec *codec,
16067 unsigned int res)
16068{
16069 switch (res >> 26) {
16070 case ALC880_HP_EVENT:
16071 alc663_m51va_speaker_automute(codec);
16072 break;
16073 case ALC880_MIC_EVENT:
16074 alc662_eeepc_mic_automute(codec);
16075 break;
16076 }
16077}
16078
16079static void alc663_mode1_inithook(struct hda_codec *codec)
16080{
16081 alc663_m51va_speaker_automute(codec);
16082 alc662_eeepc_mic_automute(codec);
16083}
16084/* ***************** Mode2 ******************************/
16085static void alc662_mode2_unsol_event(struct hda_codec *codec,
16086 unsigned int res)
16087{
16088 switch (res >> 26) {
16089 case ALC880_HP_EVENT:
16090 alc662_f5z_speaker_automute(codec);
16091 break;
16092 case ALC880_MIC_EVENT:
16093 alc662_eeepc_mic_automute(codec);
16094 break;
16095 }
16096}
16097
16098static void alc662_mode2_inithook(struct hda_codec *codec)
16099{
16100 alc662_f5z_speaker_automute(codec);
16101 alc662_eeepc_mic_automute(codec);
16102}
16103/* ***************** Mode3 ******************************/
16104static void alc663_mode3_unsol_event(struct hda_codec *codec,
16105 unsigned int res)
16106{
16107 switch (res >> 26) {
16108 case ALC880_HP_EVENT:
16109 alc663_two_hp_m1_speaker_automute(codec);
16110 break;
16111 case ALC880_MIC_EVENT:
16112 alc662_eeepc_mic_automute(codec);
16113 break;
16114 }
16115}
16116
16117static void alc663_mode3_inithook(struct hda_codec *codec)
16118{
16119 alc663_two_hp_m1_speaker_automute(codec);
16120 alc662_eeepc_mic_automute(codec);
16121}
16122/* ***************** Mode4 ******************************/
16123static void alc663_mode4_unsol_event(struct hda_codec *codec,
16124 unsigned int res)
16125{
16126 switch (res >> 26) {
16127 case ALC880_HP_EVENT:
16128 alc663_21jd_two_speaker_automute(codec);
16129 break;
16130 case ALC880_MIC_EVENT:
16131 alc662_eeepc_mic_automute(codec);
16132 break;
16133 }
16134}
16135
16136static void alc663_mode4_inithook(struct hda_codec *codec)
16137{
16138 alc663_21jd_two_speaker_automute(codec);
16139 alc662_eeepc_mic_automute(codec);
16140}
16141/* ***************** Mode5 ******************************/
16142static void alc663_mode5_unsol_event(struct hda_codec *codec,
16143 unsigned int res)
16144{
16145 switch (res >> 26) {
16146 case ALC880_HP_EVENT:
16147 alc663_15jd_two_speaker_automute(codec);
16148 break;
16149 case ALC880_MIC_EVENT:
16150 alc662_eeepc_mic_automute(codec);
16151 break;
16152 }
16153}
16154
16155static void alc663_mode5_inithook(struct hda_codec *codec)
16156{
16157 alc663_15jd_two_speaker_automute(codec);
16158 alc662_eeepc_mic_automute(codec);
16159}
16160/* ***************** Mode6 ******************************/
16161static void alc663_mode6_unsol_event(struct hda_codec *codec,
16162 unsigned int res)
16163{
16164 switch (res >> 26) {
16165 case ALC880_HP_EVENT:
16166 alc663_two_hp_m2_speaker_automute(codec);
16167 break;
16168 case ALC880_MIC_EVENT:
16169 alc662_eeepc_mic_automute(codec);
16170 break;
16171 }
16172}
16173
16174static void alc663_mode6_inithook(struct hda_codec *codec)
16175{
16176 alc663_two_hp_m2_speaker_automute(codec);
16177 alc662_eeepc_mic_automute(codec);
16178}
16179
Kailang Yang6dda9f42008-05-27 12:05:31 +020016180static void alc663_g71v_hp_automute(struct hda_codec *codec)
16181{
16182 unsigned int present;
16183 unsigned char bits;
16184
16185 present = snd_hda_codec_read(codec, 0x21, 0,
16186 AC_VERB_GET_PIN_SENSE, 0)
16187 & AC_PINSENSE_PRESENCE;
16188 bits = present ? HDA_AMP_MUTE : 0;
16189 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16190 HDA_AMP_MUTE, bits);
16191 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16192 HDA_AMP_MUTE, bits);
16193}
16194
16195static void alc663_g71v_front_automute(struct hda_codec *codec)
16196{
16197 unsigned int present;
16198 unsigned char bits;
16199
16200 present = snd_hda_codec_read(codec, 0x15, 0,
16201 AC_VERB_GET_PIN_SENSE, 0)
16202 & AC_PINSENSE_PRESENCE;
16203 bits = present ? HDA_AMP_MUTE : 0;
16204 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16205 HDA_AMP_MUTE, bits);
16206}
16207
16208static void alc663_g71v_unsol_event(struct hda_codec *codec,
16209 unsigned int res)
16210{
16211 switch (res >> 26) {
16212 case ALC880_HP_EVENT:
16213 alc663_g71v_hp_automute(codec);
16214 break;
16215 case ALC880_FRONT_EVENT:
16216 alc663_g71v_front_automute(codec);
16217 break;
16218 case ALC880_MIC_EVENT:
16219 alc662_eeepc_mic_automute(codec);
16220 break;
16221 }
16222}
16223
16224static void alc663_g71v_inithook(struct hda_codec *codec)
16225{
16226 alc663_g71v_front_automute(codec);
16227 alc663_g71v_hp_automute(codec);
16228 alc662_eeepc_mic_automute(codec);
16229}
16230
16231static void alc663_g50v_unsol_event(struct hda_codec *codec,
16232 unsigned int res)
16233{
16234 switch (res >> 26) {
16235 case ALC880_HP_EVENT:
16236 alc663_m51va_speaker_automute(codec);
16237 break;
16238 case ALC880_MIC_EVENT:
16239 alc662_eeepc_mic_automute(codec);
16240 break;
16241 }
16242}
16243
16244static void alc663_g50v_inithook(struct hda_codec *codec)
16245{
16246 alc663_m51va_speaker_automute(codec);
16247 alc662_eeepc_mic_automute(codec);
16248}
16249
Kailang Yangf1d4e282008-08-26 14:03:29 +020016250/* bind hp and internal speaker mute (with plug check) */
16251static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16252 struct snd_ctl_elem_value *ucontrol)
16253{
16254 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16255 long *valp = ucontrol->value.integer.value;
16256 int change;
16257
16258 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16259 HDA_AMP_MUTE,
16260 valp[0] ? 0 : HDA_AMP_MUTE);
16261 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16262 HDA_AMP_MUTE,
16263 valp[1] ? 0 : HDA_AMP_MUTE);
16264 if (change)
16265 alc262_hippo1_automute(codec);
16266 return change;
16267}
16268
16269static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16270 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16271 {
16272 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16273 .name = "Master Playback Switch",
16274 .info = snd_hda_mixer_amp_switch_info,
16275 .get = snd_hda_mixer_amp_switch_get,
16276 .put = alc662_ecs_master_sw_put,
16277 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16278 },
16279
16280 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16281 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16282 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16283
16284 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16285 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16286 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16287 { } /* end */
16288};
16289
Takashi Iwaicb53c622007-08-10 17:21:45 +020016290#ifdef CONFIG_SND_HDA_POWER_SAVE
16291#define alc662_loopbacks alc880_loopbacks
16292#endif
16293
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016294
16295/* pcm configuration: identiacal with ALC880 */
16296#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16297#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16298#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16299#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16300
16301/*
16302 * configuration and preset
16303 */
16304static const char *alc662_models[ALC662_MODEL_LAST] = {
16305 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16306 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16307 [ALC662_3ST_6ch] = "3stack-6ch",
16308 [ALC662_5ST_DIG] = "6stack-dig",
16309 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016310 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016311 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016312 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016313 [ALC663_ASUS_M51VA] = "m51va",
16314 [ALC663_ASUS_G71V] = "g71v",
16315 [ALC663_ASUS_H13] = "h13",
16316 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016317 [ALC663_ASUS_MODE1] = "asus-mode1",
16318 [ALC662_ASUS_MODE2] = "asus-mode2",
16319 [ALC663_ASUS_MODE3] = "asus-mode3",
16320 [ALC663_ASUS_MODE4] = "asus-mode4",
16321 [ALC663_ASUS_MODE5] = "asus-mode5",
16322 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016323 [ALC662_AUTO] = "auto",
16324};
16325
16326static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016327 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16328 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16329 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16330 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16331 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16332 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16333 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16334 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16335 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16336 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16337 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16338 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16339 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16340 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16341 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16342 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16343 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16344 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16345 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016346 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016347 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16348 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16349 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16350 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16351 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16352 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16353 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16354 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16355 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016356 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016357 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16358 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16359 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16360 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16361 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016362 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016363 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016364 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016365 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016366 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16367 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016368 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16369 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016370 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016371 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016372 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016373 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016374 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16375 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016376 {}
16377};
16378
16379static struct alc_config_preset alc662_presets[] = {
16380 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016381 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016382 .init_verbs = { alc662_init_verbs },
16383 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16384 .dac_nids = alc662_dac_nids,
16385 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016386 .dig_in_nid = ALC662_DIGIN_NID,
16387 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16388 .channel_mode = alc662_3ST_2ch_modes,
16389 .input_mux = &alc662_capture_source,
16390 },
16391 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016392 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016393 .init_verbs = { alc662_init_verbs },
16394 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16395 .dac_nids = alc662_dac_nids,
16396 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016397 .dig_in_nid = ALC662_DIGIN_NID,
16398 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16399 .channel_mode = alc662_3ST_6ch_modes,
16400 .need_dac_fix = 1,
16401 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016402 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016403 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016404 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016405 .init_verbs = { alc662_init_verbs },
16406 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16407 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016408 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16409 .channel_mode = alc662_3ST_6ch_modes,
16410 .need_dac_fix = 1,
16411 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016412 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016413 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016414 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016415 .init_verbs = { alc662_init_verbs },
16416 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16417 .dac_nids = alc662_dac_nids,
16418 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016419 .dig_in_nid = ALC662_DIGIN_NID,
16420 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16421 .channel_mode = alc662_5stack_modes,
16422 .input_mux = &alc662_capture_source,
16423 },
16424 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016425 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016426 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16427 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16428 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016429 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16430 .channel_mode = alc662_3ST_2ch_modes,
16431 .input_mux = &alc662_lenovo_101e_capture_source,
16432 .unsol_event = alc662_lenovo_101e_unsol_event,
16433 .init_hook = alc662_lenovo_101e_all_automute,
16434 },
Kailang Yang291702f2007-10-16 14:28:03 +020016435 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016436 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016437 .init_verbs = { alc662_init_verbs,
16438 alc662_eeepc_sue_init_verbs },
16439 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16440 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016441 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16442 .channel_mode = alc662_3ST_2ch_modes,
16443 .input_mux = &alc662_eeepc_capture_source,
16444 .unsol_event = alc662_eeepc_unsol_event,
16445 .init_hook = alc662_eeepc_inithook,
16446 },
Kailang Yang8c427222008-01-10 13:03:59 +010016447 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016448 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016449 alc662_chmode_mixer },
16450 .init_verbs = { alc662_init_verbs,
16451 alc662_eeepc_ep20_sue_init_verbs },
16452 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16453 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016454 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16455 .channel_mode = alc662_3ST_6ch_modes,
16456 .input_mux = &alc662_lenovo_101e_capture_source,
16457 .unsol_event = alc662_eeepc_ep20_unsol_event,
16458 .init_hook = alc662_eeepc_ep20_inithook,
16459 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016460 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016461 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016462 .init_verbs = { alc662_init_verbs,
16463 alc662_ecs_init_verbs },
16464 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16465 .dac_nids = alc662_dac_nids,
16466 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16467 .channel_mode = alc662_3ST_2ch_modes,
16468 .input_mux = &alc662_eeepc_capture_source,
16469 .unsol_event = alc662_eeepc_unsol_event,
16470 .init_hook = alc662_eeepc_inithook,
16471 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016472 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016473 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016474 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16475 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16476 .dac_nids = alc662_dac_nids,
16477 .dig_out_nid = ALC662_DIGOUT_NID,
16478 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16479 .channel_mode = alc662_3ST_2ch_modes,
16480 .input_mux = &alc663_m51va_capture_source,
16481 .unsol_event = alc663_m51va_unsol_event,
16482 .init_hook = alc663_m51va_inithook,
16483 },
16484 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016485 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016486 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16487 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16488 .dac_nids = alc662_dac_nids,
16489 .dig_out_nid = ALC662_DIGOUT_NID,
16490 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16491 .channel_mode = alc662_3ST_2ch_modes,
16492 .input_mux = &alc662_eeepc_capture_source,
16493 .unsol_event = alc663_g71v_unsol_event,
16494 .init_hook = alc663_g71v_inithook,
16495 },
16496 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016497 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016498 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16499 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16500 .dac_nids = alc662_dac_nids,
16501 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16502 .channel_mode = alc662_3ST_2ch_modes,
16503 .input_mux = &alc663_m51va_capture_source,
16504 .unsol_event = alc663_m51va_unsol_event,
16505 .init_hook = alc663_m51va_inithook,
16506 },
16507 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016508 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016509 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16510 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16511 .dac_nids = alc662_dac_nids,
16512 .dig_out_nid = ALC662_DIGOUT_NID,
16513 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16514 .channel_mode = alc662_3ST_6ch_modes,
16515 .input_mux = &alc663_capture_source,
16516 .unsol_event = alc663_g50v_unsol_event,
16517 .init_hook = alc663_g50v_inithook,
16518 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016519 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016520 .mixers = { alc663_m51va_mixer },
16521 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016522 .init_verbs = { alc662_init_verbs,
16523 alc663_21jd_amic_init_verbs },
16524 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16525 .hp_nid = 0x03,
16526 .dac_nids = alc662_dac_nids,
16527 .dig_out_nid = ALC662_DIGOUT_NID,
16528 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16529 .channel_mode = alc662_3ST_2ch_modes,
16530 .input_mux = &alc662_eeepc_capture_source,
16531 .unsol_event = alc663_mode1_unsol_event,
16532 .init_hook = alc663_mode1_inithook,
16533 },
16534 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016535 .mixers = { alc662_1bjd_mixer },
16536 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016537 .init_verbs = { alc662_init_verbs,
16538 alc662_1bjd_amic_init_verbs },
16539 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16540 .dac_nids = alc662_dac_nids,
16541 .dig_out_nid = ALC662_DIGOUT_NID,
16542 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16543 .channel_mode = alc662_3ST_2ch_modes,
16544 .input_mux = &alc662_eeepc_capture_source,
16545 .unsol_event = alc662_mode2_unsol_event,
16546 .init_hook = alc662_mode2_inithook,
16547 },
16548 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016549 .mixers = { alc663_two_hp_m1_mixer },
16550 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016551 .init_verbs = { alc662_init_verbs,
16552 alc663_two_hp_amic_m1_init_verbs },
16553 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16554 .hp_nid = 0x03,
16555 .dac_nids = alc662_dac_nids,
16556 .dig_out_nid = ALC662_DIGOUT_NID,
16557 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16558 .channel_mode = alc662_3ST_2ch_modes,
16559 .input_mux = &alc662_eeepc_capture_source,
16560 .unsol_event = alc663_mode3_unsol_event,
16561 .init_hook = alc663_mode3_inithook,
16562 },
16563 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016564 .mixers = { alc663_asus_21jd_clfe_mixer },
16565 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016566 .init_verbs = { alc662_init_verbs,
16567 alc663_21jd_amic_init_verbs},
16568 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16569 .hp_nid = 0x03,
16570 .dac_nids = alc662_dac_nids,
16571 .dig_out_nid = ALC662_DIGOUT_NID,
16572 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16573 .channel_mode = alc662_3ST_2ch_modes,
16574 .input_mux = &alc662_eeepc_capture_source,
16575 .unsol_event = alc663_mode4_unsol_event,
16576 .init_hook = alc663_mode4_inithook,
16577 },
16578 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016579 .mixers = { alc663_asus_15jd_clfe_mixer },
16580 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016581 .init_verbs = { alc662_init_verbs,
16582 alc663_15jd_amic_init_verbs },
16583 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16584 .hp_nid = 0x03,
16585 .dac_nids = alc662_dac_nids,
16586 .dig_out_nid = ALC662_DIGOUT_NID,
16587 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16588 .channel_mode = alc662_3ST_2ch_modes,
16589 .input_mux = &alc662_eeepc_capture_source,
16590 .unsol_event = alc663_mode5_unsol_event,
16591 .init_hook = alc663_mode5_inithook,
16592 },
16593 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016594 .mixers = { alc663_two_hp_m2_mixer },
16595 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016596 .init_verbs = { alc662_init_verbs,
16597 alc663_two_hp_amic_m2_init_verbs },
16598 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16599 .hp_nid = 0x03,
16600 .dac_nids = alc662_dac_nids,
16601 .dig_out_nid = ALC662_DIGOUT_NID,
16602 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16603 .channel_mode = alc662_3ST_2ch_modes,
16604 .input_mux = &alc662_eeepc_capture_source,
16605 .unsol_event = alc663_mode6_unsol_event,
16606 .init_hook = alc663_mode6_inithook,
16607 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016608};
16609
16610
16611/*
16612 * BIOS auto configuration
16613 */
16614
16615/* add playback controls from the parsed DAC table */
16616static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16617 const struct auto_pin_cfg *cfg)
16618{
16619 char name[32];
16620 static const char *chname[4] = {
16621 "Front", "Surround", NULL /*CLFE*/, "Side"
16622 };
16623 hda_nid_t nid;
16624 int i, err;
16625
16626 for (i = 0; i < cfg->line_outs; i++) {
16627 if (!spec->multiout.dac_nids[i])
16628 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016629 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016630 if (i == 2) {
16631 /* Center/LFE */
16632 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16633 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016634 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16635 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016636 if (err < 0)
16637 return err;
16638 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16639 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016640 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16641 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016642 if (err < 0)
16643 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016644 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016645 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016646 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016647 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016648 if (err < 0)
16649 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016650 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016651 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016652 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016653 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016654 if (err < 0)
16655 return err;
16656 } else {
16657 sprintf(name, "%s Playback Volume", chname[i]);
16658 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016659 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16660 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016661 if (err < 0)
16662 return err;
16663 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016664 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16665 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16666 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016667 if (err < 0)
16668 return err;
16669 }
16670 }
16671 return 0;
16672}
16673
16674/* add playback controls for speaker and HP outputs */
16675static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16676 const char *pfx)
16677{
16678 hda_nid_t nid;
16679 int err;
16680 char name[32];
16681
16682 if (!pin)
16683 return 0;
16684
Takashi Iwai24fb9172008-09-02 14:48:20 +020016685 if (pin == 0x17) {
16686 /* ALC663 has a mono output pin on 0x17 */
16687 sprintf(name, "%s Playback Switch", pfx);
16688 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16689 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16690 return err;
16691 }
16692
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016693 if (alc880_is_fixed_pin(pin)) {
16694 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016695 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016696 /* specify the DAC as the extra output */
16697 if (!spec->multiout.hp_nid)
16698 spec->multiout.hp_nid = nid;
16699 else
16700 spec->multiout.extra_out_nid[0] = nid;
16701 /* control HP volume/switch on the output mixer amp */
16702 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16703 sprintf(name, "%s Playback Volume", pfx);
16704 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16705 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16706 if (err < 0)
16707 return err;
16708 sprintf(name, "%s Playback Switch", pfx);
16709 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16710 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16711 if (err < 0)
16712 return err;
16713 } else if (alc880_is_multi_pin(pin)) {
16714 /* set manual connection */
16715 /* we have only a switch on HP-out PIN */
16716 sprintf(name, "%s Playback Switch", pfx);
16717 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16718 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16719 if (err < 0)
16720 return err;
16721 }
16722 return 0;
16723}
16724
16725/* create playback/capture controls for input pins */
16726static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16727 const struct auto_pin_cfg *cfg)
16728{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016729 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016730 int i, err, idx;
16731
16732 for (i = 0; i < AUTO_PIN_LAST; i++) {
16733 if (alc880_is_input_pin(cfg->input_pins[i])) {
16734 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16735 err = new_analog_input(spec, cfg->input_pins[i],
16736 auto_pin_cfg_labels[i],
16737 idx, 0x0b);
16738 if (err < 0)
16739 return err;
16740 imux->items[imux->num_items].label =
16741 auto_pin_cfg_labels[i];
16742 imux->items[imux->num_items].index =
16743 alc880_input_pin_idx(cfg->input_pins[i]);
16744 imux->num_items++;
16745 }
16746 }
16747 return 0;
16748}
16749
16750static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16751 hda_nid_t nid, int pin_type,
16752 int dac_idx)
16753{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016754 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016755 /* need the manual connection? */
16756 if (alc880_is_multi_pin(nid)) {
16757 struct alc_spec *spec = codec->spec;
16758 int idx = alc880_multi_pin_idx(nid);
16759 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16760 AC_VERB_SET_CONNECT_SEL,
16761 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16762 }
16763}
16764
16765static void alc662_auto_init_multi_out(struct hda_codec *codec)
16766{
16767 struct alc_spec *spec = codec->spec;
16768 int i;
16769
Kailang Yang8c427222008-01-10 13:03:59 +010016770 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016771 for (i = 0; i <= HDA_SIDE; i++) {
16772 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016773 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016774 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016775 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016776 i);
16777 }
16778}
16779
16780static void alc662_auto_init_hp_out(struct hda_codec *codec)
16781{
16782 struct alc_spec *spec = codec->spec;
16783 hda_nid_t pin;
16784
16785 pin = spec->autocfg.hp_pins[0];
16786 if (pin) /* connect to front */
16787 /* use dac 0 */
16788 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016789 pin = spec->autocfg.speaker_pins[0];
16790 if (pin)
16791 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016792}
16793
16794#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16795#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16796
16797static void alc662_auto_init_analog_input(struct hda_codec *codec)
16798{
16799 struct alc_spec *spec = codec->spec;
16800 int i;
16801
16802 for (i = 0; i < AUTO_PIN_LAST; i++) {
16803 hda_nid_t nid = spec->autocfg.input_pins[i];
16804 if (alc662_is_input_pin(nid)) {
16805 snd_hda_codec_write(codec, nid, 0,
16806 AC_VERB_SET_PIN_WIDGET_CONTROL,
16807 (i <= AUTO_PIN_FRONT_MIC ?
16808 PIN_VREF80 : PIN_IN));
16809 if (nid != ALC662_PIN_CD_NID)
16810 snd_hda_codec_write(codec, nid, 0,
16811 AC_VERB_SET_AMP_GAIN_MUTE,
16812 AMP_OUT_MUTE);
16813 }
16814 }
16815}
16816
Takashi Iwaif511b012008-08-15 16:46:42 +020016817#define alc662_auto_init_input_src alc882_auto_init_input_src
16818
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016819static int alc662_parse_auto_config(struct hda_codec *codec)
16820{
16821 struct alc_spec *spec = codec->spec;
16822 int err;
16823 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16824
16825 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16826 alc662_ignore);
16827 if (err < 0)
16828 return err;
16829 if (!spec->autocfg.line_outs)
16830 return 0; /* can't find valid BIOS pin config */
16831
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016832 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16833 if (err < 0)
16834 return err;
16835 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16836 if (err < 0)
16837 return err;
16838 err = alc662_auto_create_extra_out(spec,
16839 spec->autocfg.speaker_pins[0],
16840 "Speaker");
16841 if (err < 0)
16842 return err;
16843 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16844 "Headphone");
16845 if (err < 0)
16846 return err;
16847 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16848 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016849 return err;
16850
16851 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16852
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016853 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016854 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16855
Takashi Iwai603c4012008-07-30 15:01:44 +020016856 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016857 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016858
16859 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016860 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016861
Takashi Iwaid88897e2008-10-31 15:01:37 +010016862 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016863 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016864 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016865
16866 err = alc_auto_add_mic_boost(codec);
16867 if (err < 0)
16868 return err;
16869
Takashi Iwaie044c392008-10-27 16:56:24 +010016870 store_pin_configs(codec);
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016871 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016872}
16873
16874/* additional initialization for auto-configuration model */
16875static void alc662_auto_init(struct hda_codec *codec)
16876{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016877 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016878 alc662_auto_init_multi_out(codec);
16879 alc662_auto_init_hp_out(codec);
16880 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016881 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016882 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016883 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016884}
16885
16886static int patch_alc662(struct hda_codec *codec)
16887{
16888 struct alc_spec *spec;
16889 int err, board_config;
16890
16891 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16892 if (!spec)
16893 return -ENOMEM;
16894
16895 codec->spec = spec;
16896
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016897 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16898
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016899 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16900 alc662_models,
16901 alc662_cfg_tbl);
16902 if (board_config < 0) {
16903 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16904 "trying auto-probe from BIOS...\n");
16905 board_config = ALC662_AUTO;
16906 }
16907
16908 if (board_config == ALC662_AUTO) {
16909 /* automatic parse from the BIOS config */
16910 err = alc662_parse_auto_config(codec);
16911 if (err < 0) {
16912 alc_free(codec);
16913 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016914 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016915 printk(KERN_INFO
16916 "hda_codec: Cannot set up configuration "
16917 "from BIOS. Using base mode...\n");
16918 board_config = ALC662_3ST_2ch_DIG;
16919 }
16920 }
16921
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016922 err = snd_hda_attach_beep_device(codec, 0x1);
16923 if (err < 0) {
16924 alc_free(codec);
16925 return err;
16926 }
16927
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016928 if (board_config != ALC662_AUTO)
16929 setup_preset(spec, &alc662_presets[board_config]);
16930
Kailang Yang6dda9f42008-05-27 12:05:31 +020016931 if (codec->vendor_id == 0x10ec0663) {
16932 spec->stream_name_analog = "ALC663 Analog";
16933 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016934 } else if (codec->vendor_id == 0x10ec0272) {
16935 spec->stream_name_analog = "ALC272 Analog";
16936 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016937 } else {
16938 spec->stream_name_analog = "ALC662 Analog";
16939 spec->stream_name_digital = "ALC662 Digital";
16940 }
16941
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016942 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16943 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16944
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016945 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16946 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16947
Takashi Iwaie1406342008-02-11 18:32:32 +010016948 spec->adc_nids = alc662_adc_nids;
16949 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16950 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016951 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016952
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016953 if (!spec->cap_mixer)
16954 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016955 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016956
Takashi Iwai2134ea42008-01-10 16:53:55 +010016957 spec->vmaster_nid = 0x02;
16958
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016959 codec->patch_ops = alc_patch_ops;
16960 if (board_config == ALC662_AUTO)
16961 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016962#ifdef CONFIG_SND_HDA_POWER_SAVE
16963 if (!spec->loopback.amplist)
16964 spec->loopback.amplist = alc662_loopbacks;
16965#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016966 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016967
16968 return 0;
16969}
16970
16971/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016972 * patch entries
16973 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016974static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016975 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016976 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016977 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016978 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016979 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016980 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016981 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016982 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016983 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16984 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16985 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016986 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16987 .patch = patch_alc883 },
16988 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16989 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016990 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016991 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016992 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016993 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016994 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16995 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016996 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016997 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016998 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016999 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017000 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17001 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017002 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017003 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017004 {} /* terminator */
17005};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017006
17007MODULE_ALIAS("snd-hda-codec-id:10ec*");
17008
17009MODULE_LICENSE("GPL");
17010MODULE_DESCRIPTION("Realtek HD-audio codec");
17011
17012static struct hda_codec_preset_list realtek_list = {
17013 .preset = snd_hda_preset_realtek,
17014 .owner = THIS_MODULE,
17015};
17016
17017static int __init patch_realtek_init(void)
17018{
17019 return snd_hda_add_codec_preset(&realtek_list);
17020}
17021
17022static void __exit patch_realtek_exit(void)
17023{
17024 snd_hda_delete_codec_preset(&realtek_list);
17025}
17026
17027module_init(patch_realtek_init)
17028module_exit(patch_realtek_exit)