blob: 50ae8f33af5f982e9ffdab16b0728a2a9b62e071 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200191 ALC662_AUTO,
192 ALC662_MODEL_LAST,
193};
194
Kailang Yangdf694da2005-12-05 19:42:22 +0100195/* ALC882 models */
196enum {
197 ALC882_3ST_DIG,
198 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200199 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200200 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200201 ALC882_TARGA,
202 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200203 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100204 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200205 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200206 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200207 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100208 ALC882_MODEL_LAST,
209};
210
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200211/* ALC883 models */
212enum {
213 ALC883_3ST_2ch_DIG,
214 ALC883_3ST_6ch_DIG,
215 ALC883_3ST_6ch,
216 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200217 ALC883_TARGA_DIG,
218 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200219 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200220 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800221 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200222 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200223 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100224 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200225 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200226 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200227 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200228 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200229 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200230 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100231 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100232 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100233 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100234 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800235 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200236 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200237 ALC888_ASUS_M90V,
238 ALC888_ASUS_EEE1601,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100239 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200240 ALC883_AUTO,
241 ALC883_MODEL_LAST,
242};
243
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200244/* styles of capture selection */
245enum {
246 CAPT_MUX = 0, /* only mux based */
247 CAPT_MIX, /* only mixer based */
248 CAPT_1MUX_MIX, /* first mux and other mixers */
249};
250
Kailang Yangdf694da2005-12-05 19:42:22 +0100251/* for GPIO Poll */
252#define GPIO_MASK 0x03
253
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254struct alc_spec {
255 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100256 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100258 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100259 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
Kailang Yangdf694da2005-12-05 19:42:22 +0100261 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200262 * don't forget NULL
263 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200264 */
265 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
Takashi Iwai16ded522005-06-10 19:58:24 +0200267 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 struct hda_pcm_stream *stream_analog_playback;
269 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100270 struct hda_pcm_stream *stream_analog_alt_playback;
271 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200273 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 struct hda_pcm_stream *stream_digital_playback;
275 struct hda_pcm_stream *stream_digital_capture;
276
277 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200278 struct hda_multi_out multiout; /* playback set-up
279 * max_channels, dacs must be set
280 * dig_out_nid and hp_nid are optional
281 */
Takashi Iwai63300792008-01-24 15:31:36 +0100282 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100283 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100284 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286 /* capture */
287 unsigned int num_adc_nids;
288 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100289 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200290 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200291 int capture_style; /* capture style (CAPT_*) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
293 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200294 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 const struct hda_input_mux *input_mux;
296 unsigned int cur_mux[3];
297
298 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100299 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200301 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100304 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200305
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200306 /* dynamic controls, init_verbs and input_mux */
307 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200308 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200309 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200310 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100311
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100312 /* hooks */
313 void (*init_hook)(struct hda_codec *codec);
314 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
315
Takashi Iwai834be882006-03-01 14:16:17 +0100316 /* for pin sensing */
317 unsigned int sense_updated: 1;
318 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100319 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200320
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100321 /* other flags */
322 unsigned int no_analog :1; /* digital I/O only */
323
Takashi Iwai2134ea42008-01-10 16:53:55 +0100324 /* for virtual master */
325 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200326#ifdef CONFIG_SND_HDA_POWER_SAVE
327 struct hda_loopback_check loopback;
328#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200329
330 /* for PLL fix */
331 hda_nid_t pll_nid;
332 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100333};
334
335/*
336 * configuration template - to be copied to the spec instance
337 */
338struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200339 struct snd_kcontrol_new *mixers[5]; /* should be identical size
340 * with spec
341 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100342 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100343 const struct hda_verb *init_verbs[5];
344 unsigned int num_dacs;
345 hda_nid_t *dac_nids;
346 hda_nid_t dig_out_nid; /* optional */
347 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800348 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100349 unsigned int num_adc_nids;
350 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100351 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100352 hda_nid_t dig_in_nid;
353 unsigned int num_channel_mode;
354 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200355 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200356 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100357 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100358 void (*unsol_event)(struct hda_codec *, unsigned int);
359 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200360#ifdef CONFIG_SND_HDA_POWER_SAVE
361 struct hda_amp_list *loopbacks;
362#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363};
364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
366/*
367 * input MUX handling
368 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200369static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
370 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371{
372 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
373 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200374 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
375 if (mux_idx >= spec->num_mux_defs)
376 mux_idx = 0;
377 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378}
379
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200380static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
381 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382{
383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
384 struct alc_spec *spec = codec->spec;
385 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
386
387 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
388 return 0;
389}
390
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200391static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
392 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393{
394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
395 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100396 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100398 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100399 hda_nid_t nid = spec->capsrc_nids ?
400 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
Takashi Iwaicd896c32008-11-18 12:36:33 +0100402 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
403 imux = &spec->input_mux[mux_idx];
404
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200405 if (spec->capture_style &&
406 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100407 /* Matrix-mixer style (e.g. ALC882) */
408 unsigned int *cur_val = &spec->cur_mux[adc_idx];
409 unsigned int i, idx;
410
411 idx = ucontrol->value.enumerated.item[0];
412 if (idx >= imux->num_items)
413 idx = imux->num_items - 1;
414 if (*cur_val == idx)
415 return 0;
416 for (i = 0; i < imux->num_items; i++) {
417 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
418 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
419 imux->items[i].index,
420 HDA_AMP_MUTE, v);
421 }
422 *cur_val = idx;
423 return 1;
424 } else {
425 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100426 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100427 &spec->cur_mux[adc_idx]);
428 }
429}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200430
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431/*
432 * channel mode setting
433 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200434static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
435 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436{
437 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
438 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100439 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
440 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441}
442
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200443static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445{
446 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
447 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100448 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200449 spec->num_channel_mode,
450 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451}
452
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200453static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
454 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455{
456 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
457 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200458 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
459 spec->num_channel_mode,
460 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200461 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200462 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
463 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464}
465
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100467 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200468 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100469 * being part of a format specifier. Maximum allowed length of a value is
470 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100471 *
472 * Note: some retasking pin complexes seem to ignore requests for input
473 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
474 * are requested. Therefore order this list so that this behaviour will not
475 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200476 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
477 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200478 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100479static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100480 "Mic 50pc bias", "Mic 80pc bias",
481 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100482};
483static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100484 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100485};
486/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200487 * in the pin being assumed to be exclusively an input or an output pin. In
488 * addition, "input" pins may or may not process the mic bias option
489 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
490 * accept requests for bias as of chip versions up to March 2006) and/or
491 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100492 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200493#define ALC_PIN_DIR_IN 0x00
494#define ALC_PIN_DIR_OUT 0x01
495#define ALC_PIN_DIR_INOUT 0x02
496#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
497#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100498
Kailang Yangea1fb292008-08-26 12:58:38 +0200499/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100500 * For each direction the minimum and maximum values are given.
501 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200502static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100503 { 0, 2 }, /* ALC_PIN_DIR_IN */
504 { 3, 4 }, /* ALC_PIN_DIR_OUT */
505 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200506 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
507 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100508};
509#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
510#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
511#define alc_pin_mode_n_items(_dir) \
512 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
513
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200514static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200516{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100517 unsigned int item_num = uinfo->value.enumerated.item;
518 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
519
520 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200521 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
523
524 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
525 item_num = alc_pin_mode_min(dir);
526 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200527 return 0;
528}
529
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
531 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200532{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
535 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200537 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200538 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
539 AC_VERB_GET_PIN_WIDGET_CONTROL,
540 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200541
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100542 /* Find enumerated value for current pinctl setting */
543 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200544 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200546 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100547 return 0;
548}
549
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200550static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
551 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552{
553 signed int change;
554 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
555 hda_nid_t nid = kcontrol->private_value & 0xffff;
556 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
557 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
559 AC_VERB_GET_PIN_WIDGET_CONTROL,
560 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100561
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200562 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563 val = alc_pin_mode_min(dir);
564
565 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100566 if (change) {
567 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200568 snd_hda_codec_write_cache(codec, nid, 0,
569 AC_VERB_SET_PIN_WIDGET_CONTROL,
570 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100571
Kailang Yangea1fb292008-08-26 12:58:38 +0200572 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100573 * for the requested pin mode. Enum values of 2 or less are
574 * input modes.
575 *
576 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200577 * reduces noise slightly (particularly on input) so we'll
578 * do it. However, having both input and output buffers
579 * enabled simultaneously doesn't seem to be problematic if
580 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100581 */
582 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200583 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
584 HDA_AMP_MUTE, HDA_AMP_MUTE);
585 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
586 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100587 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200588 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
589 HDA_AMP_MUTE, HDA_AMP_MUTE);
590 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
591 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100592 }
593 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200594 return change;
595}
596
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100597#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200598 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100599 .info = alc_pin_mode_info, \
600 .get = alc_pin_mode_get, \
601 .put = alc_pin_mode_put, \
602 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100603
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100604/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
605 * together using a mask with more than one bit set. This control is
606 * currently used only by the ALC260 test model. At this stage they are not
607 * needed for any "production" models.
608 */
609#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200610#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200611
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200612static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100614{
615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
616 hda_nid_t nid = kcontrol->private_value & 0xffff;
617 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
618 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200619 unsigned int val = snd_hda_codec_read(codec, nid, 0,
620 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100621
622 *valp = (val & mask) != 0;
623 return 0;
624}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200625static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100627{
628 signed int change;
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 hda_nid_t nid = kcontrol->private_value & 0xffff;
631 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
632 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200633 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
634 AC_VERB_GET_GPIO_DATA,
635 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100636
637 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200638 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
639 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100640 gpio_data &= ~mask;
641 else
642 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200643 snd_hda_codec_write_cache(codec, nid, 0,
644 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100645
646 return change;
647}
648#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
649 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
650 .info = alc_gpio_data_info, \
651 .get = alc_gpio_data_get, \
652 .put = alc_gpio_data_put, \
653 .private_value = nid | (mask<<16) }
654#endif /* CONFIG_SND_DEBUG */
655
Jonathan Woithe92621f12006-02-28 11:47:47 +0100656/* A switch control to allow the enabling of the digital IO pins on the
657 * ALC260. This is incredibly simplistic; the intention of this control is
658 * to provide something in the test model allowing digital outputs to be
659 * identified if present. If models are found which can utilise these
660 * outputs a more complete mixer control can be devised for those models if
661 * necessary.
662 */
663#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200664#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200665
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200666static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
667 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100668{
669 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
670 hda_nid_t nid = kcontrol->private_value & 0xffff;
671 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
672 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200673 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100674 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100675
676 *valp = (val & mask) != 0;
677 return 0;
678}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
680 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100681{
682 signed int change;
683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
684 hda_nid_t nid = kcontrol->private_value & 0xffff;
685 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
686 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200687 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100688 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200689 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100690
691 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200692 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100693 if (val==0)
694 ctrl_data &= ~mask;
695 else
696 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200697 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
698 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100699
700 return change;
701}
702#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
703 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
704 .info = alc_spdif_ctrl_info, \
705 .get = alc_spdif_ctrl_get, \
706 .put = alc_spdif_ctrl_put, \
707 .private_value = nid | (mask<<16) }
708#endif /* CONFIG_SND_DEBUG */
709
Jonathan Woithef8225f62008-01-08 12:16:54 +0100710/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
711 * Again, this is only used in the ALC26x test models to help identify when
712 * the EAPD line must be asserted for features to work.
713 */
714#ifdef CONFIG_SND_DEBUG
715#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
716
717static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
718 struct snd_ctl_elem_value *ucontrol)
719{
720 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
721 hda_nid_t nid = kcontrol->private_value & 0xffff;
722 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
723 long *valp = ucontrol->value.integer.value;
724 unsigned int val = snd_hda_codec_read(codec, nid, 0,
725 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
726
727 *valp = (val & mask) != 0;
728 return 0;
729}
730
731static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
732 struct snd_ctl_elem_value *ucontrol)
733{
734 int change;
735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
736 hda_nid_t nid = kcontrol->private_value & 0xffff;
737 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
738 long val = *ucontrol->value.integer.value;
739 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
740 AC_VERB_GET_EAPD_BTLENABLE,
741 0x00);
742
743 /* Set/unset the masked control bit(s) as needed */
744 change = (!val ? 0 : mask) != (ctrl_data & mask);
745 if (!val)
746 ctrl_data &= ~mask;
747 else
748 ctrl_data |= mask;
749 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
750 ctrl_data);
751
752 return change;
753}
754
755#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
756 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
757 .info = alc_eapd_ctrl_info, \
758 .get = alc_eapd_ctrl_get, \
759 .put = alc_eapd_ctrl_put, \
760 .private_value = nid | (mask<<16) }
761#endif /* CONFIG_SND_DEBUG */
762
Kailang Yangdf694da2005-12-05 19:42:22 +0100763/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100764 */
765static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
766{
767 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
768 return;
769 spec->mixers[spec->num_mixers++] = mix;
770}
771
772static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
773{
774 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
775 return;
776 spec->init_verbs[spec->num_init_verbs++] = verb;
777}
778
Takashi Iwaidaead532008-11-28 12:55:36 +0100779#ifdef CONFIG_PROC_FS
780/*
781 * hook for proc
782 */
783static void print_realtek_coef(struct snd_info_buffer *buffer,
784 struct hda_codec *codec, hda_nid_t nid)
785{
786 int coeff;
787
788 if (nid != 0x20)
789 return;
790 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
791 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
792 coeff = snd_hda_codec_read(codec, nid, 0,
793 AC_VERB_GET_COEF_INDEX, 0);
794 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
795}
796#else
797#define print_realtek_coef NULL
798#endif
799
Takashi Iwaid88897e2008-10-31 15:01:37 +0100800/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100801 * set up from the preset table
802 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200803static void setup_preset(struct alc_spec *spec,
804 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100805{
806 int i;
807
808 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100809 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100810 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200811 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
812 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100813 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200814
Kailang Yangdf694da2005-12-05 19:42:22 +0100815 spec->channel_mode = preset->channel_mode;
816 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200817 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100818
819 spec->multiout.max_channels = spec->channel_mode[0].channels;
820
821 spec->multiout.num_dacs = preset->num_dacs;
822 spec->multiout.dac_nids = preset->dac_nids;
823 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800824 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100825 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200826
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200827 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200828 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200829 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100830 spec->input_mux = preset->input_mux;
831
832 spec->num_adc_nids = preset->num_adc_nids;
833 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100834 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100835 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100836
837 spec->unsol_event = preset->unsol_event;
838 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200839#ifdef CONFIG_SND_HDA_POWER_SAVE
840 spec->loopback.amplist = preset->loopbacks;
841#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100842}
843
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200844/* Enable GPIO mask and set output */
845static struct hda_verb alc_gpio1_init_verbs[] = {
846 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
847 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
848 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
849 { }
850};
851
852static struct hda_verb alc_gpio2_init_verbs[] = {
853 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
854 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
855 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
856 { }
857};
858
Kailang Yangbdd148a2007-05-08 15:19:08 +0200859static struct hda_verb alc_gpio3_init_verbs[] = {
860 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
861 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
862 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
863 { }
864};
865
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200866/*
867 * Fix hardware PLL issue
868 * On some codecs, the analog PLL gating control must be off while
869 * the default value is 1.
870 */
871static void alc_fix_pll(struct hda_codec *codec)
872{
873 struct alc_spec *spec = codec->spec;
874 unsigned int val;
875
876 if (!spec->pll_nid)
877 return;
878 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
879 spec->pll_coef_idx);
880 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
881 AC_VERB_GET_PROC_COEF, 0);
882 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
883 spec->pll_coef_idx);
884 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
885 val & ~(1 << spec->pll_coef_bit));
886}
887
888static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
889 unsigned int coef_idx, unsigned int coef_bit)
890{
891 struct alc_spec *spec = codec->spec;
892 spec->pll_nid = nid;
893 spec->pll_coef_idx = coef_idx;
894 spec->pll_coef_bit = coef_bit;
895 alc_fix_pll(codec);
896}
897
Kailang Yangc9b58002007-10-16 14:30:01 +0200898static void alc_sku_automute(struct hda_codec *codec)
899{
900 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200901 unsigned int present;
902 unsigned int hp_nid = spec->autocfg.hp_pins[0];
903 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
904
905 /* need to execute and sync at first */
906 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
907 present = snd_hda_codec_read(codec, hp_nid, 0,
908 AC_VERB_GET_PIN_SENSE, 0);
909 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100910 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
911 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200912}
913
Takashi Iwai4605b712008-10-31 14:18:24 +0100914#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200915static void alc_mic_automute(struct hda_codec *codec)
916{
917 struct alc_spec *spec = codec->spec;
918 unsigned int present;
919 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
920 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
921 unsigned int mix_nid = spec->capsrc_nids[0];
922 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
923
924 capsrc_idx_mic = mic_nid - 0x18;
925 capsrc_idx_fmic = fmic_nid - 0x18;
926 present = snd_hda_codec_read(codec, mic_nid, 0,
927 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
928 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
929 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
930 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
931 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
932 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
933 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
934}
Takashi Iwai4605b712008-10-31 14:18:24 +0100935#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100936#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100937#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200938
Kailang Yangc9b58002007-10-16 14:30:01 +0200939/* unsolicited event for HP jack sensing */
940static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
941{
942 if (codec->vendor_id == 0x10ec0880)
943 res >>= 28;
944 else
945 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200946 if (res == ALC880_HP_EVENT)
947 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200948
Kailang Yang7fb0d782008-10-15 11:12:35 +0200949 if (res == ALC880_MIC_EVENT)
950 alc_mic_automute(codec);
951}
952
953static void alc_inithook(struct hda_codec *codec)
954{
Kailang Yangc9b58002007-10-16 14:30:01 +0200955 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200956 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200957}
958
Kailang Yangf9423e72008-05-27 12:32:25 +0200959/* additional initialization for ALC888 variants */
960static void alc888_coef_init(struct hda_codec *codec)
961{
962 unsigned int tmp;
963
964 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
965 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
966 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
967 if ((tmp & 0xf0) == 2)
968 /* alc888S-VC */
969 snd_hda_codec_read(codec, 0x20, 0,
970 AC_VERB_SET_PROC_COEF, 0x830);
971 else
972 /* alc888-VB */
973 snd_hda_codec_read(codec, 0x20, 0,
974 AC_VERB_SET_PROC_COEF, 0x3030);
975}
976
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200977/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
978 * 31 ~ 16 : Manufacture ID
979 * 15 ~ 8 : SKU ID
980 * 7 ~ 0 : Assembly ID
981 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
982 */
983static void alc_subsystem_id(struct hda_codec *codec,
984 unsigned int porta, unsigned int porte,
985 unsigned int portd)
986{
Kailang Yangc9b58002007-10-16 14:30:01 +0200987 unsigned int ass, tmp, i;
988 unsigned nid;
989 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200990
Kailang Yangc9b58002007-10-16 14:30:01 +0200991 ass = codec->subsystem_id & 0xffff;
992 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
993 goto do_sku;
994
Kailang Yangea1fb292008-08-26 12:58:38 +0200995 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200996 * 31~30 : port conetcivity
997 * 29~21 : reserve
998 * 20 : PCBEEP input
999 * 19~16 : Check sum (15:1)
1000 * 15~1 : Custom
1001 * 0 : override
1002 */
1003 nid = 0x1d;
1004 if (codec->vendor_id == 0x10ec0260)
1005 nid = 0x17;
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001006 ass = snd_hda_codec_get_pincfg(codec, nid);
Kailang Yangc9b58002007-10-16 14:30:01 +02001007 if (!(ass & 1) && !(ass & 0x100000))
1008 return;
1009 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001010 return;
1011
Kailang Yangc9b58002007-10-16 14:30:01 +02001012 /* check sum */
1013 tmp = 0;
1014 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +01001015 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +02001016 tmp++;
1017 }
1018 if (((ass >> 16) & 0xf) != tmp)
1019 return;
1020do_sku:
1021 /*
1022 * 0 : override
1023 * 1 : Swap Jack
1024 * 2 : 0 --> Desktop, 1 --> Laptop
1025 * 3~5 : External Amplifier control
1026 * 7~6 : Reserved
1027 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001028 tmp = (ass & 0x38) >> 3; /* external Amp control */
1029 switch (tmp) {
1030 case 1:
1031 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1032 break;
1033 case 3:
1034 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1035 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001036 case 7:
1037 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1038 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001039 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001040 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001041 case 0x10ec0260:
1042 snd_hda_codec_write(codec, 0x0f, 0,
1043 AC_VERB_SET_EAPD_BTLENABLE, 2);
1044 snd_hda_codec_write(codec, 0x10, 0,
1045 AC_VERB_SET_EAPD_BTLENABLE, 2);
1046 break;
1047 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001048 case 0x10ec0267:
1049 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001050 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001051 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001052 case 0x10ec0660:
1053 case 0x10ec0662:
1054 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001055 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001056 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001057 snd_hda_codec_write(codec, 0x14, 0,
1058 AC_VERB_SET_EAPD_BTLENABLE, 2);
1059 snd_hda_codec_write(codec, 0x15, 0,
1060 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001061 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001062 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001063 switch (codec->vendor_id) {
1064 case 0x10ec0260:
1065 snd_hda_codec_write(codec, 0x1a, 0,
1066 AC_VERB_SET_COEF_INDEX, 7);
1067 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1068 AC_VERB_GET_PROC_COEF, 0);
1069 snd_hda_codec_write(codec, 0x1a, 0,
1070 AC_VERB_SET_COEF_INDEX, 7);
1071 snd_hda_codec_write(codec, 0x1a, 0,
1072 AC_VERB_SET_PROC_COEF,
1073 tmp | 0x2010);
1074 break;
1075 case 0x10ec0262:
1076 case 0x10ec0880:
1077 case 0x10ec0882:
1078 case 0x10ec0883:
1079 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001080 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001081 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001082 snd_hda_codec_write(codec, 0x20, 0,
1083 AC_VERB_SET_COEF_INDEX, 7);
1084 tmp = snd_hda_codec_read(codec, 0x20, 0,
1085 AC_VERB_GET_PROC_COEF, 0);
1086 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001087 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001088 snd_hda_codec_write(codec, 0x20, 0,
1089 AC_VERB_SET_PROC_COEF,
1090 tmp | 0x2010);
1091 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001092 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001093 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001094 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001095 case 0x10ec0267:
1096 case 0x10ec0268:
1097 snd_hda_codec_write(codec, 0x20, 0,
1098 AC_VERB_SET_COEF_INDEX, 7);
1099 tmp = snd_hda_codec_read(codec, 0x20, 0,
1100 AC_VERB_GET_PROC_COEF, 0);
1101 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001102 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001103 snd_hda_codec_write(codec, 0x20, 0,
1104 AC_VERB_SET_PROC_COEF,
1105 tmp | 0x3000);
1106 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001107 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001108 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001109 break;
1110 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001111
Kailang Yang8c427222008-01-10 13:03:59 +01001112 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001113 * when the external headphone out jack is plugged"
1114 */
Kailang Yang8c427222008-01-10 13:03:59 +01001115 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001116 return;
1117 /*
1118 * 10~8 : Jack location
1119 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1120 * 14~13: Resvered
1121 * 15 : 1 --> enable the function "Mute internal speaker
1122 * when the external headphone out jack is plugged"
1123 */
1124 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001125 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001127 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001128 else
1129 return;
1130 }
1131
1132 if (!spec->autocfg.hp_pins[0]) {
1133 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1134 if (tmp == 0)
1135 spec->autocfg.hp_pins[0] = porta;
1136 else if (tmp == 1)
1137 spec->autocfg.hp_pins[0] = porte;
1138 else if (tmp == 2)
1139 spec->autocfg.hp_pins[0] = portd;
1140 else
1141 return;
1142 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001143 if (spec->autocfg.hp_pins[0])
1144 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1145 AC_VERB_SET_UNSOLICITED_ENABLE,
1146 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001147
Takashi Iwai4605b712008-10-31 14:18:24 +01001148#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001149 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1150 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1151 snd_hda_codec_write(codec,
1152 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1153 AC_VERB_SET_UNSOLICITED_ENABLE,
1154 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001155#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001156
Kailang Yangc9b58002007-10-16 14:30:01 +02001157 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001158}
1159
Takashi Iwai41e41f12005-06-08 14:48:49 +02001160/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001161 * Fix-up pin default configurations
1162 */
1163
1164struct alc_pincfg {
1165 hda_nid_t nid;
1166 u32 val;
1167};
1168
1169static void alc_fix_pincfg(struct hda_codec *codec,
1170 const struct snd_pci_quirk *quirk,
1171 const struct alc_pincfg **pinfix)
1172{
1173 const struct alc_pincfg *cfg;
1174
1175 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1176 if (!quirk)
1177 return;
1178
1179 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001180 for (; cfg->nid; cfg++)
1181 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001182}
1183
1184/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001185 * ALC888
1186 */
1187
1188/*
1189 * 2ch mode
1190 */
1191static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1192/* Mic-in jack as mic in */
1193 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1194 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1195/* Line-in jack as Line in */
1196 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1197 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1198/* Line-Out as Front */
1199 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1200 { } /* end */
1201};
1202
1203/*
1204 * 4ch mode
1205 */
1206static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1207/* Mic-in jack as mic in */
1208 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1209 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1210/* Line-in jack as Surround */
1211 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1212 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1213/* Line-Out as Front */
1214 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1215 { } /* end */
1216};
1217
1218/*
1219 * 6ch mode
1220 */
1221static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1222/* Mic-in jack as CLFE */
1223 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1224 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1225/* Line-in jack as Surround */
1226 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1227 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1228/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1229 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1230 { } /* end */
1231};
1232
1233/*
1234 * 8ch mode
1235 */
1236static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1237/* Mic-in jack as CLFE */
1238 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1239 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1240/* Line-in jack as Surround */
1241 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1242 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1243/* Line-Out as Side */
1244 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1245 { } /* end */
1246};
1247
1248static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1249 { 2, alc888_4ST_ch2_intel_init },
1250 { 4, alc888_4ST_ch4_intel_init },
1251 { 6, alc888_4ST_ch6_intel_init },
1252 { 8, alc888_4ST_ch8_intel_init },
1253};
1254
1255/*
1256 * ALC888 Fujitsu Siemens Amillo xa3530
1257 */
1258
1259static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1260/* Front Mic: set to PIN_IN (empty by default) */
1261 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1262/* Connect Internal HP to Front */
1263 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1264 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1265 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1266/* Connect Bass HP to Front */
1267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1268 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1269 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1270/* Connect Line-Out side jack (SPDIF) to Side */
1271 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1272 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1273 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1274/* Connect Mic jack to CLFE */
1275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1276 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1277 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1278/* Connect Line-in jack to Surround */
1279 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1280 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1281 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1282/* Connect HP out jack to Front */
1283 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1284 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1285 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1286/* Enable unsolicited event for HP jack and Line-out jack */
1287 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1288 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1289 {}
1290};
1291
1292static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1293{
1294 unsigned int present;
1295 unsigned int bits;
1296 /* Line out presence */
1297 present = snd_hda_codec_read(codec, 0x17, 0,
1298 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1299 /* HP out presence */
1300 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1301 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1302 bits = present ? HDA_AMP_MUTE : 0;
1303 /* Toggle internal speakers muting */
1304 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1305 HDA_AMP_MUTE, bits);
1306 /* Toggle internal bass muting */
1307 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1308 HDA_AMP_MUTE, bits);
1309}
1310
1311static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1312 unsigned int res)
1313{
1314 if (res >> 26 == ALC880_HP_EVENT)
1315 alc888_fujitsu_xa3530_automute(codec);
1316}
1317
1318
1319/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001320 * ALC888 Acer Aspire 4930G model
1321 */
1322
1323static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1324/* Front Mic: set to PIN_IN (empty by default) */
1325 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1326/* Unselect Front Mic by default in input mixer 3 */
1327 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001328/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001329 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1330/* Connect Internal HP to front */
1331 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1332 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1333 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1334/* Connect HP out to front */
1335 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1336 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1337 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1338 { }
1339};
1340
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001341static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001342 /* Front mic only available on one ADC */
1343 {
1344 .num_items = 4,
1345 .items = {
1346 { "Mic", 0x0 },
1347 { "Line", 0x2 },
1348 { "CD", 0x4 },
1349 { "Front Mic", 0xb },
1350 },
1351 },
1352 {
1353 .num_items = 3,
1354 .items = {
1355 { "Mic", 0x0 },
1356 { "Line", 0x2 },
1357 { "CD", 0x4 },
1358 },
1359 }
1360};
1361
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001362static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001363 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1364 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1365 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1366 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1367 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1368 HDA_OUTPUT),
1369 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1370 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1371 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1372 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1373 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1374 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1375 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1376 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1377 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1379 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1380 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001381 { } /* end */
1382};
1383
1384static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1385{
1386 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001387 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001388 present = snd_hda_codec_read(codec, 0x15, 0,
1389 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001390 bits = present ? HDA_AMP_MUTE : 0;
1391 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1392 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001393}
1394
1395static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1396 unsigned int res)
1397{
1398 if (res >> 26 == ALC880_HP_EVENT)
1399 alc888_acer_aspire_4930g_automute(codec);
1400}
1401
1402/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001403 * ALC880 3-stack model
1404 *
1405 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001406 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1407 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408 */
1409
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001410static hda_nid_t alc880_dac_nids[4] = {
1411 /* front, rear, clfe, rear_surr */
1412 0x02, 0x05, 0x04, 0x03
1413};
1414
1415static hda_nid_t alc880_adc_nids[3] = {
1416 /* ADC0-2 */
1417 0x07, 0x08, 0x09,
1418};
1419
1420/* The datasheet says the node 0x07 is connected from inputs,
1421 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001422 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001424static hda_nid_t alc880_adc_nids_alt[2] = {
1425 /* ADC1-2 */
1426 0x08, 0x09,
1427};
1428
1429#define ALC880_DIGOUT_NID 0x06
1430#define ALC880_DIGIN_NID 0x0a
1431
1432static struct hda_input_mux alc880_capture_source = {
1433 .num_items = 4,
1434 .items = {
1435 { "Mic", 0x0 },
1436 { "Front Mic", 0x3 },
1437 { "Line", 0x2 },
1438 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001440};
1441
1442/* channel source setting (2/6 channel selection for 3-stack) */
1443/* 2ch mode */
1444static struct hda_verb alc880_threestack_ch2_init[] = {
1445 /* set line-in to input, mute it */
1446 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1447 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1448 /* set mic-in to input vref 80%, mute it */
1449 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1450 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001451 { } /* end */
1452};
1453
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001454/* 6ch mode */
1455static struct hda_verb alc880_threestack_ch6_init[] = {
1456 /* set line-in to output, unmute it */
1457 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1458 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1459 /* set mic-in to output, unmute it */
1460 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1461 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1462 { } /* end */
1463};
1464
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001465static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001466 { 2, alc880_threestack_ch2_init },
1467 { 6, alc880_threestack_ch6_init },
1468};
1469
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001470static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001471 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001472 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001473 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001474 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001475 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1476 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001477 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1478 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1480 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1481 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1482 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1484 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1485 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1486 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001487 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001488 {
1489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1490 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001491 .info = alc_ch_mode_info,
1492 .get = alc_ch_mode_get,
1493 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001494 },
1495 { } /* end */
1496};
1497
1498/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001499static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1500 struct snd_ctl_elem_info *uinfo)
1501{
1502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1503 struct alc_spec *spec = codec->spec;
1504 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001505
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001506 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001507 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1508 HDA_INPUT);
1509 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001510 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001511 return err;
1512}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001514static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1515 unsigned int size, unsigned int __user *tlv)
1516{
1517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1518 struct alc_spec *spec = codec->spec;
1519 int err;
1520
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001521 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001522 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1523 HDA_INPUT);
1524 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001525 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001526 return err;
1527}
1528
1529typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1530 struct snd_ctl_elem_value *ucontrol);
1531
1532static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1533 struct snd_ctl_elem_value *ucontrol,
1534 getput_call_t func)
1535{
1536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1537 struct alc_spec *spec = codec->spec;
1538 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1539 int err;
1540
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001541 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001542 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1543 3, 0, HDA_INPUT);
1544 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001545 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001546 return err;
1547}
1548
1549static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1550 struct snd_ctl_elem_value *ucontrol)
1551{
1552 return alc_cap_getput_caller(kcontrol, ucontrol,
1553 snd_hda_mixer_amp_volume_get);
1554}
1555
1556static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1557 struct snd_ctl_elem_value *ucontrol)
1558{
1559 return alc_cap_getput_caller(kcontrol, ucontrol,
1560 snd_hda_mixer_amp_volume_put);
1561}
1562
1563/* capture mixer elements */
1564#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1565
1566static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1567 struct snd_ctl_elem_value *ucontrol)
1568{
1569 return alc_cap_getput_caller(kcontrol, ucontrol,
1570 snd_hda_mixer_amp_switch_get);
1571}
1572
1573static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1574 struct snd_ctl_elem_value *ucontrol)
1575{
1576 return alc_cap_getput_caller(kcontrol, ucontrol,
1577 snd_hda_mixer_amp_switch_put);
1578}
1579
1580#define DEFINE_CAPMIX(num) \
1581static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1582 { \
1583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1584 .name = "Capture Switch", \
1585 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1586 .count = num, \
1587 .info = alc_cap_sw_info, \
1588 .get = alc_cap_sw_get, \
1589 .put = alc_cap_sw_put, \
1590 }, \
1591 { \
1592 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1593 .name = "Capture Volume", \
1594 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1595 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1596 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1597 .count = num, \
1598 .info = alc_cap_vol_info, \
1599 .get = alc_cap_vol_get, \
1600 .put = alc_cap_vol_put, \
1601 .tlv = { .c = alc_cap_vol_tlv }, \
1602 }, \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001603 { \
1604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1605 /* .name = "Capture Source", */ \
1606 .name = "Input Source", \
1607 .count = num, \
1608 .info = alc_mux_enum_info, \
1609 .get = alc_mux_enum_get, \
1610 .put = alc_mux_enum_put, \
1611 }, \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001612 { } /* end */ \
1613}
1614
1615/* up to three ADCs */
1616DEFINE_CAPMIX(1);
1617DEFINE_CAPMIX(2);
1618DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001619
1620
1621/*
1622 * ALC880 5-stack model
1623 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001624 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1625 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001626 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1627 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1628 */
1629
1630/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001631static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001632 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001633 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001634 { } /* end */
1635};
1636
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001637/* channel source setting (6/8 channel selection for 5-stack) */
1638/* 6ch mode */
1639static struct hda_verb alc880_fivestack_ch6_init[] = {
1640 /* set line-in to input, mute it */
1641 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1642 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001643 { } /* end */
1644};
1645
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001646/* 8ch mode */
1647static struct hda_verb alc880_fivestack_ch8_init[] = {
1648 /* set line-in to output, unmute it */
1649 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1650 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1651 { } /* end */
1652};
1653
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001654static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001655 { 6, alc880_fivestack_ch6_init },
1656 { 8, alc880_fivestack_ch8_init },
1657};
1658
1659
1660/*
1661 * ALC880 6-stack model
1662 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001663 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1664 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001665 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1666 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1667 */
1668
1669static hda_nid_t alc880_6st_dac_nids[4] = {
1670 /* front, rear, clfe, rear_surr */
1671 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001672};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001673
1674static struct hda_input_mux alc880_6stack_capture_source = {
1675 .num_items = 4,
1676 .items = {
1677 { "Mic", 0x0 },
1678 { "Front Mic", 0x1 },
1679 { "Line", 0x2 },
1680 { "CD", 0x4 },
1681 },
1682};
1683
1684/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001685static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001686 { 8, NULL },
1687};
1688
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001689static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001690 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001691 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001692 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001693 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001694 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1695 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001696 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1697 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001698 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001699 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001700 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1701 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1702 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1703 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1704 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1705 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1706 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1707 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001708 {
1709 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1710 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001711 .info = alc_ch_mode_info,
1712 .get = alc_ch_mode_get,
1713 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001714 },
1715 { } /* end */
1716};
1717
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001718
1719/*
1720 * ALC880 W810 model
1721 *
1722 * W810 has rear IO for:
1723 * Front (DAC 02)
1724 * Surround (DAC 03)
1725 * Center/LFE (DAC 04)
1726 * Digital out (06)
1727 *
1728 * The system also has a pair of internal speakers, and a headphone jack.
1729 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001730 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001731 * There is a variable resistor to control the speaker or headphone
1732 * volume. This is a hardware-only device without a software API.
1733 *
1734 * Plugging headphones in will disable the internal speakers. This is
1735 * implemented in hardware, not via the driver using jack sense. In
1736 * a similar fashion, plugging into the rear socket marked "front" will
1737 * disable both the speakers and headphones.
1738 *
1739 * For input, there's a microphone jack, and an "audio in" jack.
1740 * These may not do anything useful with this driver yet, because I
1741 * haven't setup any initialization verbs for these yet...
1742 */
1743
1744static hda_nid_t alc880_w810_dac_nids[3] = {
1745 /* front, rear/surround, clfe */
1746 0x02, 0x03, 0x04
1747};
1748
1749/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001750static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001751 { 6, NULL }
1752};
1753
1754/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001755static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001756 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001757 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001758 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001759 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001760 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1761 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001762 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1763 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001764 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1765 { } /* end */
1766};
1767
1768
1769/*
1770 * Z710V model
1771 *
1772 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001773 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1774 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001775 */
1776
1777static hda_nid_t alc880_z71v_dac_nids[1] = {
1778 0x02
1779};
1780#define ALC880_Z71V_HP_DAC 0x03
1781
1782/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001783static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001784 { 2, NULL }
1785};
1786
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001787static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001788 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001789 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001790 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001791 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1796 { } /* end */
1797};
1798
1799
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001800/*
1801 * ALC880 F1734 model
1802 *
1803 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1804 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1805 */
1806
1807static hda_nid_t alc880_f1734_dac_nids[1] = {
1808 0x03
1809};
1810#define ALC880_F1734_HP_DAC 0x02
1811
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001812static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001813 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001814 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001815 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1816 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001817 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1818 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001821 { } /* end */
1822};
1823
Takashi Iwai937b4162008-02-11 14:52:36 +01001824static struct hda_input_mux alc880_f1734_capture_source = {
1825 .num_items = 2,
1826 .items = {
1827 { "Mic", 0x1 },
1828 { "CD", 0x4 },
1829 },
1830};
1831
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001833/*
1834 * ALC880 ASUS model
1835 *
1836 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1837 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1838 * Mic = 0x18, Line = 0x1a
1839 */
1840
1841#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1842#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1843
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001844static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001845 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001846 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001847 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001848 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001849 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1850 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001851 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1852 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001853 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1854 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1855 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1856 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001859 {
1860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1861 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001862 .info = alc_ch_mode_info,
1863 .get = alc_ch_mode_get,
1864 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001865 },
1866 { } /* end */
1867};
1868
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001869/*
1870 * ALC880 ASUS W1V model
1871 *
1872 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1873 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1874 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1875 */
1876
1877/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001878static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001879 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1880 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001881 { } /* end */
1882};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001883
Kailang Yangdf694da2005-12-05 19:42:22 +01001884/* TCL S700 */
1885static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1886 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1887 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1889 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1890 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1893 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1894 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001895 { } /* end */
1896};
1897
Kailang Yangccc656c2006-10-17 12:32:26 +02001898/* Uniwill */
1899static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001900 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1901 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1902 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1903 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001904 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1905 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1906 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1907 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1908 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1909 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1910 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1911 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1914 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1915 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001916 {
1917 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1918 .name = "Channel Mode",
1919 .info = alc_ch_mode_info,
1920 .get = alc_ch_mode_get,
1921 .put = alc_ch_mode_put,
1922 },
1923 { } /* end */
1924};
1925
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001926static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1927 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1928 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1929 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1930 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1933 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1934 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1935 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1936 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1937 { } /* end */
1938};
1939
Kailang Yangccc656c2006-10-17 12:32:26 +02001940static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001941 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1942 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1943 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1944 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001945 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1946 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1947 { } /* end */
1948};
1949
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001951 * virtual master controls
1952 */
1953
1954/*
1955 * slave controls for virtual master
1956 */
1957static const char *alc_slave_vols[] = {
1958 "Front Playback Volume",
1959 "Surround Playback Volume",
1960 "Center Playback Volume",
1961 "LFE Playback Volume",
1962 "Side Playback Volume",
1963 "Headphone Playback Volume",
1964 "Speaker Playback Volume",
1965 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001966 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001967 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001968 NULL,
1969};
1970
1971static const char *alc_slave_sws[] = {
1972 "Front Playback Switch",
1973 "Surround Playback Switch",
1974 "Center Playback Switch",
1975 "LFE Playback Switch",
1976 "Side Playback Switch",
1977 "Headphone Playback Switch",
1978 "Speaker Playback Switch",
1979 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001980 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001981 NULL,
1982};
1983
1984/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001985 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001986 */
Takashi Iwai603c4012008-07-30 15:01:44 +02001987
1988static void alc_free_kctls(struct hda_codec *codec);
1989
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01001990/* additional beep mixers; the actual parameters are overwritten at build */
1991static struct snd_kcontrol_new alc_beep_mixer[] = {
1992 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
1993 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
1994 { } /* end */
1995};
1996
Linus Torvalds1da177e2005-04-16 15:20:36 -07001997static int alc_build_controls(struct hda_codec *codec)
1998{
1999 struct alc_spec *spec = codec->spec;
2000 int err;
2001 int i;
2002
2003 for (i = 0; i < spec->num_mixers; i++) {
2004 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2005 if (err < 0)
2006 return err;
2007 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002008 if (spec->cap_mixer) {
2009 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2010 if (err < 0)
2011 return err;
2012 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002014 err = snd_hda_create_spdif_out_ctls(codec,
2015 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002016 if (err < 0)
2017 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002018 if (!spec->no_analog) {
2019 err = snd_hda_create_spdif_share_sw(codec,
2020 &spec->multiout);
2021 if (err < 0)
2022 return err;
2023 spec->multiout.share_spdif = 1;
2024 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002025 }
2026 if (spec->dig_in_nid) {
2027 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2028 if (err < 0)
2029 return err;
2030 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002031
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002032 /* create beep controls if needed */
2033 if (spec->beep_amp) {
2034 struct snd_kcontrol_new *knew;
2035 for (knew = alc_beep_mixer; knew->name; knew++) {
2036 struct snd_kcontrol *kctl;
2037 kctl = snd_ctl_new1(knew, codec);
2038 if (!kctl)
2039 return -ENOMEM;
2040 kctl->private_value = spec->beep_amp;
2041 err = snd_hda_ctl_add(codec, kctl);
2042 if (err < 0)
2043 return err;
2044 }
2045 }
2046
Takashi Iwai2134ea42008-01-10 16:53:55 +01002047 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002048 if (!spec->no_analog &&
2049 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002050 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002051 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002052 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002053 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002054 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002055 if (err < 0)
2056 return err;
2057 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002058 if (!spec->no_analog &&
2059 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002060 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2061 NULL, alc_slave_sws);
2062 if (err < 0)
2063 return err;
2064 }
2065
Takashi Iwai603c4012008-07-30 15:01:44 +02002066 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002067 return 0;
2068}
2069
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002070
Linus Torvalds1da177e2005-04-16 15:20:36 -07002071/*
2072 * initialize the codec volumes, etc
2073 */
2074
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002075/*
2076 * generic initialization of ADC, input mixers and output mixers
2077 */
2078static struct hda_verb alc880_volume_init_verbs[] = {
2079 /*
2080 * Unmute ADC0-2 and set the default input to mic-in
2081 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002082 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002083 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002084 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002085 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002086 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002087 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002088
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002089 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2090 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002091 * Note: PASD motherboards uses the Line In 2 as the input for front
2092 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002093 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002094 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002095 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2096 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002103 /*
2104 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002105 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002106 /* set vol=0 to output mixers */
2107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2108 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2109 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2110 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2111 /* set up input amps for analog loopback */
2112 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002113 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002115 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2116 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002117 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2118 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002119 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2120 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002121
2122 { }
2123};
2124
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002125/*
2126 * 3-stack pin configuration:
2127 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2128 */
2129static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2130 /*
2131 * preset connection lists of input pins
2132 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2133 */
2134 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2135 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2136 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2137
2138 /*
2139 * Set pin mode and muting
2140 */
2141 /* set front pin widgets 0x14 for output */
2142 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2143 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2144 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2145 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2146 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2147 /* Mic2 (as headphone out) for HP output */
2148 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2149 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2150 /* Line In pin widget for input */
2151 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2152 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2153 /* Line2 (as front mic) pin widget for input and vref at 80% */
2154 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2155 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2156 /* CD pin widget for input */
2157 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2158
2159 { }
2160};
2161
2162/*
2163 * 5-stack pin configuration:
2164 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2165 * line-in/side = 0x1a, f-mic = 0x1b
2166 */
2167static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2168 /*
2169 * preset connection lists of input pins
2170 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2171 */
2172 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2173 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2174
2175 /*
2176 * Set pin mode and muting
2177 */
2178 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002179 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2180 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2181 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2182 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002183 /* unmute pins for output (no gain on this amp) */
2184 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2185 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2186 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2187 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2188
Linus Torvalds1da177e2005-04-16 15:20:36 -07002189 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002190 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002191 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2192 /* Mic2 (as headphone out) for HP output */
2193 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002194 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002195 /* Line In pin widget for input */
2196 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2197 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2198 /* Line2 (as front mic) pin widget for input and vref at 80% */
2199 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2200 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2201 /* CD pin widget for input */
2202 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002203
2204 { }
2205};
2206
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207/*
2208 * W810 pin configuration:
2209 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2210 */
2211static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002212 /* hphone/speaker input selector: front DAC */
2213 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2214
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002215 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2216 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2217 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2218 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2219 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2220 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2221
2222 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002223 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002224
Linus Torvalds1da177e2005-04-16 15:20:36 -07002225 { }
2226};
2227
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002228/*
2229 * Z71V pin configuration:
2230 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2231 */
2232static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002233 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002234 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002237
Takashi Iwai16ded522005-06-10 19:58:24 +02002238 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002239 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002240 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002241 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002242
2243 { }
2244};
2245
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002246/*
2247 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002248 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2249 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002250 */
2251static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2252 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2253
Takashi Iwai16ded522005-06-10 19:58:24 +02002254 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002255 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002258 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002260 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002261 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2262
Takashi Iwai16ded522005-06-10 19:58:24 +02002263 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002264 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002265 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002266 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002267 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002268 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002269 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002270 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002271 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002272
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002273 { }
2274};
Takashi Iwai16ded522005-06-10 19:58:24 +02002275
Kailang Yangccc656c2006-10-17 12:32:26 +02002276/*
2277 * Uniwill pin configuration:
2278 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2279 * line = 0x1a
2280 */
2281static struct hda_verb alc880_uniwill_init_verbs[] = {
2282 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2283
2284 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2285 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2286 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2288 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2289 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2290 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2291 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2292 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2293 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2294 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2295 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2296 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2297 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2298
2299 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2300 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2301 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2302 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2305 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2306 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2307 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2308
2309 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2310 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2311
2312 { }
2313};
2314
2315/*
2316* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002317* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002318 */
2319static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2320 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2321
2322 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2323 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2324 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2325 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2326 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2327 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2328 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2330 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2332 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2334
2335 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2336 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2337 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2338 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2339 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2340 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2341
2342 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2343 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2344
2345 { }
2346};
2347
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002348static struct hda_verb alc880_beep_init_verbs[] = {
2349 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2350 { }
2351};
2352
Kailang Yangccc656c2006-10-17 12:32:26 +02002353/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002354static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002355{
2356 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002357 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002358
2359 present = snd_hda_codec_read(codec, 0x14, 0,
2360 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002361 bits = present ? HDA_AMP_MUTE : 0;
2362 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2363 HDA_AMP_MUTE, bits);
2364 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2365 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002366}
2367
2368/* auto-toggle front mic */
2369static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2370{
2371 unsigned int present;
2372 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002373
2374 present = snd_hda_codec_read(codec, 0x18, 0,
2375 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002376 bits = present ? HDA_AMP_MUTE : 0;
2377 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002378}
2379
2380static void alc880_uniwill_automute(struct hda_codec *codec)
2381{
2382 alc880_uniwill_hp_automute(codec);
2383 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002384}
2385
2386static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2387 unsigned int res)
2388{
2389 /* Looks like the unsol event is incompatible with the standard
2390 * definition. 4bit tag is placed at 28 bit!
2391 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002392 switch (res >> 28) {
2393 case ALC880_HP_EVENT:
2394 alc880_uniwill_hp_automute(codec);
2395 break;
2396 case ALC880_MIC_EVENT:
2397 alc880_uniwill_mic_automute(codec);
2398 break;
2399 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002400}
2401
2402static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2403{
2404 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002405 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002406
2407 present = snd_hda_codec_read(codec, 0x14, 0,
2408 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002409 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002410 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002411}
2412
2413static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2414{
2415 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002416
Kailang Yangccc656c2006-10-17 12:32:26 +02002417 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002418 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2419 present &= HDA_AMP_VOLMASK;
2420 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2421 HDA_AMP_VOLMASK, present);
2422 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2423 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002424}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002425
Kailang Yangccc656c2006-10-17 12:32:26 +02002426static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2427 unsigned int res)
2428{
2429 /* Looks like the unsol event is incompatible with the standard
2430 * definition. 4bit tag is placed at 28 bit!
2431 */
2432 if ((res >> 28) == ALC880_HP_EVENT)
2433 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002434 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002435 alc880_uniwill_p53_dcvol_automute(codec);
2436}
2437
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002438/*
2439 * F1734 pin configuration:
2440 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2441 */
2442static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002443 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002444 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2445 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2446 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2447 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2448
2449 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2450 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2453
2454 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2455 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002456 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002457 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2458 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2459 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2460 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2461 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2462 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002463
Takashi Iwai937b4162008-02-11 14:52:36 +01002464 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2465 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2466
Takashi Iwai16ded522005-06-10 19:58:24 +02002467 { }
2468};
2469
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002470/*
2471 * ASUS pin configuration:
2472 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2473 */
2474static struct hda_verb alc880_pin_asus_init_verbs[] = {
2475 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2476 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2477 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2478 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2479
2480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2481 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2483 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2484 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2485 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2486 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2488
2489 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2490 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2491 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2492 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2493 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2494 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2495 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2497 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002498
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002499 { }
2500};
2501
2502/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002503#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2504#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002505
Kailang Yangdf694da2005-12-05 19:42:22 +01002506/* Clevo m520g init */
2507static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2508 /* headphone output */
2509 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2510 /* line-out */
2511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2513 /* Line-in */
2514 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2515 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2516 /* CD */
2517 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2518 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2519 /* Mic1 (rear panel) */
2520 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2521 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2522 /* Mic2 (front panel) */
2523 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2524 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2525 /* headphone */
2526 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2527 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2528 /* change to EAPD mode */
2529 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2530 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2531
2532 { }
2533};
2534
2535static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002536 /* change to EAPD mode */
2537 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2538 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2539
Kailang Yangdf694da2005-12-05 19:42:22 +01002540 /* Headphone output */
2541 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2542 /* Front output*/
2543 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2544 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2545
2546 /* Line In pin widget for input */
2547 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2548 /* CD pin widget for input */
2549 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2550 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2551 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2552
2553 /* change to EAPD mode */
2554 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2555 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2556
2557 { }
2558};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002559
2560/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002561 * LG m1 express dual
2562 *
2563 * Pin assignment:
2564 * Rear Line-In/Out (blue): 0x14
2565 * Build-in Mic-In: 0x15
2566 * Speaker-out: 0x17
2567 * HP-Out (green): 0x1b
2568 * Mic-In/Out (red): 0x19
2569 * SPDIF-Out: 0x1e
2570 */
2571
2572/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2573static hda_nid_t alc880_lg_dac_nids[3] = {
2574 0x05, 0x02, 0x03
2575};
2576
2577/* seems analog CD is not working */
2578static struct hda_input_mux alc880_lg_capture_source = {
2579 .num_items = 3,
2580 .items = {
2581 { "Mic", 0x1 },
2582 { "Line", 0x5 },
2583 { "Internal Mic", 0x6 },
2584 },
2585};
2586
2587/* 2,4,6 channel modes */
2588static struct hda_verb alc880_lg_ch2_init[] = {
2589 /* set line-in and mic-in to input */
2590 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2591 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2592 { }
2593};
2594
2595static struct hda_verb alc880_lg_ch4_init[] = {
2596 /* set line-in to out and mic-in to input */
2597 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2598 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2599 { }
2600};
2601
2602static struct hda_verb alc880_lg_ch6_init[] = {
2603 /* set line-in and mic-in to output */
2604 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2605 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2606 { }
2607};
2608
2609static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2610 { 2, alc880_lg_ch2_init },
2611 { 4, alc880_lg_ch4_init },
2612 { 6, alc880_lg_ch6_init },
2613};
2614
2615static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002616 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2617 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002618 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2619 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2620 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2621 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2622 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2623 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2624 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2625 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2626 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2627 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2628 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2629 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2630 {
2631 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2632 .name = "Channel Mode",
2633 .info = alc_ch_mode_info,
2634 .get = alc_ch_mode_get,
2635 .put = alc_ch_mode_put,
2636 },
2637 { } /* end */
2638};
2639
2640static struct hda_verb alc880_lg_init_verbs[] = {
2641 /* set capture source to mic-in */
2642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2643 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2644 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2645 /* mute all amp mixer inputs */
2646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002649 /* line-in to input */
2650 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2651 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2652 /* built-in mic */
2653 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2654 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2655 /* speaker-out */
2656 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2657 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2658 /* mic-in to input */
2659 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2660 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2661 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2662 /* HP-out */
2663 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2664 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2665 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2666 /* jack sense */
2667 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2668 { }
2669};
2670
2671/* toggle speaker-output according to the hp-jack state */
2672static void alc880_lg_automute(struct hda_codec *codec)
2673{
2674 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002675 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002676
2677 present = snd_hda_codec_read(codec, 0x1b, 0,
2678 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002679 bits = present ? HDA_AMP_MUTE : 0;
2680 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2681 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002682}
2683
2684static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2685{
2686 /* Looks like the unsol event is incompatible with the standard
2687 * definition. 4bit tag is placed at 28 bit!
2688 */
2689 if ((res >> 28) == 0x01)
2690 alc880_lg_automute(codec);
2691}
2692
2693/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002694 * LG LW20
2695 *
2696 * Pin assignment:
2697 * Speaker-out: 0x14
2698 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002699 * Built-in Mic-In: 0x19
2700 * Line-In: 0x1b
2701 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002702 * SPDIF-Out: 0x1e
2703 */
2704
Takashi Iwaid6815182006-03-23 16:06:23 +01002705static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002706 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002707 .items = {
2708 { "Mic", 0x0 },
2709 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002710 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002711 },
2712};
2713
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002714#define alc880_lg_lw_modes alc880_threestack_modes
2715
Takashi Iwaid6815182006-03-23 16:06:23 +01002716static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002717 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2718 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2719 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2720 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2721 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2722 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2723 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2724 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2725 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2726 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002727 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2728 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2729 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2730 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002731 {
2732 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2733 .name = "Channel Mode",
2734 .info = alc_ch_mode_info,
2735 .get = alc_ch_mode_get,
2736 .put = alc_ch_mode_put,
2737 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002738 { } /* end */
2739};
2740
2741static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002742 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2743 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2744 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2745
Takashi Iwaid6815182006-03-23 16:06:23 +01002746 /* set capture source to mic-in */
2747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2748 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2749 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002750 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002751 /* speaker-out */
2752 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2753 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2754 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002755 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2756 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2757 /* mic-in to input */
2758 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2759 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2760 /* built-in mic */
2761 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2762 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2763 /* jack sense */
2764 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2765 { }
2766};
2767
2768/* toggle speaker-output according to the hp-jack state */
2769static void alc880_lg_lw_automute(struct hda_codec *codec)
2770{
2771 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002772 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002773
2774 present = snd_hda_codec_read(codec, 0x1b, 0,
2775 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002776 bits = present ? HDA_AMP_MUTE : 0;
2777 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2778 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002779}
2780
2781static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2782{
2783 /* Looks like the unsol event is incompatible with the standard
2784 * definition. 4bit tag is placed at 28 bit!
2785 */
2786 if ((res >> 28) == 0x01)
2787 alc880_lg_lw_automute(codec);
2788}
2789
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002790static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2791 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2792 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2793 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2794 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2795 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2796 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2797 { } /* end */
2798};
2799
2800static struct hda_input_mux alc880_medion_rim_capture_source = {
2801 .num_items = 2,
2802 .items = {
2803 { "Mic", 0x0 },
2804 { "Internal Mic", 0x1 },
2805 },
2806};
2807
2808static struct hda_verb alc880_medion_rim_init_verbs[] = {
2809 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2810
2811 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2812 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2813
2814 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2815 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2816 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2817 /* Mic2 (as headphone out) for HP output */
2818 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2820 /* Internal Speaker */
2821 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2822 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2823
2824 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2825 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2826
2827 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2828 { }
2829};
2830
2831/* toggle speaker-output according to the hp-jack state */
2832static void alc880_medion_rim_automute(struct hda_codec *codec)
2833{
2834 unsigned int present;
2835 unsigned char bits;
2836
2837 present = snd_hda_codec_read(codec, 0x14, 0,
2838 AC_VERB_GET_PIN_SENSE, 0)
2839 & AC_PINSENSE_PRESENCE;
2840 bits = present ? HDA_AMP_MUTE : 0;
2841 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2842 HDA_AMP_MUTE, bits);
2843 if (present)
2844 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2845 else
2846 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2847}
2848
2849static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2850 unsigned int res)
2851{
2852 /* Looks like the unsol event is incompatible with the standard
2853 * definition. 4bit tag is placed at 28 bit!
2854 */
2855 if ((res >> 28) == ALC880_HP_EVENT)
2856 alc880_medion_rim_automute(codec);
2857}
2858
Takashi Iwaicb53c622007-08-10 17:21:45 +02002859#ifdef CONFIG_SND_HDA_POWER_SAVE
2860static struct hda_amp_list alc880_loopbacks[] = {
2861 { 0x0b, HDA_INPUT, 0 },
2862 { 0x0b, HDA_INPUT, 1 },
2863 { 0x0b, HDA_INPUT, 2 },
2864 { 0x0b, HDA_INPUT, 3 },
2865 { 0x0b, HDA_INPUT, 4 },
2866 { } /* end */
2867};
2868
2869static struct hda_amp_list alc880_lg_loopbacks[] = {
2870 { 0x0b, HDA_INPUT, 1 },
2871 { 0x0b, HDA_INPUT, 6 },
2872 { 0x0b, HDA_INPUT, 7 },
2873 { } /* end */
2874};
2875#endif
2876
Takashi Iwaid6815182006-03-23 16:06:23 +01002877/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002878 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002879 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002880
Linus Torvalds1da177e2005-04-16 15:20:36 -07002881static int alc_init(struct hda_codec *codec)
2882{
2883 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002884 unsigned int i;
2885
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002886 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002887 if (codec->vendor_id == 0x10ec0888)
2888 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002889
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002890 for (i = 0; i < spec->num_init_verbs; i++)
2891 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002892
2893 if (spec->init_hook)
2894 spec->init_hook(codec);
2895
Linus Torvalds1da177e2005-04-16 15:20:36 -07002896 return 0;
2897}
2898
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002899static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2900{
2901 struct alc_spec *spec = codec->spec;
2902
2903 if (spec->unsol_event)
2904 spec->unsol_event(codec, res);
2905}
2906
Takashi Iwaicb53c622007-08-10 17:21:45 +02002907#ifdef CONFIG_SND_HDA_POWER_SAVE
2908static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2909{
2910 struct alc_spec *spec = codec->spec;
2911 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2912}
2913#endif
2914
Linus Torvalds1da177e2005-04-16 15:20:36 -07002915/*
2916 * Analog playback callbacks
2917 */
2918static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2919 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002920 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002921{
2922 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002923 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2924 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002925}
2926
2927static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2928 struct hda_codec *codec,
2929 unsigned int stream_tag,
2930 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002931 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002932{
2933 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002934 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2935 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002936}
2937
2938static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2939 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002940 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941{
2942 struct alc_spec *spec = codec->spec;
2943 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2944}
2945
2946/*
2947 * Digital out
2948 */
2949static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2950 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002951 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002952{
2953 struct alc_spec *spec = codec->spec;
2954 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2955}
2956
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002957static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2958 struct hda_codec *codec,
2959 unsigned int stream_tag,
2960 unsigned int format,
2961 struct snd_pcm_substream *substream)
2962{
2963 struct alc_spec *spec = codec->spec;
2964 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2965 stream_tag, format, substream);
2966}
2967
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01002968static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2969 struct hda_codec *codec,
2970 struct snd_pcm_substream *substream)
2971{
2972 struct alc_spec *spec = codec->spec;
2973 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2974}
2975
Linus Torvalds1da177e2005-04-16 15:20:36 -07002976static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2977 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002978 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002979{
2980 struct alc_spec *spec = codec->spec;
2981 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2982}
2983
2984/*
2985 * Analog capture
2986 */
Takashi Iwai63300792008-01-24 15:31:36 +01002987static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002988 struct hda_codec *codec,
2989 unsigned int stream_tag,
2990 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002991 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002992{
2993 struct alc_spec *spec = codec->spec;
2994
Takashi Iwai63300792008-01-24 15:31:36 +01002995 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002996 stream_tag, 0, format);
2997 return 0;
2998}
2999
Takashi Iwai63300792008-01-24 15:31:36 +01003000static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003001 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003002 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003{
3004 struct alc_spec *spec = codec->spec;
3005
Takashi Iwai888afa12008-03-18 09:57:50 +01003006 snd_hda_codec_cleanup_stream(codec,
3007 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003008 return 0;
3009}
3010
3011
3012/*
3013 */
3014static struct hda_pcm_stream alc880_pcm_analog_playback = {
3015 .substreams = 1,
3016 .channels_min = 2,
3017 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003018 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003019 .ops = {
3020 .open = alc880_playback_pcm_open,
3021 .prepare = alc880_playback_pcm_prepare,
3022 .cleanup = alc880_playback_pcm_cleanup
3023 },
3024};
3025
3026static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003027 .substreams = 1,
3028 .channels_min = 2,
3029 .channels_max = 2,
3030 /* NID is set in alc_build_pcms */
3031};
3032
3033static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3034 .substreams = 1,
3035 .channels_min = 2,
3036 .channels_max = 2,
3037 /* NID is set in alc_build_pcms */
3038};
3039
3040static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3041 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003042 .channels_min = 2,
3043 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003044 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003045 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003046 .prepare = alc880_alt_capture_pcm_prepare,
3047 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003048 },
3049};
3050
3051static struct hda_pcm_stream alc880_pcm_digital_playback = {
3052 .substreams = 1,
3053 .channels_min = 2,
3054 .channels_max = 2,
3055 /* NID is set in alc_build_pcms */
3056 .ops = {
3057 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003058 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003059 .prepare = alc880_dig_playback_pcm_prepare,
3060 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003061 },
3062};
3063
3064static struct hda_pcm_stream alc880_pcm_digital_capture = {
3065 .substreams = 1,
3066 .channels_min = 2,
3067 .channels_max = 2,
3068 /* NID is set in alc_build_pcms */
3069};
3070
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003071/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003072static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003073 .substreams = 0,
3074 .channels_min = 0,
3075 .channels_max = 0,
3076};
3077
Linus Torvalds1da177e2005-04-16 15:20:36 -07003078static int alc_build_pcms(struct hda_codec *codec)
3079{
3080 struct alc_spec *spec = codec->spec;
3081 struct hda_pcm *info = spec->pcm_rec;
3082 int i;
3083
3084 codec->num_pcms = 1;
3085 codec->pcm_info = info;
3086
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003087 if (spec->no_analog)
3088 goto skip_analog;
3089
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003091 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003092 if (snd_BUG_ON(!spec->multiout.dac_nids))
3093 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003094 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3095 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3096 }
3097 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003098 if (snd_BUG_ON(!spec->adc_nids))
3099 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003100 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3101 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3102 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003103
Takashi Iwai4a471b72005-12-07 13:56:29 +01003104 if (spec->channel_mode) {
3105 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3106 for (i = 0; i < spec->num_channel_mode; i++) {
3107 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3108 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3109 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003110 }
3111 }
3112
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003113 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003114 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003115 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003116 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003117 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003118 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003119 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003120 if (spec->dig_out_type)
3121 info->pcm_type = spec->dig_out_type;
3122 else
3123 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003124 if (spec->multiout.dig_out_nid &&
3125 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003126 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3127 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3128 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003129 if (spec->dig_in_nid &&
3130 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003131 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3132 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3133 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003134 /* FIXME: do we need this for all Realtek codec models? */
3135 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003136 }
3137
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003138 if (spec->no_analog)
3139 return 0;
3140
Takashi Iwaie08a0072006-09-07 17:52:14 +02003141 /* If the use of more than one ADC is requested for the current
3142 * model, configure a second analog capture-only PCM.
3143 */
3144 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003145 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3146 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003147 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003148 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003149 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003150 if (spec->alt_dac_nid) {
3151 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3152 *spec->stream_analog_alt_playback;
3153 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3154 spec->alt_dac_nid;
3155 } else {
3156 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3157 alc_pcm_null_stream;
3158 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3159 }
3160 if (spec->num_adc_nids > 1) {
3161 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3162 *spec->stream_analog_alt_capture;
3163 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3164 spec->adc_nids[1];
3165 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3166 spec->num_adc_nids - 1;
3167 } else {
3168 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3169 alc_pcm_null_stream;
3170 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003171 }
3172 }
3173
Linus Torvalds1da177e2005-04-16 15:20:36 -07003174 return 0;
3175}
3176
Takashi Iwai603c4012008-07-30 15:01:44 +02003177static void alc_free_kctls(struct hda_codec *codec)
3178{
3179 struct alc_spec *spec = codec->spec;
3180
3181 if (spec->kctls.list) {
3182 struct snd_kcontrol_new *kctl = spec->kctls.list;
3183 int i;
3184 for (i = 0; i < spec->kctls.used; i++)
3185 kfree(kctl[i].name);
3186 }
3187 snd_array_free(&spec->kctls);
3188}
3189
Linus Torvalds1da177e2005-04-16 15:20:36 -07003190static void alc_free(struct hda_codec *codec)
3191{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003192 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003193
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003194 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003195 return;
3196
Takashi Iwai603c4012008-07-30 15:01:44 +02003197 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003198 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003199 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003200}
3201
Takashi Iwaie044c392008-10-27 16:56:24 +01003202#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003203static int alc_resume(struct hda_codec *codec)
3204{
Takashi Iwaie044c392008-10-27 16:56:24 +01003205 codec->patch_ops.init(codec);
3206 snd_hda_codec_resume_amp(codec);
3207 snd_hda_codec_resume_cache(codec);
3208 return 0;
3209}
Takashi Iwaie044c392008-10-27 16:56:24 +01003210#endif
3211
Linus Torvalds1da177e2005-04-16 15:20:36 -07003212/*
3213 */
3214static struct hda_codec_ops alc_patch_ops = {
3215 .build_controls = alc_build_controls,
3216 .build_pcms = alc_build_pcms,
3217 .init = alc_init,
3218 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003219 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003220#ifdef SND_HDA_NEEDS_RESUME
3221 .resume = alc_resume,
3222#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003223#ifdef CONFIG_SND_HDA_POWER_SAVE
3224 .check_power_status = alc_check_power_status,
3225#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003226};
3227
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003228
3229/*
3230 * Test configuration for debugging
3231 *
3232 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3233 * enum controls.
3234 */
3235#ifdef CONFIG_SND_DEBUG
3236static hda_nid_t alc880_test_dac_nids[4] = {
3237 0x02, 0x03, 0x04, 0x05
3238};
3239
3240static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003241 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003242 .items = {
3243 { "In-1", 0x0 },
3244 { "In-2", 0x1 },
3245 { "In-3", 0x2 },
3246 { "In-4", 0x3 },
3247 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003248 { "Front", 0x5 },
3249 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003250 },
3251};
3252
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003253static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003254 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003255 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003256 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003257 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003258};
3259
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003260static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3261 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003262{
3263 static char *texts[] = {
3264 "N/A", "Line Out", "HP Out",
3265 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3266 };
3267 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3268 uinfo->count = 1;
3269 uinfo->value.enumerated.items = 8;
3270 if (uinfo->value.enumerated.item >= 8)
3271 uinfo->value.enumerated.item = 7;
3272 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3273 return 0;
3274}
3275
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003276static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3277 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003278{
3279 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3280 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3281 unsigned int pin_ctl, item = 0;
3282
3283 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3284 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3285 if (pin_ctl & AC_PINCTL_OUT_EN) {
3286 if (pin_ctl & AC_PINCTL_HP_EN)
3287 item = 2;
3288 else
3289 item = 1;
3290 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3291 switch (pin_ctl & AC_PINCTL_VREFEN) {
3292 case AC_PINCTL_VREF_HIZ: item = 3; break;
3293 case AC_PINCTL_VREF_50: item = 4; break;
3294 case AC_PINCTL_VREF_GRD: item = 5; break;
3295 case AC_PINCTL_VREF_80: item = 6; break;
3296 case AC_PINCTL_VREF_100: item = 7; break;
3297 }
3298 }
3299 ucontrol->value.enumerated.item[0] = item;
3300 return 0;
3301}
3302
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003303static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3304 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003305{
3306 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3307 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3308 static unsigned int ctls[] = {
3309 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3310 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3311 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3312 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3313 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3314 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3315 };
3316 unsigned int old_ctl, new_ctl;
3317
3318 old_ctl = snd_hda_codec_read(codec, nid, 0,
3319 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3320 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3321 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003322 int val;
3323 snd_hda_codec_write_cache(codec, nid, 0,
3324 AC_VERB_SET_PIN_WIDGET_CONTROL,
3325 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003326 val = ucontrol->value.enumerated.item[0] >= 3 ?
3327 HDA_AMP_MUTE : 0;
3328 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3329 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003330 return 1;
3331 }
3332 return 0;
3333}
3334
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003335static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3336 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003337{
3338 static char *texts[] = {
3339 "Front", "Surround", "CLFE", "Side"
3340 };
3341 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3342 uinfo->count = 1;
3343 uinfo->value.enumerated.items = 4;
3344 if (uinfo->value.enumerated.item >= 4)
3345 uinfo->value.enumerated.item = 3;
3346 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3347 return 0;
3348}
3349
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003350static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3351 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003352{
3353 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3354 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3355 unsigned int sel;
3356
3357 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3358 ucontrol->value.enumerated.item[0] = sel & 3;
3359 return 0;
3360}
3361
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003362static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3363 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003364{
3365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3366 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3367 unsigned int sel;
3368
3369 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3370 if (ucontrol->value.enumerated.item[0] != sel) {
3371 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003372 snd_hda_codec_write_cache(codec, nid, 0,
3373 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003374 return 1;
3375 }
3376 return 0;
3377}
3378
3379#define PIN_CTL_TEST(xname,nid) { \
3380 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3381 .name = xname, \
3382 .info = alc_test_pin_ctl_info, \
3383 .get = alc_test_pin_ctl_get, \
3384 .put = alc_test_pin_ctl_put, \
3385 .private_value = nid \
3386 }
3387
3388#define PIN_SRC_TEST(xname,nid) { \
3389 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3390 .name = xname, \
3391 .info = alc_test_pin_src_info, \
3392 .get = alc_test_pin_src_get, \
3393 .put = alc_test_pin_src_put, \
3394 .private_value = nid \
3395 }
3396
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003397static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003398 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3399 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3400 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3401 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003402 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3403 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3404 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3405 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003406 PIN_CTL_TEST("Front Pin Mode", 0x14),
3407 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3408 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3409 PIN_CTL_TEST("Side Pin Mode", 0x17),
3410 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3411 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3412 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3413 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3414 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3415 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3416 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3417 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3418 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3419 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3420 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3421 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3422 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3423 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3424 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3425 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3426 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3427 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003428 {
3429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3430 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003431 .info = alc_ch_mode_info,
3432 .get = alc_ch_mode_get,
3433 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003434 },
3435 { } /* end */
3436};
3437
3438static struct hda_verb alc880_test_init_verbs[] = {
3439 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003440 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3441 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3442 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3443 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3444 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3445 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3446 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3447 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003448 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003449 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3450 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3451 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3452 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003453 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003454 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3455 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3456 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3457 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003458 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3460 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3461 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3462 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003463 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003464 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3465 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003466 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3467 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3468 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003469 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3471 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3472 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3473 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003474 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003476 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003477 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003478 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003479 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003480 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003481 /* Analog input/passthru */
3482 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3483 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3484 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3485 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3486 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003487 { }
3488};
3489#endif
3490
Linus Torvalds1da177e2005-04-16 15:20:36 -07003491/*
3492 */
3493
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003494static const char *alc880_models[ALC880_MODEL_LAST] = {
3495 [ALC880_3ST] = "3stack",
3496 [ALC880_TCL_S700] = "tcl",
3497 [ALC880_3ST_DIG] = "3stack-digout",
3498 [ALC880_CLEVO] = "clevo",
3499 [ALC880_5ST] = "5stack",
3500 [ALC880_5ST_DIG] = "5stack-digout",
3501 [ALC880_W810] = "w810",
3502 [ALC880_Z71V] = "z71v",
3503 [ALC880_6ST] = "6stack",
3504 [ALC880_6ST_DIG] = "6stack-digout",
3505 [ALC880_ASUS] = "asus",
3506 [ALC880_ASUS_W1V] = "asus-w1v",
3507 [ALC880_ASUS_DIG] = "asus-dig",
3508 [ALC880_ASUS_DIG2] = "asus-dig2",
3509 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003510 [ALC880_UNIWILL_P53] = "uniwill-p53",
3511 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003512 [ALC880_F1734] = "F1734",
3513 [ALC880_LG] = "lg",
3514 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003515 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003516#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003517 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003518#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003519 [ALC880_AUTO] = "auto",
3520};
3521
3522static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003523 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003524 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3525 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3526 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3527 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3528 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3529 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3530 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3531 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003532 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3533 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003534 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3535 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3536 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3537 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3538 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3539 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3540 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3541 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3542 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3543 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003544 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003545 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3546 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3547 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003548 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003549 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003550 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3551 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003552 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3553 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003554 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3555 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3556 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3557 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003558 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3559 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003560 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003561 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003562 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003563 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003564 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3565 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003566 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003567 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003568 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003569 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003570 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003571 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003572 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003573 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003574 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003575 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3576 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003577 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003578 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3579 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3580 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3581 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003582 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3583 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003584 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003585 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003586 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3587 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003588 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3589 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3590 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003591 /* default Intel */
3592 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003593 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3594 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003595 {}
3596};
3597
Takashi Iwai16ded522005-06-10 19:58:24 +02003598/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003599 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003600 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003601static struct alc_config_preset alc880_presets[] = {
3602 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003603 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003604 .init_verbs = { alc880_volume_init_verbs,
3605 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003606 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003607 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003608 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3609 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003610 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003611 .input_mux = &alc880_capture_source,
3612 },
3613 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003614 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003615 .init_verbs = { alc880_volume_init_verbs,
3616 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003617 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003618 .dac_nids = alc880_dac_nids,
3619 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003620 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3621 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003622 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003623 .input_mux = &alc880_capture_source,
3624 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003625 [ALC880_TCL_S700] = {
3626 .mixers = { alc880_tcl_s700_mixer },
3627 .init_verbs = { alc880_volume_init_verbs,
3628 alc880_pin_tcl_S700_init_verbs,
3629 alc880_gpio2_init_verbs },
3630 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3631 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003632 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3633 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003634 .hp_nid = 0x03,
3635 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3636 .channel_mode = alc880_2_jack_modes,
3637 .input_mux = &alc880_capture_source,
3638 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003639 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003640 .mixers = { alc880_three_stack_mixer,
3641 alc880_five_stack_mixer},
3642 .init_verbs = { alc880_volume_init_verbs,
3643 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003644 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3645 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003646 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3647 .channel_mode = alc880_fivestack_modes,
3648 .input_mux = &alc880_capture_source,
3649 },
3650 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003651 .mixers = { alc880_three_stack_mixer,
3652 alc880_five_stack_mixer },
3653 .init_verbs = { alc880_volume_init_verbs,
3654 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003655 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3656 .dac_nids = alc880_dac_nids,
3657 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003658 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3659 .channel_mode = alc880_fivestack_modes,
3660 .input_mux = &alc880_capture_source,
3661 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003662 [ALC880_6ST] = {
3663 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003664 .init_verbs = { alc880_volume_init_verbs,
3665 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003666 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3667 .dac_nids = alc880_6st_dac_nids,
3668 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3669 .channel_mode = alc880_sixstack_modes,
3670 .input_mux = &alc880_6stack_capture_source,
3671 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003672 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003673 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003674 .init_verbs = { alc880_volume_init_verbs,
3675 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003676 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3677 .dac_nids = alc880_6st_dac_nids,
3678 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003679 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3680 .channel_mode = alc880_sixstack_modes,
3681 .input_mux = &alc880_6stack_capture_source,
3682 },
3683 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003684 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003685 .init_verbs = { alc880_volume_init_verbs,
3686 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003687 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003688 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3689 .dac_nids = alc880_w810_dac_nids,
3690 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003691 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3692 .channel_mode = alc880_w810_modes,
3693 .input_mux = &alc880_capture_source,
3694 },
3695 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003696 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003697 .init_verbs = { alc880_volume_init_verbs,
3698 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003699 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3700 .dac_nids = alc880_z71v_dac_nids,
3701 .dig_out_nid = ALC880_DIGOUT_NID,
3702 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003703 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3704 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003705 .input_mux = &alc880_capture_source,
3706 },
3707 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003708 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003709 .init_verbs = { alc880_volume_init_verbs,
3710 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003711 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3712 .dac_nids = alc880_f1734_dac_nids,
3713 .hp_nid = 0x02,
3714 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3715 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003716 .input_mux = &alc880_f1734_capture_source,
3717 .unsol_event = alc880_uniwill_p53_unsol_event,
3718 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003719 },
3720 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003721 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003722 .init_verbs = { alc880_volume_init_verbs,
3723 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003724 alc880_gpio1_init_verbs },
3725 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3726 .dac_nids = alc880_asus_dac_nids,
3727 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3728 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003729 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003730 .input_mux = &alc880_capture_source,
3731 },
3732 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003733 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003734 .init_verbs = { alc880_volume_init_verbs,
3735 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003736 alc880_gpio1_init_verbs },
3737 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3738 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003739 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003740 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3741 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003742 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003743 .input_mux = &alc880_capture_source,
3744 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003745 [ALC880_ASUS_DIG2] = {
3746 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003747 .init_verbs = { alc880_volume_init_verbs,
3748 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003749 alc880_gpio2_init_verbs }, /* use GPIO2 */
3750 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3751 .dac_nids = alc880_asus_dac_nids,
3752 .dig_out_nid = ALC880_DIGOUT_NID,
3753 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3754 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003755 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003756 .input_mux = &alc880_capture_source,
3757 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003758 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003759 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003760 .init_verbs = { alc880_volume_init_verbs,
3761 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003762 alc880_gpio1_init_verbs },
3763 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3764 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003765 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003766 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3767 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003768 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003769 .input_mux = &alc880_capture_source,
3770 },
3771 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003772 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003773 .init_verbs = { alc880_volume_init_verbs,
3774 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003775 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3776 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003777 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003778 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3779 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003780 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003781 .input_mux = &alc880_capture_source,
3782 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003783 [ALC880_UNIWILL] = {
3784 .mixers = { alc880_uniwill_mixer },
3785 .init_verbs = { alc880_volume_init_verbs,
3786 alc880_uniwill_init_verbs },
3787 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3788 .dac_nids = alc880_asus_dac_nids,
3789 .dig_out_nid = ALC880_DIGOUT_NID,
3790 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3791 .channel_mode = alc880_threestack_modes,
3792 .need_dac_fix = 1,
3793 .input_mux = &alc880_capture_source,
3794 .unsol_event = alc880_uniwill_unsol_event,
3795 .init_hook = alc880_uniwill_automute,
3796 },
3797 [ALC880_UNIWILL_P53] = {
3798 .mixers = { alc880_uniwill_p53_mixer },
3799 .init_verbs = { alc880_volume_init_verbs,
3800 alc880_uniwill_p53_init_verbs },
3801 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3802 .dac_nids = alc880_asus_dac_nids,
3803 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003804 .channel_mode = alc880_threestack_modes,
3805 .input_mux = &alc880_capture_source,
3806 .unsol_event = alc880_uniwill_p53_unsol_event,
3807 .init_hook = alc880_uniwill_p53_hp_automute,
3808 },
3809 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003810 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003811 .init_verbs = { alc880_volume_init_verbs,
3812 alc880_uniwill_p53_init_verbs,
3813 alc880_beep_init_verbs },
3814 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3815 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003816 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003817 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3818 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003819 .input_mux = &alc880_capture_source,
3820 .unsol_event = alc880_uniwill_p53_unsol_event,
3821 .init_hook = alc880_uniwill_p53_hp_automute,
3822 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003823 [ALC880_CLEVO] = {
3824 .mixers = { alc880_three_stack_mixer },
3825 .init_verbs = { alc880_volume_init_verbs,
3826 alc880_pin_clevo_init_verbs },
3827 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3828 .dac_nids = alc880_dac_nids,
3829 .hp_nid = 0x03,
3830 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3831 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003832 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003833 .input_mux = &alc880_capture_source,
3834 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003835 [ALC880_LG] = {
3836 .mixers = { alc880_lg_mixer },
3837 .init_verbs = { alc880_volume_init_verbs,
3838 alc880_lg_init_verbs },
3839 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3840 .dac_nids = alc880_lg_dac_nids,
3841 .dig_out_nid = ALC880_DIGOUT_NID,
3842 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3843 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003844 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003845 .input_mux = &alc880_lg_capture_source,
3846 .unsol_event = alc880_lg_unsol_event,
3847 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003848#ifdef CONFIG_SND_HDA_POWER_SAVE
3849 .loopbacks = alc880_lg_loopbacks,
3850#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003851 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003852 [ALC880_LG_LW] = {
3853 .mixers = { alc880_lg_lw_mixer },
3854 .init_verbs = { alc880_volume_init_verbs,
3855 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003856 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003857 .dac_nids = alc880_dac_nids,
3858 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003859 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3860 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003861 .input_mux = &alc880_lg_lw_capture_source,
3862 .unsol_event = alc880_lg_lw_unsol_event,
3863 .init_hook = alc880_lg_lw_automute,
3864 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003865 [ALC880_MEDION_RIM] = {
3866 .mixers = { alc880_medion_rim_mixer },
3867 .init_verbs = { alc880_volume_init_verbs,
3868 alc880_medion_rim_init_verbs,
3869 alc_gpio2_init_verbs },
3870 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3871 .dac_nids = alc880_dac_nids,
3872 .dig_out_nid = ALC880_DIGOUT_NID,
3873 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3874 .channel_mode = alc880_2_jack_modes,
3875 .input_mux = &alc880_medion_rim_capture_source,
3876 .unsol_event = alc880_medion_rim_unsol_event,
3877 .init_hook = alc880_medion_rim_automute,
3878 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003879#ifdef CONFIG_SND_DEBUG
3880 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003881 .mixers = { alc880_test_mixer },
3882 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003883 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3884 .dac_nids = alc880_test_dac_nids,
3885 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003886 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3887 .channel_mode = alc880_test_modes,
3888 .input_mux = &alc880_test_capture_source,
3889 },
3890#endif
3891};
3892
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003893/*
3894 * Automatic parse of I/O pins from the BIOS configuration
3895 */
3896
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003897enum {
3898 ALC_CTL_WIDGET_VOL,
3899 ALC_CTL_WIDGET_MUTE,
3900 ALC_CTL_BIND_MUTE,
3901};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003902static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003903 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3904 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003905 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003906};
3907
3908/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003909static int add_control(struct alc_spec *spec, int type, const char *name,
3910 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003911{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003912 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003913
Takashi Iwai603c4012008-07-30 15:01:44 +02003914 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3915 knew = snd_array_new(&spec->kctls);
3916 if (!knew)
3917 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003918 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003919 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003920 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003921 return -ENOMEM;
3922 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003923 return 0;
3924}
3925
3926#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3927#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3928#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3929#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3930#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3931#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3932#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3933#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3934#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3935#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3936#define ALC880_PIN_CD_NID 0x1c
3937
3938/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003939static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3940 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003941{
3942 hda_nid_t nid;
3943 int assigned[4];
3944 int i, j;
3945
3946 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003947 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003948
3949 /* check the pins hardwired to audio widget */
3950 for (i = 0; i < cfg->line_outs; i++) {
3951 nid = cfg->line_out_pins[i];
3952 if (alc880_is_fixed_pin(nid)) {
3953 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003954 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003955 assigned[idx] = 1;
3956 }
3957 }
3958 /* left pins can be connect to any audio widget */
3959 for (i = 0; i < cfg->line_outs; i++) {
3960 nid = cfg->line_out_pins[i];
3961 if (alc880_is_fixed_pin(nid))
3962 continue;
3963 /* search for an empty channel */
3964 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003965 if (!assigned[j]) {
3966 spec->multiout.dac_nids[i] =
3967 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003968 assigned[j] = 1;
3969 break;
3970 }
3971 }
3972 }
3973 spec->multiout.num_dacs = cfg->line_outs;
3974 return 0;
3975}
3976
3977/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003978static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3979 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003980{
3981 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003982 static const char *chname[4] = {
3983 "Front", "Surround", NULL /*CLFE*/, "Side"
3984 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003985 hda_nid_t nid;
3986 int i, err;
3987
3988 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003989 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003990 continue;
3991 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3992 if (i == 2) {
3993 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003994 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3995 "Center Playback Volume",
3996 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3997 HDA_OUTPUT));
3998 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003999 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004000 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4001 "LFE Playback Volume",
4002 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4003 HDA_OUTPUT));
4004 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004005 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004006 err = add_control(spec, ALC_CTL_BIND_MUTE,
4007 "Center Playback Switch",
4008 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4009 HDA_INPUT));
4010 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004011 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004012 err = add_control(spec, ALC_CTL_BIND_MUTE,
4013 "LFE Playback Switch",
4014 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4015 HDA_INPUT));
4016 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004017 return err;
4018 } else {
4019 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004020 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4021 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4022 HDA_OUTPUT));
4023 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004024 return err;
4025 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004026 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4027 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4028 HDA_INPUT));
4029 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004030 return err;
4031 }
4032 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004033 return 0;
4034}
4035
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004036/* add playback controls for speaker and HP outputs */
4037static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4038 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004039{
4040 hda_nid_t nid;
4041 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004042 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004043
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004044 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004045 return 0;
4046
4047 if (alc880_is_fixed_pin(pin)) {
4048 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004049 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004050 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004051 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004052 else
4053 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004054 /* control HP volume/switch on the output mixer amp */
4055 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004056 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004057 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4058 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4059 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004060 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004061 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004062 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4063 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4064 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004065 return err;
4066 } else if (alc880_is_multi_pin(pin)) {
4067 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004068 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004069 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004070 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4071 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4072 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004073 return err;
4074 }
4075 return 0;
4076}
4077
4078/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004079static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4080 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004081 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004082{
4083 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004084 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004085
4086 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004087 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4088 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4089 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004090 return err;
4091 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004092 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4093 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4094 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004095 return err;
4096 return 0;
4097}
4098
4099/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004100static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4101 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004102{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004103 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004104 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004105
4106 for (i = 0; i < AUTO_PIN_LAST; i++) {
4107 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004108 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004109 err = new_analog_input(spec, cfg->input_pins[i],
4110 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004111 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004112 if (err < 0)
4113 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004114 imux->items[imux->num_items].label =
4115 auto_pin_cfg_labels[i];
4116 imux->items[imux->num_items].index =
4117 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004118 imux->num_items++;
4119 }
4120 }
4121 return 0;
4122}
4123
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004124static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4125 unsigned int pin_type)
4126{
4127 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4128 pin_type);
4129 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004130 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4131 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004132}
4133
Kailang Yangdf694da2005-12-05 19:42:22 +01004134static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4135 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004136 int dac_idx)
4137{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004138 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004139 /* need the manual connection? */
4140 if (alc880_is_multi_pin(nid)) {
4141 struct alc_spec *spec = codec->spec;
4142 int idx = alc880_multi_pin_idx(nid);
4143 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4144 AC_VERB_SET_CONNECT_SEL,
4145 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4146 }
4147}
4148
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004149static int get_pin_type(int line_out_type)
4150{
4151 if (line_out_type == AUTO_PIN_HP_OUT)
4152 return PIN_HP;
4153 else
4154 return PIN_OUT;
4155}
4156
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004157static void alc880_auto_init_multi_out(struct hda_codec *codec)
4158{
4159 struct alc_spec *spec = codec->spec;
4160 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004161
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004162 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004163 for (i = 0; i < spec->autocfg.line_outs; i++) {
4164 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004165 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4166 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004167 }
4168}
4169
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004170static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004171{
4172 struct alc_spec *spec = codec->spec;
4173 hda_nid_t pin;
4174
Takashi Iwai82bc9552006-03-21 11:24:42 +01004175 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004176 if (pin) /* connect to front */
4177 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004178 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004179 if (pin) /* connect to front */
4180 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4181}
4182
4183static void alc880_auto_init_analog_input(struct hda_codec *codec)
4184{
4185 struct alc_spec *spec = codec->spec;
4186 int i;
4187
4188 for (i = 0; i < AUTO_PIN_LAST; i++) {
4189 hda_nid_t nid = spec->autocfg.input_pins[i];
4190 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004191 snd_hda_codec_write(codec, nid, 0,
4192 AC_VERB_SET_PIN_WIDGET_CONTROL,
4193 i <= AUTO_PIN_FRONT_MIC ?
4194 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004195 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004196 snd_hda_codec_write(codec, nid, 0,
4197 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004198 AMP_OUT_MUTE);
4199 }
4200 }
4201}
4202
4203/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004204/* return 1 if successful, 0 if the proper config is not found,
4205 * or a negative error code
4206 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004207static int alc880_parse_auto_config(struct hda_codec *codec)
4208{
4209 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004210 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004211 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004212
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004213 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4214 alc880_ignore);
4215 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004216 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004217 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004218 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004219
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004220 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4221 if (err < 0)
4222 return err;
4223 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4224 if (err < 0)
4225 return err;
4226 err = alc880_auto_create_extra_out(spec,
4227 spec->autocfg.speaker_pins[0],
4228 "Speaker");
4229 if (err < 0)
4230 return err;
4231 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4232 "Headphone");
4233 if (err < 0)
4234 return err;
4235 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4236 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004237 return err;
4238
4239 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4240
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004241 /* check multiple SPDIF-out (for recent codecs) */
4242 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4243 hda_nid_t dig_nid;
4244 err = snd_hda_get_connections(codec,
4245 spec->autocfg.dig_out_pins[i],
4246 &dig_nid, 1);
4247 if (err < 0)
4248 continue;
4249 if (!i)
4250 spec->multiout.dig_out_nid = dig_nid;
4251 else {
4252 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4253 spec->slave_dig_outs[i - 1] = dig_nid;
4254 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4255 break;
4256 }
4257 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004258 if (spec->autocfg.dig_in_pin)
4259 spec->dig_in_nid = ALC880_DIGIN_NID;
4260
Takashi Iwai603c4012008-07-30 15:01:44 +02004261 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004262 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004263
Takashi Iwaid88897e2008-10-31 15:01:37 +01004264 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004265
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004266 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004267 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004268
4269 return 1;
4270}
4271
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004272/* additional initialization for auto-configuration model */
4273static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004274{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004275 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004276 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004277 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004278 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004279 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004280 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004281}
4282
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004283static void set_capture_mixer(struct alc_spec *spec)
4284{
4285 static struct snd_kcontrol_new *caps[3] = {
4286 alc_capture_mixer1,
4287 alc_capture_mixer2,
4288 alc_capture_mixer3,
4289 };
Takashi Iwai30d72e92008-11-27 15:25:34 +01004290 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004291 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4292}
4293
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004294#define set_beep_amp(spec, nid, idx, dir) \
4295 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4296
4297/*
4298 * OK, here we have finally the patch for ALC880
4299 */
4300
Linus Torvalds1da177e2005-04-16 15:20:36 -07004301static int patch_alc880(struct hda_codec *codec)
4302{
4303 struct alc_spec *spec;
4304 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004305 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004306
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004307 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004308 if (spec == NULL)
4309 return -ENOMEM;
4310
4311 codec->spec = spec;
4312
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004313 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4314 alc880_models,
4315 alc880_cfg_tbl);
4316 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004317 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4318 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004319 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004320 }
4321
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004322 if (board_config == ALC880_AUTO) {
4323 /* automatic parse from the BIOS config */
4324 err = alc880_parse_auto_config(codec);
4325 if (err < 0) {
4326 alc_free(codec);
4327 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004328 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004329 printk(KERN_INFO
4330 "hda_codec: Cannot set up configuration "
4331 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004332 board_config = ALC880_3ST;
4333 }
4334 }
4335
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004336 err = snd_hda_attach_beep_device(codec, 0x1);
4337 if (err < 0) {
4338 alc_free(codec);
4339 return err;
4340 }
4341
Kailang Yangdf694da2005-12-05 19:42:22 +01004342 if (board_config != ALC880_AUTO)
4343 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004344
4345 spec->stream_name_analog = "ALC880 Analog";
4346 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4347 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004348 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004349
4350 spec->stream_name_digital = "ALC880 Digital";
4351 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4352 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4353
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004354 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004355 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004356 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004357 /* get type */
4358 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004359 if (wcap != AC_WID_AUD_IN) {
4360 spec->adc_nids = alc880_adc_nids_alt;
4361 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004362 } else {
4363 spec->adc_nids = alc880_adc_nids;
4364 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004365 }
4366 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004367 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004368 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004369
Takashi Iwai2134ea42008-01-10 16:53:55 +01004370 spec->vmaster_nid = 0x0c;
4371
Linus Torvalds1da177e2005-04-16 15:20:36 -07004372 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004373 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004374 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004375#ifdef CONFIG_SND_HDA_POWER_SAVE
4376 if (!spec->loopback.amplist)
4377 spec->loopback.amplist = alc880_loopbacks;
4378#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004379 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004380
4381 return 0;
4382}
4383
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004384
Linus Torvalds1da177e2005-04-16 15:20:36 -07004385/*
4386 * ALC260 support
4387 */
4388
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004389static hda_nid_t alc260_dac_nids[1] = {
4390 /* front */
4391 0x02,
4392};
4393
4394static hda_nid_t alc260_adc_nids[1] = {
4395 /* ADC0 */
4396 0x04,
4397};
4398
Kailang Yangdf694da2005-12-05 19:42:22 +01004399static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004400 /* ADC1 */
4401 0x05,
4402};
4403
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004404/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4405 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4406 */
4407static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004408 /* ADC0, ADC1 */
4409 0x04, 0x05
4410};
4411
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004412#define ALC260_DIGOUT_NID 0x03
4413#define ALC260_DIGIN_NID 0x06
4414
4415static struct hda_input_mux alc260_capture_source = {
4416 .num_items = 4,
4417 .items = {
4418 { "Mic", 0x0 },
4419 { "Front Mic", 0x1 },
4420 { "Line", 0x2 },
4421 { "CD", 0x4 },
4422 },
4423};
4424
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004425/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004426 * headphone jack and the internal CD lines since these are the only pins at
4427 * which audio can appear. For flexibility, also allow the option of
4428 * recording the mixer output on the second ADC (ADC0 doesn't have a
4429 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004430 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004431static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4432 {
4433 .num_items = 3,
4434 .items = {
4435 { "Mic/Line", 0x0 },
4436 { "CD", 0x4 },
4437 { "Headphone", 0x2 },
4438 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004439 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004440 {
4441 .num_items = 4,
4442 .items = {
4443 { "Mic/Line", 0x0 },
4444 { "CD", 0x4 },
4445 { "Headphone", 0x2 },
4446 { "Mixer", 0x5 },
4447 },
4448 },
4449
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004450};
4451
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004452/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4453 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004454 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004455static struct hda_input_mux alc260_acer_capture_sources[2] = {
4456 {
4457 .num_items = 4,
4458 .items = {
4459 { "Mic", 0x0 },
4460 { "Line", 0x2 },
4461 { "CD", 0x4 },
4462 { "Headphone", 0x5 },
4463 },
4464 },
4465 {
4466 .num_items = 5,
4467 .items = {
4468 { "Mic", 0x0 },
4469 { "Line", 0x2 },
4470 { "CD", 0x4 },
4471 { "Headphone", 0x6 },
4472 { "Mixer", 0x5 },
4473 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004474 },
4475};
Michael Schwingencc959482009-02-22 18:58:45 +01004476
4477/* Maxdata Favorit 100XS */
4478static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4479 {
4480 .num_items = 2,
4481 .items = {
4482 { "Line/Mic", 0x0 },
4483 { "CD", 0x4 },
4484 },
4485 },
4486 {
4487 .num_items = 3,
4488 .items = {
4489 { "Line/Mic", 0x0 },
4490 { "CD", 0x4 },
4491 { "Mixer", 0x5 },
4492 },
4493 },
4494};
4495
Linus Torvalds1da177e2005-04-16 15:20:36 -07004496/*
4497 * This is just place-holder, so there's something for alc_build_pcms to look
4498 * at when it calculates the maximum number of channels. ALC260 has no mixer
4499 * element which allows changing the channel mode, so the verb list is
4500 * never used.
4501 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004502static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004503 { 2, NULL },
4504};
4505
Kailang Yangdf694da2005-12-05 19:42:22 +01004506
4507/* Mixer combinations
4508 *
4509 * basic: base_output + input + pc_beep + capture
4510 * HP: base_output + input + capture_alt
4511 * HP_3013: hp_3013 + input + capture
4512 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004513 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004514 */
4515
4516static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004517 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004518 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4520 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4521 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4522 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4523 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004524};
Kailang Yangdf694da2005-12-05 19:42:22 +01004525
4526static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004527 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4528 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4529 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4530 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4532 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4533 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4534 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004535 { } /* end */
4536};
4537
Takashi Iwaibec15c32008-01-28 18:16:30 +01004538/* update HP, line and mono out pins according to the master switch */
4539static void alc260_hp_master_update(struct hda_codec *codec,
4540 hda_nid_t hp, hda_nid_t line,
4541 hda_nid_t mono)
4542{
4543 struct alc_spec *spec = codec->spec;
4544 unsigned int val = spec->master_sw ? PIN_HP : 0;
4545 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004546 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004547 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004548 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004549 val);
4550 /* mono (speaker) depending on the HP jack sense */
4551 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004552 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004553 val);
4554}
4555
4556static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4557 struct snd_ctl_elem_value *ucontrol)
4558{
4559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4560 struct alc_spec *spec = codec->spec;
4561 *ucontrol->value.integer.value = spec->master_sw;
4562 return 0;
4563}
4564
4565static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4566 struct snd_ctl_elem_value *ucontrol)
4567{
4568 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4569 struct alc_spec *spec = codec->spec;
4570 int val = !!*ucontrol->value.integer.value;
4571 hda_nid_t hp, line, mono;
4572
4573 if (val == spec->master_sw)
4574 return 0;
4575 spec->master_sw = val;
4576 hp = (kcontrol->private_value >> 16) & 0xff;
4577 line = (kcontrol->private_value >> 8) & 0xff;
4578 mono = kcontrol->private_value & 0xff;
4579 alc260_hp_master_update(codec, hp, line, mono);
4580 return 1;
4581}
4582
4583static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4584 {
4585 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4586 .name = "Master Playback Switch",
4587 .info = snd_ctl_boolean_mono_info,
4588 .get = alc260_hp_master_sw_get,
4589 .put = alc260_hp_master_sw_put,
4590 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4591 },
4592 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4593 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4594 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4595 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4596 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4597 HDA_OUTPUT),
4598 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4599 { } /* end */
4600};
4601
4602static struct hda_verb alc260_hp_unsol_verbs[] = {
4603 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4604 {},
4605};
4606
4607static void alc260_hp_automute(struct hda_codec *codec)
4608{
4609 struct alc_spec *spec = codec->spec;
4610 unsigned int present;
4611
4612 present = snd_hda_codec_read(codec, 0x10, 0,
4613 AC_VERB_GET_PIN_SENSE, 0);
4614 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4615 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4616}
4617
4618static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4619{
4620 if ((res >> 26) == ALC880_HP_EVENT)
4621 alc260_hp_automute(codec);
4622}
4623
Kailang Yangdf694da2005-12-05 19:42:22 +01004624static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004625 {
4626 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4627 .name = "Master Playback Switch",
4628 .info = snd_ctl_boolean_mono_info,
4629 .get = alc260_hp_master_sw_get,
4630 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004631 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004632 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004633 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4634 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4635 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4636 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4637 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4638 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004639 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4640 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004641 { } /* end */
4642};
4643
Kailang Yang3f878302008-08-26 13:02:23 +02004644static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4645 .ops = &snd_hda_bind_vol,
4646 .values = {
4647 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4648 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4649 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4650 0
4651 },
4652};
4653
4654static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4655 .ops = &snd_hda_bind_sw,
4656 .values = {
4657 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4658 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4659 0
4660 },
4661};
4662
4663static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4664 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4665 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4666 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4667 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4668 { } /* end */
4669};
4670
Takashi Iwaibec15c32008-01-28 18:16:30 +01004671static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4672 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4673 {},
4674};
4675
4676static void alc260_hp_3013_automute(struct hda_codec *codec)
4677{
4678 struct alc_spec *spec = codec->spec;
4679 unsigned int present;
4680
4681 present = snd_hda_codec_read(codec, 0x15, 0,
4682 AC_VERB_GET_PIN_SENSE, 0);
4683 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004684 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004685}
4686
4687static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4688 unsigned int res)
4689{
4690 if ((res >> 26) == ALC880_HP_EVENT)
4691 alc260_hp_3013_automute(codec);
4692}
4693
Kailang Yang3f878302008-08-26 13:02:23 +02004694static void alc260_hp_3012_automute(struct hda_codec *codec)
4695{
4696 unsigned int present, bits;
4697
4698 present = snd_hda_codec_read(codec, 0x10, 0,
4699 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4700
4701 bits = present ? 0 : PIN_OUT;
4702 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4703 bits);
4704 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4705 bits);
4706 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4707 bits);
4708}
4709
4710static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4711 unsigned int res)
4712{
4713 if ((res >> 26) == ALC880_HP_EVENT)
4714 alc260_hp_3012_automute(codec);
4715}
4716
4717/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004718 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4719 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004720static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004721 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004722 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004723 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004724 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4725 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4726 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4727 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004728 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004729 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4730 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004731 { } /* end */
4732};
4733
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004734/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4735 * versions of the ALC260 don't act on requests to enable mic bias from NID
4736 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4737 * datasheet doesn't mention this restriction. At this stage it's not clear
4738 * whether this behaviour is intentional or is a hardware bug in chip
4739 * revisions available in early 2006. Therefore for now allow the
4740 * "Headphone Jack Mode" control to span all choices, but if it turns out
4741 * that the lack of mic bias for this NID is intentional we could change the
4742 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4743 *
4744 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4745 * don't appear to make the mic bias available from the "line" jack, even
4746 * though the NID used for this jack (0x14) can supply it. The theory is
4747 * that perhaps Acer have included blocking capacitors between the ALC260
4748 * and the output jack. If this turns out to be the case for all such
4749 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4750 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004751 *
4752 * The C20x Tablet series have a mono internal speaker which is controlled
4753 * via the chip's Mono sum widget and pin complex, so include the necessary
4754 * controls for such models. On models without a "mono speaker" the control
4755 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004756 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004757static struct snd_kcontrol_new alc260_acer_mixer[] = {
4758 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4759 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004760 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004761 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004762 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004763 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004764 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004765 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4766 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4767 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4768 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4769 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4770 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4771 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4772 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004773 { } /* end */
4774};
4775
Michael Schwingencc959482009-02-22 18:58:45 +01004776/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4777 */
4778static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4779 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4780 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4781 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4782 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4783 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4784 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4785 { } /* end */
4786};
4787
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004788/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4789 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4790 */
4791static struct snd_kcontrol_new alc260_will_mixer[] = {
4792 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4793 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4795 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4796 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4797 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4798 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4799 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4800 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4801 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004802 { } /* end */
4803};
4804
4805/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4806 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4807 */
4808static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4809 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4810 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4812 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4813 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4814 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4815 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4816 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4817 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4818 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4819 { } /* end */
4820};
4821
Kailang Yangdf694da2005-12-05 19:42:22 +01004822/*
4823 * initialization verbs
4824 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004825static struct hda_verb alc260_init_verbs[] = {
4826 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004827 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004828 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004829 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004830 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004831 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004832 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004833 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004834 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004835 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004836 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004837 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004838 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004839 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004840 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004841 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004842 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004843 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4844 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004845 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004846 /* set connection select to line in (default select for this ADC) */
4847 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004848 /* mute capture amp left and right */
4849 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4850 /* set connection select to line in (default select for this ADC) */
4851 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004852 /* set vol=0 Line-Out mixer amp left and right */
4853 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4854 /* unmute pin widget amp left and right (no gain on this amp) */
4855 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4856 /* set vol=0 HP mixer amp left and right */
4857 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4858 /* unmute pin widget amp left and right (no gain on this amp) */
4859 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4860 /* set vol=0 Mono mixer amp left and right */
4861 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4862 /* unmute pin widget amp left and right (no gain on this amp) */
4863 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4864 /* unmute LINE-2 out pin */
4865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004866 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4867 * Line In 2 = 0x03
4868 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004869 /* mute analog inputs */
4870 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4871 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4872 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4873 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004875 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004876 /* mute Front out path */
4877 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4878 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4879 /* mute Headphone out path */
4880 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4881 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4882 /* mute Mono out path */
4883 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4884 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004885 { }
4886};
4887
Takashi Iwai474167d2006-05-17 17:17:43 +02004888#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004889static struct hda_verb alc260_hp_init_verbs[] = {
4890 /* Headphone and output */
4891 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4892 /* mono output */
4893 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4894 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4895 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4896 /* Mic2 (front panel) pin widget for input and vref at 80% */
4897 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4898 /* Line In pin widget for input */
4899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4900 /* Line-2 pin widget for output */
4901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4902 /* CD pin widget for input */
4903 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4904 /* unmute amp left and right */
4905 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4906 /* set connection select to line in (default select for this ADC) */
4907 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4908 /* unmute Line-Out mixer amp left and right (volume = 0) */
4909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4910 /* mute pin widget amp left and right (no gain on this amp) */
4911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4912 /* unmute HP mixer amp left and right (volume = 0) */
4913 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4914 /* mute pin widget amp left and right (no gain on this amp) */
4915 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004916 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4917 * Line In 2 = 0x03
4918 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004919 /* mute analog inputs */
4920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4921 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4922 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4923 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4924 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004925 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4926 /* Unmute Front out path */
4927 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4928 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4929 /* Unmute Headphone out path */
4930 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4931 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4932 /* Unmute Mono out path */
4933 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4934 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4935 { }
4936};
Takashi Iwai474167d2006-05-17 17:17:43 +02004937#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004938
4939static struct hda_verb alc260_hp_3013_init_verbs[] = {
4940 /* Line out and output */
4941 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4942 /* mono output */
4943 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4944 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4945 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4946 /* Mic2 (front panel) pin widget for input and vref at 80% */
4947 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4948 /* Line In pin widget for input */
4949 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4950 /* Headphone pin widget for output */
4951 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4952 /* CD pin widget for input */
4953 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4954 /* unmute amp left and right */
4955 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4956 /* set connection select to line in (default select for this ADC) */
4957 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4958 /* unmute Line-Out mixer amp left and right (volume = 0) */
4959 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4960 /* mute pin widget amp left and right (no gain on this amp) */
4961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4962 /* unmute HP mixer amp left and right (volume = 0) */
4963 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4964 /* mute pin widget amp left and right (no gain on this amp) */
4965 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004966 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4967 * Line In 2 = 0x03
4968 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004969 /* mute analog inputs */
4970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4974 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004975 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4976 /* Unmute Front out path */
4977 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4978 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4979 /* Unmute Headphone out path */
4980 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4981 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4982 /* Unmute Mono out path */
4983 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4984 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4985 { }
4986};
4987
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004988/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004989 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4990 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004991 */
4992static struct hda_verb alc260_fujitsu_init_verbs[] = {
4993 /* Disable all GPIOs */
4994 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4995 /* Internal speaker is connected to headphone pin */
4996 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4997 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4998 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004999 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5000 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5001 /* Ensure all other unused pins are disabled and muted. */
5002 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5003 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005004 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005005 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005006 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005007 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5008 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5009 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005010
Jonathan Woithef7ace402006-02-28 11:46:14 +01005011 /* Disable digital (SPDIF) pins */
5012 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5013 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005014
Kailang Yangea1fb292008-08-26 12:58:38 +02005015 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005016 * when acting as an output.
5017 */
5018 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5019
5020 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005021 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5022 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5023 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5024 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5025 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5026 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5027 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5028 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5029 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005030
Jonathan Woithef7ace402006-02-28 11:46:14 +01005031 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5032 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5033 /* Unmute Line1 pin widget output buffer since it starts as an output.
5034 * If the pin mode is changed by the user the pin mode control will
5035 * take care of enabling the pin's input/output buffers as needed.
5036 * Therefore there's no need to enable the input buffer at this
5037 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005038 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005039 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005040 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005041 * mixer ctrl)
5042 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005043 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005044
Jonathan Woithef7ace402006-02-28 11:46:14 +01005045 /* Mute capture amp left and right */
5046 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005047 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005048 * in (on mic1 pin)
5049 */
5050 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005051
Jonathan Woithef7ace402006-02-28 11:46:14 +01005052 /* Do the same for the second ADC: mute capture input amp and
5053 * set ADC connection to line in (on mic1 pin)
5054 */
5055 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5056 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005057
Jonathan Woithef7ace402006-02-28 11:46:14 +01005058 /* Mute all inputs to mixer widget (even unconnected ones) */
5059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5061 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5062 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5063 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5064 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5065 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5066 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005067
5068 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005069};
5070
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005071/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5072 * similar laptops (adapted from Fujitsu init verbs).
5073 */
5074static struct hda_verb alc260_acer_init_verbs[] = {
5075 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5076 * the headphone jack. Turn this on and rely on the standard mute
5077 * methods whenever the user wants to turn these outputs off.
5078 */
5079 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5080 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5081 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5082 /* Internal speaker/Headphone jack is connected to Line-out pin */
5083 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5084 /* Internal microphone/Mic jack is connected to Mic1 pin */
5085 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5086 /* Line In jack is connected to Line1 pin */
5087 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005088 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5089 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005090 /* Ensure all other unused pins are disabled and muted. */
5091 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5092 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005093 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5094 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5096 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5097 /* Disable digital (SPDIF) pins */
5098 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5099 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5100
Kailang Yangea1fb292008-08-26 12:58:38 +02005101 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005102 * bus when acting as outputs.
5103 */
5104 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5105 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5106
5107 /* Start with output sum widgets muted and their output gains at min */
5108 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5109 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5110 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5111 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5112 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5113 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5114 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5115 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5116 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5117
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005118 /* Unmute Line-out pin widget amp left and right
5119 * (no equiv mixer ctrl)
5120 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005121 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005122 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5123 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005124 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5125 * inputs. If the pin mode is changed by the user the pin mode control
5126 * will take care of enabling the pin's input/output buffers as needed.
5127 * Therefore there's no need to enable the input buffer at this
5128 * stage.
5129 */
5130 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5131 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5132
5133 /* Mute capture amp left and right */
5134 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5135 /* Set ADC connection select to match default mixer setting - mic
5136 * (on mic1 pin)
5137 */
5138 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5139
5140 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005141 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005142 */
5143 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005144 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005145
5146 /* Mute all inputs to mixer widget (even unconnected ones) */
5147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5151 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5152 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5153 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5154 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5155
5156 { }
5157};
5158
Michael Schwingencc959482009-02-22 18:58:45 +01005159/* Initialisation sequence for Maxdata Favorit 100XS
5160 * (adapted from Acer init verbs).
5161 */
5162static struct hda_verb alc260_favorit100_init_verbs[] = {
5163 /* GPIO 0 enables the output jack.
5164 * Turn this on and rely on the standard mute
5165 * methods whenever the user wants to turn these outputs off.
5166 */
5167 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5168 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5169 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5170 /* Line/Mic input jack is connected to Mic1 pin */
5171 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5172 /* Ensure all other unused pins are disabled and muted. */
5173 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5174 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5175 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5176 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5177 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5178 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5179 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5180 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5183 /* Disable digital (SPDIF) pins */
5184 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5185 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5186
5187 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5188 * bus when acting as outputs.
5189 */
5190 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5191 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5192
5193 /* Start with output sum widgets muted and their output gains at min */
5194 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5195 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5197 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5198 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5200 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5201 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5202 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5203
5204 /* Unmute Line-out pin widget amp left and right
5205 * (no equiv mixer ctrl)
5206 */
5207 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5208 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5209 * inputs. If the pin mode is changed by the user the pin mode control
5210 * will take care of enabling the pin's input/output buffers as needed.
5211 * Therefore there's no need to enable the input buffer at this
5212 * stage.
5213 */
5214 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5215
5216 /* Mute capture amp left and right */
5217 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5218 /* Set ADC connection select to match default mixer setting - mic
5219 * (on mic1 pin)
5220 */
5221 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5222
5223 /* Do similar with the second ADC: mute capture input amp and
5224 * set ADC connection to mic to match ALSA's default state.
5225 */
5226 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5227 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5228
5229 /* Mute all inputs to mixer widget (even unconnected ones) */
5230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5231 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5235 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5236 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5238
5239 { }
5240};
5241
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005242static struct hda_verb alc260_will_verbs[] = {
5243 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5244 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5245 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5246 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5247 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5248 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5249 {}
5250};
5251
5252static struct hda_verb alc260_replacer_672v_verbs[] = {
5253 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5254 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5255 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5256
5257 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5258 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5259 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5260
5261 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5262 {}
5263};
5264
5265/* toggle speaker-output according to the hp-jack state */
5266static void alc260_replacer_672v_automute(struct hda_codec *codec)
5267{
5268 unsigned int present;
5269
5270 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5271 present = snd_hda_codec_read(codec, 0x0f, 0,
5272 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5273 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005274 snd_hda_codec_write_cache(codec, 0x01, 0,
5275 AC_VERB_SET_GPIO_DATA, 1);
5276 snd_hda_codec_write_cache(codec, 0x0f, 0,
5277 AC_VERB_SET_PIN_WIDGET_CONTROL,
5278 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005279 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005280 snd_hda_codec_write_cache(codec, 0x01, 0,
5281 AC_VERB_SET_GPIO_DATA, 0);
5282 snd_hda_codec_write_cache(codec, 0x0f, 0,
5283 AC_VERB_SET_PIN_WIDGET_CONTROL,
5284 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005285 }
5286}
5287
5288static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5289 unsigned int res)
5290{
5291 if ((res >> 26) == ALC880_HP_EVENT)
5292 alc260_replacer_672v_automute(codec);
5293}
5294
Kailang Yang3f878302008-08-26 13:02:23 +02005295static struct hda_verb alc260_hp_dc7600_verbs[] = {
5296 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5297 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5298 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5299 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5300 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5301 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5302 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5303 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5304 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5305 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5306 {}
5307};
5308
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005309/* Test configuration for debugging, modelled after the ALC880 test
5310 * configuration.
5311 */
5312#ifdef CONFIG_SND_DEBUG
5313static hda_nid_t alc260_test_dac_nids[1] = {
5314 0x02,
5315};
5316static hda_nid_t alc260_test_adc_nids[2] = {
5317 0x04, 0x05,
5318};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005319/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005320 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005321 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005322 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005323static struct hda_input_mux alc260_test_capture_sources[2] = {
5324 {
5325 .num_items = 7,
5326 .items = {
5327 { "MIC1 pin", 0x0 },
5328 { "MIC2 pin", 0x1 },
5329 { "LINE1 pin", 0x2 },
5330 { "LINE2 pin", 0x3 },
5331 { "CD pin", 0x4 },
5332 { "LINE-OUT pin", 0x5 },
5333 { "HP-OUT pin", 0x6 },
5334 },
5335 },
5336 {
5337 .num_items = 8,
5338 .items = {
5339 { "MIC1 pin", 0x0 },
5340 { "MIC2 pin", 0x1 },
5341 { "LINE1 pin", 0x2 },
5342 { "LINE2 pin", 0x3 },
5343 { "CD pin", 0x4 },
5344 { "Mixer", 0x5 },
5345 { "LINE-OUT pin", 0x6 },
5346 { "HP-OUT pin", 0x7 },
5347 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005348 },
5349};
5350static struct snd_kcontrol_new alc260_test_mixer[] = {
5351 /* Output driver widgets */
5352 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5353 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5354 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5355 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5356 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5357 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5358
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005359 /* Modes for retasking pin widgets
5360 * Note: the ALC260 doesn't seem to act on requests to enable mic
5361 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5362 * mention this restriction. At this stage it's not clear whether
5363 * this behaviour is intentional or is a hardware bug in chip
5364 * revisions available at least up until early 2006. Therefore for
5365 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5366 * choices, but if it turns out that the lack of mic bias for these
5367 * NIDs is intentional we could change their modes from
5368 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5369 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005370 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5371 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5372 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5373 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5374 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5375 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5376
5377 /* Loopback mixer controls */
5378 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5379 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5380 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5381 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5382 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5383 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5384 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5385 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5386 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5387 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005388 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5389 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5390 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5391 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005392
5393 /* Controls for GPIO pins, assuming they are configured as outputs */
5394 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5395 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5396 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5397 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5398
Jonathan Woithe92621f12006-02-28 11:47:47 +01005399 /* Switches to allow the digital IO pins to be enabled. The datasheet
5400 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005401 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005402 */
5403 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5404 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5405
Jonathan Woithef8225f62008-01-08 12:16:54 +01005406 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5407 * this output to turn on an external amplifier.
5408 */
5409 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5410 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5411
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005412 { } /* end */
5413};
5414static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005415 /* Enable all GPIOs as outputs with an initial value of 0 */
5416 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5417 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5418 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5419
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005420 /* Enable retasking pins as output, initially without power amp */
5421 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5422 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5423 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5424 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5425 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5426 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5427
Jonathan Woithe92621f12006-02-28 11:47:47 +01005428 /* Disable digital (SPDIF) pins initially, but users can enable
5429 * them via a mixer switch. In the case of SPDIF-out, this initverb
5430 * payload also sets the generation to 0, output to be in "consumer"
5431 * PCM format, copyright asserted, no pre-emphasis and no validity
5432 * control.
5433 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005434 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5435 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5436
Kailang Yangea1fb292008-08-26 12:58:38 +02005437 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005438 * OUT1 sum bus when acting as an output.
5439 */
5440 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5441 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5442 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5443 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5444
5445 /* Start with output sum widgets muted and their output gains at min */
5446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5447 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5448 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5449 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5450 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5451 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5452 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5453 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5454 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5455
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005456 /* Unmute retasking pin widget output buffers since the default
5457 * state appears to be output. As the pin mode is changed by the
5458 * user the pin mode control will take care of enabling the pin's
5459 * input/output buffers as needed.
5460 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005461 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5462 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5463 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5464 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5465 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5466 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5467 /* Also unmute the mono-out pin widget */
5468 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5469
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005470 /* Mute capture amp left and right */
5471 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005472 /* Set ADC connection select to match default mixer setting (mic1
5473 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005474 */
5475 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5476
5477 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005478 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005479 */
5480 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5481 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5482
5483 /* Mute all inputs to mixer widget (even unconnected ones) */
5484 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5485 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5490 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5492
5493 { }
5494};
5495#endif
5496
Takashi Iwai63300792008-01-24 15:31:36 +01005497#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5498#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005499
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005500#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5501#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5502
Kailang Yangdf694da2005-12-05 19:42:22 +01005503/*
5504 * for BIOS auto-configuration
5505 */
5506
5507static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005508 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005509{
5510 hda_nid_t nid_vol;
5511 unsigned long vol_val, sw_val;
5512 char name[32];
5513 int err;
5514
5515 if (nid >= 0x0f && nid < 0x11) {
5516 nid_vol = nid - 0x7;
5517 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5518 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5519 } else if (nid == 0x11) {
5520 nid_vol = nid - 0x7;
5521 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5522 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5523 } else if (nid >= 0x12 && nid <= 0x15) {
5524 nid_vol = 0x08;
5525 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5526 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5527 } else
5528 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005529
Takashi Iwai863b4512008-10-21 17:01:47 +02005530 if (!(*vol_bits & (1 << nid_vol))) {
5531 /* first control for the volume widget */
5532 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5533 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5534 if (err < 0)
5535 return err;
5536 *vol_bits |= (1 << nid_vol);
5537 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005538 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005539 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5540 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005541 return err;
5542 return 1;
5543}
5544
5545/* add playback controls from the parsed DAC table */
5546static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5547 const struct auto_pin_cfg *cfg)
5548{
5549 hda_nid_t nid;
5550 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005551 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005552
5553 spec->multiout.num_dacs = 1;
5554 spec->multiout.dac_nids = spec->private_dac_nids;
5555 spec->multiout.dac_nids[0] = 0x02;
5556
5557 nid = cfg->line_out_pins[0];
5558 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005559 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005560 if (err < 0)
5561 return err;
5562 }
5563
Takashi Iwai82bc9552006-03-21 11:24:42 +01005564 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005565 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005566 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005567 if (err < 0)
5568 return err;
5569 }
5570
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005571 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005572 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005573 err = alc260_add_playback_controls(spec, nid, "Headphone",
5574 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005575 if (err < 0)
5576 return err;
5577 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005578 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005579}
5580
5581/* create playback/capture controls for input pins */
5582static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5583 const struct auto_pin_cfg *cfg)
5584{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005585 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005586 int i, err, idx;
5587
5588 for (i = 0; i < AUTO_PIN_LAST; i++) {
5589 if (cfg->input_pins[i] >= 0x12) {
5590 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005591 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005592 auto_pin_cfg_labels[i], idx,
5593 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005594 if (err < 0)
5595 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005596 imux->items[imux->num_items].label =
5597 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005598 imux->items[imux->num_items].index = idx;
5599 imux->num_items++;
5600 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005601 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005602 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005603 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005604 auto_pin_cfg_labels[i], idx,
5605 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005606 if (err < 0)
5607 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005608 imux->items[imux->num_items].label =
5609 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005610 imux->items[imux->num_items].index = idx;
5611 imux->num_items++;
5612 }
5613 }
5614 return 0;
5615}
5616
5617static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5618 hda_nid_t nid, int pin_type,
5619 int sel_idx)
5620{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005621 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005622 /* need the manual connection? */
5623 if (nid >= 0x12) {
5624 int idx = nid - 0x12;
5625 snd_hda_codec_write(codec, idx + 0x0b, 0,
5626 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005627 }
5628}
5629
5630static void alc260_auto_init_multi_out(struct hda_codec *codec)
5631{
5632 struct alc_spec *spec = codec->spec;
5633 hda_nid_t nid;
5634
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005635 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005636 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005637 if (nid) {
5638 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5639 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5640 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005641
Takashi Iwai82bc9552006-03-21 11:24:42 +01005642 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005643 if (nid)
5644 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5645
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005646 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005647 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005648 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005649}
Kailang Yangdf694da2005-12-05 19:42:22 +01005650
5651#define ALC260_PIN_CD_NID 0x16
5652static void alc260_auto_init_analog_input(struct hda_codec *codec)
5653{
5654 struct alc_spec *spec = codec->spec;
5655 int i;
5656
5657 for (i = 0; i < AUTO_PIN_LAST; i++) {
5658 hda_nid_t nid = spec->autocfg.input_pins[i];
5659 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005660 snd_hda_codec_write(codec, nid, 0,
5661 AC_VERB_SET_PIN_WIDGET_CONTROL,
5662 i <= AUTO_PIN_FRONT_MIC ?
5663 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005664 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005665 snd_hda_codec_write(codec, nid, 0,
5666 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005667 AMP_OUT_MUTE);
5668 }
5669 }
5670}
5671
5672/*
5673 * generic initialization of ADC, input mixers and output mixers
5674 */
5675static struct hda_verb alc260_volume_init_verbs[] = {
5676 /*
5677 * Unmute ADC0-1 and set the default input to mic-in
5678 */
5679 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5680 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5681 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5682 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005683
Kailang Yangdf694da2005-12-05 19:42:22 +01005684 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5685 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005686 * Note: PASD motherboards uses the Line In 2 as the input for
5687 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005688 */
5689 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005690 /* mute analog inputs */
5691 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5692 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005696
5697 /*
5698 * Set up output mixers (0x08 - 0x0a)
5699 */
5700 /* set vol=0 to output mixers */
5701 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5702 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5703 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5704 /* set up input amps for analog loopback */
5705 /* Amp Indices: DAC = 0, mixer = 1 */
5706 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5707 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5708 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5709 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5710 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5711 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005712
Kailang Yangdf694da2005-12-05 19:42:22 +01005713 { }
5714};
5715
5716static int alc260_parse_auto_config(struct hda_codec *codec)
5717{
5718 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005719 int err;
5720 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5721
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005722 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5723 alc260_ignore);
5724 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005725 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005726 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5727 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005728 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005729 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005730 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005731 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5732 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005733 return err;
5734
5735 spec->multiout.max_channels = 2;
5736
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005737 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005738 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005739 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005740 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005741
Takashi Iwaid88897e2008-10-31 15:01:37 +01005742 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005743
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005744 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005745 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005746
Kailang Yangdf694da2005-12-05 19:42:22 +01005747 return 1;
5748}
5749
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005750/* additional initialization for auto-configuration model */
5751static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005752{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005753 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005754 alc260_auto_init_multi_out(codec);
5755 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005756 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005757 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005758}
5759
Takashi Iwaicb53c622007-08-10 17:21:45 +02005760#ifdef CONFIG_SND_HDA_POWER_SAVE
5761static struct hda_amp_list alc260_loopbacks[] = {
5762 { 0x07, HDA_INPUT, 0 },
5763 { 0x07, HDA_INPUT, 1 },
5764 { 0x07, HDA_INPUT, 2 },
5765 { 0x07, HDA_INPUT, 3 },
5766 { 0x07, HDA_INPUT, 4 },
5767 { } /* end */
5768};
5769#endif
5770
Kailang Yangdf694da2005-12-05 19:42:22 +01005771/*
5772 * ALC260 configurations
5773 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005774static const char *alc260_models[ALC260_MODEL_LAST] = {
5775 [ALC260_BASIC] = "basic",
5776 [ALC260_HP] = "hp",
5777 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005778 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005779 [ALC260_FUJITSU_S702X] = "fujitsu",
5780 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005781 [ALC260_WILL] = "will",
5782 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005783 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005784#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005785 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005786#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005787 [ALC260_AUTO] = "auto",
5788};
5789
5790static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005791 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005792 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01005793 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01005794 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005795 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005796 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005797 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005798 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005799 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5800 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5801 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5802 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5803 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5804 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5805 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5806 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5807 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005808 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005809 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005810 {}
5811};
5812
Kailang Yangdf694da2005-12-05 19:42:22 +01005813static struct alc_config_preset alc260_presets[] = {
5814 [ALC260_BASIC] = {
5815 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005816 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005817 .init_verbs = { alc260_init_verbs },
5818 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5819 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005820 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005821 .adc_nids = alc260_adc_nids,
5822 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5823 .channel_mode = alc260_modes,
5824 .input_mux = &alc260_capture_source,
5825 },
5826 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005827 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005828 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005829 .init_verbs = { alc260_init_verbs,
5830 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005831 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5832 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005833 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5834 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005835 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5836 .channel_mode = alc260_modes,
5837 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005838 .unsol_event = alc260_hp_unsol_event,
5839 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005840 },
Kailang Yang3f878302008-08-26 13:02:23 +02005841 [ALC260_HP_DC7600] = {
5842 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005843 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005844 .init_verbs = { alc260_init_verbs,
5845 alc260_hp_dc7600_verbs },
5846 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5847 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005848 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5849 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005850 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5851 .channel_mode = alc260_modes,
5852 .input_mux = &alc260_capture_source,
5853 .unsol_event = alc260_hp_3012_unsol_event,
5854 .init_hook = alc260_hp_3012_automute,
5855 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005856 [ALC260_HP_3013] = {
5857 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005858 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005859 .init_verbs = { alc260_hp_3013_init_verbs,
5860 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005861 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5862 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005863 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5864 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005865 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5866 .channel_mode = alc260_modes,
5867 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005868 .unsol_event = alc260_hp_3013_unsol_event,
5869 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005870 },
5871 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005872 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005873 .init_verbs = { alc260_fujitsu_init_verbs },
5874 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5875 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005876 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5877 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005878 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5879 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005880 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5881 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005882 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005883 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005884 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005885 .init_verbs = { alc260_acer_init_verbs },
5886 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5887 .dac_nids = alc260_dac_nids,
5888 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5889 .adc_nids = alc260_dual_adc_nids,
5890 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5891 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005892 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5893 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005894 },
Michael Schwingencc959482009-02-22 18:58:45 +01005895 [ALC260_FAVORIT100] = {
5896 .mixers = { alc260_favorit100_mixer },
5897 .init_verbs = { alc260_favorit100_init_verbs },
5898 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5899 .dac_nids = alc260_dac_nids,
5900 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5901 .adc_nids = alc260_dual_adc_nids,
5902 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5903 .channel_mode = alc260_modes,
5904 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
5905 .input_mux = alc260_favorit100_capture_sources,
5906 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005907 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005908 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005909 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5910 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5911 .dac_nids = alc260_dac_nids,
5912 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5913 .adc_nids = alc260_adc_nids,
5914 .dig_out_nid = ALC260_DIGOUT_NID,
5915 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5916 .channel_mode = alc260_modes,
5917 .input_mux = &alc260_capture_source,
5918 },
5919 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005920 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005921 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5922 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5923 .dac_nids = alc260_dac_nids,
5924 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5925 .adc_nids = alc260_adc_nids,
5926 .dig_out_nid = ALC260_DIGOUT_NID,
5927 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5928 .channel_mode = alc260_modes,
5929 .input_mux = &alc260_capture_source,
5930 .unsol_event = alc260_replacer_672v_unsol_event,
5931 .init_hook = alc260_replacer_672v_automute,
5932 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005933#ifdef CONFIG_SND_DEBUG
5934 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005935 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005936 .init_verbs = { alc260_test_init_verbs },
5937 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5938 .dac_nids = alc260_test_dac_nids,
5939 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5940 .adc_nids = alc260_test_adc_nids,
5941 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5942 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005943 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5944 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005945 },
5946#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005947};
5948
Linus Torvalds1da177e2005-04-16 15:20:36 -07005949static int patch_alc260(struct hda_codec *codec)
5950{
5951 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005952 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005953
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005954 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005955 if (spec == NULL)
5956 return -ENOMEM;
5957
5958 codec->spec = spec;
5959
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005960 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5961 alc260_models,
5962 alc260_cfg_tbl);
5963 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005964 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5965 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005966 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005967 }
5968
Kailang Yangdf694da2005-12-05 19:42:22 +01005969 if (board_config == ALC260_AUTO) {
5970 /* automatic parse from the BIOS config */
5971 err = alc260_parse_auto_config(codec);
5972 if (err < 0) {
5973 alc_free(codec);
5974 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005975 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005976 printk(KERN_INFO
5977 "hda_codec: Cannot set up configuration "
5978 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005979 board_config = ALC260_BASIC;
5980 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005981 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005982
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005983 err = snd_hda_attach_beep_device(codec, 0x1);
5984 if (err < 0) {
5985 alc_free(codec);
5986 return err;
5987 }
5988
Kailang Yangdf694da2005-12-05 19:42:22 +01005989 if (board_config != ALC260_AUTO)
5990 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005991
5992 spec->stream_name_analog = "ALC260 Analog";
5993 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5994 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5995
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005996 spec->stream_name_digital = "ALC260 Digital";
5997 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5998 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5999
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006000 if (!spec->adc_nids && spec->input_mux) {
6001 /* check whether NID 0x04 is valid */
6002 unsigned int wcap = get_wcaps(codec, 0x04);
6003 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6004 /* get type */
6005 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6006 spec->adc_nids = alc260_adc_nids_alt;
6007 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6008 } else {
6009 spec->adc_nids = alc260_adc_nids;
6010 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6011 }
6012 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006013 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006014 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006015
Takashi Iwai2134ea42008-01-10 16:53:55 +01006016 spec->vmaster_nid = 0x08;
6017
Linus Torvalds1da177e2005-04-16 15:20:36 -07006018 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006019 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006020 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006021#ifdef CONFIG_SND_HDA_POWER_SAVE
6022 if (!spec->loopback.amplist)
6023 spec->loopback.amplist = alc260_loopbacks;
6024#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006025 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006026
6027 return 0;
6028}
6029
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006030
Linus Torvalds1da177e2005-04-16 15:20:36 -07006031/*
6032 * ALC882 support
6033 *
6034 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6035 * configuration. Each pin widget can choose any input DACs and a mixer.
6036 * Each ADC is connected from a mixer of all inputs. This makes possible
6037 * 6-channel independent captures.
6038 *
6039 * In addition, an independent DAC for the multi-playback (not used in this
6040 * driver yet).
6041 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006042#define ALC882_DIGOUT_NID 0x06
6043#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006044
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006045static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006046 { 8, NULL }
6047};
6048
6049static hda_nid_t alc882_dac_nids[4] = {
6050 /* front, rear, clfe, rear_surr */
6051 0x02, 0x03, 0x04, 0x05
6052};
6053
Kailang Yangdf694da2005-12-05 19:42:22 +01006054/* identical with ALC880 */
6055#define alc882_adc_nids alc880_adc_nids
6056#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006057
Takashi Iwaie1406342008-02-11 18:32:32 +01006058static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6059static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6060
Linus Torvalds1da177e2005-04-16 15:20:36 -07006061/* input MUX */
6062/* FIXME: should be a matrix-type input source selection */
6063
6064static struct hda_input_mux alc882_capture_source = {
6065 .num_items = 4,
6066 .items = {
6067 { "Mic", 0x0 },
6068 { "Front Mic", 0x1 },
6069 { "Line", 0x2 },
6070 { "CD", 0x4 },
6071 },
6072};
Kailang Yangdf694da2005-12-05 19:42:22 +01006073/*
Kailang Yang272a5272007-05-14 11:00:38 +02006074 * 2ch mode
6075 */
6076static struct hda_verb alc882_3ST_ch2_init[] = {
6077 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6078 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6079 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6080 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6081 { } /* end */
6082};
6083
6084/*
6085 * 6ch mode
6086 */
6087static struct hda_verb alc882_3ST_ch6_init[] = {
6088 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6089 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6090 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6091 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6092 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6093 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6094 { } /* end */
6095};
6096
6097static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6098 { 2, alc882_3ST_ch2_init },
6099 { 6, alc882_3ST_ch6_init },
6100};
6101
6102/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006103 * 6ch mode
6104 */
6105static struct hda_verb alc882_sixstack_ch6_init[] = {
6106 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6107 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6108 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6109 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6110 { } /* end */
6111};
6112
6113/*
6114 * 8ch mode
6115 */
6116static struct hda_verb alc882_sixstack_ch8_init[] = {
6117 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6118 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6119 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6120 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6121 { } /* end */
6122};
6123
6124static struct hda_channel_mode alc882_sixstack_modes[2] = {
6125 { 6, alc882_sixstack_ch6_init },
6126 { 8, alc882_sixstack_ch8_init },
6127};
6128
Takashi Iwai87350ad2007-08-16 18:19:38 +02006129/*
6130 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6131 */
6132
6133/*
6134 * 2ch mode
6135 */
6136static struct hda_verb alc885_mbp_ch2_init[] = {
6137 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6138 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6139 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6140 { } /* end */
6141};
6142
6143/*
6144 * 6ch mode
6145 */
6146static struct hda_verb alc885_mbp_ch6_init[] = {
6147 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6148 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6149 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6150 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6151 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6152 { } /* end */
6153};
6154
6155static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6156 { 2, alc885_mbp_ch2_init },
6157 { 6, alc885_mbp_ch6_init },
6158};
6159
6160
Linus Torvalds1da177e2005-04-16 15:20:36 -07006161/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6162 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6163 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006164static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006165 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006166 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006167 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006168 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6170 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006171 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006173 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006174 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6177 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6178 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6179 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006181 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006182 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6183 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006184 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006185 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006186 { } /* end */
6187};
6188
Takashi Iwai87350ad2007-08-16 18:19:38 +02006189static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006190 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6191 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6192 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6193 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6194 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6195 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6197 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006198 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006199 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6200 { } /* end */
6201};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006202static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6203 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6204 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6205 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6206 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6207 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6208 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6209 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6210 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006212 { } /* end */
6213};
6214
Kailang Yang272a5272007-05-14 11:00:38 +02006215static struct snd_kcontrol_new alc882_targa_mixer[] = {
6216 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6217 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6218 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6219 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6220 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6221 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6222 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006225 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006226 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006228 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006229 { } /* end */
6230};
6231
6232/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6233 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6234 */
6235static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6236 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6237 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6238 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6239 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6240 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6241 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6242 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6243 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6244 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6245 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6247 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006248 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006249 { } /* end */
6250};
6251
Takashi Iwai914759b2007-09-06 14:52:04 +02006252static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6253 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6254 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6255 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6256 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6257 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6258 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6259 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6260 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6261 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6262 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006263 { } /* end */
6264};
6265
Kailang Yangdf694da2005-12-05 19:42:22 +01006266static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6267 {
6268 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6269 .name = "Channel Mode",
6270 .info = alc_ch_mode_info,
6271 .get = alc_ch_mode_get,
6272 .put = alc_ch_mode_put,
6273 },
6274 { } /* end */
6275};
6276
Linus Torvalds1da177e2005-04-16 15:20:36 -07006277static struct hda_verb alc882_init_verbs[] = {
6278 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006279 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006282 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006283 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6284 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6285 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006286 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006287 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6288 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006290 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006291 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6292 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6293 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006294
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006295 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006296 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006297 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006298 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006299 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006300 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006302 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006303 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006304 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006306 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006307 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006308 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006309 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006310 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006311 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006312 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006313 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6314 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006315 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006316 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6317 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006318 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006319 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6320 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6321 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6322 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6323 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006324 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006325 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006326
6327 /* FIXME: use matrix-type input source selection */
6328 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6329 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006334 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006335 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6336 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6337 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6338 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006339 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006340 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6343 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6344 /* ADC1: mute amp left and right */
6345 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006346 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006347 /* ADC2: mute amp left and right */
6348 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006349 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006350 /* ADC3: mute amp left and right */
6351 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006352 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006353
6354 { }
6355};
6356
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006357static struct hda_verb alc882_eapd_verbs[] = {
6358 /* change to EAPD mode */
6359 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006360 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006361 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006362};
6363
Tobin Davis9102cd12006-12-15 10:02:12 +01006364/* Mac Pro test */
6365static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6366 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6367 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6368 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6369 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6370 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006371 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006372 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6373 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006374 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006375 { } /* end */
6376};
6377
6378static struct hda_verb alc882_macpro_init_verbs[] = {
6379 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6380 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6383 /* Front Pin: output 0 (0x0c) */
6384 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6385 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6386 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6387 /* Front Mic pin: input vref at 80% */
6388 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6389 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6390 /* Speaker: output */
6391 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6392 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6393 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6394 /* Headphone output (output 0 - 0x0c) */
6395 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6396 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6397 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6398
6399 /* FIXME: use matrix-type input source selection */
6400 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6401 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6405 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6406 /* Input mixer2 */
6407 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6408 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6409 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6410 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6411 /* Input mixer3 */
6412 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6415 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6416 /* ADC1: mute amp left and right */
6417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6418 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6419 /* ADC2: mute amp left and right */
6420 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6421 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6422 /* ADC3: mute amp left and right */
6423 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6424 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6425
6426 { }
6427};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006428
Takashi Iwai87350ad2007-08-16 18:19:38 +02006429/* Macbook Pro rev3 */
6430static struct hda_verb alc885_mbp3_init_verbs[] = {
6431 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6432 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6433 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6434 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6435 /* Rear mixer */
6436 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6438 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6439 /* Front Pin: output 0 (0x0c) */
6440 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6441 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6442 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6443 /* HP Pin: output 0 (0x0d) */
6444 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6445 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6446 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6447 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6448 /* Mic (rear) pin: input vref at 80% */
6449 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6450 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6451 /* Front Mic pin: input vref at 80% */
6452 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6453 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6454 /* Line In pin: use output 1 when in LineOut mode */
6455 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6456 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6457 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6458
6459 /* FIXME: use matrix-type input source selection */
6460 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6461 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6462 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6463 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6464 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6465 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6466 /* Input mixer2 */
6467 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6468 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6469 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6470 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6471 /* Input mixer3 */
6472 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6473 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6474 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6475 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6476 /* ADC1: mute amp left and right */
6477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6478 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6479 /* ADC2: mute amp left and right */
6480 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6481 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6482 /* ADC3: mute amp left and right */
6483 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6484 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6485
6486 { }
6487};
6488
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006489/* iMac 24 mixer. */
6490static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6491 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6492 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6493 { } /* end */
6494};
6495
6496/* iMac 24 init verbs. */
6497static struct hda_verb alc885_imac24_init_verbs[] = {
6498 /* Internal speakers: output 0 (0x0c) */
6499 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6500 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6501 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6502 /* Internal speakers: output 0 (0x0c) */
6503 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6504 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6505 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6506 /* Headphone: output 0 (0x0c) */
6507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6509 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6510 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6511 /* Front Mic: input vref at 80% */
6512 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6513 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6514 { }
6515};
6516
6517/* Toggle speaker-output according to the hp-jack state */
6518static void alc885_imac24_automute(struct hda_codec *codec)
6519{
6520 unsigned int present;
6521
6522 present = snd_hda_codec_read(codec, 0x14, 0,
6523 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006524 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6525 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6526 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6527 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006528}
6529
6530/* Processes unsolicited events. */
6531static void alc885_imac24_unsol_event(struct hda_codec *codec,
6532 unsigned int res)
6533{
6534 /* Headphone insertion or removal. */
6535 if ((res >> 26) == ALC880_HP_EVENT)
6536 alc885_imac24_automute(codec);
6537}
6538
Takashi Iwai87350ad2007-08-16 18:19:38 +02006539static void alc885_mbp3_automute(struct hda_codec *codec)
6540{
6541 unsigned int present;
6542
6543 present = snd_hda_codec_read(codec, 0x15, 0,
6544 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6545 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6546 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6547 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6548 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6549
6550}
6551static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6552 unsigned int res)
6553{
6554 /* Headphone insertion or removal. */
6555 if ((res >> 26) == ALC880_HP_EVENT)
6556 alc885_mbp3_automute(codec);
6557}
6558
6559
Kailang Yang272a5272007-05-14 11:00:38 +02006560static struct hda_verb alc882_targa_verbs[] = {
6561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6563
6564 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6565 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006566
Kailang Yang272a5272007-05-14 11:00:38 +02006567 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6568 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6569 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6570
6571 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6572 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6573 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6574 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6575 { } /* end */
6576};
6577
6578/* toggle speaker-output according to the hp-jack state */
6579static void alc882_targa_automute(struct hda_codec *codec)
6580{
6581 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006582
Kailang Yang272a5272007-05-14 11:00:38 +02006583 present = snd_hda_codec_read(codec, 0x14, 0,
6584 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006585 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6586 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006587 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6588 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006589}
6590
6591static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6592{
6593 /* Looks like the unsol event is incompatible with the standard
6594 * definition. 4bit tag is placed at 26 bit!
6595 */
6596 if (((res >> 26) == ALC880_HP_EVENT)) {
6597 alc882_targa_automute(codec);
6598 }
6599}
6600
6601static struct hda_verb alc882_asus_a7j_verbs[] = {
6602 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6604
6605 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6607 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006608
Kailang Yang272a5272007-05-14 11:00:38 +02006609 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6610 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6611 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6612
6613 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6614 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6615 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6616 { } /* end */
6617};
6618
Takashi Iwai914759b2007-09-06 14:52:04 +02006619static struct hda_verb alc882_asus_a7m_verbs[] = {
6620 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6621 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6622
6623 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6625 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006626
Takashi Iwai914759b2007-09-06 14:52:04 +02006627 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6628 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6629 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6630
6631 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6632 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6633 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6634 { } /* end */
6635};
6636
Tobin Davis9102cd12006-12-15 10:02:12 +01006637static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6638{
6639 unsigned int gpiostate, gpiomask, gpiodir;
6640
6641 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6642 AC_VERB_GET_GPIO_DATA, 0);
6643
6644 if (!muted)
6645 gpiostate |= (1 << pin);
6646 else
6647 gpiostate &= ~(1 << pin);
6648
6649 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6650 AC_VERB_GET_GPIO_MASK, 0);
6651 gpiomask |= (1 << pin);
6652
6653 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6654 AC_VERB_GET_GPIO_DIRECTION, 0);
6655 gpiodir |= (1 << pin);
6656
6657
6658 snd_hda_codec_write(codec, codec->afg, 0,
6659 AC_VERB_SET_GPIO_MASK, gpiomask);
6660 snd_hda_codec_write(codec, codec->afg, 0,
6661 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6662
6663 msleep(1);
6664
6665 snd_hda_codec_write(codec, codec->afg, 0,
6666 AC_VERB_SET_GPIO_DATA, gpiostate);
6667}
6668
Takashi Iwai7debbe52007-08-16 15:01:03 +02006669/* set up GPIO at initialization */
6670static void alc885_macpro_init_hook(struct hda_codec *codec)
6671{
6672 alc882_gpio_mute(codec, 0, 0);
6673 alc882_gpio_mute(codec, 1, 0);
6674}
6675
6676/* set up GPIO and update auto-muting at initialization */
6677static void alc885_imac24_init_hook(struct hda_codec *codec)
6678{
6679 alc885_macpro_init_hook(codec);
6680 alc885_imac24_automute(codec);
6681}
6682
Kailang Yangdf694da2005-12-05 19:42:22 +01006683/*
6684 * generic initialization of ADC, input mixers and output mixers
6685 */
6686static struct hda_verb alc882_auto_init_verbs[] = {
6687 /*
6688 * Unmute ADC0-2 and set the default input to mic-in
6689 */
6690 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6691 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6692 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6693 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6694 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6695 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6696
Takashi Iwaicb53c622007-08-10 17:21:45 +02006697 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006698 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006699 * Note: PASD motherboards uses the Line In 2 as the input for
6700 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006701 */
6702 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006708
6709 /*
6710 * Set up output mixers (0x0c - 0x0f)
6711 */
6712 /* set vol=0 to output mixers */
6713 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6714 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6715 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6716 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6717 /* set up input amps for analog loopback */
6718 /* Amp Indices: DAC = 0, mixer = 1 */
6719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6721 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6722 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6723 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6724 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6725 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6726 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6727 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6728 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6729
6730 /* FIXME: use matrix-type input source selection */
6731 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6732 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6733 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6734 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6735 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6736 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6737 /* Input mixer2 */
6738 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6739 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6740 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6741 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6742 /* Input mixer3 */
6743 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6744 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6747
6748 { }
6749};
6750
Takashi Iwaicb53c622007-08-10 17:21:45 +02006751#ifdef CONFIG_SND_HDA_POWER_SAVE
6752#define alc882_loopbacks alc880_loopbacks
6753#endif
6754
Kailang Yangdf694da2005-12-05 19:42:22 +01006755/* pcm configuration: identiacal with ALC880 */
6756#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6757#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6758#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6759#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6760
6761/*
6762 * configuration and preset
6763 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006764static const char *alc882_models[ALC882_MODEL_LAST] = {
6765 [ALC882_3ST_DIG] = "3stack-dig",
6766 [ALC882_6ST_DIG] = "6stack-dig",
6767 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006768 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006769 [ALC882_TARGA] = "targa",
6770 [ALC882_ASUS_A7J] = "asus-a7j",
6771 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006772 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006773 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006774 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006775 [ALC882_AUTO] = "auto",
6776};
6777
6778static struct snd_pci_quirk alc882_cfg_tbl[] = {
6779 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006780 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006781 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006782 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006783 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006784 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006785 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006786 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006787 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006788 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6789 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6790 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006791 {}
6792};
6793
6794static struct alc_config_preset alc882_presets[] = {
6795 [ALC882_3ST_DIG] = {
6796 .mixers = { alc882_base_mixer },
6797 .init_verbs = { alc882_init_verbs },
6798 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6799 .dac_nids = alc882_dac_nids,
6800 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006801 .dig_in_nid = ALC882_DIGIN_NID,
6802 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6803 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006804 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006805 .input_mux = &alc882_capture_source,
6806 },
6807 [ALC882_6ST_DIG] = {
6808 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6809 .init_verbs = { alc882_init_verbs },
6810 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6811 .dac_nids = alc882_dac_nids,
6812 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006813 .dig_in_nid = ALC882_DIGIN_NID,
6814 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6815 .channel_mode = alc882_sixstack_modes,
6816 .input_mux = &alc882_capture_source,
6817 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006818 [ALC882_ARIMA] = {
6819 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6820 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6821 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6822 .dac_nids = alc882_dac_nids,
6823 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6824 .channel_mode = alc882_sixstack_modes,
6825 .input_mux = &alc882_capture_source,
6826 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006827 [ALC882_W2JC] = {
6828 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6829 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6830 alc880_gpio1_init_verbs },
6831 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6832 .dac_nids = alc882_dac_nids,
6833 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6834 .channel_mode = alc880_threestack_modes,
6835 .need_dac_fix = 1,
6836 .input_mux = &alc882_capture_source,
6837 .dig_out_nid = ALC882_DIGOUT_NID,
6838 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006839 [ALC885_MBP3] = {
6840 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6841 .init_verbs = { alc885_mbp3_init_verbs,
6842 alc880_gpio1_init_verbs },
6843 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6844 .dac_nids = alc882_dac_nids,
6845 .channel_mode = alc885_mbp_6ch_modes,
6846 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6847 .input_mux = &alc882_capture_source,
6848 .dig_out_nid = ALC882_DIGOUT_NID,
6849 .dig_in_nid = ALC882_DIGIN_NID,
6850 .unsol_event = alc885_mbp3_unsol_event,
6851 .init_hook = alc885_mbp3_automute,
6852 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006853 [ALC885_MACPRO] = {
6854 .mixers = { alc882_macpro_mixer },
6855 .init_verbs = { alc882_macpro_init_verbs },
6856 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6857 .dac_nids = alc882_dac_nids,
6858 .dig_out_nid = ALC882_DIGOUT_NID,
6859 .dig_in_nid = ALC882_DIGIN_NID,
6860 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6861 .channel_mode = alc882_ch_modes,
6862 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006863 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006864 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006865 [ALC885_IMAC24] = {
6866 .mixers = { alc885_imac24_mixer },
6867 .init_verbs = { alc885_imac24_init_verbs },
6868 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6869 .dac_nids = alc882_dac_nids,
6870 .dig_out_nid = ALC882_DIGOUT_NID,
6871 .dig_in_nid = ALC882_DIGIN_NID,
6872 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6873 .channel_mode = alc882_ch_modes,
6874 .input_mux = &alc882_capture_source,
6875 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006876 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006877 },
Kailang Yang272a5272007-05-14 11:00:38 +02006878 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006879 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006880 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6881 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6882 .dac_nids = alc882_dac_nids,
6883 .dig_out_nid = ALC882_DIGOUT_NID,
6884 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6885 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006886 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006887 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6888 .channel_mode = alc882_3ST_6ch_modes,
6889 .need_dac_fix = 1,
6890 .input_mux = &alc882_capture_source,
6891 .unsol_event = alc882_targa_unsol_event,
6892 .init_hook = alc882_targa_automute,
6893 },
6894 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006895 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006896 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6897 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6898 .dac_nids = alc882_dac_nids,
6899 .dig_out_nid = ALC882_DIGOUT_NID,
6900 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6901 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006902 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006903 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6904 .channel_mode = alc882_3ST_6ch_modes,
6905 .need_dac_fix = 1,
6906 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006907 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006908 [ALC882_ASUS_A7M] = {
6909 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6910 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6911 alc880_gpio1_init_verbs,
6912 alc882_asus_a7m_verbs },
6913 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6914 .dac_nids = alc882_dac_nids,
6915 .dig_out_nid = ALC882_DIGOUT_NID,
6916 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6917 .channel_mode = alc880_threestack_modes,
6918 .need_dac_fix = 1,
6919 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006920 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006921};
6922
6923
6924/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006925 * Pin config fixes
6926 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006927enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006928 PINFIX_ABIT_AW9D_MAX
6929};
6930
6931static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6932 { 0x15, 0x01080104 }, /* side */
6933 { 0x16, 0x01011012 }, /* rear */
6934 { 0x17, 0x01016011 }, /* clfe */
6935 { }
6936};
6937
6938static const struct alc_pincfg *alc882_pin_fixes[] = {
6939 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6940};
6941
6942static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6943 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6944 {}
6945};
6946
6947/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006948 * BIOS auto configuration
6949 */
6950static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6951 hda_nid_t nid, int pin_type,
6952 int dac_idx)
6953{
6954 /* set as output */
6955 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006956 int idx;
6957
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006958 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006959 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6960 idx = 4;
6961 else
6962 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006963 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6964
6965}
6966
6967static void alc882_auto_init_multi_out(struct hda_codec *codec)
6968{
6969 struct alc_spec *spec = codec->spec;
6970 int i;
6971
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006972 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006973 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006974 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006975 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006976 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006977 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006978 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006979 }
6980}
6981
6982static void alc882_auto_init_hp_out(struct hda_codec *codec)
6983{
6984 struct alc_spec *spec = codec->spec;
6985 hda_nid_t pin;
6986
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006987 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006988 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006989 /* use dac 0 */
6990 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006991 pin = spec->autocfg.speaker_pins[0];
6992 if (pin)
6993 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006994}
6995
6996#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6997#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6998
6999static void alc882_auto_init_analog_input(struct hda_codec *codec)
7000{
7001 struct alc_spec *spec = codec->spec;
7002 int i;
7003
7004 for (i = 0; i < AUTO_PIN_LAST; i++) {
7005 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007006 unsigned int vref;
7007 if (!nid)
7008 continue;
7009 vref = PIN_IN;
7010 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02007011 unsigned int pincap;
7012 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
7013 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01007014 AC_PINCAP_VREF_80)
7015 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01007016 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01007017 snd_hda_codec_write(codec, nid, 0,
7018 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
7019 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7020 snd_hda_codec_write(codec, nid, 0,
7021 AC_VERB_SET_AMP_GAIN_MUTE,
7022 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007023 }
7024}
7025
Takashi Iwaif511b012008-08-15 16:46:42 +02007026static void alc882_auto_init_input_src(struct hda_codec *codec)
7027{
7028 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007029 int c;
7030
7031 for (c = 0; c < spec->num_adc_nids; c++) {
7032 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7033 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007034 unsigned int mux_idx;
7035 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007036 int conns, mute, idx, item;
7037
7038 conns = snd_hda_get_connections(codec, nid, conn_list,
7039 ARRAY_SIZE(conn_list));
7040 if (conns < 0)
7041 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007042 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7043 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007044 for (idx = 0; idx < conns; idx++) {
7045 /* if the current connection is the selected one,
7046 * unmute it as default - otherwise mute it
7047 */
7048 mute = AMP_IN_MUTE(idx);
7049 for (item = 0; item < imux->num_items; item++) {
7050 if (imux->items[item].index == idx) {
7051 if (spec->cur_mux[c] == item)
7052 mute = AMP_IN_UNMUTE(idx);
7053 break;
7054 }
7055 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007056 /* check if we have a selector or mixer
7057 * we could check for the widget type instead, but
7058 * just check for Amp-In presence (in case of mixer
7059 * without amp-in there is something wrong, this
7060 * function shouldn't be used or capsrc nid is wrong)
7061 */
7062 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7063 snd_hda_codec_write(codec, nid, 0,
7064 AC_VERB_SET_AMP_GAIN_MUTE,
7065 mute);
7066 else if (mute != AMP_IN_MUTE(idx))
7067 snd_hda_codec_write(codec, nid, 0,
7068 AC_VERB_SET_CONNECT_SEL,
7069 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007070 }
7071 }
7072}
7073
Takashi Iwai776e1842007-08-29 15:07:11 +02007074/* add mic boosts if needed */
7075static int alc_auto_add_mic_boost(struct hda_codec *codec)
7076{
7077 struct alc_spec *spec = codec->spec;
7078 int err;
7079 hda_nid_t nid;
7080
7081 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007082 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007083 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7084 "Mic Boost",
7085 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7086 if (err < 0)
7087 return err;
7088 }
7089 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007090 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007091 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7092 "Front Mic Boost",
7093 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7094 if (err < 0)
7095 return err;
7096 }
7097 return 0;
7098}
7099
Kailang Yangdf694da2005-12-05 19:42:22 +01007100/* almost identical with ALC880 parser... */
7101static int alc882_parse_auto_config(struct hda_codec *codec)
7102{
7103 struct alc_spec *spec = codec->spec;
7104 int err = alc880_parse_auto_config(codec);
7105
7106 if (err < 0)
7107 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007108 else if (!err)
7109 return 0; /* no config found */
7110
7111 err = alc_auto_add_mic_boost(codec);
7112 if (err < 0)
7113 return err;
7114
7115 /* hack - override the init verbs */
7116 spec->init_verbs[0] = alc882_auto_init_verbs;
7117
7118 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007119}
7120
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007121/* additional initialization for auto-configuration model */
7122static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007123{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007124 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007125 alc882_auto_init_multi_out(codec);
7126 alc882_auto_init_hp_out(codec);
7127 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007128 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007129 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007130 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007131}
7132
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007133static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7134
Linus Torvalds1da177e2005-04-16 15:20:36 -07007135static int patch_alc882(struct hda_codec *codec)
7136{
7137 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007138 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007139
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007140 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007141 if (spec == NULL)
7142 return -ENOMEM;
7143
Linus Torvalds1da177e2005-04-16 15:20:36 -07007144 codec->spec = spec;
7145
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007146 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7147 alc882_models,
7148 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007149
Kailang Yangdf694da2005-12-05 19:42:22 +01007150 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007151 /* Pick up systems that don't supply PCI SSID */
7152 switch (codec->subsystem_id) {
7153 case 0x106b0c00: /* Mac Pro */
7154 board_config = ALC885_MACPRO;
7155 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007156 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007157 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007158 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007159 board_config = ALC885_IMAC24;
7160 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007161 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007162 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007163 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007164 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007165 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007166 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007167 board_config = ALC885_MBP3;
7168 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007169 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007170 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007171 if (codec->revision_id == 0x100101 ||
7172 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007173 alc_free(codec);
7174 return patch_alc883(codec);
7175 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007176 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7177 "trying auto-probe from BIOS...\n");
7178 board_config = ALC882_AUTO;
7179 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007180 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007181
Takashi Iwaif95474e2007-07-10 00:47:43 +02007182 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7183
Kailang Yangdf694da2005-12-05 19:42:22 +01007184 if (board_config == ALC882_AUTO) {
7185 /* automatic parse from the BIOS config */
7186 err = alc882_parse_auto_config(codec);
7187 if (err < 0) {
7188 alc_free(codec);
7189 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007190 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007191 printk(KERN_INFO
7192 "hda_codec: Cannot set up configuration "
7193 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007194 board_config = ALC882_3ST_DIG;
7195 }
7196 }
7197
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007198 err = snd_hda_attach_beep_device(codec, 0x1);
7199 if (err < 0) {
7200 alc_free(codec);
7201 return err;
7202 }
7203
Kailang Yangdf694da2005-12-05 19:42:22 +01007204 if (board_config != ALC882_AUTO)
7205 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007206
Kailang Yang2f893282008-05-27 12:14:47 +02007207 if (codec->vendor_id == 0x10ec0885) {
7208 spec->stream_name_analog = "ALC885 Analog";
7209 spec->stream_name_digital = "ALC885 Digital";
7210 } else {
7211 spec->stream_name_analog = "ALC882 Analog";
7212 spec->stream_name_digital = "ALC882 Digital";
7213 }
7214
Kailang Yangdf694da2005-12-05 19:42:22 +01007215 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7216 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007217 /* FIXME: setup DAC5 */
7218 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7219 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007220
Kailang Yangdf694da2005-12-05 19:42:22 +01007221 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7222 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007223
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007224 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007225 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007226 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007227 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007228 /* get type */
7229 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007230 if (wcap != AC_WID_AUD_IN) {
7231 spec->adc_nids = alc882_adc_nids_alt;
7232 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007233 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007234 } else {
7235 spec->adc_nids = alc882_adc_nids;
7236 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007237 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007238 }
7239 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007240 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007241 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007242
Takashi Iwai2134ea42008-01-10 16:53:55 +01007243 spec->vmaster_nid = 0x0c;
7244
Linus Torvalds1da177e2005-04-16 15:20:36 -07007245 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007246 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007247 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007248#ifdef CONFIG_SND_HDA_POWER_SAVE
7249 if (!spec->loopback.amplist)
7250 spec->loopback.amplist = alc882_loopbacks;
7251#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007252 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007253
7254 return 0;
7255}
7256
7257/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007258 * ALC883 support
7259 *
7260 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7261 * configuration. Each pin widget can choose any input DACs and a mixer.
7262 * Each ADC is connected from a mixer of all inputs. This makes possible
7263 * 6-channel independent captures.
7264 *
7265 * In addition, an independent DAC for the multi-playback (not used in this
7266 * driver yet).
7267 */
7268#define ALC883_DIGOUT_NID 0x06
7269#define ALC883_DIGIN_NID 0x0a
7270
Wu Fengguang3ab90932008-11-17 09:51:09 +01007271#define ALC1200_DIGOUT_NID 0x10
7272
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007273static hda_nid_t alc883_dac_nids[4] = {
7274 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007275 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007276};
7277
7278static hda_nid_t alc883_adc_nids[2] = {
7279 /* ADC1-2 */
7280 0x08, 0x09,
7281};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007282
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007283static hda_nid_t alc883_adc_nids_alt[1] = {
7284 /* ADC1 */
7285 0x08,
7286};
7287
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007288static hda_nid_t alc883_adc_nids_rev[2] = {
7289 /* ADC2-1 */
7290 0x09, 0x08
7291};
7292
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007293#define alc889_adc_nids alc880_adc_nids
7294
Takashi Iwaie1406342008-02-11 18:32:32 +01007295static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7296
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007297static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7298
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007299#define alc889_capsrc_nids alc882_capsrc_nids
7300
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007301/* input MUX */
7302/* FIXME: should be a matrix-type input source selection */
7303
7304static struct hda_input_mux alc883_capture_source = {
7305 .num_items = 4,
7306 .items = {
7307 { "Mic", 0x0 },
7308 { "Front Mic", 0x1 },
7309 { "Line", 0x2 },
7310 { "CD", 0x4 },
7311 },
7312};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007313
Jiang zhe17bba1b2008-06-04 12:11:07 +02007314static struct hda_input_mux alc883_3stack_6ch_intel = {
7315 .num_items = 4,
7316 .items = {
7317 { "Mic", 0x1 },
7318 { "Front Mic", 0x0 },
7319 { "Line", 0x2 },
7320 { "CD", 0x4 },
7321 },
7322};
7323
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007324static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7325 .num_items = 2,
7326 .items = {
7327 { "Mic", 0x1 },
7328 { "Line", 0x2 },
7329 },
7330};
7331
Kailang Yang272a5272007-05-14 11:00:38 +02007332static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7333 .num_items = 4,
7334 .items = {
7335 { "Mic", 0x0 },
7336 { "iMic", 0x1 },
7337 { "Line", 0x2 },
7338 { "CD", 0x4 },
7339 },
7340};
7341
Jiang zhefb97dc62008-03-06 11:07:11 +01007342static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7343 .num_items = 2,
7344 .items = {
7345 { "Mic", 0x0 },
7346 { "Int Mic", 0x1 },
7347 },
7348};
7349
Kailang Yange2757d52008-08-26 13:17:46 +02007350static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7351 .num_items = 3,
7352 .items = {
7353 { "Mic", 0x0 },
7354 { "Front Mic", 0x1 },
7355 { "Line", 0x4 },
7356 },
7357};
7358
7359static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7360 .num_items = 2,
7361 .items = {
7362 { "Mic", 0x0 },
7363 { "Line", 0x2 },
7364 },
7365};
7366
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007367/*
7368 * 2ch mode
7369 */
7370static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7371 { 2, NULL }
7372};
7373
7374/*
7375 * 2ch mode
7376 */
7377static struct hda_verb alc883_3ST_ch2_init[] = {
7378 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7379 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7380 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7381 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7382 { } /* end */
7383};
7384
7385/*
Tobin Davisb2011312007-09-17 12:45:11 +02007386 * 4ch mode
7387 */
7388static struct hda_verb alc883_3ST_ch4_init[] = {
7389 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7390 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7391 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7392 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7393 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7394 { } /* end */
7395};
7396
7397/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007398 * 6ch mode
7399 */
7400static struct hda_verb alc883_3ST_ch6_init[] = {
7401 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7402 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7403 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7404 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7405 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7406 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7407 { } /* end */
7408};
7409
Tobin Davisb2011312007-09-17 12:45:11 +02007410static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007411 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007412 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007413 { 6, alc883_3ST_ch6_init },
7414};
7415
7416/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007417 * 2ch mode
7418 */
7419static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7420 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7421 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7422 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7423 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7424 { } /* end */
7425};
7426
7427/*
7428 * 4ch mode
7429 */
7430static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7431 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7432 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7433 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7434 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7435 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7436 { } /* end */
7437};
7438
7439/*
7440 * 6ch mode
7441 */
7442static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7443 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7444 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7445 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7446 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7447 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7448 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7449 { } /* end */
7450};
7451
7452static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7453 { 2, alc883_3ST_ch2_intel_init },
7454 { 4, alc883_3ST_ch4_intel_init },
7455 { 6, alc883_3ST_ch6_intel_init },
7456};
7457
7458/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007459 * 6ch mode
7460 */
7461static struct hda_verb alc883_sixstack_ch6_init[] = {
7462 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7463 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7464 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7465 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7466 { } /* end */
7467};
7468
7469/*
7470 * 8ch mode
7471 */
7472static struct hda_verb alc883_sixstack_ch8_init[] = {
7473 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7474 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7475 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7476 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7477 { } /* end */
7478};
7479
7480static struct hda_channel_mode alc883_sixstack_modes[2] = {
7481 { 6, alc883_sixstack_ch6_init },
7482 { 8, alc883_sixstack_ch8_init },
7483};
7484
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007485static struct hda_verb alc883_medion_eapd_verbs[] = {
7486 /* eanable EAPD on medion laptop */
7487 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7488 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7489 { }
7490};
7491
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007492/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7493 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7494 */
7495
7496static struct snd_kcontrol_new alc883_base_mixer[] = {
7497 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7498 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7499 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7500 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7501 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7502 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7503 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7504 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7505 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7506 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7507 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7508 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7509 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7510 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7511 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7512 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007513 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007514 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7515 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007516 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007517 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007518 { } /* end */
7519};
7520
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007521static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7522 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7523 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7524 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7525 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7526 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7527 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7528 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7529 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7530 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7531 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7532 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7533 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7534 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007535 { } /* end */
7536};
7537
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007538static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007539 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7540 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7541 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7542 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7543 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7544 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7545 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7546 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7547 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7548 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007549 { } /* end */
7550};
7551
Jiang zhefb97dc62008-03-06 11:07:11 +01007552static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7553 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7554 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7555 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7556 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7557 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7558 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7559 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7560 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7561 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7562 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007563 { } /* end */
7564};
7565
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007566static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7567 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7568 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7569 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7570 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7571 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7572 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7573 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007575 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007576 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7577 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007578 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007579 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007580 { } /* end */
7581};
7582
7583static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7584 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7585 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7586 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7587 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7588 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7589 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7590 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7591 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7592 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7593 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7594 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7595 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7596 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007598 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007599 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7600 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007601 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007602 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007603 { } /* end */
7604};
7605
Jiang zhe17bba1b2008-06-04 12:11:07 +02007606static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7607 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7608 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7609 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7610 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7611 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7612 HDA_OUTPUT),
7613 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7614 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7615 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7616 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7617 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7618 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7619 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7620 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7621 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7622 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7623 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7624 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7625 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7626 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007627 { } /* end */
7628};
7629
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007630static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007631 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007632 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007633 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007634 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007635 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7636 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007637 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7638 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007639 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7640 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7641 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7642 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7643 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7644 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007645 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7647 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007648 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007649 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007650 { } /* end */
7651};
7652
Kailang Yangccc656c2006-10-17 12:32:26 +02007653static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7654 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7656 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7657 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7658 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7659 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7660 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7661 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7662 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7663 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7664 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7665 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7666 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007668 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007669 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007670 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007671};
Kailang Yangccc656c2006-10-17 12:32:26 +02007672
7673static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7674 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7675 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7676 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7677 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7678 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7679 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007680 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007682 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7683 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7684 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007685 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007686};
Kailang Yangccc656c2006-10-17 12:32:26 +02007687
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007688static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7689 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7690 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007691 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7692 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007693 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7694 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7695 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007697 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007698};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007699
Kailang Yang272a5272007-05-14 11:00:38 +02007700static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7701 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7702 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7703 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7708 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7709 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007710 { } /* end */
7711};
7712
7713static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7714 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7715 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7716 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7717 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7718 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7721 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7722 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007723 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007724};
Kailang Yang272a5272007-05-14 11:00:38 +02007725
Tobin Davis2880a862007-08-07 11:50:26 +02007726static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007727 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7728 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007729 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007730 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7731 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7733 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7734 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007735 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007736};
Tobin Davis2880a862007-08-07 11:50:26 +02007737
Kailang Yange2757d52008-08-26 13:17:46 +02007738static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7739 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7740 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7741 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7742 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7743 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7744 0x0d, 1, 0x0, HDA_OUTPUT),
7745 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7746 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7747 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7748 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7749 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7750 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7751 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7752 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7753 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7754 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7755 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7756 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7757 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7758 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7759 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7760 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7761 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007762 { } /* end */
7763};
7764
7765static struct hda_bind_ctls alc883_bind_cap_vol = {
7766 .ops = &snd_hda_bind_vol,
7767 .values = {
7768 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7769 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7770 0
7771 },
7772};
7773
7774static struct hda_bind_ctls alc883_bind_cap_switch = {
7775 .ops = &snd_hda_bind_sw,
7776 .values = {
7777 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7778 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7779 0
7780 },
7781};
7782
7783static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7784 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7785 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7786 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7787 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7788 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7789 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7790 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7791 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007792 { } /* end */
7793};
7794
7795static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007796 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7797 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7798 {
7799 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7800 /* .name = "Capture Source", */
7801 .name = "Input Source",
7802 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007803 .info = alc_mux_enum_info,
7804 .get = alc_mux_enum_get,
7805 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007806 },
7807 { } /* end */
7808};
7809
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007810static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7811 {
7812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7813 .name = "Channel Mode",
7814 .info = alc_ch_mode_info,
7815 .get = alc_ch_mode_get,
7816 .put = alc_ch_mode_put,
7817 },
7818 { } /* end */
7819};
7820
7821static struct hda_verb alc883_init_verbs[] = {
7822 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007823 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007824 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7825 /* ADC2: mute amp left and right */
7826 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7827 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7828 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7829 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7830 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7832 /* Rear mixer */
7833 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7835 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7836 /* CLFE mixer */
7837 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7838 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7839 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7840 /* Side mixer */
7841 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7842 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7843 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7844
Takashi Iwaicb53c622007-08-10 17:21:45 +02007845 /* mute analog input loopbacks */
7846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7848 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007851
7852 /* Front Pin: output 0 (0x0c) */
7853 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7854 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7855 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7856 /* Rear Pin: output 1 (0x0d) */
7857 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7858 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7859 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7860 /* CLFE Pin: output 2 (0x0e) */
7861 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7862 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7863 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7864 /* Side Pin: output 3 (0x0f) */
7865 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7866 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7867 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7868 /* Mic (rear) pin: input vref at 80% */
7869 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7870 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7871 /* Front Mic pin: input vref at 80% */
7872 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7873 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7874 /* Line In pin: input */
7875 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7877 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7878 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7879 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7880 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7881 /* CD pin widget for input */
7882 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7883
7884 /* FIXME: use matrix-type input source selection */
7885 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7886 /* Input mixer2 */
7887 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007888 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7889 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7890 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007891 /* Input mixer3 */
7892 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007893 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7895 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007896 { }
7897};
7898
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007899/* toggle speaker-output according to the hp-jack state */
7900static void alc883_mitac_hp_automute(struct hda_codec *codec)
7901{
7902 unsigned int present;
7903
7904 present = snd_hda_codec_read(codec, 0x15, 0,
7905 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7906 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7907 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7908 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7909 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7910}
7911
7912/* auto-toggle front mic */
7913/*
7914static void alc883_mitac_mic_automute(struct hda_codec *codec)
7915{
7916 unsigned int present;
7917 unsigned char bits;
7918
7919 present = snd_hda_codec_read(codec, 0x18, 0,
7920 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7921 bits = present ? HDA_AMP_MUTE : 0;
7922 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7923}
7924*/
7925
7926static void alc883_mitac_automute(struct hda_codec *codec)
7927{
7928 alc883_mitac_hp_automute(codec);
7929 /* alc883_mitac_mic_automute(codec); */
7930}
7931
7932static void alc883_mitac_unsol_event(struct hda_codec *codec,
7933 unsigned int res)
7934{
7935 switch (res >> 26) {
7936 case ALC880_HP_EVENT:
7937 alc883_mitac_hp_automute(codec);
7938 break;
7939 case ALC880_MIC_EVENT:
7940 /* alc883_mitac_mic_automute(codec); */
7941 break;
7942 }
7943}
7944
7945static struct hda_verb alc883_mitac_verbs[] = {
7946 /* HP */
7947 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7948 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7949 /* Subwoofer */
7950 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7951 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7952
7953 /* enable unsolicited event */
7954 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7955 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7956
7957 { } /* end */
7958};
7959
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007960static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007961 /* HP */
7962 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7963 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7964 /* Int speaker */
7965 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7967
7968 /* enable unsolicited event */
7969 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007970 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007971
7972 { } /* end */
7973};
7974
Jiang zhefb97dc62008-03-06 11:07:11 +01007975static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7976 /* HP */
7977 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7979 /* Subwoofer */
7980 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7981 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7982
7983 /* enable unsolicited event */
7984 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7985
7986 { } /* end */
7987};
7988
Kailang Yangccc656c2006-10-17 12:32:26 +02007989static struct hda_verb alc883_tagra_verbs[] = {
7990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7992
7993 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7994 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007995
Kailang Yangccc656c2006-10-17 12:32:26 +02007996 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7997 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7998 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7999
8000 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008001 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8002 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8003 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02008004
8005 { } /* end */
8006};
8007
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008008static struct hda_verb alc883_lenovo_101e_verbs[] = {
8009 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8010 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8011 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8012 { } /* end */
8013};
8014
Kailang Yang272a5272007-05-14 11:00:38 +02008015static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8016 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8017 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8018 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8019 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8020 { } /* end */
8021};
8022
8023static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8024 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8026 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8027 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8028 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8029 { } /* end */
8030};
8031
Kailang Yang189609a2007-08-20 11:31:23 +02008032static struct hda_verb alc883_haier_w66_verbs[] = {
8033 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8034 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8035
8036 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8037
8038 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8039 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8040 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8042 { } /* end */
8043};
8044
Kailang Yange2757d52008-08-26 13:17:46 +02008045static struct hda_verb alc888_lenovo_sky_verbs[] = {
8046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8049 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8050 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8051 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8052 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8053 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8054 { } /* end */
8055};
8056
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008057static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008058 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008059 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8060 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008061 { }
8062};
8063
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008064static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008065 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8066 { }
8067};
8068
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008069static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008070 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8071 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8072 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8073 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8074 { }
8075};
8076
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008077static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008078 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8079 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8080 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8081 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8082 { }
8083};
8084
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008085static struct hda_channel_mode alc888_3st_hp_modes[2] = {
8086 { 2, alc888_3st_hp_2ch_init },
8087 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008088};
8089
Kailang Yang272a5272007-05-14 11:00:38 +02008090/* toggle front-jack and RCA according to the hp-jack state */
8091static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8092{
8093 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008094
Kailang Yang272a5272007-05-14 11:00:38 +02008095 present = snd_hda_codec_read(codec, 0x1b, 0,
8096 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008097 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8098 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8099 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8100 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008101}
8102
8103/* toggle RCA according to the front-jack state */
8104static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8105{
8106 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008107
Kailang Yang272a5272007-05-14 11:00:38 +02008108 present = snd_hda_codec_read(codec, 0x14, 0,
8109 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008110 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8111 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008112}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008113
Kailang Yang272a5272007-05-14 11:00:38 +02008114static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8115 unsigned int res)
8116{
8117 if ((res >> 26) == ALC880_HP_EVENT)
8118 alc888_lenovo_ms7195_front_automute(codec);
8119 if ((res >> 26) == ALC880_FRONT_EVENT)
8120 alc888_lenovo_ms7195_rca_automute(codec);
8121}
8122
8123static struct hda_verb alc883_medion_md2_verbs[] = {
8124 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8126
8127 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8128
8129 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8130 { } /* end */
8131};
8132
8133/* toggle speaker-output according to the hp-jack state */
8134static void alc883_medion_md2_automute(struct hda_codec *codec)
8135{
8136 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008137
Kailang Yang272a5272007-05-14 11:00:38 +02008138 present = snd_hda_codec_read(codec, 0x14, 0,
8139 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008140 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8141 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008142}
8143
8144static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8145 unsigned int res)
8146{
8147 if ((res >> 26) == ALC880_HP_EVENT)
8148 alc883_medion_md2_automute(codec);
8149}
8150
Kailang Yangccc656c2006-10-17 12:32:26 +02008151/* toggle speaker-output according to the hp-jack state */
8152static void alc883_tagra_automute(struct hda_codec *codec)
8153{
8154 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008155 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008156
8157 present = snd_hda_codec_read(codec, 0x14, 0,
8158 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008159 bits = present ? HDA_AMP_MUTE : 0;
8160 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8161 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008162 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8163 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008164}
8165
8166static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8167{
8168 if ((res >> 26) == ALC880_HP_EVENT)
8169 alc883_tagra_automute(codec);
8170}
8171
Jiang zhe368c7a92008-03-04 11:20:33 +01008172/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008173static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008174{
8175 unsigned int present;
8176 unsigned char bits;
8177
8178 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8179 & AC_PINSENSE_PRESENCE;
8180 bits = present ? HDA_AMP_MUTE : 0;
8181 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8182 HDA_AMP_MUTE, bits);
8183}
8184
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008185static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8186{
8187 unsigned int present;
8188
8189 present = snd_hda_codec_read(codec, 0x18, 0,
8190 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8191 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8192 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8193}
8194
8195static void alc883_clevo_m720_automute(struct hda_codec *codec)
8196{
8197 alc883_clevo_m720_hp_automute(codec);
8198 alc883_clevo_m720_mic_automute(codec);
8199}
8200
8201static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008202 unsigned int res)
8203{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008204 switch (res >> 26) {
8205 case ALC880_HP_EVENT:
8206 alc883_clevo_m720_hp_automute(codec);
8207 break;
8208 case ALC880_MIC_EVENT:
8209 alc883_clevo_m720_mic_automute(codec);
8210 break;
8211 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008212}
8213
Jiang zhefb97dc62008-03-06 11:07:11 +01008214/* toggle speaker-output according to the hp-jack state */
8215static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8216{
8217 unsigned int present;
8218 unsigned char bits;
8219
8220 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8221 & AC_PINSENSE_PRESENCE;
8222 bits = present ? HDA_AMP_MUTE : 0;
8223 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8224 HDA_AMP_MUTE, bits);
8225}
8226
8227static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8228 unsigned int res)
8229{
8230 if ((res >> 26) == ALC880_HP_EVENT)
8231 alc883_2ch_fujitsu_pi2515_automute(codec);
8232}
8233
Kailang Yang189609a2007-08-20 11:31:23 +02008234static void alc883_haier_w66_automute(struct hda_codec *codec)
8235{
8236 unsigned int present;
8237 unsigned char bits;
8238
8239 present = snd_hda_codec_read(codec, 0x1b, 0,
8240 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8241 bits = present ? 0x80 : 0;
8242 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8243 0x80, bits);
8244}
8245
8246static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8247 unsigned int res)
8248{
8249 if ((res >> 26) == ALC880_HP_EVENT)
8250 alc883_haier_w66_automute(codec);
8251}
8252
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008253static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8254{
8255 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008256 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008257
8258 present = snd_hda_codec_read(codec, 0x14, 0,
8259 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008260 bits = present ? HDA_AMP_MUTE : 0;
8261 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8262 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008263}
8264
8265static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8266{
8267 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008268 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008269
8270 present = snd_hda_codec_read(codec, 0x1b, 0,
8271 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008272 bits = present ? HDA_AMP_MUTE : 0;
8273 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8274 HDA_AMP_MUTE, bits);
8275 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8276 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008277}
8278
8279static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8280 unsigned int res)
8281{
8282 if ((res >> 26) == ALC880_HP_EVENT)
8283 alc883_lenovo_101e_all_automute(codec);
8284 if ((res >> 26) == ALC880_FRONT_EVENT)
8285 alc883_lenovo_101e_ispeaker_automute(codec);
8286}
8287
Takashi Iwai676a9b52007-08-16 15:23:35 +02008288/* toggle speaker-output according to the hp-jack state */
8289static void alc883_acer_aspire_automute(struct hda_codec *codec)
8290{
8291 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008292
Takashi Iwai676a9b52007-08-16 15:23:35 +02008293 present = snd_hda_codec_read(codec, 0x14, 0,
8294 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8295 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8296 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8297 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8298 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8299}
8300
8301static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8302 unsigned int res)
8303{
8304 if ((res >> 26) == ALC880_HP_EVENT)
8305 alc883_acer_aspire_automute(codec);
8306}
8307
Kailang Yangd1a991a2007-08-15 16:21:59 +02008308static struct hda_verb alc883_acer_eapd_verbs[] = {
8309 /* HP Pin: output 0 (0x0c) */
8310 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8311 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8312 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8313 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8315 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008316 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008317 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8318 /* eanable EAPD on medion laptop */
8319 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8320 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008321 /* enable unsolicited event */
8322 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008323 { }
8324};
8325
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008326static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8327{
8328 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008329
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008330 present = snd_hda_codec_read(codec, 0x1b, 0,
8331 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8332 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8333 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8334 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8335 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8336 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8337 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8338 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8339 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8340}
8341
8342static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8343 unsigned int res)
8344{
8345 switch (res >> 26) {
8346 case ALC880_HP_EVENT:
Takashi Iwai939778a2009-02-05 15:57:55 +01008347 /* printk(KERN_DEBUG "hp_event\n"); */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008348 alc888_6st_dell_front_automute(codec);
8349 break;
8350 }
8351}
8352
Kailang Yange2757d52008-08-26 13:17:46 +02008353static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8354{
8355 unsigned int mute;
8356 unsigned int present;
8357
8358 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8359 present = snd_hda_codec_read(codec, 0x1b, 0,
8360 AC_VERB_GET_PIN_SENSE, 0);
8361 present = (present & 0x80000000) != 0;
8362 if (present) {
8363 /* mute internal speaker */
8364 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8365 HDA_AMP_MUTE, HDA_AMP_MUTE);
8366 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8367 HDA_AMP_MUTE, HDA_AMP_MUTE);
8368 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8369 HDA_AMP_MUTE, HDA_AMP_MUTE);
8370 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8371 HDA_AMP_MUTE, HDA_AMP_MUTE);
8372 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8373 HDA_AMP_MUTE, HDA_AMP_MUTE);
8374 } else {
8375 /* unmute internal speaker if necessary */
8376 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8377 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8378 HDA_AMP_MUTE, mute);
8379 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8380 HDA_AMP_MUTE, mute);
8381 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8382 HDA_AMP_MUTE, mute);
8383 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8384 HDA_AMP_MUTE, mute);
8385 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8386 HDA_AMP_MUTE, mute);
8387 }
8388}
8389
8390static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8391 unsigned int res)
8392{
8393 if ((res >> 26) == ALC880_HP_EVENT)
8394 alc888_lenovo_sky_front_automute(codec);
8395}
8396
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008397/*
8398 * generic initialization of ADC, input mixers and output mixers
8399 */
8400static struct hda_verb alc883_auto_init_verbs[] = {
8401 /*
8402 * Unmute ADC0-2 and set the default input to mic-in
8403 */
8404 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8405 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8406 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8407 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8408
Takashi Iwaicb53c622007-08-10 17:21:45 +02008409 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008410 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008411 * Note: PASD motherboards uses the Line In 2 as the input for
8412 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008413 */
8414 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008415 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8416 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8417 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8418 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8419 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008420
8421 /*
8422 * Set up output mixers (0x0c - 0x0f)
8423 */
8424 /* set vol=0 to output mixers */
8425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8426 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8427 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8428 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8429 /* set up input amps for analog loopback */
8430 /* Amp Indices: DAC = 0, mixer = 1 */
8431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8432 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8433 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8434 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8435 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8436 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8437 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8438 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8439 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8440 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8441
8442 /* FIXME: use matrix-type input source selection */
8443 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8444 /* Input mixer1 */
8445 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8446 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8447 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008448 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008449 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8450 /* Input mixer2 */
8451 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8452 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8453 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008454 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008455 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008456
8457 { }
8458};
8459
Kailang Yange2757d52008-08-26 13:17:46 +02008460static struct hda_verb alc888_asus_m90v_verbs[] = {
8461 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8462 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8463 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8464 /* enable unsolicited event */
8465 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8466 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8467 { } /* end */
8468};
8469
8470static void alc883_nb_mic_automute(struct hda_codec *codec)
8471{
8472 unsigned int present;
8473
8474 present = snd_hda_codec_read(codec, 0x18, 0,
8475 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8476 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8477 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8478 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8479 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8480}
8481
8482static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8483{
8484 unsigned int present;
8485 unsigned char bits;
8486
8487 present = snd_hda_codec_read(codec, 0x1b, 0,
8488 AC_VERB_GET_PIN_SENSE, 0)
8489 & AC_PINSENSE_PRESENCE;
8490 bits = present ? 0 : PIN_OUT;
8491 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8492 bits);
8493 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8494 bits);
8495 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8496 bits);
8497}
8498
8499static void alc883_mode2_unsol_event(struct hda_codec *codec,
8500 unsigned int res)
8501{
8502 switch (res >> 26) {
8503 case ALC880_HP_EVENT:
8504 alc883_M90V_speaker_automute(codec);
8505 break;
8506 case ALC880_MIC_EVENT:
8507 alc883_nb_mic_automute(codec);
8508 break;
8509 }
8510}
8511
8512static void alc883_mode2_inithook(struct hda_codec *codec)
8513{
8514 alc883_M90V_speaker_automute(codec);
8515 alc883_nb_mic_automute(codec);
8516}
8517
8518static struct hda_verb alc888_asus_eee1601_verbs[] = {
8519 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8520 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8521 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8524 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8525 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8526 /* enable unsolicited event */
8527 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8528 { } /* end */
8529};
8530
8531static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8532{
8533 unsigned int present;
8534 unsigned char bits;
8535
8536 present = snd_hda_codec_read(codec, 0x14, 0,
8537 AC_VERB_GET_PIN_SENSE, 0)
8538 & AC_PINSENSE_PRESENCE;
8539 bits = present ? 0 : PIN_OUT;
8540 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8541 bits);
8542}
8543
8544static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8545 unsigned int res)
8546{
8547 switch (res >> 26) {
8548 case ALC880_HP_EVENT:
8549 alc883_eee1601_speaker_automute(codec);
8550 break;
8551 }
8552}
8553
8554static void alc883_eee1601_inithook(struct hda_codec *codec)
8555{
8556 alc883_eee1601_speaker_automute(codec);
8557}
8558
Takashi Iwaicb53c622007-08-10 17:21:45 +02008559#ifdef CONFIG_SND_HDA_POWER_SAVE
8560#define alc883_loopbacks alc880_loopbacks
8561#endif
8562
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008563/* pcm configuration: identiacal with ALC880 */
8564#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8565#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008566#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008567#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8568#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8569
8570/*
8571 * configuration and preset
8572 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008573static const char *alc883_models[ALC883_MODEL_LAST] = {
8574 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8575 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8576 [ALC883_3ST_6ch] = "3stack-6ch",
8577 [ALC883_6ST_DIG] = "6stack-dig",
8578 [ALC883_TARGA_DIG] = "targa-dig",
8579 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008580 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008581 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008582 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008583 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008584 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008585 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008586 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008587 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8588 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008589 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008590 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008591 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008592 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008593 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008594 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008595 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008596 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008597 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008598 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008599 [ALC883_AUTO] = "auto",
8600};
8601
8602static struct snd_pci_quirk alc883_cfg_tbl[] = {
8603 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008604 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008605 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008606 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8607 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008608 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008609 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8610 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008611 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8612 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01008613 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008614 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008615 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8616 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008617 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8618 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008619 /* default Acer */
8620 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008621 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008622 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008623 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8624 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008625 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008626 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008627 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008628 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008629 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008630 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008631 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008632 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008633 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008634 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008635 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8636 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008637 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008638 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008639 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008640 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8641 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8642 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008643 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008644 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008645 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008646 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8647 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8648 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8649 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8650 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8651 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8652 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8653 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8654 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008655 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8656 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008657 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008658 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008659 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008660 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008661 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008662 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008663 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008664 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8665 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008666 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008667 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008668 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaif67d8172009-02-04 23:30:19 +01008669 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8670 ALC883_FUJITSU_PI2515),
Jiang zhefb97dc62008-03-06 11:07:11 +01008671 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008672 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8673 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008674 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008675 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008676 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8677 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008678 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008679 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008680 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008681 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008682 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008683 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8684 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008685 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008686 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008687 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008688 {}
8689};
8690
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008691static hda_nid_t alc1200_slave_dig_outs[] = {
8692 ALC883_DIGOUT_NID, 0,
8693};
8694
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008695static struct alc_config_preset alc883_presets[] = {
8696 [ALC883_3ST_2ch_DIG] = {
8697 .mixers = { alc883_3ST_2ch_mixer },
8698 .init_verbs = { alc883_init_verbs },
8699 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8700 .dac_nids = alc883_dac_nids,
8701 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008702 .dig_in_nid = ALC883_DIGIN_NID,
8703 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8704 .channel_mode = alc883_3ST_2ch_modes,
8705 .input_mux = &alc883_capture_source,
8706 },
8707 [ALC883_3ST_6ch_DIG] = {
8708 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8709 .init_verbs = { alc883_init_verbs },
8710 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8711 .dac_nids = alc883_dac_nids,
8712 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008713 .dig_in_nid = ALC883_DIGIN_NID,
8714 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8715 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008716 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008717 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008718 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008719 [ALC883_3ST_6ch] = {
8720 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8721 .init_verbs = { alc883_init_verbs },
8722 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8723 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008724 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8725 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008726 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008727 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008728 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008729 [ALC883_3ST_6ch_INTEL] = {
8730 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8731 .init_verbs = { alc883_init_verbs },
8732 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8733 .dac_nids = alc883_dac_nids,
8734 .dig_out_nid = ALC883_DIGOUT_NID,
8735 .dig_in_nid = ALC883_DIGIN_NID,
8736 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8737 .channel_mode = alc883_3ST_6ch_intel_modes,
8738 .need_dac_fix = 1,
8739 .input_mux = &alc883_3stack_6ch_intel,
8740 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008741 [ALC883_6ST_DIG] = {
8742 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8743 .init_verbs = { alc883_init_verbs },
8744 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8745 .dac_nids = alc883_dac_nids,
8746 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008747 .dig_in_nid = ALC883_DIGIN_NID,
8748 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8749 .channel_mode = alc883_sixstack_modes,
8750 .input_mux = &alc883_capture_source,
8751 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008752 [ALC883_TARGA_DIG] = {
8753 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8754 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8755 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8756 .dac_nids = alc883_dac_nids,
8757 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008758 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8759 .channel_mode = alc883_3ST_6ch_modes,
8760 .need_dac_fix = 1,
8761 .input_mux = &alc883_capture_source,
8762 .unsol_event = alc883_tagra_unsol_event,
8763 .init_hook = alc883_tagra_automute,
8764 },
8765 [ALC883_TARGA_2ch_DIG] = {
8766 .mixers = { alc883_tagra_2ch_mixer},
8767 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8768 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8769 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008770 .adc_nids = alc883_adc_nids_alt,
8771 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008772 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008773 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8774 .channel_mode = alc883_3ST_2ch_modes,
8775 .input_mux = &alc883_capture_source,
8776 .unsol_event = alc883_tagra_unsol_event,
8777 .init_hook = alc883_tagra_automute,
8778 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008779 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008780 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008781 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8782 * and the headphone jack. Turn this on and rely on the
8783 * standard mute methods whenever the user wants to turn
8784 * these outputs off.
8785 */
8786 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8787 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8788 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008789 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8790 .channel_mode = alc883_3ST_2ch_modes,
8791 .input_mux = &alc883_capture_source,
8792 },
Tobin Davis2880a862007-08-07 11:50:26 +02008793 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008794 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008795 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008796 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8797 .dac_nids = alc883_dac_nids,
8798 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008799 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8800 .channel_mode = alc883_3ST_2ch_modes,
8801 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008802 .unsol_event = alc883_acer_aspire_unsol_event,
8803 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008804 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008805 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008806 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008807 alc883_chmode_mixer },
8808 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8809 alc888_acer_aspire_4930g_verbs },
8810 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8811 .dac_nids = alc883_dac_nids,
8812 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8813 .adc_nids = alc883_adc_nids_rev,
8814 .capsrc_nids = alc883_capsrc_nids_rev,
8815 .dig_out_nid = ALC883_DIGOUT_NID,
8816 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8817 .channel_mode = alc883_3ST_6ch_modes,
8818 .need_dac_fix = 1,
8819 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008820 ARRAY_SIZE(alc888_2_capture_sources),
8821 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008822 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8823 .init_hook = alc888_acer_aspire_4930g_automute,
8824 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008825 [ALC883_MEDION] = {
8826 .mixers = { alc883_fivestack_mixer,
8827 alc883_chmode_mixer },
8828 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008829 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008830 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8831 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008832 .adc_nids = alc883_adc_nids_alt,
8833 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008834 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8835 .channel_mode = alc883_sixstack_modes,
8836 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008837 },
Kailang Yang272a5272007-05-14 11:00:38 +02008838 [ALC883_MEDION_MD2] = {
8839 .mixers = { alc883_medion_md2_mixer},
8840 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8841 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8842 .dac_nids = alc883_dac_nids,
8843 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008844 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8845 .channel_mode = alc883_3ST_2ch_modes,
8846 .input_mux = &alc883_capture_source,
8847 .unsol_event = alc883_medion_md2_unsol_event,
8848 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008849 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008850 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008851 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008852 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8853 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8854 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008855 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8856 .channel_mode = alc883_3ST_2ch_modes,
8857 .input_mux = &alc883_capture_source,
8858 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008859 [ALC883_CLEVO_M720] = {
8860 .mixers = { alc883_clevo_m720_mixer },
8861 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008862 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8863 .dac_nids = alc883_dac_nids,
8864 .dig_out_nid = ALC883_DIGOUT_NID,
8865 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8866 .channel_mode = alc883_3ST_2ch_modes,
8867 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008868 .unsol_event = alc883_clevo_m720_unsol_event,
8869 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008870 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008871 [ALC883_LENOVO_101E_2ch] = {
8872 .mixers = { alc883_lenovo_101e_2ch_mixer},
8873 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8874 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8875 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008876 .adc_nids = alc883_adc_nids_alt,
8877 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008878 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8879 .channel_mode = alc883_3ST_2ch_modes,
8880 .input_mux = &alc883_lenovo_101e_capture_source,
8881 .unsol_event = alc883_lenovo_101e_unsol_event,
8882 .init_hook = alc883_lenovo_101e_all_automute,
8883 },
Kailang Yang272a5272007-05-14 11:00:38 +02008884 [ALC883_LENOVO_NB0763] = {
8885 .mixers = { alc883_lenovo_nb0763_mixer },
8886 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8887 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8888 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008889 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8890 .channel_mode = alc883_3ST_2ch_modes,
8891 .need_dac_fix = 1,
8892 .input_mux = &alc883_lenovo_nb0763_capture_source,
8893 .unsol_event = alc883_medion_md2_unsol_event,
8894 .init_hook = alc883_medion_md2_automute,
8895 },
8896 [ALC888_LENOVO_MS7195_DIG] = {
8897 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8898 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8899 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8900 .dac_nids = alc883_dac_nids,
8901 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008902 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8903 .channel_mode = alc883_3ST_6ch_modes,
8904 .need_dac_fix = 1,
8905 .input_mux = &alc883_capture_source,
8906 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8907 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008908 },
8909 [ALC883_HAIER_W66] = {
8910 .mixers = { alc883_tagra_2ch_mixer},
8911 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8912 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8913 .dac_nids = alc883_dac_nids,
8914 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008915 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8916 .channel_mode = alc883_3ST_2ch_modes,
8917 .input_mux = &alc883_capture_source,
8918 .unsol_event = alc883_haier_w66_unsol_event,
8919 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008920 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008921 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008922 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008923 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008924 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8925 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008926 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8927 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008928 .need_dac_fix = 1,
8929 .input_mux = &alc883_capture_source,
8930 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008931 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008932 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008933 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8934 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8935 .dac_nids = alc883_dac_nids,
8936 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008937 .dig_in_nid = ALC883_DIGIN_NID,
8938 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8939 .channel_mode = alc883_sixstack_modes,
8940 .input_mux = &alc883_capture_source,
8941 .unsol_event = alc888_6st_dell_unsol_event,
8942 .init_hook = alc888_6st_dell_front_automute,
8943 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008944 [ALC883_MITAC] = {
8945 .mixers = { alc883_mitac_mixer },
8946 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8947 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8948 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008949 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8950 .channel_mode = alc883_3ST_2ch_modes,
8951 .input_mux = &alc883_capture_source,
8952 .unsol_event = alc883_mitac_unsol_event,
8953 .init_hook = alc883_mitac_automute,
8954 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008955 [ALC883_FUJITSU_PI2515] = {
8956 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8957 .init_verbs = { alc883_init_verbs,
8958 alc883_2ch_fujitsu_pi2515_verbs},
8959 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8960 .dac_nids = alc883_dac_nids,
8961 .dig_out_nid = ALC883_DIGOUT_NID,
8962 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8963 .channel_mode = alc883_3ST_2ch_modes,
8964 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8965 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8966 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8967 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008968 [ALC888_FUJITSU_XA3530] = {
8969 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8970 .init_verbs = { alc883_init_verbs,
8971 alc888_fujitsu_xa3530_verbs },
8972 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8973 .dac_nids = alc883_dac_nids,
8974 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8975 .adc_nids = alc883_adc_nids_rev,
8976 .capsrc_nids = alc883_capsrc_nids_rev,
8977 .dig_out_nid = ALC883_DIGOUT_NID,
8978 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8979 .channel_mode = alc888_4ST_8ch_intel_modes,
8980 .num_mux_defs =
8981 ARRAY_SIZE(alc888_2_capture_sources),
8982 .input_mux = alc888_2_capture_sources,
8983 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
8984 .init_hook = alc888_fujitsu_xa3530_automute,
8985 },
Kailang Yange2757d52008-08-26 13:17:46 +02008986 [ALC888_LENOVO_SKY] = {
8987 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8988 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8989 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8990 .dac_nids = alc883_dac_nids,
8991 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008992 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8993 .channel_mode = alc883_sixstack_modes,
8994 .need_dac_fix = 1,
8995 .input_mux = &alc883_lenovo_sky_capture_source,
8996 .unsol_event = alc883_lenovo_sky_unsol_event,
8997 .init_hook = alc888_lenovo_sky_front_automute,
8998 },
8999 [ALC888_ASUS_M90V] = {
9000 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9001 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9002 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9003 .dac_nids = alc883_dac_nids,
9004 .dig_out_nid = ALC883_DIGOUT_NID,
9005 .dig_in_nid = ALC883_DIGIN_NID,
9006 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9007 .channel_mode = alc883_3ST_6ch_modes,
9008 .need_dac_fix = 1,
9009 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9010 .unsol_event = alc883_mode2_unsol_event,
9011 .init_hook = alc883_mode2_inithook,
9012 },
9013 [ALC888_ASUS_EEE1601] = {
9014 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009015 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009016 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9017 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9018 .dac_nids = alc883_dac_nids,
9019 .dig_out_nid = ALC883_DIGOUT_NID,
9020 .dig_in_nid = ALC883_DIGIN_NID,
9021 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9022 .channel_mode = alc883_3ST_2ch_modes,
9023 .need_dac_fix = 1,
9024 .input_mux = &alc883_asus_eee1601_capture_source,
9025 .unsol_event = alc883_eee1601_unsol_event,
9026 .init_hook = alc883_eee1601_inithook,
9027 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009028 [ALC1200_ASUS_P5Q] = {
9029 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9030 .init_verbs = { alc883_init_verbs },
9031 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9032 .dac_nids = alc883_dac_nids,
9033 .dig_out_nid = ALC1200_DIGOUT_NID,
9034 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009035 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009036 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9037 .channel_mode = alc883_sixstack_modes,
9038 .input_mux = &alc883_capture_source,
9039 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009040};
9041
9042
9043/*
9044 * BIOS auto configuration
9045 */
9046static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9047 hda_nid_t nid, int pin_type,
9048 int dac_idx)
9049{
9050 /* set as output */
9051 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009052 int idx;
9053
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009054 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009055 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9056 idx = 4;
9057 else
9058 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009059 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9060
9061}
9062
9063static void alc883_auto_init_multi_out(struct hda_codec *codec)
9064{
9065 struct alc_spec *spec = codec->spec;
9066 int i;
9067
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009068 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009069 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009070 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009071 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009072 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009073 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009074 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009075 }
9076}
9077
9078static void alc883_auto_init_hp_out(struct hda_codec *codec)
9079{
9080 struct alc_spec *spec = codec->spec;
9081 hda_nid_t pin;
9082
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009083 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009084 if (pin) /* connect to front */
9085 /* use dac 0 */
9086 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009087 pin = spec->autocfg.speaker_pins[0];
9088 if (pin)
9089 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009090}
9091
9092#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9093#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9094
9095static void alc883_auto_init_analog_input(struct hda_codec *codec)
9096{
9097 struct alc_spec *spec = codec->spec;
9098 int i;
9099
9100 for (i = 0; i < AUTO_PIN_LAST; i++) {
9101 hda_nid_t nid = spec->autocfg.input_pins[i];
9102 if (alc883_is_input_pin(nid)) {
9103 snd_hda_codec_write(codec, nid, 0,
9104 AC_VERB_SET_PIN_WIDGET_CONTROL,
9105 (i <= AUTO_PIN_FRONT_MIC ?
9106 PIN_VREF80 : PIN_IN));
9107 if (nid != ALC883_PIN_CD_NID)
9108 snd_hda_codec_write(codec, nid, 0,
9109 AC_VERB_SET_AMP_GAIN_MUTE,
9110 AMP_OUT_MUTE);
9111 }
9112 }
9113}
9114
Takashi Iwaif511b012008-08-15 16:46:42 +02009115#define alc883_auto_init_input_src alc882_auto_init_input_src
9116
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009117/* almost identical with ALC880 parser... */
9118static int alc883_parse_auto_config(struct hda_codec *codec)
9119{
9120 struct alc_spec *spec = codec->spec;
9121 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009122 struct auto_pin_cfg *cfg = &spec->autocfg;
9123 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009124
9125 if (err < 0)
9126 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009127 else if (!err)
9128 return 0; /* no config found */
9129
9130 err = alc_auto_add_mic_boost(codec);
9131 if (err < 0)
9132 return err;
9133
9134 /* hack - override the init verbs */
9135 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009136
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009137 /* setup input_mux for ALC889 */
9138 if (codec->vendor_id == 0x10ec0889) {
9139 /* digital-mic input pin is excluded in alc880_auto_create..()
9140 * because it's under 0x18
9141 */
9142 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9143 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9144 struct hda_input_mux *imux = &spec->private_imux[0];
9145 for (i = 1; i < 3; i++)
9146 memcpy(&spec->private_imux[i],
9147 &spec->private_imux[0],
9148 sizeof(spec->private_imux[0]));
9149 imux->items[imux->num_items].label = "Int DMic";
9150 imux->items[imux->num_items].index = 0x0b;
9151 imux->num_items++;
9152 spec->num_mux_defs = 3;
9153 spec->input_mux = spec->private_imux;
9154 }
9155 }
9156
Takashi Iwai776e1842007-08-29 15:07:11 +02009157 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009158}
9159
9160/* additional initialization for auto-configuration model */
9161static void alc883_auto_init(struct hda_codec *codec)
9162{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009163 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009164 alc883_auto_init_multi_out(codec);
9165 alc883_auto_init_hp_out(codec);
9166 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009167 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009168 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009169 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009170}
9171
9172static int patch_alc883(struct hda_codec *codec)
9173{
9174 struct alc_spec *spec;
9175 int err, board_config;
9176
9177 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9178 if (spec == NULL)
9179 return -ENOMEM;
9180
9181 codec->spec = spec;
9182
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009183 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9184
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009185 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9186 alc883_models,
9187 alc883_cfg_tbl);
9188 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009189 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9190 "trying auto-probe from BIOS...\n");
9191 board_config = ALC883_AUTO;
9192 }
9193
9194 if (board_config == ALC883_AUTO) {
9195 /* automatic parse from the BIOS config */
9196 err = alc883_parse_auto_config(codec);
9197 if (err < 0) {
9198 alc_free(codec);
9199 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009200 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009201 printk(KERN_INFO
9202 "hda_codec: Cannot set up configuration "
9203 "from BIOS. Using base mode...\n");
9204 board_config = ALC883_3ST_2ch_DIG;
9205 }
9206 }
9207
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009208 err = snd_hda_attach_beep_device(codec, 0x1);
9209 if (err < 0) {
9210 alc_free(codec);
9211 return err;
9212 }
9213
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009214 if (board_config != ALC883_AUTO)
9215 setup_preset(spec, &alc883_presets[board_config]);
9216
Kailang Yang2f893282008-05-27 12:14:47 +02009217 switch (codec->vendor_id) {
9218 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009219 if (codec->revision_id == 0x100101) {
9220 spec->stream_name_analog = "ALC1200 Analog";
9221 spec->stream_name_digital = "ALC1200 Digital";
9222 } else {
9223 spec->stream_name_analog = "ALC888 Analog";
9224 spec->stream_name_digital = "ALC888 Digital";
9225 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009226 if (!spec->num_adc_nids) {
9227 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9228 spec->adc_nids = alc883_adc_nids;
9229 }
9230 if (!spec->capsrc_nids)
9231 spec->capsrc_nids = alc883_capsrc_nids;
9232 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009233 break;
9234 case 0x10ec0889:
9235 spec->stream_name_analog = "ALC889 Analog";
9236 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009237 if (!spec->num_adc_nids) {
9238 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9239 spec->adc_nids = alc889_adc_nids;
9240 }
9241 if (!spec->capsrc_nids)
9242 spec->capsrc_nids = alc889_capsrc_nids;
9243 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9244 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009245 break;
9246 default:
9247 spec->stream_name_analog = "ALC883 Analog";
9248 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009249 if (!spec->num_adc_nids) {
9250 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9251 spec->adc_nids = alc883_adc_nids;
9252 }
9253 if (!spec->capsrc_nids)
9254 spec->capsrc_nids = alc883_capsrc_nids;
9255 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009256 break;
9257 }
9258
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009259 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9260 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009261 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009262
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009263 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9264 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9265
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009266 if (!spec->cap_mixer)
9267 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009268 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009269
Takashi Iwai2134ea42008-01-10 16:53:55 +01009270 spec->vmaster_nid = 0x0c;
9271
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009272 codec->patch_ops = alc_patch_ops;
9273 if (board_config == ALC883_AUTO)
9274 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009275
Takashi Iwaicb53c622007-08-10 17:21:45 +02009276#ifdef CONFIG_SND_HDA_POWER_SAVE
9277 if (!spec->loopback.amplist)
9278 spec->loopback.amplist = alc883_loopbacks;
9279#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009280 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009281
9282 return 0;
9283}
9284
9285/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009286 * ALC262 support
9287 */
9288
9289#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9290#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9291
9292#define alc262_dac_nids alc260_dac_nids
9293#define alc262_adc_nids alc882_adc_nids
9294#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009295#define alc262_capsrc_nids alc882_capsrc_nids
9296#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009297
9298#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009299#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009300
Kailang Yang4e555fe2008-08-26 13:05:55 +02009301static hda_nid_t alc262_dmic_adc_nids[1] = {
9302 /* ADC0 */
9303 0x09
9304};
9305
9306static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9307
Kailang Yangdf694da2005-12-05 19:42:22 +01009308static struct snd_kcontrol_new alc262_base_mixer[] = {
9309 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9310 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9311 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9312 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9313 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9314 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9316 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009317 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009318 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9319 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009320 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009321 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9322 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9323 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9324 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009325 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009326};
9327
Kailang Yangccc656c2006-10-17 12:32:26 +02009328static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9329 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9330 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9331 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9332 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9333 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9334 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009337 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009338 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9339 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009340 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009341 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9342 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9343 { } /* end */
9344};
9345
Takashi Iwaice875f02008-01-28 18:17:43 +01009346/* update HP, line and mono-out pins according to the master switch */
9347static void alc262_hp_master_update(struct hda_codec *codec)
9348{
9349 struct alc_spec *spec = codec->spec;
9350 int val = spec->master_sw;
9351
9352 /* HP & line-out */
9353 snd_hda_codec_write_cache(codec, 0x1b, 0,
9354 AC_VERB_SET_PIN_WIDGET_CONTROL,
9355 val ? PIN_HP : 0);
9356 snd_hda_codec_write_cache(codec, 0x15, 0,
9357 AC_VERB_SET_PIN_WIDGET_CONTROL,
9358 val ? PIN_HP : 0);
9359 /* mono (speaker) depending on the HP jack sense */
9360 val = val && !spec->jack_present;
9361 snd_hda_codec_write_cache(codec, 0x16, 0,
9362 AC_VERB_SET_PIN_WIDGET_CONTROL,
9363 val ? PIN_OUT : 0);
9364}
9365
9366static void alc262_hp_bpc_automute(struct hda_codec *codec)
9367{
9368 struct alc_spec *spec = codec->spec;
9369 unsigned int presence;
9370 presence = snd_hda_codec_read(codec, 0x1b, 0,
9371 AC_VERB_GET_PIN_SENSE, 0);
9372 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9373 alc262_hp_master_update(codec);
9374}
9375
9376static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9377{
9378 if ((res >> 26) != ALC880_HP_EVENT)
9379 return;
9380 alc262_hp_bpc_automute(codec);
9381}
9382
9383static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9384{
9385 struct alc_spec *spec = codec->spec;
9386 unsigned int presence;
9387 presence = snd_hda_codec_read(codec, 0x15, 0,
9388 AC_VERB_GET_PIN_SENSE, 0);
9389 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9390 alc262_hp_master_update(codec);
9391}
9392
9393static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9394 unsigned int res)
9395{
9396 if ((res >> 26) != ALC880_HP_EVENT)
9397 return;
9398 alc262_hp_wildwest_automute(codec);
9399}
9400
9401static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9402 struct snd_ctl_elem_value *ucontrol)
9403{
9404 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9405 struct alc_spec *spec = codec->spec;
9406 *ucontrol->value.integer.value = spec->master_sw;
9407 return 0;
9408}
9409
9410static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9411 struct snd_ctl_elem_value *ucontrol)
9412{
9413 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9414 struct alc_spec *spec = codec->spec;
9415 int val = !!*ucontrol->value.integer.value;
9416
9417 if (val == spec->master_sw)
9418 return 0;
9419 spec->master_sw = val;
9420 alc262_hp_master_update(codec);
9421 return 1;
9422}
9423
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009424static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009425 {
9426 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9427 .name = "Master Playback Switch",
9428 .info = snd_ctl_boolean_mono_info,
9429 .get = alc262_hp_master_sw_get,
9430 .put = alc262_hp_master_sw_put,
9431 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009432 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9433 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9434 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009435 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9436 HDA_OUTPUT),
9437 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9438 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9440 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009441 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009442 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9443 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009444 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009445 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9446 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9447 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9448 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009449 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9450 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9451 { } /* end */
9452};
9453
Kailang Yangcd7509a2007-01-26 18:33:17 +01009454static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009455 {
9456 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9457 .name = "Master Playback Switch",
9458 .info = snd_ctl_boolean_mono_info,
9459 .get = alc262_hp_master_sw_get,
9460 .put = alc262_hp_master_sw_put,
9461 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009462 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9463 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9464 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9465 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009466 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9467 HDA_OUTPUT),
9468 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9469 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009470 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9471 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009472 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009473 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9474 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9475 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9476 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009477 { } /* end */
9478};
9479
9480static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9481 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9482 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009483 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009484 { } /* end */
9485};
9486
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009487/* mute/unmute internal speaker according to the hp jack and mute state */
9488static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9489{
9490 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009491
9492 if (force || !spec->sense_updated) {
9493 unsigned int present;
9494 present = snd_hda_codec_read(codec, 0x15, 0,
9495 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009496 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009497 spec->sense_updated = 1;
9498 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009499 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9500 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009501}
9502
9503static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9504 unsigned int res)
9505{
9506 if ((res >> 26) != ALC880_HP_EVENT)
9507 return;
9508 alc262_hp_t5735_automute(codec, 1);
9509}
9510
9511static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9512{
9513 alc262_hp_t5735_automute(codec, 1);
9514}
9515
9516static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009517 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9518 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9520 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9521 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9522 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9523 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9524 { } /* end */
9525};
9526
9527static struct hda_verb alc262_hp_t5735_verbs[] = {
9528 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9529 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9530
9531 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9532 { }
9533};
9534
Kailang Yang8c427222008-01-10 13:03:59 +01009535static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009536 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9537 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009538 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9539 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009540 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9541 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9542 { } /* end */
9543};
9544
9545static struct hda_verb alc262_hp_rp5700_verbs[] = {
9546 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9547 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9548 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9549 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9550 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9551 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9552 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9554 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9555 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9556 {}
9557};
9558
9559static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9560 .num_items = 1,
9561 .items = {
9562 { "Line", 0x1 },
9563 },
9564};
9565
Takashi Iwai0724ea22007-08-23 00:31:43 +02009566/* bind hp and internal speaker mute (with plug check) */
9567static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9568 struct snd_ctl_elem_value *ucontrol)
9569{
9570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9571 long *valp = ucontrol->value.integer.value;
9572 int change;
9573
9574 /* change hp mute */
9575 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9576 HDA_AMP_MUTE,
9577 valp[0] ? 0 : HDA_AMP_MUTE);
9578 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9579 HDA_AMP_MUTE,
9580 valp[1] ? 0 : HDA_AMP_MUTE);
9581 if (change) {
9582 /* change speaker according to HP jack state */
9583 struct alc_spec *spec = codec->spec;
9584 unsigned int mute;
9585 if (spec->jack_present)
9586 mute = HDA_AMP_MUTE;
9587 else
9588 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9589 HDA_OUTPUT, 0);
9590 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9591 HDA_AMP_MUTE, mute);
9592 }
9593 return change;
9594}
Takashi Iwai5b319542007-07-26 11:49:22 +02009595
Kailang Yang272a5272007-05-14 11:00:38 +02009596static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009597 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9598 {
9599 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9600 .name = "Master Playback Switch",
9601 .info = snd_hda_mixer_amp_switch_info,
9602 .get = snd_hda_mixer_amp_switch_get,
9603 .put = alc262_sony_master_sw_put,
9604 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9605 },
Kailang Yang272a5272007-05-14 11:00:38 +02009606 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9607 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9608 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9609 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9610 { } /* end */
9611};
9612
Kailang Yang83c34212007-07-05 11:43:05 +02009613static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9614 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9615 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9616 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9619 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9620 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9621 { } /* end */
9622};
Kailang Yang272a5272007-05-14 11:00:38 +02009623
Tony Vroonba340e82009-02-02 19:01:30 +00009624static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9625 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9626 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9627 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9628 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9629 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9630 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9631 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9632 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9633 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9634 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9635 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9636 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9637 { } /* end */
9638};
9639
9640static struct hda_verb alc262_tyan_verbs[] = {
9641 /* Headphone automute */
9642 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9643 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9644 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9645
9646 /* P11 AUX_IN, white 4-pin connector */
9647 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9648 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9649 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9650 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9651
9652 {}
9653};
9654
9655/* unsolicited event for HP jack sensing */
9656static void alc262_tyan_automute(struct hda_codec *codec)
9657{
9658 unsigned int mute;
9659 unsigned int present;
9660
9661 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9662 present = snd_hda_codec_read(codec, 0x1b, 0,
9663 AC_VERB_GET_PIN_SENSE, 0);
9664 present = (present & 0x80000000) != 0;
9665 if (present) {
9666 /* mute line output on ATX panel */
9667 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9668 HDA_AMP_MUTE, HDA_AMP_MUTE);
9669 } else {
9670 /* unmute line output if necessary */
9671 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9672 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9673 HDA_AMP_MUTE, mute);
9674 }
9675}
9676
9677static void alc262_tyan_unsol_event(struct hda_codec *codec,
9678 unsigned int res)
9679{
9680 if ((res >> 26) != ALC880_HP_EVENT)
9681 return;
9682 alc262_tyan_automute(codec);
9683}
9684
Kailang Yangdf694da2005-12-05 19:42:22 +01009685#define alc262_capture_mixer alc882_capture_mixer
9686#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9687
9688/*
9689 * generic initialization of ADC, input mixers and output mixers
9690 */
9691static struct hda_verb alc262_init_verbs[] = {
9692 /*
9693 * Unmute ADC0-2 and set the default input to mic-in
9694 */
9695 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9697 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9698 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9699 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9700 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9701
Takashi Iwaicb53c622007-08-10 17:21:45 +02009702 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009703 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009704 * Note: PASD motherboards uses the Line In 2 as the input for
9705 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009706 */
9707 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009713
9714 /*
9715 * Set up output mixers (0x0c - 0x0e)
9716 */
9717 /* set vol=0 to output mixers */
9718 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9719 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9720 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9721 /* set up input amps for analog loopback */
9722 /* Amp Indices: DAC = 0, mixer = 1 */
9723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9727 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9728 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9729
9730 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9732 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9733 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9734 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9735 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9736
9737 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9738 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9739 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9741 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009742
Kailang Yangdf694da2005-12-05 19:42:22 +01009743 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9744 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009745
Kailang Yangdf694da2005-12-05 19:42:22 +01009746 /* FIXME: use matrix-type input source selection */
9747 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9748 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9750 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9751 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9752 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9753 /* Input mixer2 */
9754 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9755 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9756 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9757 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9758 /* Input mixer3 */
9759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9760 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9761 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009762 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009763
9764 { }
9765};
9766
Kailang Yang4e555fe2008-08-26 13:05:55 +02009767static struct hda_verb alc262_eapd_verbs[] = {
9768 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9769 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9770 { }
9771};
9772
Kailang Yangccc656c2006-10-17 12:32:26 +02009773static struct hda_verb alc262_hippo_unsol_verbs[] = {
9774 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9775 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9776 {}
9777};
9778
9779static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9780 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9781 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9782 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9783
9784 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9785 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9786 {}
9787};
9788
Kailang Yang272a5272007-05-14 11:00:38 +02009789static struct hda_verb alc262_sony_unsol_verbs[] = {
9790 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9791 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9792 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9793
9794 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009796 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009797};
9798
Kailang Yang4e555fe2008-08-26 13:05:55 +02009799static struct hda_input_mux alc262_dmic_capture_source = {
9800 .num_items = 2,
9801 .items = {
9802 { "Int DMic", 0x9 },
9803 { "Mic", 0x0 },
9804 },
9805};
9806
9807static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9808 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9809 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9810 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009813 { } /* end */
9814};
9815
9816static struct hda_verb alc262_toshiba_s06_verbs[] = {
9817 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9818 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9820 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9821 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9822 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9823 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9824 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9825 {}
9826};
9827
9828static void alc262_dmic_automute(struct hda_codec *codec)
9829{
9830 unsigned int present;
9831
9832 present = snd_hda_codec_read(codec, 0x18, 0,
9833 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9834 snd_hda_codec_write(codec, 0x22, 0,
9835 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9836}
9837
9838/* toggle speaker-output according to the hp-jack state */
9839static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9840{
9841 unsigned int present;
9842 unsigned char bits;
9843
9844 present = snd_hda_codec_read(codec, 0x15, 0,
9845 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9846 bits = present ? 0 : PIN_OUT;
9847 snd_hda_codec_write(codec, 0x14, 0,
9848 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9849}
9850
9851
9852
9853/* unsolicited event for HP jack sensing */
9854static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9855 unsigned int res)
9856{
9857 if ((res >> 26) == ALC880_HP_EVENT)
9858 alc262_toshiba_s06_speaker_automute(codec);
9859 if ((res >> 26) == ALC880_MIC_EVENT)
9860 alc262_dmic_automute(codec);
9861
9862}
9863
9864static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9865{
9866 alc262_toshiba_s06_speaker_automute(codec);
9867 alc262_dmic_automute(codec);
9868}
9869
Kailang Yangccc656c2006-10-17 12:32:26 +02009870/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009871static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009872{
9873 struct alc_spec *spec = codec->spec;
9874 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009875 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009876
Takashi Iwai5b319542007-07-26 11:49:22 +02009877 /* need to execute and sync at first */
9878 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9879 present = snd_hda_codec_read(codec, 0x15, 0,
9880 AC_VERB_GET_PIN_SENSE, 0);
9881 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009882 if (spec->jack_present) {
9883 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009884 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9885 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009886 } else {
9887 /* unmute internal speaker if necessary */
9888 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009889 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9890 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009891 }
9892}
9893
9894/* unsolicited event for HP jack sensing */
9895static void alc262_hippo_unsol_event(struct hda_codec *codec,
9896 unsigned int res)
9897{
9898 if ((res >> 26) != ALC880_HP_EVENT)
9899 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009900 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009901}
9902
Takashi Iwai5b319542007-07-26 11:49:22 +02009903static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009904{
Kailang Yangccc656c2006-10-17 12:32:26 +02009905 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009906 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009907
Takashi Iwai5b319542007-07-26 11:49:22 +02009908 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9909 present = snd_hda_codec_read(codec, 0x1b, 0,
9910 AC_VERB_GET_PIN_SENSE, 0);
9911 present = (present & 0x80000000) != 0;
9912 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009913 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009914 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9915 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009916 } else {
9917 /* unmute internal speaker if necessary */
9918 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009919 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9920 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009921 }
9922}
9923
9924/* unsolicited event for HP jack sensing */
9925static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9926 unsigned int res)
9927{
9928 if ((res >> 26) != ALC880_HP_EVENT)
9929 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009930 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009931}
9932
Takashi Iwai834be882006-03-01 14:16:17 +01009933/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009934 * nec model
9935 * 0x15 = headphone
9936 * 0x16 = internal speaker
9937 * 0x18 = external mic
9938 */
9939
9940static struct snd_kcontrol_new alc262_nec_mixer[] = {
9941 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9942 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9943
9944 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9945 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9946 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9947
9948 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9949 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9950 { } /* end */
9951};
9952
9953static struct hda_verb alc262_nec_verbs[] = {
9954 /* Unmute Speaker */
9955 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9956
9957 /* Headphone */
9958 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9959 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9960
9961 /* External mic to headphone */
9962 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9963 /* External mic to speaker */
9964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9965 {}
9966};
9967
9968/*
Takashi Iwai834be882006-03-01 14:16:17 +01009969 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009970 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9971 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009972 */
9973
9974#define ALC_HP_EVENT 0x37
9975
9976static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9977 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009979 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9980 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009981 {}
9982};
9983
Jiang zhe0e31daf2008-03-20 12:12:39 +01009984static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9985 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9986 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9987 {}
9988};
9989
Takashi Iwai834be882006-03-01 14:16:17 +01009990static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009991 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009992 .items = {
9993 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009994 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009995 { "CD", 0x4 },
9996 },
9997};
9998
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009999static struct hda_input_mux alc262_HP_capture_source = {
10000 .num_items = 5,
10001 .items = {
10002 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010003 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010004 { "Line", 0x2 },
10005 { "CD", 0x4 },
10006 { "AUX IN", 0x6 },
10007 },
10008};
10009
zhejiangaccbe492007-08-31 12:36:05 +020010010static struct hda_input_mux alc262_HP_D7000_capture_source = {
10011 .num_items = 4,
10012 .items = {
10013 { "Mic", 0x0 },
10014 { "Front Mic", 0x2 },
10015 { "Line", 0x1 },
10016 { "CD", 0x4 },
10017 },
10018};
10019
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010020/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010021static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10022{
10023 struct alc_spec *spec = codec->spec;
10024 unsigned int mute;
10025
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010026 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010027 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010028 /* need to execute and sync at first */
10029 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010030 /* check laptop HP jack */
10031 present = snd_hda_codec_read(codec, 0x14, 0,
10032 AC_VERB_GET_PIN_SENSE, 0);
10033 /* need to execute and sync at first */
10034 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10035 /* check docking HP jack */
10036 present |= snd_hda_codec_read(codec, 0x1b, 0,
10037 AC_VERB_GET_PIN_SENSE, 0);
10038 if (present & AC_PINSENSE_PRESENCE)
10039 spec->jack_present = 1;
10040 else
10041 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010042 spec->sense_updated = 1;
10043 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010044 /* unmute internal speaker only if both HPs are unplugged and
10045 * master switch is on
10046 */
10047 if (spec->jack_present)
10048 mute = HDA_AMP_MUTE;
10049 else
Takashi Iwai834be882006-03-01 14:16:17 +010010050 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010051 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10052 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010053}
10054
10055/* unsolicited event for HP jack sensing */
10056static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10057 unsigned int res)
10058{
10059 if ((res >> 26) != ALC_HP_EVENT)
10060 return;
10061 alc262_fujitsu_automute(codec, 1);
10062}
10063
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010064static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10065{
10066 alc262_fujitsu_automute(codec, 1);
10067}
10068
Takashi Iwai834be882006-03-01 14:16:17 +010010069/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010070static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10071 .ops = &snd_hda_bind_vol,
10072 .values = {
10073 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10074 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10075 0
10076 },
10077};
Takashi Iwai834be882006-03-01 14:16:17 +010010078
Jiang zhe0e31daf2008-03-20 12:12:39 +010010079/* mute/unmute internal speaker according to the hp jack and mute state */
10080static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10081{
10082 struct alc_spec *spec = codec->spec;
10083 unsigned int mute;
10084
10085 if (force || !spec->sense_updated) {
10086 unsigned int present_int_hp;
10087 /* need to execute and sync at first */
10088 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10089 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10090 AC_VERB_GET_PIN_SENSE, 0);
10091 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10092 spec->sense_updated = 1;
10093 }
10094 if (spec->jack_present) {
10095 /* mute internal speaker */
10096 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10097 HDA_AMP_MUTE, HDA_AMP_MUTE);
10098 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10099 HDA_AMP_MUTE, HDA_AMP_MUTE);
10100 } else {
10101 /* unmute internal speaker if necessary */
10102 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10103 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10104 HDA_AMP_MUTE, mute);
10105 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10106 HDA_AMP_MUTE, mute);
10107 }
10108}
10109
10110/* unsolicited event for HP jack sensing */
10111static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10112 unsigned int res)
10113{
10114 if ((res >> 26) != ALC_HP_EVENT)
10115 return;
10116 alc262_lenovo_3000_automute(codec, 1);
10117}
10118
Takashi Iwai834be882006-03-01 14:16:17 +010010119/* bind hp and internal speaker mute (with plug check) */
10120static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10121 struct snd_ctl_elem_value *ucontrol)
10122{
10123 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10124 long *valp = ucontrol->value.integer.value;
10125 int change;
10126
Tony Vroon5d9fab22008-03-14 17:09:18 +010010127 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10128 HDA_AMP_MUTE,
10129 valp ? 0 : HDA_AMP_MUTE);
10130 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10131 HDA_AMP_MUTE,
10132 valp ? 0 : HDA_AMP_MUTE);
10133
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010134 if (change)
10135 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010136 return change;
10137}
10138
10139static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010140 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010141 {
10142 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10143 .name = "Master Playback Switch",
10144 .info = snd_hda_mixer_amp_switch_info,
10145 .get = snd_hda_mixer_amp_switch_get,
10146 .put = alc262_fujitsu_master_sw_put,
10147 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10148 },
10149 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10150 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10151 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10153 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010154 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10155 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10156 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010157 { } /* end */
10158};
10159
Jiang zhe0e31daf2008-03-20 12:12:39 +010010160/* bind hp and internal speaker mute (with plug check) */
10161static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10162 struct snd_ctl_elem_value *ucontrol)
10163{
10164 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10165 long *valp = ucontrol->value.integer.value;
10166 int change;
10167
10168 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10169 HDA_AMP_MUTE,
10170 valp ? 0 : HDA_AMP_MUTE);
10171
10172 if (change)
10173 alc262_lenovo_3000_automute(codec, 0);
10174 return change;
10175}
10176
10177static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10178 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10179 {
10180 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10181 .name = "Master Playback Switch",
10182 .info = snd_hda_mixer_amp_switch_info,
10183 .get = snd_hda_mixer_amp_switch_get,
10184 .put = alc262_lenovo_3000_master_sw_put,
10185 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10186 },
10187 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10188 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10189 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10192 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10193 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10194 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10195 { } /* end */
10196};
10197
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010198static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10199 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10200 {
10201 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10202 .name = "Master Playback Switch",
10203 .info = snd_hda_mixer_amp_switch_info,
10204 .get = snd_hda_mixer_amp_switch_get,
10205 .put = alc262_sony_master_sw_put,
10206 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10207 },
10208 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10210 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10211 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10212 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10213 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10214 { } /* end */
10215};
10216
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010217/* additional init verbs for Benq laptops */
10218static struct hda_verb alc262_EAPD_verbs[] = {
10219 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10220 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10221 {}
10222};
10223
Kailang Yang83c34212007-07-05 11:43:05 +020010224static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10225 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10226 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10227
10228 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10229 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10230 {}
10231};
10232
Tobin Davisf651b502007-10-26 12:40:47 +020010233/* Samsung Q1 Ultra Vista model setup */
10234static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010235 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10236 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10238 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10239 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010240 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010241 { } /* end */
10242};
10243
10244static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010245 /* output mixer */
10246 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10247 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10249 /* speaker */
10250 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10251 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10252 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10253 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10254 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010255 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10258 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10259 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10260 /* internal mic */
10261 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10263 /* ADC, choose mic */
10264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10265 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10267 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10270 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10271 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10272 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010274 {}
10275};
10276
Tobin Davisf651b502007-10-26 12:40:47 +020010277/* mute/unmute internal speaker according to the hp jack and mute state */
10278static void alc262_ultra_automute(struct hda_codec *codec)
10279{
10280 struct alc_spec *spec = codec->spec;
10281 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010282
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010283 mute = 0;
10284 /* auto-mute only when HP is used as HP */
10285 if (!spec->cur_mux[0]) {
10286 unsigned int present;
10287 /* need to execute and sync at first */
10288 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10289 present = snd_hda_codec_read(codec, 0x15, 0,
10290 AC_VERB_GET_PIN_SENSE, 0);
10291 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10292 if (spec->jack_present)
10293 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010294 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010295 /* mute/unmute internal speaker */
10296 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10297 HDA_AMP_MUTE, mute);
10298 /* mute/unmute HP */
10299 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10300 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010301}
10302
10303/* unsolicited event for HP jack sensing */
10304static void alc262_ultra_unsol_event(struct hda_codec *codec,
10305 unsigned int res)
10306{
10307 if ((res >> 26) != ALC880_HP_EVENT)
10308 return;
10309 alc262_ultra_automute(codec);
10310}
10311
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010312static struct hda_input_mux alc262_ultra_capture_source = {
10313 .num_items = 2,
10314 .items = {
10315 { "Mic", 0x1 },
10316 { "Headphone", 0x7 },
10317 },
10318};
10319
10320static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10321 struct snd_ctl_elem_value *ucontrol)
10322{
10323 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10324 struct alc_spec *spec = codec->spec;
10325 int ret;
10326
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010327 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010328 if (!ret)
10329 return 0;
10330 /* reprogram the HP pin as mic or HP according to the input source */
10331 snd_hda_codec_write_cache(codec, 0x15, 0,
10332 AC_VERB_SET_PIN_WIDGET_CONTROL,
10333 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10334 alc262_ultra_automute(codec); /* mute/unmute HP */
10335 return ret;
10336}
10337
10338static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10339 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10340 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10341 {
10342 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10343 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010344 .info = alc_mux_enum_info,
10345 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010346 .put = alc262_ultra_mux_enum_put,
10347 },
10348 { } /* end */
10349};
10350
Kailang Yangdf694da2005-12-05 19:42:22 +010010351/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010352static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10353 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010354{
10355 hda_nid_t nid;
10356 int err;
10357
10358 spec->multiout.num_dacs = 1; /* only use one dac */
10359 spec->multiout.dac_nids = spec->private_dac_nids;
10360 spec->multiout.dac_nids[0] = 2;
10361
10362 nid = cfg->line_out_pins[0];
10363 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010364 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10365 "Front Playback Volume",
10366 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10367 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010368 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010369 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10370 "Front Playback Switch",
10371 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10372 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010373 return err;
10374 }
10375
Takashi Iwai82bc9552006-03-21 11:24:42 +010010376 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010377 if (nid) {
10378 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010379 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10380 "Speaker Playback Volume",
10381 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10382 HDA_OUTPUT));
10383 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010384 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010385 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10386 "Speaker Playback Switch",
10387 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10388 HDA_OUTPUT));
10389 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010390 return err;
10391 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010392 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10393 "Speaker Playback Switch",
10394 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10395 HDA_OUTPUT));
10396 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010397 return err;
10398 }
10399 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010400 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010401 if (nid) {
10402 /* spec->multiout.hp_nid = 2; */
10403 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010404 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10405 "Headphone Playback Volume",
10406 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10407 HDA_OUTPUT));
10408 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010409 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010410 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10411 "Headphone Playback Switch",
10412 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10413 HDA_OUTPUT));
10414 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010415 return err;
10416 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010417 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10418 "Headphone Playback Switch",
10419 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10420 HDA_OUTPUT));
10421 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010422 return err;
10423 }
10424 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010425 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010426}
10427
10428/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010429#define alc262_auto_create_analog_input_ctls \
10430 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010431
10432/*
10433 * generic initialization of ADC, input mixers and output mixers
10434 */
10435static struct hda_verb alc262_volume_init_verbs[] = {
10436 /*
10437 * Unmute ADC0-2 and set the default input to mic-in
10438 */
10439 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10441 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10442 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10443 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10444 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10445
Takashi Iwaicb53c622007-08-10 17:21:45 +020010446 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010447 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010448 * Note: PASD motherboards uses the Line In 2 as the input for
10449 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010450 */
10451 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010452 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10453 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10454 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010457
10458 /*
10459 * Set up output mixers (0x0c - 0x0f)
10460 */
10461 /* set vol=0 to output mixers */
10462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10464 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010465
Kailang Yangdf694da2005-12-05 19:42:22 +010010466 /* set up input amps for analog loopback */
10467 /* Amp Indices: DAC = 0, mixer = 1 */
10468 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10470 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10472 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10474
10475 /* FIXME: use matrix-type input source selection */
10476 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10477 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10478 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10479 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10480 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10481 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10482 /* Input mixer2 */
10483 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10487 /* Input mixer3 */
10488 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10489 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10490 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10492
10493 { }
10494};
10495
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010496static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10497 /*
10498 * Unmute ADC0-2 and set the default input to mic-in
10499 */
10500 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10502 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10504 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10506
Takashi Iwaicb53c622007-08-10 17:21:45 +020010507 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010508 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010509 * Note: PASD motherboards uses the Line In 2 as the input for
10510 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010511 */
10512 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010513 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010520
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010521 /*
10522 * Set up output mixers (0x0c - 0x0e)
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},
10528
10529 /* 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
Takashi Iwaice875f02008-01-28 18:17:43 +010010538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10540 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10541
10542 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10543 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10544
10545 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10546 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10547
10548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10549 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10550 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10551 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10552 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10553
10554 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10555 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10556 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10557 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10558 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10559 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10560
10561
10562 /* FIXME: use matrix-type input source selection */
10563 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10564 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10565 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10566 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10567 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10568 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10569 /* Input mixer2 */
10570 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10571 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10572 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10574 /* Input mixer3 */
10575 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10579
Takashi Iwaice875f02008-01-28 18:17:43 +010010580 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10581
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010582 { }
10583};
10584
Kailang Yangcd7509a2007-01-26 18:33:17 +010010585static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10586 /*
10587 * Unmute ADC0-2 and set the default input to mic-in
10588 */
10589 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10591 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10592 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10593 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10594 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10595
Takashi Iwaicb53c622007-08-10 17:21:45 +020010596 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010597 * mixer widget
10598 * Note: PASD motherboards uses the Line In 2 as the input for front
10599 * panel mic (mic 2)
10600 */
10601 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10604 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10605 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10606 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10607 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10608 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10609 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010610 /*
10611 * Set up output mixers (0x0c - 0x0e)
10612 */
10613 /* set vol=0 to output mixers */
10614 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10615 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10616 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10617
10618 /* set up input amps for analog loopback */
10619 /* Amp Indices: DAC = 0, mixer = 1 */
10620 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10621 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10622 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10623 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10624 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10625 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10626
10627
10628 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10629 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10630 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10631 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10632 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10633 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10634 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10635
10636 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10638
10639 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10640 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10641
10642 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10644 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10645 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10646 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10647 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10648
10649 /* FIXME: use matrix-type input source selection */
10650 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10651 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10652 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10653 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10654 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10657 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10659 /* Input mixer2 */
10660 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10661 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10662 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10663 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10665 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10667 /* Input mixer3 */
10668 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10673 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10675
Takashi Iwaice875f02008-01-28 18:17:43 +010010676 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10677
Kailang Yangcd7509a2007-01-26 18:33:17 +010010678 { }
10679};
10680
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010681static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10682
10683 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10684 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10685 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10686
10687 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10688 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10689 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10690 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10691
10692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10693 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10694 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10695 {}
10696};
10697
10698
Takashi Iwaicb53c622007-08-10 17:21:45 +020010699#ifdef CONFIG_SND_HDA_POWER_SAVE
10700#define alc262_loopbacks alc880_loopbacks
10701#endif
10702
Kailang Yangdf694da2005-12-05 19:42:22 +010010703/* pcm configuration: identiacal with ALC880 */
10704#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10705#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10706#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10707#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10708
10709/*
10710 * BIOS auto configuration
10711 */
10712static int alc262_parse_auto_config(struct hda_codec *codec)
10713{
10714 struct alc_spec *spec = codec->spec;
10715 int err;
10716 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10717
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010718 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10719 alc262_ignore);
10720 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010721 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010722 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010723 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010724 spec->multiout.max_channels = 2;
10725 spec->no_analog = 1;
10726 goto dig_only;
10727 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010728 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010729 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010730 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10731 if (err < 0)
10732 return err;
10733 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10734 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010735 return err;
10736
10737 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10738
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010739 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010740 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010741 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010742 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010743 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010744 if (spec->autocfg.dig_in_pin)
10745 spec->dig_in_nid = ALC262_DIGIN_NID;
10746
Takashi Iwai603c4012008-07-30 15:01:44 +020010747 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010748 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010749
Takashi Iwaid88897e2008-10-31 15:01:37 +010010750 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010751 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010752 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010753
Takashi Iwai776e1842007-08-29 15:07:11 +020010754 err = alc_auto_add_mic_boost(codec);
10755 if (err < 0)
10756 return err;
10757
Kailang Yangdf694da2005-12-05 19:42:22 +010010758 return 1;
10759}
10760
10761#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10762#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10763#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010764#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010765
10766
10767/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010768static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010769{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010770 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010771 alc262_auto_init_multi_out(codec);
10772 alc262_auto_init_hp_out(codec);
10773 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010774 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010775 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010776 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010777}
10778
10779/*
10780 * configuration and preset
10781 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010782static const char *alc262_models[ALC262_MODEL_LAST] = {
10783 [ALC262_BASIC] = "basic",
10784 [ALC262_HIPPO] = "hippo",
10785 [ALC262_HIPPO_1] = "hippo_1",
10786 [ALC262_FUJITSU] = "fujitsu",
10787 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010788 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010789 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010790 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010791 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010792 [ALC262_BENQ_T31] = "benq-t31",
10793 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010794 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010795 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010796 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010797 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010798 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010799 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010800 [ALC262_AUTO] = "auto",
10801};
10802
10803static struct snd_pci_quirk alc262_cfg_tbl[] = {
10804 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010805 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010806 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10807 ALC262_HP_BPC),
10808 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10809 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010810 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010811 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010812 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010813 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010814 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010815 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010816 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010817 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010818 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10819 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10820 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010821 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10822 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010823 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010824 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010825 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010826 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10827 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10828 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwai57a5ef42008-11-28 14:46:28 +010010829 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
10830 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010831 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010832 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010833 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010834 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010835 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010836 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010837 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10838 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010839 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010840 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010841 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010842 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010843 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010844 {}
10845};
10846
10847static struct alc_config_preset alc262_presets[] = {
10848 [ALC262_BASIC] = {
10849 .mixers = { alc262_base_mixer },
10850 .init_verbs = { alc262_init_verbs },
10851 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10852 .dac_nids = alc262_dac_nids,
10853 .hp_nid = 0x03,
10854 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10855 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010856 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010857 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010858 [ALC262_HIPPO] = {
10859 .mixers = { alc262_base_mixer },
10860 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10861 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10862 .dac_nids = alc262_dac_nids,
10863 .hp_nid = 0x03,
10864 .dig_out_nid = ALC262_DIGOUT_NID,
10865 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10866 .channel_mode = alc262_modes,
10867 .input_mux = &alc262_capture_source,
10868 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010869 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010870 },
10871 [ALC262_HIPPO_1] = {
10872 .mixers = { alc262_hippo1_mixer },
10873 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10874 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10875 .dac_nids = alc262_dac_nids,
10876 .hp_nid = 0x02,
10877 .dig_out_nid = ALC262_DIGOUT_NID,
10878 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10879 .channel_mode = alc262_modes,
10880 .input_mux = &alc262_capture_source,
10881 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010882 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010883 },
Takashi Iwai834be882006-03-01 14:16:17 +010010884 [ALC262_FUJITSU] = {
10885 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010886 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10887 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010888 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10889 .dac_nids = alc262_dac_nids,
10890 .hp_nid = 0x03,
10891 .dig_out_nid = ALC262_DIGOUT_NID,
10892 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10893 .channel_mode = alc262_modes,
10894 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010895 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010896 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010897 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010898 [ALC262_HP_BPC] = {
10899 .mixers = { alc262_HP_BPC_mixer },
10900 .init_verbs = { alc262_HP_BPC_init_verbs },
10901 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10902 .dac_nids = alc262_dac_nids,
10903 .hp_nid = 0x03,
10904 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10905 .channel_mode = alc262_modes,
10906 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010907 .unsol_event = alc262_hp_bpc_unsol_event,
10908 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010909 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010910 [ALC262_HP_BPC_D7000_WF] = {
10911 .mixers = { alc262_HP_BPC_WildWest_mixer },
10912 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10913 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10914 .dac_nids = alc262_dac_nids,
10915 .hp_nid = 0x03,
10916 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10917 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010918 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010919 .unsol_event = alc262_hp_wildwest_unsol_event,
10920 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010921 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010922 [ALC262_HP_BPC_D7000_WL] = {
10923 .mixers = { alc262_HP_BPC_WildWest_mixer,
10924 alc262_HP_BPC_WildWest_option_mixer },
10925 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10926 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10927 .dac_nids = alc262_dac_nids,
10928 .hp_nid = 0x03,
10929 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10930 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010931 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010932 .unsol_event = alc262_hp_wildwest_unsol_event,
10933 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010934 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010935 [ALC262_HP_TC_T5735] = {
10936 .mixers = { alc262_hp_t5735_mixer },
10937 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10938 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10939 .dac_nids = alc262_dac_nids,
10940 .hp_nid = 0x03,
10941 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10942 .channel_mode = alc262_modes,
10943 .input_mux = &alc262_capture_source,
10944 .unsol_event = alc262_hp_t5735_unsol_event,
10945 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010946 },
10947 [ALC262_HP_RP5700] = {
10948 .mixers = { alc262_hp_rp5700_mixer },
10949 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10950 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10951 .dac_nids = alc262_dac_nids,
10952 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10953 .channel_mode = alc262_modes,
10954 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010955 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010956 [ALC262_BENQ_ED8] = {
10957 .mixers = { alc262_base_mixer },
10958 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10959 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10960 .dac_nids = alc262_dac_nids,
10961 .hp_nid = 0x03,
10962 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10963 .channel_mode = alc262_modes,
10964 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010965 },
Kailang Yang272a5272007-05-14 11:00:38 +020010966 [ALC262_SONY_ASSAMD] = {
10967 .mixers = { alc262_sony_mixer },
10968 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10969 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10970 .dac_nids = alc262_dac_nids,
10971 .hp_nid = 0x02,
10972 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10973 .channel_mode = alc262_modes,
10974 .input_mux = &alc262_capture_source,
10975 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010976 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010977 },
10978 [ALC262_BENQ_T31] = {
10979 .mixers = { alc262_benq_t31_mixer },
10980 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10981 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10982 .dac_nids = alc262_dac_nids,
10983 .hp_nid = 0x03,
10984 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10985 .channel_mode = alc262_modes,
10986 .input_mux = &alc262_capture_source,
10987 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010988 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010989 },
Tobin Davisf651b502007-10-26 12:40:47 +020010990 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010991 .mixers = { alc262_ultra_mixer },
10992 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010993 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010994 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10995 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010996 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10997 .channel_mode = alc262_modes,
10998 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010999 .adc_nids = alc262_adc_nids, /* ADC0 */
11000 .capsrc_nids = alc262_capsrc_nids,
11001 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011002 .unsol_event = alc262_ultra_unsol_event,
11003 .init_hook = alc262_ultra_automute,
11004 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011005 [ALC262_LENOVO_3000] = {
11006 .mixers = { alc262_lenovo_3000_mixer },
11007 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11008 alc262_lenovo_3000_unsol_verbs },
11009 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11010 .dac_nids = alc262_dac_nids,
11011 .hp_nid = 0x03,
11012 .dig_out_nid = ALC262_DIGOUT_NID,
11013 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11014 .channel_mode = alc262_modes,
11015 .input_mux = &alc262_fujitsu_capture_source,
11016 .unsol_event = alc262_lenovo_3000_unsol_event,
11017 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011018 [ALC262_NEC] = {
11019 .mixers = { alc262_nec_mixer },
11020 .init_verbs = { alc262_nec_verbs },
11021 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11022 .dac_nids = alc262_dac_nids,
11023 .hp_nid = 0x03,
11024 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11025 .channel_mode = alc262_modes,
11026 .input_mux = &alc262_capture_source,
11027 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011028 [ALC262_TOSHIBA_S06] = {
11029 .mixers = { alc262_toshiba_s06_mixer },
11030 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11031 alc262_eapd_verbs },
11032 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11033 .capsrc_nids = alc262_dmic_capsrc_nids,
11034 .dac_nids = alc262_dac_nids,
11035 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11036 .dig_out_nid = ALC262_DIGOUT_NID,
11037 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11038 .channel_mode = alc262_modes,
11039 .input_mux = &alc262_dmic_capture_source,
11040 .unsol_event = alc262_toshiba_s06_unsol_event,
11041 .init_hook = alc262_toshiba_s06_init_hook,
11042 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011043 [ALC262_TOSHIBA_RX1] = {
11044 .mixers = { alc262_toshiba_rx1_mixer },
11045 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11046 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11047 .dac_nids = alc262_dac_nids,
11048 .hp_nid = 0x03,
11049 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11050 .channel_mode = alc262_modes,
11051 .input_mux = &alc262_capture_source,
11052 .unsol_event = alc262_hippo_unsol_event,
11053 .init_hook = alc262_hippo_automute,
11054 },
Tony Vroonba340e82009-02-02 19:01:30 +000011055 [ALC262_TYAN] = {
11056 .mixers = { alc262_tyan_mixer },
11057 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11058 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11059 .dac_nids = alc262_dac_nids,
11060 .hp_nid = 0x02,
11061 .dig_out_nid = ALC262_DIGOUT_NID,
11062 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11063 .channel_mode = alc262_modes,
11064 .input_mux = &alc262_capture_source,
11065 .unsol_event = alc262_tyan_unsol_event,
11066 .init_hook = alc262_tyan_automute,
11067 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011068};
11069
11070static int patch_alc262(struct hda_codec *codec)
11071{
11072 struct alc_spec *spec;
11073 int board_config;
11074 int err;
11075
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011076 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011077 if (spec == NULL)
11078 return -ENOMEM;
11079
11080 codec->spec = spec;
11081#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011082 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11083 * under-run
11084 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011085 {
11086 int tmp;
11087 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11088 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11089 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11090 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11091 }
11092#endif
11093
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011094 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11095
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011096 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11097 alc262_models,
11098 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011099
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011100 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011101 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11102 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011103 board_config = ALC262_AUTO;
11104 }
11105
11106 if (board_config == ALC262_AUTO) {
11107 /* automatic parse from the BIOS config */
11108 err = alc262_parse_auto_config(codec);
11109 if (err < 0) {
11110 alc_free(codec);
11111 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011112 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011113 printk(KERN_INFO
11114 "hda_codec: Cannot set up configuration "
11115 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011116 board_config = ALC262_BASIC;
11117 }
11118 }
11119
Takashi Iwai07eba612009-02-19 08:06:35 +010011120 if (!spec->no_analog) {
11121 err = snd_hda_attach_beep_device(codec, 0x1);
11122 if (err < 0) {
11123 alc_free(codec);
11124 return err;
11125 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011126 }
11127
Kailang Yangdf694da2005-12-05 19:42:22 +010011128 if (board_config != ALC262_AUTO)
11129 setup_preset(spec, &alc262_presets[board_config]);
11130
11131 spec->stream_name_analog = "ALC262 Analog";
11132 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11133 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011134
Kailang Yangdf694da2005-12-05 19:42:22 +010011135 spec->stream_name_digital = "ALC262 Digital";
11136 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11137 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11138
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011139 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011140 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011141 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011142 unsigned int wcap = get_wcaps(codec, 0x07);
11143
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011144 /* get type */
11145 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011146 if (wcap != AC_WID_AUD_IN) {
11147 spec->adc_nids = alc262_adc_nids_alt;
11148 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011149 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011150 } else {
11151 spec->adc_nids = alc262_adc_nids;
11152 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011153 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011154 }
11155 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011156 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011157 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011158 if (!spec->no_analog)
11159 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011160
Takashi Iwai2134ea42008-01-10 16:53:55 +010011161 spec->vmaster_nid = 0x0c;
11162
Kailang Yangdf694da2005-12-05 19:42:22 +010011163 codec->patch_ops = alc_patch_ops;
11164 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011165 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011166#ifdef CONFIG_SND_HDA_POWER_SAVE
11167 if (!spec->loopback.amplist)
11168 spec->loopback.amplist = alc262_loopbacks;
11169#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011170 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011171
Kailang Yangdf694da2005-12-05 19:42:22 +010011172 return 0;
11173}
11174
Kailang Yangdf694da2005-12-05 19:42:22 +010011175/*
Kailang Yanga361d842007-06-05 12:30:55 +020011176 * ALC268 channel source setting (2 channel)
11177 */
11178#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11179#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011180
Kailang Yanga361d842007-06-05 12:30:55 +020011181static hda_nid_t alc268_dac_nids[2] = {
11182 /* front, hp */
11183 0x02, 0x03
11184};
11185
11186static hda_nid_t alc268_adc_nids[2] = {
11187 /* ADC0-1 */
11188 0x08, 0x07
11189};
11190
11191static hda_nid_t alc268_adc_nids_alt[1] = {
11192 /* ADC0 */
11193 0x08
11194};
11195
Takashi Iwaie1406342008-02-11 18:32:32 +010011196static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11197
Kailang Yanga361d842007-06-05 12:30:55 +020011198static struct snd_kcontrol_new alc268_base_mixer[] = {
11199 /* output mixer control */
11200 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11201 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11202 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11203 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011204 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11205 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11206 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011207 { }
11208};
11209
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011210/* bind Beep switches of both NID 0x0f and 0x10 */
11211static struct hda_bind_ctls alc268_bind_beep_sw = {
11212 .ops = &snd_hda_bind_sw,
11213 .values = {
11214 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11215 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11216 0
11217 },
11218};
11219
11220static struct snd_kcontrol_new alc268_beep_mixer[] = {
11221 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11222 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11223 { }
11224};
11225
Kailang Yangd1a991a2007-08-15 16:21:59 +020011226static struct hda_verb alc268_eapd_verbs[] = {
11227 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11228 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11229 { }
11230};
11231
Takashi Iwaid2738092007-08-16 14:59:45 +020011232/* Toshiba specific */
11233#define alc268_toshiba_automute alc262_hippo_automute
11234
11235static struct hda_verb alc268_toshiba_verbs[] = {
11236 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11237 { } /* end */
11238};
11239
Kailang Yang8ef355d2008-08-26 13:10:22 +020011240static struct hda_input_mux alc268_acer_lc_capture_source = {
11241 .num_items = 2,
11242 .items = {
11243 { "i-Mic", 0x6 },
11244 { "E-Mic", 0x0 },
11245 },
11246};
11247
Takashi Iwaid2738092007-08-16 14:59:45 +020011248/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011249/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011250static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11251 .ops = &snd_hda_bind_vol,
11252 .values = {
11253 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11254 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11255 0
11256 },
11257};
11258
Takashi Iwai889c4392007-08-23 18:56:52 +020011259/* mute/unmute internal speaker according to the hp jack and mute state */
11260static void alc268_acer_automute(struct hda_codec *codec, int force)
11261{
11262 struct alc_spec *spec = codec->spec;
11263 unsigned int mute;
11264
11265 if (force || !spec->sense_updated) {
11266 unsigned int present;
11267 present = snd_hda_codec_read(codec, 0x14, 0,
11268 AC_VERB_GET_PIN_SENSE, 0);
11269 spec->jack_present = (present & 0x80000000) != 0;
11270 spec->sense_updated = 1;
11271 }
11272 if (spec->jack_present)
11273 mute = HDA_AMP_MUTE; /* mute internal speaker */
11274 else /* unmute internal speaker if necessary */
11275 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11276 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11277 HDA_AMP_MUTE, mute);
11278}
11279
11280
11281/* bind hp and internal speaker mute (with plug check) */
11282static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11283 struct snd_ctl_elem_value *ucontrol)
11284{
11285 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11286 long *valp = ucontrol->value.integer.value;
11287 int change;
11288
11289 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11290 HDA_AMP_MUTE,
11291 valp[0] ? 0 : HDA_AMP_MUTE);
11292 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11293 HDA_AMP_MUTE,
11294 valp[1] ? 0 : HDA_AMP_MUTE);
11295 if (change)
11296 alc268_acer_automute(codec, 0);
11297 return change;
11298}
Takashi Iwaid2738092007-08-16 14:59:45 +020011299
Kailang Yang8ef355d2008-08-26 13:10:22 +020011300static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11301 /* output mixer control */
11302 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11303 {
11304 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11305 .name = "Master Playback Switch",
11306 .info = snd_hda_mixer_amp_switch_info,
11307 .get = snd_hda_mixer_amp_switch_get,
11308 .put = alc268_acer_master_sw_put,
11309 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11310 },
11311 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11312 { }
11313};
11314
Takashi Iwaid2738092007-08-16 14:59:45 +020011315static struct snd_kcontrol_new alc268_acer_mixer[] = {
11316 /* output mixer control */
11317 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11318 {
11319 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11320 .name = "Master Playback Switch",
11321 .info = snd_hda_mixer_amp_switch_info,
11322 .get = snd_hda_mixer_amp_switch_get,
11323 .put = alc268_acer_master_sw_put,
11324 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11325 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011326 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11327 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11328 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011329 { }
11330};
11331
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011332static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11333 /* output mixer control */
11334 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11335 {
11336 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11337 .name = "Master Playback Switch",
11338 .info = snd_hda_mixer_amp_switch_info,
11339 .get = snd_hda_mixer_amp_switch_get,
11340 .put = alc268_acer_master_sw_put,
11341 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11342 },
11343 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11344 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11345 { }
11346};
11347
Kailang Yang8ef355d2008-08-26 13:10:22 +020011348static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11349 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11350 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11351 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11352 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11353 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11354 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11355 { }
11356};
11357
Takashi Iwaid2738092007-08-16 14:59:45 +020011358static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011359 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11360 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11362 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011363 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11364 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011365 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11366 { }
11367};
11368
11369/* unsolicited event for HP jack sensing */
11370static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11371 unsigned int res)
11372{
Takashi Iwai889c4392007-08-23 18:56:52 +020011373 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011374 return;
11375 alc268_toshiba_automute(codec);
11376}
11377
11378static void alc268_acer_unsol_event(struct hda_codec *codec,
11379 unsigned int res)
11380{
Takashi Iwai889c4392007-08-23 18:56:52 +020011381 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011382 return;
11383 alc268_acer_automute(codec, 1);
11384}
11385
Takashi Iwai889c4392007-08-23 18:56:52 +020011386static void alc268_acer_init_hook(struct hda_codec *codec)
11387{
11388 alc268_acer_automute(codec, 1);
11389}
11390
Kailang Yang8ef355d2008-08-26 13:10:22 +020011391/* toggle speaker-output according to the hp-jack state */
11392static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11393{
11394 unsigned int present;
11395 unsigned char bits;
11396
11397 present = snd_hda_codec_read(codec, 0x15, 0,
11398 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11399 bits = present ? AMP_IN_MUTE(0) : 0;
11400 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11401 AMP_IN_MUTE(0), bits);
11402 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11403 AMP_IN_MUTE(0), bits);
11404}
11405
11406
11407static void alc268_acer_mic_automute(struct hda_codec *codec)
11408{
11409 unsigned int present;
11410
11411 present = snd_hda_codec_read(codec, 0x18, 0,
11412 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11413 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11414 present ? 0x0 : 0x6);
11415}
11416
11417static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11418 unsigned int res)
11419{
11420 if ((res >> 26) == ALC880_HP_EVENT)
11421 alc268_aspire_one_speaker_automute(codec);
11422 if ((res >> 26) == ALC880_MIC_EVENT)
11423 alc268_acer_mic_automute(codec);
11424}
11425
11426static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11427{
11428 alc268_aspire_one_speaker_automute(codec);
11429 alc268_acer_mic_automute(codec);
11430}
11431
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011432static struct snd_kcontrol_new alc268_dell_mixer[] = {
11433 /* output mixer control */
11434 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11435 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11436 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11437 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11438 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11439 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11440 { }
11441};
11442
11443static struct hda_verb alc268_dell_verbs[] = {
11444 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11446 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11447 { }
11448};
11449
11450/* mute/unmute internal speaker according to the hp jack and mute state */
11451static void alc268_dell_automute(struct hda_codec *codec)
11452{
11453 unsigned int present;
11454 unsigned int mute;
11455
11456 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11457 if (present & 0x80000000)
11458 mute = HDA_AMP_MUTE;
11459 else
11460 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11461 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11462 HDA_AMP_MUTE, mute);
11463}
11464
11465static void alc268_dell_unsol_event(struct hda_codec *codec,
11466 unsigned int res)
11467{
11468 if ((res >> 26) != ALC880_HP_EVENT)
11469 return;
11470 alc268_dell_automute(codec);
11471}
11472
11473#define alc268_dell_init_hook alc268_dell_automute
11474
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011475static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11476 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11477 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11478 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11479 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11480 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11481 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11482 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11483 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11484 { }
11485};
11486
11487static struct hda_verb alc267_quanta_il1_verbs[] = {
11488 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11489 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11490 { }
11491};
11492
11493static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11494{
11495 unsigned int present;
11496
11497 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11498 & AC_PINSENSE_PRESENCE;
11499 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11500 present ? 0 : PIN_OUT);
11501}
11502
11503static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11504{
11505 unsigned int present;
11506
11507 present = snd_hda_codec_read(codec, 0x18, 0,
11508 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11509 snd_hda_codec_write(codec, 0x23, 0,
11510 AC_VERB_SET_CONNECT_SEL,
11511 present ? 0x00 : 0x01);
11512}
11513
11514static void alc267_quanta_il1_automute(struct hda_codec *codec)
11515{
11516 alc267_quanta_il1_hp_automute(codec);
11517 alc267_quanta_il1_mic_automute(codec);
11518}
11519
11520static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11521 unsigned int res)
11522{
11523 switch (res >> 26) {
11524 case ALC880_HP_EVENT:
11525 alc267_quanta_il1_hp_automute(codec);
11526 break;
11527 case ALC880_MIC_EVENT:
11528 alc267_quanta_il1_mic_automute(codec);
11529 break;
11530 }
11531}
11532
Kailang Yanga361d842007-06-05 12:30:55 +020011533/*
11534 * generic initialization of ADC, input mixers and output mixers
11535 */
11536static struct hda_verb alc268_base_init_verbs[] = {
11537 /* Unmute DAC0-1 and set vol = 0 */
11538 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011539 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011540
11541 /*
11542 * Set up output mixers (0x0c - 0x0e)
11543 */
11544 /* set vol=0 to output mixers */
11545 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011546 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11547
11548 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11549 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11550
11551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11552 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11553 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11554 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11555 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11556 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11557 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11558 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11559
11560 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11561 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11562 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11563 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011564 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011565
11566 /* set PCBEEP vol = 0, mute connections */
11567 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11568 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11569 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011570
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011571 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011572
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011573 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11575 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11576 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011577
Kailang Yanga361d842007-06-05 12:30:55 +020011578 { }
11579};
11580
11581/*
11582 * generic initialization of ADC, input mixers and output mixers
11583 */
11584static struct hda_verb alc268_volume_init_verbs[] = {
11585 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011586 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11587 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011588
11589 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11590 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11591 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11592 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11593 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11594
Kailang Yanga361d842007-06-05 12:30:55 +020011595 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011596 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11597 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11598
11599 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011600 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011601
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011602 /* set PCBEEP vol = 0, mute connections */
11603 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11604 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11605 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011606
11607 { }
11608};
11609
Kailang Yanga361d842007-06-05 12:30:55 +020011610static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11611 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11612 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11613 {
11614 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11615 /* The multiple "Capture Source" controls confuse alsamixer
11616 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011617 */
11618 /* .name = "Capture Source", */
11619 .name = "Input Source",
11620 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011621 .info = alc_mux_enum_info,
11622 .get = alc_mux_enum_get,
11623 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011624 },
11625 { } /* end */
11626};
11627
11628static struct snd_kcontrol_new alc268_capture_mixer[] = {
11629 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11630 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11631 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11632 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11633 {
11634 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11635 /* The multiple "Capture Source" controls confuse alsamixer
11636 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011637 */
11638 /* .name = "Capture Source", */
11639 .name = "Input Source",
11640 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011641 .info = alc_mux_enum_info,
11642 .get = alc_mux_enum_get,
11643 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011644 },
11645 { } /* end */
11646};
11647
11648static struct hda_input_mux alc268_capture_source = {
11649 .num_items = 4,
11650 .items = {
11651 { "Mic", 0x0 },
11652 { "Front Mic", 0x1 },
11653 { "Line", 0x2 },
11654 { "CD", 0x3 },
11655 },
11656};
11657
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011658static struct hda_input_mux alc268_acer_capture_source = {
11659 .num_items = 3,
11660 .items = {
11661 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011662 { "Internal Mic", 0x1 },
11663 { "Line", 0x2 },
11664 },
11665};
11666
11667static struct hda_input_mux alc268_acer_dmic_capture_source = {
11668 .num_items = 3,
11669 .items = {
11670 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011671 { "Internal Mic", 0x6 },
11672 { "Line", 0x2 },
11673 },
11674};
11675
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011676#ifdef CONFIG_SND_DEBUG
11677static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011678 /* Volume widgets */
11679 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11680 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11681 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11682 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11683 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11684 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11685 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11686 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11687 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11688 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11689 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11690 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11691 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011692 /* The below appears problematic on some hardwares */
11693 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011694 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11695 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11696 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11697 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11698
11699 /* Modes for retasking pin widgets */
11700 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11701 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11702 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11703 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11704
11705 /* Controls for GPIO pins, assuming they are configured as outputs */
11706 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11707 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11708 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11709 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11710
11711 /* Switches to allow the digital SPDIF output pin to be enabled.
11712 * The ALC268 does not have an SPDIF input.
11713 */
11714 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11715
11716 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11717 * this output to turn on an external amplifier.
11718 */
11719 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11720 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11721
11722 { } /* end */
11723};
11724#endif
11725
Kailang Yanga361d842007-06-05 12:30:55 +020011726/* create input playback/capture controls for the given pin */
11727static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11728 const char *ctlname, int idx)
11729{
11730 char name[32];
11731 int err;
11732
11733 sprintf(name, "%s Playback Volume", ctlname);
11734 if (nid == 0x14) {
11735 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11736 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11737 HDA_OUTPUT));
11738 if (err < 0)
11739 return err;
11740 } else if (nid == 0x15) {
11741 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11742 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11743 HDA_OUTPUT));
11744 if (err < 0)
11745 return err;
11746 } else
11747 return -1;
11748 sprintf(name, "%s Playback Switch", ctlname);
11749 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11750 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11751 if (err < 0)
11752 return err;
11753 return 0;
11754}
11755
11756/* add playback controls from the parsed DAC table */
11757static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11758 const struct auto_pin_cfg *cfg)
11759{
11760 hda_nid_t nid;
11761 int err;
11762
11763 spec->multiout.num_dacs = 2; /* only use one dac */
11764 spec->multiout.dac_nids = spec->private_dac_nids;
11765 spec->multiout.dac_nids[0] = 2;
11766 spec->multiout.dac_nids[1] = 3;
11767
11768 nid = cfg->line_out_pins[0];
11769 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011770 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011771
11772 nid = cfg->speaker_pins[0];
11773 if (nid == 0x1d) {
11774 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11775 "Speaker Playback Volume",
11776 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11777 if (err < 0)
11778 return err;
11779 }
11780 nid = cfg->hp_pins[0];
11781 if (nid)
11782 alc268_new_analog_output(spec, nid, "Headphone", 0);
11783
11784 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11785 if (nid == 0x16) {
11786 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11787 "Mono Playback Switch",
11788 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11789 if (err < 0)
11790 return err;
11791 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011792 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011793}
11794
11795/* create playback/capture controls for input pins */
11796static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11797 const struct auto_pin_cfg *cfg)
11798{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011799 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011800 int i, idx1;
11801
11802 for (i = 0; i < AUTO_PIN_LAST; i++) {
11803 switch(cfg->input_pins[i]) {
11804 case 0x18:
11805 idx1 = 0; /* Mic 1 */
11806 break;
11807 case 0x19:
11808 idx1 = 1; /* Mic 2 */
11809 break;
11810 case 0x1a:
11811 idx1 = 2; /* Line In */
11812 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011813 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011814 idx1 = 3; /* CD */
11815 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011816 case 0x12:
11817 case 0x13:
11818 idx1 = 6; /* digital mics */
11819 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011820 default:
11821 continue;
11822 }
11823 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11824 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011825 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011826 }
11827 return 0;
11828}
11829
11830static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11831{
11832 struct alc_spec *spec = codec->spec;
11833 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11834 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11835 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11836 unsigned int dac_vol1, dac_vol2;
11837
11838 if (speaker_nid) {
11839 snd_hda_codec_write(codec, speaker_nid, 0,
11840 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11841 snd_hda_codec_write(codec, 0x0f, 0,
11842 AC_VERB_SET_AMP_GAIN_MUTE,
11843 AMP_IN_UNMUTE(1));
11844 snd_hda_codec_write(codec, 0x10, 0,
11845 AC_VERB_SET_AMP_GAIN_MUTE,
11846 AMP_IN_UNMUTE(1));
11847 } else {
11848 snd_hda_codec_write(codec, 0x0f, 0,
11849 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11850 snd_hda_codec_write(codec, 0x10, 0,
11851 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11852 }
11853
11854 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011855 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011856 dac_vol2 = AMP_OUT_ZERO;
11857 else if (line_nid == 0x15)
11858 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011859 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011860 dac_vol2 = AMP_OUT_ZERO;
11861 else if (hp_nid == 0x15)
11862 dac_vol1 = AMP_OUT_ZERO;
11863 if (line_nid != 0x16 || hp_nid != 0x16 ||
11864 spec->autocfg.line_out_pins[1] != 0x16 ||
11865 spec->autocfg.line_out_pins[2] != 0x16)
11866 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11867
11868 snd_hda_codec_write(codec, 0x02, 0,
11869 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11870 snd_hda_codec_write(codec, 0x03, 0,
11871 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11872}
11873
11874/* pcm configuration: identiacal with ALC880 */
11875#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11876#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011877#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011878#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11879
11880/*
11881 * BIOS auto configuration
11882 */
11883static int alc268_parse_auto_config(struct hda_codec *codec)
11884{
11885 struct alc_spec *spec = codec->spec;
11886 int err;
11887 static hda_nid_t alc268_ignore[] = { 0 };
11888
11889 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11890 alc268_ignore);
11891 if (err < 0)
11892 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011893 if (!spec->autocfg.line_outs) {
11894 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11895 spec->multiout.max_channels = 2;
11896 spec->no_analog = 1;
11897 goto dig_only;
11898 }
Kailang Yanga361d842007-06-05 12:30:55 +020011899 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011900 }
Kailang Yanga361d842007-06-05 12:30:55 +020011901 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11902 if (err < 0)
11903 return err;
11904 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11905 if (err < 0)
11906 return err;
11907
11908 spec->multiout.max_channels = 2;
11909
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011910 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020011911 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011912 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020011913 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011914 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11915 }
Takashi Iwai603c4012008-07-30 15:01:44 +020011916 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011917 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011918
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011919 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011920 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011921
Takashi Iwaid88897e2008-10-31 15:01:37 +010011922 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011923 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011924 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011925
Takashi Iwai776e1842007-08-29 15:07:11 +020011926 err = alc_auto_add_mic_boost(codec);
11927 if (err < 0)
11928 return err;
11929
Kailang Yanga361d842007-06-05 12:30:55 +020011930 return 1;
11931}
11932
11933#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11934#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11935#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11936
11937/* init callback for auto-configuration model -- overriding the default init */
11938static void alc268_auto_init(struct hda_codec *codec)
11939{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011940 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011941 alc268_auto_init_multi_out(codec);
11942 alc268_auto_init_hp_out(codec);
11943 alc268_auto_init_mono_speaker_out(codec);
11944 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011945 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011946 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011947}
11948
11949/*
11950 * configuration and preset
11951 */
11952static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011953 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011954 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011955 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011956 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011957 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011958 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011959 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011960 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011961#ifdef CONFIG_SND_DEBUG
11962 [ALC268_TEST] = "test",
11963#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011964 [ALC268_AUTO] = "auto",
11965};
11966
11967static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011968 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011969 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011970 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011971 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011972 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011973 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11974 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011975 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011976 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011977 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011978 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011979 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011980 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011981 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011982 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011983 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011984 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011985 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011986 {}
11987};
11988
11989static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011990 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010011991 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011992 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11993 alc267_quanta_il1_verbs },
11994 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11995 .dac_nids = alc268_dac_nids,
11996 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11997 .adc_nids = alc268_adc_nids_alt,
11998 .hp_nid = 0x03,
11999 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12000 .channel_mode = alc268_modes,
12001 .input_mux = &alc268_capture_source,
12002 .unsol_event = alc267_quanta_il1_unsol_event,
12003 .init_hook = alc267_quanta_il1_automute,
12004 },
Kailang Yanga361d842007-06-05 12:30:55 +020012005 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012006 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12007 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012008 .init_verbs = { alc268_base_init_verbs },
12009 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12010 .dac_nids = alc268_dac_nids,
12011 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12012 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012013 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012014 .hp_nid = 0x03,
12015 .dig_out_nid = ALC268_DIGOUT_NID,
12016 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12017 .channel_mode = alc268_modes,
12018 .input_mux = &alc268_capture_source,
12019 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012020 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012021 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12022 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012023 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12024 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012025 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12026 .dac_nids = alc268_dac_nids,
12027 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12028 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012029 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012030 .hp_nid = 0x03,
12031 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12032 .channel_mode = alc268_modes,
12033 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012034 .unsol_event = alc268_toshiba_unsol_event,
12035 .init_hook = alc268_toshiba_automute,
12036 },
12037 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012038 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12039 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012040 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12041 alc268_acer_verbs },
12042 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12043 .dac_nids = alc268_dac_nids,
12044 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12045 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012046 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012047 .hp_nid = 0x02,
12048 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12049 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012050 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012051 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012052 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012053 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012054 [ALC268_ACER_DMIC] = {
12055 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12056 alc268_beep_mixer },
12057 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12058 alc268_acer_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 .capsrc_nids = alc268_capsrc_nids,
12064 .hp_nid = 0x02,
12065 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12066 .channel_mode = alc268_modes,
12067 .input_mux = &alc268_acer_dmic_capture_source,
12068 .unsol_event = alc268_acer_unsol_event,
12069 .init_hook = alc268_acer_init_hook,
12070 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012071 [ALC268_ACER_ASPIRE_ONE] = {
12072 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012073 alc268_beep_mixer,
12074 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012075 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12076 alc268_acer_aspire_one_verbs },
12077 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12078 .dac_nids = alc268_dac_nids,
12079 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12080 .adc_nids = alc268_adc_nids_alt,
12081 .capsrc_nids = alc268_capsrc_nids,
12082 .hp_nid = 0x03,
12083 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12084 .channel_mode = alc268_modes,
12085 .input_mux = &alc268_acer_lc_capture_source,
12086 .unsol_event = alc268_acer_lc_unsol_event,
12087 .init_hook = alc268_acer_lc_init_hook,
12088 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012089 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012090 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012091 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12092 alc268_dell_verbs },
12093 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12094 .dac_nids = alc268_dac_nids,
12095 .hp_nid = 0x02,
12096 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12097 .channel_mode = alc268_modes,
12098 .unsol_event = alc268_dell_unsol_event,
12099 .init_hook = alc268_dell_init_hook,
12100 .input_mux = &alc268_capture_source,
12101 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012102 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012103 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12104 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012105 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12106 alc268_toshiba_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,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012112 .hp_nid = 0x03,
12113 .dig_out_nid = ALC268_DIGOUT_NID,
12114 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12115 .channel_mode = alc268_modes,
12116 .input_mux = &alc268_capture_source,
12117 .unsol_event = alc268_toshiba_unsol_event,
12118 .init_hook = alc268_toshiba_automute
12119 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012120#ifdef CONFIG_SND_DEBUG
12121 [ALC268_TEST] = {
12122 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12123 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12124 alc268_volume_init_verbs },
12125 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12126 .dac_nids = alc268_dac_nids,
12127 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12128 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012129 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012130 .hp_nid = 0x03,
12131 .dig_out_nid = ALC268_DIGOUT_NID,
12132 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12133 .channel_mode = alc268_modes,
12134 .input_mux = &alc268_capture_source,
12135 },
12136#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012137};
12138
12139static int patch_alc268(struct hda_codec *codec)
12140{
12141 struct alc_spec *spec;
12142 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012143 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012144
12145 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12146 if (spec == NULL)
12147 return -ENOMEM;
12148
12149 codec->spec = spec;
12150
12151 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12152 alc268_models,
12153 alc268_cfg_tbl);
12154
12155 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12156 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12157 "trying auto-probe from BIOS...\n");
12158 board_config = ALC268_AUTO;
12159 }
12160
12161 if (board_config == ALC268_AUTO) {
12162 /* automatic parse from the BIOS config */
12163 err = alc268_parse_auto_config(codec);
12164 if (err < 0) {
12165 alc_free(codec);
12166 return err;
12167 } else if (!err) {
12168 printk(KERN_INFO
12169 "hda_codec: Cannot set up configuration "
12170 "from BIOS. Using base mode...\n");
12171 board_config = ALC268_3ST;
12172 }
12173 }
12174
12175 if (board_config != ALC268_AUTO)
12176 setup_preset(spec, &alc268_presets[board_config]);
12177
Kailang Yang2f893282008-05-27 12:14:47 +020012178 if (codec->vendor_id == 0x10ec0267) {
12179 spec->stream_name_analog = "ALC267 Analog";
12180 spec->stream_name_digital = "ALC267 Digital";
12181 } else {
12182 spec->stream_name_analog = "ALC268 Analog";
12183 spec->stream_name_digital = "ALC268 Digital";
12184 }
12185
Kailang Yanga361d842007-06-05 12:30:55 +020012186 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12187 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012188 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012189
Kailang Yanga361d842007-06-05 12:30:55 +020012190 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12191
Takashi Iwai22971e32009-02-10 11:56:44 +010012192 has_beep = 0;
12193 for (i = 0; i < spec->num_mixers; i++) {
12194 if (spec->mixers[i] == alc268_beep_mixer) {
12195 has_beep = 1;
12196 break;
12197 }
12198 }
12199
12200 if (has_beep) {
12201 err = snd_hda_attach_beep_device(codec, 0x1);
12202 if (err < 0) {
12203 alc_free(codec);
12204 return err;
12205 }
12206 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12207 /* override the amp caps for beep generator */
12208 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012209 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12210 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12211 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12212 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012213 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012214
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012215 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012216 /* check whether NID 0x07 is valid */
12217 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012218 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012219
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012220 /* get type */
12221 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012222 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012223 spec->adc_nids = alc268_adc_nids_alt;
12224 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012225 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012226 } else {
12227 spec->adc_nids = alc268_adc_nids;
12228 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012229 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012230 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012231 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012232 /* set default input source */
12233 for (i = 0; i < spec->num_adc_nids; i++)
12234 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12235 0, AC_VERB_SET_CONNECT_SEL,
12236 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012237 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012238
12239 spec->vmaster_nid = 0x02;
12240
Kailang Yanga361d842007-06-05 12:30:55 +020012241 codec->patch_ops = alc_patch_ops;
12242 if (board_config == ALC268_AUTO)
12243 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012244
Takashi Iwaidaead532008-11-28 12:55:36 +010012245 codec->proc_widget_hook = print_realtek_coef;
12246
Kailang Yanga361d842007-06-05 12:30:55 +020012247 return 0;
12248}
12249
12250/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012251 * ALC269 channel source setting (2 channel)
12252 */
12253#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12254
12255#define alc269_dac_nids alc260_dac_nids
12256
12257static hda_nid_t alc269_adc_nids[1] = {
12258 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012259 0x08,
12260};
12261
Takashi Iwaie01bf502008-08-21 16:25:07 +020012262static hda_nid_t alc269_capsrc_nids[1] = {
12263 0x23,
12264};
12265
12266/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12267 * not a mux!
12268 */
12269
Kailang Yangf53281e2008-07-18 12:36:43 +020012270static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12271 .num_items = 2,
12272 .items = {
12273 { "i-Mic", 0x5 },
12274 { "e-Mic", 0x0 },
12275 },
12276};
12277
12278static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12279 .num_items = 2,
12280 .items = {
12281 { "i-Mic", 0x1 },
12282 { "e-Mic", 0x0 },
12283 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012284};
12285
12286#define alc269_modes alc260_modes
12287#define alc269_capture_source alc880_lg_lw_capture_source
12288
12289static struct snd_kcontrol_new alc269_base_mixer[] = {
12290 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12291 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12292 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12293 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12296 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12297 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12298 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12299 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12300 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12301 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12302 { } /* end */
12303};
12304
Kailang Yang60db6b52008-08-26 13:13:00 +020012305static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12306 /* output mixer control */
12307 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12308 {
12309 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12310 .name = "Master Playback Switch",
12311 .info = snd_hda_mixer_amp_switch_info,
12312 .get = snd_hda_mixer_amp_switch_get,
12313 .put = alc268_acer_master_sw_put,
12314 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12315 },
12316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12318 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12319 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12320 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12321 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012322 { }
12323};
12324
Tony Vroon64154832008-11-06 15:08:49 +000012325static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12326 /* output mixer control */
12327 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12328 {
12329 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12330 .name = "Master Playback Switch",
12331 .info = snd_hda_mixer_amp_switch_info,
12332 .get = snd_hda_mixer_amp_switch_get,
12333 .put = alc268_acer_master_sw_put,
12334 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12335 },
12336 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12337 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12338 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12339 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12340 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12341 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12342 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12343 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12344 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012345 { }
12346};
12347
Kailang Yangf53281e2008-07-18 12:36:43 +020012348/* bind volumes of both NID 0x0c and 0x0d */
12349static struct hda_bind_ctls alc269_epc_bind_vol = {
12350 .ops = &snd_hda_bind_vol,
12351 .values = {
12352 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12353 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12354 0
12355 },
12356};
12357
12358static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12359 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12360 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12361 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12362 { } /* end */
12363};
12364
Kailang Yangf6a92242007-12-13 16:52:54 +010012365/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012366static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12367 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12368 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012369 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12370 { } /* end */
12371};
12372
12373/* FSC amilo */
12374static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12375 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12376 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12377 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012378 { } /* end */
12379};
12380
Kailang Yang60db6b52008-08-26 13:13:00 +020012381static struct hda_verb alc269_quanta_fl1_verbs[] = {
12382 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12383 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12384 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12385 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12386 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12387 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12388 { }
12389};
12390
Tony Vroon64154832008-11-06 15:08:49 +000012391static struct hda_verb alc269_lifebook_verbs[] = {
12392 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12393 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12394 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12395 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12396 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12397 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12398 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12399 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12400 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12401 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12402 { }
12403};
12404
Kailang Yang60db6b52008-08-26 13:13:00 +020012405/* toggle speaker-output according to the hp-jack state */
12406static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12407{
12408 unsigned int present;
12409 unsigned char bits;
12410
12411 present = snd_hda_codec_read(codec, 0x15, 0,
12412 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12413 bits = present ? AMP_IN_MUTE(0) : 0;
12414 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12415 AMP_IN_MUTE(0), bits);
12416 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12417 AMP_IN_MUTE(0), bits);
12418
12419 snd_hda_codec_write(codec, 0x20, 0,
12420 AC_VERB_SET_COEF_INDEX, 0x0c);
12421 snd_hda_codec_write(codec, 0x20, 0,
12422 AC_VERB_SET_PROC_COEF, 0x680);
12423
12424 snd_hda_codec_write(codec, 0x20, 0,
12425 AC_VERB_SET_COEF_INDEX, 0x0c);
12426 snd_hda_codec_write(codec, 0x20, 0,
12427 AC_VERB_SET_PROC_COEF, 0x480);
12428}
12429
Tony Vroon64154832008-11-06 15:08:49 +000012430/* toggle speaker-output according to the hp-jacks state */
12431static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12432{
12433 unsigned int present;
12434 unsigned char bits;
12435
12436 /* Check laptop headphone socket */
12437 present = snd_hda_codec_read(codec, 0x15, 0,
12438 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12439
12440 /* Check port replicator headphone socket */
12441 present |= snd_hda_codec_read(codec, 0x1a, 0,
12442 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12443
12444 bits = present ? AMP_IN_MUTE(0) : 0;
12445 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12446 AMP_IN_MUTE(0), bits);
12447 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12448 AMP_IN_MUTE(0), bits);
12449
12450 snd_hda_codec_write(codec, 0x20, 0,
12451 AC_VERB_SET_COEF_INDEX, 0x0c);
12452 snd_hda_codec_write(codec, 0x20, 0,
12453 AC_VERB_SET_PROC_COEF, 0x680);
12454
12455 snd_hda_codec_write(codec, 0x20, 0,
12456 AC_VERB_SET_COEF_INDEX, 0x0c);
12457 snd_hda_codec_write(codec, 0x20, 0,
12458 AC_VERB_SET_PROC_COEF, 0x480);
12459}
12460
Kailang Yang60db6b52008-08-26 13:13:00 +020012461static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12462{
12463 unsigned int present;
12464
12465 present = snd_hda_codec_read(codec, 0x18, 0,
12466 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12467 snd_hda_codec_write(codec, 0x23, 0,
12468 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12469}
12470
Tony Vroon64154832008-11-06 15:08:49 +000012471static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12472{
12473 unsigned int present_laptop;
12474 unsigned int present_dock;
12475
12476 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12477 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12478
12479 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12480 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12481
12482 /* Laptop mic port overrides dock mic port, design decision */
12483 if (present_dock)
12484 snd_hda_codec_write(codec, 0x23, 0,
12485 AC_VERB_SET_CONNECT_SEL, 0x3);
12486 if (present_laptop)
12487 snd_hda_codec_write(codec, 0x23, 0,
12488 AC_VERB_SET_CONNECT_SEL, 0x0);
12489 if (!present_dock && !present_laptop)
12490 snd_hda_codec_write(codec, 0x23, 0,
12491 AC_VERB_SET_CONNECT_SEL, 0x1);
12492}
12493
Kailang Yang60db6b52008-08-26 13:13:00 +020012494static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12495 unsigned int res)
12496{
12497 if ((res >> 26) == ALC880_HP_EVENT)
12498 alc269_quanta_fl1_speaker_automute(codec);
12499 if ((res >> 26) == ALC880_MIC_EVENT)
12500 alc269_quanta_fl1_mic_automute(codec);
12501}
12502
Tony Vroon64154832008-11-06 15:08:49 +000012503static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12504 unsigned int res)
12505{
12506 if ((res >> 26) == ALC880_HP_EVENT)
12507 alc269_lifebook_speaker_automute(codec);
12508 if ((res >> 26) == ALC880_MIC_EVENT)
12509 alc269_lifebook_mic_autoswitch(codec);
12510}
12511
Kailang Yang60db6b52008-08-26 13:13:00 +020012512static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12513{
12514 alc269_quanta_fl1_speaker_automute(codec);
12515 alc269_quanta_fl1_mic_automute(codec);
12516}
12517
Tony Vroon64154832008-11-06 15:08:49 +000012518static void alc269_lifebook_init_hook(struct hda_codec *codec)
12519{
12520 alc269_lifebook_speaker_automute(codec);
12521 alc269_lifebook_mic_autoswitch(codec);
12522}
12523
Kailang Yang60db6b52008-08-26 13:13:00 +020012524static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12525 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12526 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12527 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12528 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12529 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12530 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12531 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12532 {}
12533};
12534
12535static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12536 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12537 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12538 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12539 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12540 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12541 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12542 {}
12543};
12544
12545/* toggle speaker-output according to the hp-jack state */
12546static void alc269_speaker_automute(struct hda_codec *codec)
12547{
12548 unsigned int present;
12549 unsigned char bits;
12550
12551 present = snd_hda_codec_read(codec, 0x15, 0,
12552 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12553 bits = present ? AMP_IN_MUTE(0) : 0;
12554 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12555 AMP_IN_MUTE(0), bits);
12556 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12557 AMP_IN_MUTE(0), bits);
12558}
12559
12560static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12561{
12562 unsigned int present;
12563
12564 present = snd_hda_codec_read(codec, 0x18, 0,
12565 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12566 snd_hda_codec_write(codec, 0x23, 0,
12567 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12568}
12569
12570static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12571{
12572 unsigned int present;
12573
12574 present = snd_hda_codec_read(codec, 0x18, 0,
12575 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12576 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12577 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12578 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12579 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12580}
12581
12582/* unsolicited event for HP jack sensing */
12583static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12584 unsigned int res)
12585{
12586 if ((res >> 26) == ALC880_HP_EVENT)
12587 alc269_speaker_automute(codec);
12588
12589 if ((res >> 26) == ALC880_MIC_EVENT)
12590 alc269_eeepc_dmic_automute(codec);
12591}
12592
12593static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12594{
12595 alc269_speaker_automute(codec);
12596 alc269_eeepc_dmic_automute(codec);
12597}
12598
12599/* unsolicited event for HP jack sensing */
12600static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12601 unsigned int res)
12602{
12603 if ((res >> 26) == ALC880_HP_EVENT)
12604 alc269_speaker_automute(codec);
12605
12606 if ((res >> 26) == ALC880_MIC_EVENT)
12607 alc269_eeepc_amic_automute(codec);
12608}
12609
12610static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12611{
12612 alc269_speaker_automute(codec);
12613 alc269_eeepc_amic_automute(codec);
12614}
12615
Kailang Yangf6a92242007-12-13 16:52:54 +010012616/*
12617 * generic initialization of ADC, input mixers and output mixers
12618 */
12619static struct hda_verb alc269_init_verbs[] = {
12620 /*
12621 * Unmute ADC0 and set the default input to mic-in
12622 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012623 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012624
12625 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12626 * analog-loopback mixer widget
12627 * Note: PASD motherboards uses the Line In 2 as the input for
12628 * front panel mic (mic 2)
12629 */
12630 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12631 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12632 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12633 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12634 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12635 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12636
12637 /*
12638 * Set up output mixers (0x0c - 0x0e)
12639 */
12640 /* set vol=0 to output mixers */
12641 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12642 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12643
12644 /* set up input amps for analog loopback */
12645 /* Amp Indices: DAC = 0, mixer = 1 */
12646 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12647 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12648 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12649 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12650 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12651 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12652
12653 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12654 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12655 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12656 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12657 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12658 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12659 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12660
12661 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12664 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12665 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12666 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12667 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12668
12669 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12670 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12671
12672 /* FIXME: use matrix-type input source selection */
12673 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12674 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012675 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12676 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012677 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12678 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12679
12680 /* set EAPD */
12681 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12682 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12683 { }
12684};
12685
12686/* add playback controls from the parsed DAC table */
12687static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12688 const struct auto_pin_cfg *cfg)
12689{
12690 hda_nid_t nid;
12691 int err;
12692
12693 spec->multiout.num_dacs = 1; /* only use one dac */
12694 spec->multiout.dac_nids = spec->private_dac_nids;
12695 spec->multiout.dac_nids[0] = 2;
12696
12697 nid = cfg->line_out_pins[0];
12698 if (nid) {
12699 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12700 "Front Playback Volume",
12701 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12702 if (err < 0)
12703 return err;
12704 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12705 "Front Playback Switch",
12706 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12707 if (err < 0)
12708 return err;
12709 }
12710
12711 nid = cfg->speaker_pins[0];
12712 if (nid) {
12713 if (!cfg->line_out_pins[0]) {
12714 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12715 "Speaker Playback Volume",
12716 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12717 HDA_OUTPUT));
12718 if (err < 0)
12719 return err;
12720 }
12721 if (nid == 0x16) {
12722 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12723 "Speaker Playback Switch",
12724 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12725 HDA_OUTPUT));
12726 if (err < 0)
12727 return err;
12728 } else {
12729 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12730 "Speaker Playback Switch",
12731 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12732 HDA_OUTPUT));
12733 if (err < 0)
12734 return err;
12735 }
12736 }
12737 nid = cfg->hp_pins[0];
12738 if (nid) {
12739 /* spec->multiout.hp_nid = 2; */
12740 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12741 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12742 "Headphone Playback Volume",
12743 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12744 HDA_OUTPUT));
12745 if (err < 0)
12746 return err;
12747 }
12748 if (nid == 0x16) {
12749 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12750 "Headphone Playback Switch",
12751 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12752 HDA_OUTPUT));
12753 if (err < 0)
12754 return err;
12755 } else {
12756 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12757 "Headphone Playback Switch",
12758 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12759 HDA_OUTPUT));
12760 if (err < 0)
12761 return err;
12762 }
12763 }
12764 return 0;
12765}
12766
Takashi Iwaiee956e02008-10-31 17:16:31 +010012767static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12768 const struct auto_pin_cfg *cfg)
12769{
12770 int err;
12771
12772 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12773 if (err < 0)
12774 return err;
12775 /* digital-mic input pin is excluded in alc880_auto_create..()
12776 * because it's under 0x18
12777 */
12778 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12779 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012780 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012781 imux->items[imux->num_items].label = "Int Mic";
12782 imux->items[imux->num_items].index = 0x05;
12783 imux->num_items++;
12784 }
12785 return 0;
12786}
Kailang Yangf6a92242007-12-13 16:52:54 +010012787
12788#ifdef CONFIG_SND_HDA_POWER_SAVE
12789#define alc269_loopbacks alc880_loopbacks
12790#endif
12791
12792/* pcm configuration: identiacal with ALC880 */
12793#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12794#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12795#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12796#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12797
12798/*
12799 * BIOS auto configuration
12800 */
12801static int alc269_parse_auto_config(struct hda_codec *codec)
12802{
12803 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012804 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012805 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12806
12807 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12808 alc269_ignore);
12809 if (err < 0)
12810 return err;
12811
12812 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12813 if (err < 0)
12814 return err;
12815 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12816 if (err < 0)
12817 return err;
12818
12819 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12820
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012821 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012822 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12823
Takashi Iwai603c4012008-07-30 15:01:44 +020012824 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012825 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012826
Takashi Iwaid88897e2008-10-31 15:01:37 +010012827 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012828 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012829 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012830 /* set default input source */
12831 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12832 0, AC_VERB_SET_CONNECT_SEL,
12833 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012834
12835 err = alc_auto_add_mic_boost(codec);
12836 if (err < 0)
12837 return err;
12838
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012839 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012840 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012841
Kailang Yangf6a92242007-12-13 16:52:54 +010012842 return 1;
12843}
12844
12845#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12846#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12847#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12848
12849
12850/* init callback for auto-configuration model -- overriding the default init */
12851static void alc269_auto_init(struct hda_codec *codec)
12852{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012853 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012854 alc269_auto_init_multi_out(codec);
12855 alc269_auto_init_hp_out(codec);
12856 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012857 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012858 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012859}
12860
12861/*
12862 * configuration and preset
12863 */
12864static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012865 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012866 [ALC269_QUANTA_FL1] = "quanta",
12867 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012868 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012869 [ALC269_FUJITSU] = "fujitsu",
12870 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012871};
12872
12873static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012874 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012875 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12876 ALC269_ASUS_EEEPC_P703),
12877 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12878 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012879 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12880 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012881 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012882 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012883 {}
12884};
12885
12886static struct alc_config_preset alc269_presets[] = {
12887 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012888 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012889 .init_verbs = { alc269_init_verbs },
12890 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12891 .dac_nids = alc269_dac_nids,
12892 .hp_nid = 0x03,
12893 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12894 .channel_mode = alc269_modes,
12895 .input_mux = &alc269_capture_source,
12896 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012897 [ALC269_QUANTA_FL1] = {
12898 .mixers = { alc269_quanta_fl1_mixer },
12899 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12900 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12901 .dac_nids = alc269_dac_nids,
12902 .hp_nid = 0x03,
12903 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12904 .channel_mode = alc269_modes,
12905 .input_mux = &alc269_capture_source,
12906 .unsol_event = alc269_quanta_fl1_unsol_event,
12907 .init_hook = alc269_quanta_fl1_init_hook,
12908 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012909 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012910 .mixers = { alc269_eeepc_mixer },
12911 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012912 .init_verbs = { alc269_init_verbs,
12913 alc269_eeepc_amic_init_verbs },
12914 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12915 .dac_nids = alc269_dac_nids,
12916 .hp_nid = 0x03,
12917 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12918 .channel_mode = alc269_modes,
12919 .input_mux = &alc269_eeepc_amic_capture_source,
12920 .unsol_event = alc269_eeepc_amic_unsol_event,
12921 .init_hook = alc269_eeepc_amic_inithook,
12922 },
12923 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012924 .mixers = { alc269_eeepc_mixer },
12925 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012926 .init_verbs = { alc269_init_verbs,
12927 alc269_eeepc_dmic_init_verbs },
12928 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12929 .dac_nids = alc269_dac_nids,
12930 .hp_nid = 0x03,
12931 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12932 .channel_mode = alc269_modes,
12933 .input_mux = &alc269_eeepc_dmic_capture_source,
12934 .unsol_event = alc269_eeepc_dmic_unsol_event,
12935 .init_hook = alc269_eeepc_dmic_inithook,
12936 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012937 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012938 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012939 .cap_mixer = alc269_epc_capture_mixer,
12940 .init_verbs = { alc269_init_verbs,
12941 alc269_eeepc_dmic_init_verbs },
12942 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12943 .dac_nids = alc269_dac_nids,
12944 .hp_nid = 0x03,
12945 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12946 .channel_mode = alc269_modes,
12947 .input_mux = &alc269_eeepc_dmic_capture_source,
12948 .unsol_event = alc269_eeepc_dmic_unsol_event,
12949 .init_hook = alc269_eeepc_dmic_inithook,
12950 },
Tony Vroon64154832008-11-06 15:08:49 +000012951 [ALC269_LIFEBOOK] = {
12952 .mixers = { alc269_lifebook_mixer },
12953 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12954 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12955 .dac_nids = alc269_dac_nids,
12956 .hp_nid = 0x03,
12957 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12958 .channel_mode = alc269_modes,
12959 .input_mux = &alc269_capture_source,
12960 .unsol_event = alc269_lifebook_unsol_event,
12961 .init_hook = alc269_lifebook_init_hook,
12962 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012963};
12964
12965static int patch_alc269(struct hda_codec *codec)
12966{
12967 struct alc_spec *spec;
12968 int board_config;
12969 int err;
12970
12971 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12972 if (spec == NULL)
12973 return -ENOMEM;
12974
12975 codec->spec = spec;
12976
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012977 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12978
Kailang Yangf6a92242007-12-13 16:52:54 +010012979 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12980 alc269_models,
12981 alc269_cfg_tbl);
12982
12983 if (board_config < 0) {
12984 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12985 "trying auto-probe from BIOS...\n");
12986 board_config = ALC269_AUTO;
12987 }
12988
12989 if (board_config == ALC269_AUTO) {
12990 /* automatic parse from the BIOS config */
12991 err = alc269_parse_auto_config(codec);
12992 if (err < 0) {
12993 alc_free(codec);
12994 return err;
12995 } else if (!err) {
12996 printk(KERN_INFO
12997 "hda_codec: Cannot set up configuration "
12998 "from BIOS. Using base mode...\n");
12999 board_config = ALC269_BASIC;
13000 }
13001 }
13002
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013003 err = snd_hda_attach_beep_device(codec, 0x1);
13004 if (err < 0) {
13005 alc_free(codec);
13006 return err;
13007 }
13008
Kailang Yangf6a92242007-12-13 16:52:54 +010013009 if (board_config != ALC269_AUTO)
13010 setup_preset(spec, &alc269_presets[board_config]);
13011
13012 spec->stream_name_analog = "ALC269 Analog";
13013 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13014 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13015
13016 spec->stream_name_digital = "ALC269 Digital";
13017 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13018 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13019
13020 spec->adc_nids = alc269_adc_nids;
13021 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013022 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013023 if (!spec->cap_mixer)
13024 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013025 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013026
13027 codec->patch_ops = alc_patch_ops;
13028 if (board_config == ALC269_AUTO)
13029 spec->init_hook = alc269_auto_init;
13030#ifdef CONFIG_SND_HDA_POWER_SAVE
13031 if (!spec->loopback.amplist)
13032 spec->loopback.amplist = alc269_loopbacks;
13033#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013034 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013035
13036 return 0;
13037}
13038
13039/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013040 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13041 */
13042
13043/*
13044 * set the path ways for 2 channel output
13045 * need to set the codec line out and mic 1 pin widgets to inputs
13046 */
13047static struct hda_verb alc861_threestack_ch2_init[] = {
13048 /* set pin widget 1Ah (line in) for input */
13049 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013050 /* set pin widget 18h (mic1/2) for input, for mic also enable
13051 * the vref
13052 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013053 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13054
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013055 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13056#if 0
13057 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13058 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13059#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013060 { } /* end */
13061};
13062/*
13063 * 6ch mode
13064 * need to set the codec line out and mic 1 pin widgets to outputs
13065 */
13066static struct hda_verb alc861_threestack_ch6_init[] = {
13067 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13068 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13069 /* set pin widget 18h (mic1) for output (CLFE)*/
13070 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13071
13072 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013073 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013074
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013075 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13076#if 0
13077 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13078 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13079#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013080 { } /* end */
13081};
13082
13083static struct hda_channel_mode alc861_threestack_modes[2] = {
13084 { 2, alc861_threestack_ch2_init },
13085 { 6, alc861_threestack_ch6_init },
13086};
Takashi Iwai22309c32006-08-09 16:57:28 +020013087/* Set mic1 as input and unmute the mixer */
13088static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13089 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13090 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13091 { } /* end */
13092};
13093/* Set mic1 as output and mute mixer */
13094static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13095 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13096 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13097 { } /* end */
13098};
13099
13100static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13101 { 2, alc861_uniwill_m31_ch2_init },
13102 { 4, alc861_uniwill_m31_ch4_init },
13103};
Kailang Yangdf694da2005-12-05 19:42:22 +010013104
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013105/* Set mic1 and line-in as input and unmute the mixer */
13106static struct hda_verb alc861_asus_ch2_init[] = {
13107 /* set pin widget 1Ah (line in) for input */
13108 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013109 /* set pin widget 18h (mic1/2) for input, for mic also enable
13110 * the vref
13111 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013112 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13113
13114 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13115#if 0
13116 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13117 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13118#endif
13119 { } /* end */
13120};
13121/* Set mic1 nad line-in as output and mute mixer */
13122static struct hda_verb alc861_asus_ch6_init[] = {
13123 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13124 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13125 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13126 /* set pin widget 18h (mic1) for output (CLFE)*/
13127 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13128 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13129 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13130 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13131
13132 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13133#if 0
13134 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13135 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13136#endif
13137 { } /* end */
13138};
13139
13140static struct hda_channel_mode alc861_asus_modes[2] = {
13141 { 2, alc861_asus_ch2_init },
13142 { 6, alc861_asus_ch6_init },
13143};
13144
Kailang Yangdf694da2005-12-05 19:42:22 +010013145/* patch-ALC861 */
13146
13147static struct snd_kcontrol_new alc861_base_mixer[] = {
13148 /* output mixer control */
13149 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13150 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13151 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13152 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13153 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13154
13155 /*Input mixer control */
13156 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13157 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13158 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13159 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13160 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13161 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13163 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13164 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13165 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013166
Kailang Yangdf694da2005-12-05 19:42:22 +010013167 { } /* end */
13168};
13169
13170static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13171 /* output mixer control */
13172 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13173 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13174 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13175 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13176 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13177
13178 /* Input mixer control */
13179 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13180 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13181 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13182 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13183 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13184 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13185 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13186 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13187 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13188 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013189
Kailang Yangdf694da2005-12-05 19:42:22 +010013190 {
13191 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13192 .name = "Channel Mode",
13193 .info = alc_ch_mode_info,
13194 .get = alc_ch_mode_get,
13195 .put = alc_ch_mode_put,
13196 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13197 },
13198 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013199};
13200
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013201static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013202 /* output mixer control */
13203 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13204 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13205 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013206
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013207 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013208};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013209
Takashi Iwai22309c32006-08-09 16:57:28 +020013210static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13211 /* output mixer control */
13212 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13213 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13214 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13215 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13216 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13217
13218 /* Input mixer control */
13219 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13220 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13221 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13222 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13223 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13224 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13226 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13228 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013229
Takashi Iwai22309c32006-08-09 16:57:28 +020013230 {
13231 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13232 .name = "Channel Mode",
13233 .info = alc_ch_mode_info,
13234 .get = alc_ch_mode_get,
13235 .put = alc_ch_mode_put,
13236 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13237 },
13238 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013239};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013240
13241static struct snd_kcontrol_new alc861_asus_mixer[] = {
13242 /* output mixer control */
13243 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13244 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13245 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13246 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13247 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13248
13249 /* Input mixer control */
13250 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13251 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13252 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13253 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13254 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13255 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13256 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13257 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13258 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013259 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13260
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013261 {
13262 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13263 .name = "Channel Mode",
13264 .info = alc_ch_mode_info,
13265 .get = alc_ch_mode_get,
13266 .put = alc_ch_mode_put,
13267 .private_value = ARRAY_SIZE(alc861_asus_modes),
13268 },
13269 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013270};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013271
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013272/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013273static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013274 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13275 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013276 { }
13277};
13278
Kailang Yangdf694da2005-12-05 19:42:22 +010013279/*
13280 * generic initialization of ADC, input mixers and output mixers
13281 */
13282static struct hda_verb alc861_base_init_verbs[] = {
13283 /*
13284 * Unmute ADC0 and set the default input to mic-in
13285 */
13286 /* port-A for surround (rear panel) */
13287 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13288 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13289 /* port-B for mic-in (rear panel) with vref */
13290 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13291 /* port-C for line-in (rear panel) */
13292 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13293 /* port-D for Front */
13294 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13295 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13296 /* port-E for HP out (front panel) */
13297 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13298 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013299 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013300 /* port-F for mic-in (front panel) with vref */
13301 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13302 /* port-G for CLFE (rear panel) */
13303 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13304 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13305 /* port-H for side (rear panel) */
13306 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13307 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13308 /* CD-in */
13309 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13310 /* route front mic to ADC1*/
13311 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13312 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013313
Kailang Yangdf694da2005-12-05 19:42:22 +010013314 /* Unmute DAC0~3 & spdif out*/
13315 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13316 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13317 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13318 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13319 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013320
Kailang Yangdf694da2005-12-05 19:42:22 +010013321 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13322 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13323 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13324 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13325 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013326
Kailang Yangdf694da2005-12-05 19:42:22 +010013327 /* Unmute Stereo Mixer 15 */
13328 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13329 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13330 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013331 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013332
13333 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13334 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13335 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13336 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13337 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13339 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13340 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013341 /* hp used DAC 3 (Front) */
13342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013343 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13344
13345 { }
13346};
13347
13348static struct hda_verb alc861_threestack_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, 0x00 },
13354 /* port-B for mic-in (rear panel) with vref */
13355 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13356 /* port-C for line-in (rear panel) */
13357 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13358 /* port-D for Front */
13359 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13360 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13361 /* port-E for HP out (front panel) */
13362 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13363 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013364 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013365 /* port-F for mic-in (front panel) with vref */
13366 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13367 /* port-G for CLFE (rear panel) */
13368 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13369 /* port-H for side (rear panel) */
13370 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13371 /* CD-in */
13372 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13373 /* route front mic to ADC1*/
13374 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13375 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13376 /* Unmute DAC0~3 & spdif out*/
13377 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13378 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13379 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13380 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013382
Kailang Yangdf694da2005-12-05 19:42:22 +010013383 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13384 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13385 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13386 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13387 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013388
Kailang Yangdf694da2005-12-05 19:42:22 +010013389 /* Unmute Stereo Mixer 15 */
13390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13391 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13392 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013394
13395 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13396 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13397 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13398 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13399 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13400 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13401 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13402 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013403 /* hp used DAC 3 (Front) */
13404 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013405 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13406 { }
13407};
Takashi Iwai22309c32006-08-09 16:57:28 +020013408
13409static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13410 /*
13411 * Unmute ADC0 and set the default input to mic-in
13412 */
13413 /* port-A for surround (rear panel) */
13414 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13415 /* port-B for mic-in (rear panel) with vref */
13416 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13417 /* port-C for line-in (rear panel) */
13418 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13419 /* port-D for Front */
13420 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13421 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13422 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013423 /* this has to be set to VREF80 */
13424 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013425 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013426 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013427 /* port-F for mic-in (front panel) with vref */
13428 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13429 /* port-G for CLFE (rear panel) */
13430 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13431 /* port-H for side (rear panel) */
13432 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13433 /* CD-in */
13434 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13435 /* route front mic to ADC1*/
13436 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13437 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13438 /* Unmute DAC0~3 & spdif out*/
13439 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13440 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13441 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13442 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13443 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013444
Takashi Iwai22309c32006-08-09 16:57:28 +020013445 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13446 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13447 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13448 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13449 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013450
Takashi Iwai22309c32006-08-09 16:57:28 +020013451 /* Unmute Stereo Mixer 15 */
13452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13453 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13454 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013455 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013456
13457 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13458 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13459 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13460 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13461 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13462 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13463 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13464 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013465 /* hp used DAC 3 (Front) */
13466 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013467 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13468 { }
13469};
13470
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013471static struct hda_verb alc861_asus_init_verbs[] = {
13472 /*
13473 * Unmute ADC0 and set the default input to mic-in
13474 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013475 /* port-A for surround (rear panel)
13476 * according to codec#0 this is the HP jack
13477 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013478 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13479 /* route front PCM to HP */
13480 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
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 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013491 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013492 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +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, 0x40 },
13497 /* port-H for side (rear panel) */
13498 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
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},
13510 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13511 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13512 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13513 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13514 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013515
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013516 /* Unmute Stereo Mixer 15 */
13517 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13518 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013521
13522 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13523 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13524 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13525 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13526 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13527 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13528 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13529 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013530 /* hp used DAC 3 (Front) */
13531 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013532 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13533 { }
13534};
13535
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013536/* additional init verbs for ASUS laptops */
13537static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13538 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13539 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13540 { }
13541};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013542
Kailang Yangdf694da2005-12-05 19:42:22 +010013543/*
13544 * generic initialization of ADC, input mixers and output mixers
13545 */
13546static struct hda_verb alc861_auto_init_verbs[] = {
13547 /*
13548 * Unmute ADC0 and set the default input to mic-in
13549 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013550 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013551 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013552
Kailang Yangdf694da2005-12-05 19:42:22 +010013553 /* Unmute DAC0~3 & spdif out*/
13554 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13555 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13556 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13557 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013559
Kailang Yangdf694da2005-12-05 19:42:22 +010013560 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13561 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13562 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13563 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13564 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013565
Kailang Yangdf694da2005-12-05 19:42:22 +010013566 /* Unmute Stereo Mixer 15 */
13567 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13568 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13569 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13570 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13571
13572 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13573 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13574 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13575 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13576 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13577 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13578 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13579 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13580
13581 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13582 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013583 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13584 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013585 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13586 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013587 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13588 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013589
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013590 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013591
13592 { }
13593};
13594
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013595static struct hda_verb alc861_toshiba_init_verbs[] = {
13596 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013597
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013598 { }
13599};
13600
13601/* toggle speaker-output according to the hp-jack state */
13602static void alc861_toshiba_automute(struct hda_codec *codec)
13603{
13604 unsigned int present;
13605
13606 present = snd_hda_codec_read(codec, 0x0f, 0,
13607 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013608 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13609 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13610 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13611 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013612}
13613
13614static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13615 unsigned int res)
13616{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013617 if ((res >> 26) == ALC880_HP_EVENT)
13618 alc861_toshiba_automute(codec);
13619}
13620
Kailang Yangdf694da2005-12-05 19:42:22 +010013621/* pcm configuration: identiacal with ALC880 */
13622#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13623#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13624#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13625#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13626
13627
13628#define ALC861_DIGOUT_NID 0x07
13629
13630static struct hda_channel_mode alc861_8ch_modes[1] = {
13631 { 8, NULL }
13632};
13633
13634static hda_nid_t alc861_dac_nids[4] = {
13635 /* front, surround, clfe, side */
13636 0x03, 0x06, 0x05, 0x04
13637};
13638
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013639static hda_nid_t alc660_dac_nids[3] = {
13640 /* front, clfe, surround */
13641 0x03, 0x05, 0x06
13642};
13643
Kailang Yangdf694da2005-12-05 19:42:22 +010013644static hda_nid_t alc861_adc_nids[1] = {
13645 /* ADC0-2 */
13646 0x08,
13647};
13648
13649static struct hda_input_mux alc861_capture_source = {
13650 .num_items = 5,
13651 .items = {
13652 { "Mic", 0x0 },
13653 { "Front Mic", 0x3 },
13654 { "Line", 0x1 },
13655 { "CD", 0x4 },
13656 { "Mixer", 0x5 },
13657 },
13658};
13659
13660/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013661static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13662 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013663{
13664 int i;
13665 hda_nid_t nid;
13666
13667 spec->multiout.dac_nids = spec->private_dac_nids;
13668 for (i = 0; i < cfg->line_outs; i++) {
13669 nid = cfg->line_out_pins[i];
13670 if (nid) {
13671 if (i >= ARRAY_SIZE(alc861_dac_nids))
13672 continue;
13673 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13674 }
13675 }
13676 spec->multiout.num_dacs = cfg->line_outs;
13677 return 0;
13678}
13679
13680/* add playback controls from the parsed DAC table */
13681static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13682 const struct auto_pin_cfg *cfg)
13683{
13684 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013685 static const char *chname[4] = {
13686 "Front", "Surround", NULL /*CLFE*/, "Side"
13687 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013688 hda_nid_t nid;
13689 int i, idx, err;
13690
13691 for (i = 0; i < cfg->line_outs; i++) {
13692 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013693 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013694 continue;
13695 if (nid == 0x05) {
13696 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013697 err = add_control(spec, ALC_CTL_BIND_MUTE,
13698 "Center Playback Switch",
13699 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13700 HDA_OUTPUT));
13701 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013702 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013703 err = add_control(spec, ALC_CTL_BIND_MUTE,
13704 "LFE Playback Switch",
13705 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13706 HDA_OUTPUT));
13707 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013708 return err;
13709 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013710 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13711 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013712 if (nid == alc861_dac_nids[idx])
13713 break;
13714 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013715 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13716 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13717 HDA_OUTPUT));
13718 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013719 return err;
13720 }
13721 }
13722 return 0;
13723}
13724
13725static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13726{
13727 int err;
13728 hda_nid_t nid;
13729
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013730 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013731 return 0;
13732
13733 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13734 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013735 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13736 "Headphone Playback Switch",
13737 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13738 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013739 return err;
13740 spec->multiout.hp_nid = nid;
13741 }
13742 return 0;
13743}
13744
13745/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013746static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13747 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013748{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013749 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013750 int i, err, idx, idx1;
13751
13752 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013753 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013754 case 0x0c:
13755 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013756 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013757 break;
13758 case 0x0f:
13759 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013760 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013761 break;
13762 case 0x0d:
13763 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013764 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013765 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013766 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013767 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013768 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013769 break;
13770 case 0x11:
13771 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013772 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013773 break;
13774 default:
13775 continue;
13776 }
13777
Takashi Iwai4a471b72005-12-07 13:56:29 +010013778 err = new_analog_input(spec, cfg->input_pins[i],
13779 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013780 if (err < 0)
13781 return err;
13782
Takashi Iwai4a471b72005-12-07 13:56:29 +010013783 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013784 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013785 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013786 }
13787 return 0;
13788}
13789
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013790static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13791 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013792 int pin_type, int dac_idx)
13793{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013794 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13795 pin_type);
13796 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13797 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013798}
13799
13800static void alc861_auto_init_multi_out(struct hda_codec *codec)
13801{
13802 struct alc_spec *spec = codec->spec;
13803 int i;
13804
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013805 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013806 for (i = 0; i < spec->autocfg.line_outs; i++) {
13807 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013808 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013809 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013810 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013811 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013812 }
13813}
13814
13815static void alc861_auto_init_hp_out(struct hda_codec *codec)
13816{
13817 struct alc_spec *spec = codec->spec;
13818 hda_nid_t pin;
13819
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013820 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013821 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013822 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13823 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013824 pin = spec->autocfg.speaker_pins[0];
13825 if (pin)
13826 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013827}
13828
13829static void alc861_auto_init_analog_input(struct hda_codec *codec)
13830{
13831 struct alc_spec *spec = codec->spec;
13832 int i;
13833
13834 for (i = 0; i < AUTO_PIN_LAST; i++) {
13835 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013836 if (nid >= 0x0c && nid <= 0x11) {
13837 snd_hda_codec_write(codec, nid, 0,
13838 AC_VERB_SET_PIN_WIDGET_CONTROL,
13839 i <= AUTO_PIN_FRONT_MIC ?
13840 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013841 }
13842 }
13843}
13844
13845/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013846/* return 1 if successful, 0 if the proper config is not found,
13847 * or a negative error code
13848 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013849static int alc861_parse_auto_config(struct hda_codec *codec)
13850{
13851 struct alc_spec *spec = codec->spec;
13852 int err;
13853 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13854
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013855 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13856 alc861_ignore);
13857 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013858 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013859 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013860 return 0; /* can't find valid BIOS pin config */
13861
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013862 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13863 if (err < 0)
13864 return err;
13865 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13866 if (err < 0)
13867 return err;
13868 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13869 if (err < 0)
13870 return err;
13871 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13872 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013873 return err;
13874
13875 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13876
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013877 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013878 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13879
Takashi Iwai603c4012008-07-30 15:01:44 +020013880 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013881 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013882
Takashi Iwaid88897e2008-10-31 15:01:37 +010013883 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013884
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013885 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013886 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013887
13888 spec->adc_nids = alc861_adc_nids;
13889 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013890 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013891
13892 return 1;
13893}
13894
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013895/* additional initialization for auto-configuration model */
13896static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013897{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013898 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013899 alc861_auto_init_multi_out(codec);
13900 alc861_auto_init_hp_out(codec);
13901 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013902 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013903 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013904}
13905
Takashi Iwaicb53c622007-08-10 17:21:45 +020013906#ifdef CONFIG_SND_HDA_POWER_SAVE
13907static struct hda_amp_list alc861_loopbacks[] = {
13908 { 0x15, HDA_INPUT, 0 },
13909 { 0x15, HDA_INPUT, 1 },
13910 { 0x15, HDA_INPUT, 2 },
13911 { 0x15, HDA_INPUT, 3 },
13912 { } /* end */
13913};
13914#endif
13915
Kailang Yangdf694da2005-12-05 19:42:22 +010013916
13917/*
13918 * configuration and preset
13919 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013920static const char *alc861_models[ALC861_MODEL_LAST] = {
13921 [ALC861_3ST] = "3stack",
13922 [ALC660_3ST] = "3stack-660",
13923 [ALC861_3ST_DIG] = "3stack-dig",
13924 [ALC861_6ST_DIG] = "6stack-dig",
13925 [ALC861_UNIWILL_M31] = "uniwill-m31",
13926 [ALC861_TOSHIBA] = "toshiba",
13927 [ALC861_ASUS] = "asus",
13928 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13929 [ALC861_AUTO] = "auto",
13930};
13931
13932static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013933 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013934 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13935 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13936 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013937 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013938 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013939 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013940 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13941 * Any other models that need this preset?
13942 */
13943 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013944 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13945 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013946 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13947 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13948 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13949 /* FIXME: the below seems conflict */
13950 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13951 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13952 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013953 {}
13954};
13955
13956static struct alc_config_preset alc861_presets[] = {
13957 [ALC861_3ST] = {
13958 .mixers = { alc861_3ST_mixer },
13959 .init_verbs = { alc861_threestack_init_verbs },
13960 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13961 .dac_nids = alc861_dac_nids,
13962 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13963 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013964 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013965 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13966 .adc_nids = alc861_adc_nids,
13967 .input_mux = &alc861_capture_source,
13968 },
13969 [ALC861_3ST_DIG] = {
13970 .mixers = { alc861_base_mixer },
13971 .init_verbs = { alc861_threestack_init_verbs },
13972 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13973 .dac_nids = alc861_dac_nids,
13974 .dig_out_nid = ALC861_DIGOUT_NID,
13975 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13976 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013977 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013978 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13979 .adc_nids = alc861_adc_nids,
13980 .input_mux = &alc861_capture_source,
13981 },
13982 [ALC861_6ST_DIG] = {
13983 .mixers = { alc861_base_mixer },
13984 .init_verbs = { alc861_base_init_verbs },
13985 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13986 .dac_nids = alc861_dac_nids,
13987 .dig_out_nid = ALC861_DIGOUT_NID,
13988 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13989 .channel_mode = alc861_8ch_modes,
13990 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13991 .adc_nids = alc861_adc_nids,
13992 .input_mux = &alc861_capture_source,
13993 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013994 [ALC660_3ST] = {
13995 .mixers = { alc861_3ST_mixer },
13996 .init_verbs = { alc861_threestack_init_verbs },
13997 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13998 .dac_nids = alc660_dac_nids,
13999 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14000 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014001 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014002 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14003 .adc_nids = alc861_adc_nids,
14004 .input_mux = &alc861_capture_source,
14005 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014006 [ALC861_UNIWILL_M31] = {
14007 .mixers = { alc861_uniwill_m31_mixer },
14008 .init_verbs = { alc861_uniwill_m31_init_verbs },
14009 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14010 .dac_nids = alc861_dac_nids,
14011 .dig_out_nid = ALC861_DIGOUT_NID,
14012 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14013 .channel_mode = alc861_uniwill_m31_modes,
14014 .need_dac_fix = 1,
14015 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14016 .adc_nids = alc861_adc_nids,
14017 .input_mux = &alc861_capture_source,
14018 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014019 [ALC861_TOSHIBA] = {
14020 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014021 .init_verbs = { alc861_base_init_verbs,
14022 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014023 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14024 .dac_nids = alc861_dac_nids,
14025 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14026 .channel_mode = alc883_3ST_2ch_modes,
14027 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14028 .adc_nids = alc861_adc_nids,
14029 .input_mux = &alc861_capture_source,
14030 .unsol_event = alc861_toshiba_unsol_event,
14031 .init_hook = alc861_toshiba_automute,
14032 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014033 [ALC861_ASUS] = {
14034 .mixers = { alc861_asus_mixer },
14035 .init_verbs = { alc861_asus_init_verbs },
14036 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14037 .dac_nids = alc861_dac_nids,
14038 .dig_out_nid = ALC861_DIGOUT_NID,
14039 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14040 .channel_mode = alc861_asus_modes,
14041 .need_dac_fix = 1,
14042 .hp_nid = 0x06,
14043 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14044 .adc_nids = alc861_adc_nids,
14045 .input_mux = &alc861_capture_source,
14046 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014047 [ALC861_ASUS_LAPTOP] = {
14048 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14049 .init_verbs = { alc861_asus_init_verbs,
14050 alc861_asus_laptop_init_verbs },
14051 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14052 .dac_nids = alc861_dac_nids,
14053 .dig_out_nid = ALC861_DIGOUT_NID,
14054 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14055 .channel_mode = alc883_3ST_2ch_modes,
14056 .need_dac_fix = 1,
14057 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14058 .adc_nids = alc861_adc_nids,
14059 .input_mux = &alc861_capture_source,
14060 },
14061};
Kailang Yangdf694da2005-12-05 19:42:22 +010014062
14063
14064static int patch_alc861(struct hda_codec *codec)
14065{
14066 struct alc_spec *spec;
14067 int board_config;
14068 int err;
14069
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014070 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014071 if (spec == NULL)
14072 return -ENOMEM;
14073
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014074 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014075
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014076 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14077 alc861_models,
14078 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014079
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014080 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014081 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14082 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014083 board_config = ALC861_AUTO;
14084 }
14085
14086 if (board_config == ALC861_AUTO) {
14087 /* automatic parse from the BIOS config */
14088 err = alc861_parse_auto_config(codec);
14089 if (err < 0) {
14090 alc_free(codec);
14091 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014092 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014093 printk(KERN_INFO
14094 "hda_codec: Cannot set up configuration "
14095 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014096 board_config = ALC861_3ST_DIG;
14097 }
14098 }
14099
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014100 err = snd_hda_attach_beep_device(codec, 0x23);
14101 if (err < 0) {
14102 alc_free(codec);
14103 return err;
14104 }
14105
Kailang Yangdf694da2005-12-05 19:42:22 +010014106 if (board_config != ALC861_AUTO)
14107 setup_preset(spec, &alc861_presets[board_config]);
14108
14109 spec->stream_name_analog = "ALC861 Analog";
14110 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14111 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14112
14113 spec->stream_name_digital = "ALC861 Digital";
14114 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14115 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14116
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014117 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14118
Takashi Iwai2134ea42008-01-10 16:53:55 +010014119 spec->vmaster_nid = 0x03;
14120
Kailang Yangdf694da2005-12-05 19:42:22 +010014121 codec->patch_ops = alc_patch_ops;
14122 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014123 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014124#ifdef CONFIG_SND_HDA_POWER_SAVE
14125 if (!spec->loopback.amplist)
14126 spec->loopback.amplist = alc861_loopbacks;
14127#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014128 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014129
Kailang Yangdf694da2005-12-05 19:42:22 +010014130 return 0;
14131}
14132
14133/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014134 * ALC861-VD support
14135 *
14136 * Based on ALC882
14137 *
14138 * In addition, an independent DAC
14139 */
14140#define ALC861VD_DIGOUT_NID 0x06
14141
14142static hda_nid_t alc861vd_dac_nids[4] = {
14143 /* front, surr, clfe, side surr */
14144 0x02, 0x03, 0x04, 0x05
14145};
14146
14147/* dac_nids for ALC660vd are in a different order - according to
14148 * Realtek's driver.
14149 * This should probably tesult in a different mixer for 6stack models
14150 * of ALC660vd codecs, but for now there is only 3stack mixer
14151 * - and it is the same as in 861vd.
14152 * adc_nids in ALC660vd are (is) the same as in 861vd
14153 */
14154static hda_nid_t alc660vd_dac_nids[3] = {
14155 /* front, rear, clfe, rear_surr */
14156 0x02, 0x04, 0x03
14157};
14158
14159static hda_nid_t alc861vd_adc_nids[1] = {
14160 /* ADC0 */
14161 0x09,
14162};
14163
Takashi Iwaie1406342008-02-11 18:32:32 +010014164static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14165
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014166/* input MUX */
14167/* FIXME: should be a matrix-type input source selection */
14168static struct hda_input_mux alc861vd_capture_source = {
14169 .num_items = 4,
14170 .items = {
14171 { "Mic", 0x0 },
14172 { "Front Mic", 0x1 },
14173 { "Line", 0x2 },
14174 { "CD", 0x4 },
14175 },
14176};
14177
Kailang Yang272a5272007-05-14 11:00:38 +020014178static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014179 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014180 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014181 { "Ext Mic", 0x0 },
14182 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014183 },
14184};
14185
Kailang Yangd1a991a2007-08-15 16:21:59 +020014186static struct hda_input_mux alc861vd_hp_capture_source = {
14187 .num_items = 2,
14188 .items = {
14189 { "Front Mic", 0x0 },
14190 { "ATAPI Mic", 0x1 },
14191 },
14192};
14193
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014194/*
14195 * 2ch mode
14196 */
14197static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14198 { 2, NULL }
14199};
14200
14201/*
14202 * 6ch mode
14203 */
14204static struct hda_verb alc861vd_6stack_ch6_init[] = {
14205 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14206 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14207 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14208 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14209 { } /* end */
14210};
14211
14212/*
14213 * 8ch mode
14214 */
14215static struct hda_verb alc861vd_6stack_ch8_init[] = {
14216 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14217 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14218 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14219 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14220 { } /* end */
14221};
14222
14223static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14224 { 6, alc861vd_6stack_ch6_init },
14225 { 8, alc861vd_6stack_ch8_init },
14226};
14227
14228static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14229 {
14230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14231 .name = "Channel Mode",
14232 .info = alc_ch_mode_info,
14233 .get = alc_ch_mode_get,
14234 .put = alc_ch_mode_put,
14235 },
14236 { } /* end */
14237};
14238
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014239/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14240 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14241 */
14242static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14243 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14244 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14245
14246 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14247 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14248
14249 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14250 HDA_OUTPUT),
14251 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14252 HDA_OUTPUT),
14253 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14254 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14255
14256 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14257 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14258
14259 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14260
14261 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14263 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14264
14265 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14266 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14267 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14268
14269 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14270 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14271
14272 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14273 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14274
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014275 { } /* end */
14276};
14277
14278static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14279 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14280 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14281
14282 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14283
14284 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14285 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14286 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14287
14288 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14289 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14290 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14291
14292 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14293 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14294
14295 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14296 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14297
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014298 { } /* end */
14299};
14300
Kailang Yangbdd148a2007-05-08 15:19:08 +020014301static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14302 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14303 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14304 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14305
14306 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14307
14308 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14310 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14311
14312 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14313 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14314 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14315
14316 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14317 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14318
14319 { } /* end */
14320};
14321
Tobin Davisb419f342008-03-07 11:57:51 +010014322/* Pin assignment: Speaker=0x14, HP = 0x15,
14323 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014324 */
14325static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014326 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14327 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014328 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14329 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014330 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14331 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14332 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14333 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14334 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14335 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014336 { } /* end */
14337};
14338
Kailang Yangd1a991a2007-08-15 16:21:59 +020014339/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14340 * Front Mic=0x18, ATAPI Mic = 0x19,
14341 */
14342static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14343 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14344 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14345 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14346 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14347 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14348 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14349 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14350 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014351
Kailang Yangd1a991a2007-08-15 16:21:59 +020014352 { } /* end */
14353};
14354
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014355/*
14356 * generic initialization of ADC, input mixers and output mixers
14357 */
14358static struct hda_verb alc861vd_volume_init_verbs[] = {
14359 /*
14360 * Unmute ADC0 and set the default input to mic-in
14361 */
14362 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14363 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14364
14365 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14366 * the analog-loopback mixer widget
14367 */
14368 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14373 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014374
14375 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014380
14381 /*
14382 * Set up output mixers (0x02 - 0x05)
14383 */
14384 /* set vol=0 to output mixers */
14385 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14386 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14387 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14388 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14389
14390 /* set up input amps for analog loopback */
14391 /* Amp Indices: DAC = 0, mixer = 1 */
14392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14395 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14397 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14398 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14400
14401 { }
14402};
14403
14404/*
14405 * 3-stack pin configuration:
14406 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14407 */
14408static struct hda_verb alc861vd_3stack_init_verbs[] = {
14409 /*
14410 * Set pin mode and muting
14411 */
14412 /* set front pin widgets 0x14 for output */
14413 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14414 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14415 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14416
14417 /* Mic (rear) pin: input vref at 80% */
14418 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14419 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14420 /* Front Mic pin: input vref at 80% */
14421 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14422 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14423 /* Line In pin: input */
14424 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14425 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14426 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14427 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14428 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14429 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14430 /* CD pin widget for input */
14431 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14432
14433 { }
14434};
14435
14436/*
14437 * 6-stack pin configuration:
14438 */
14439static struct hda_verb alc861vd_6stack_init_verbs[] = {
14440 /*
14441 * Set pin mode and muting
14442 */
14443 /* set front pin widgets 0x14 for output */
14444 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14445 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14446 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14447
14448 /* Rear Pin: output 1 (0x0d) */
14449 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14451 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14452 /* CLFE Pin: output 2 (0x0e) */
14453 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14454 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14455 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14456 /* Side Pin: output 3 (0x0f) */
14457 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14458 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14459 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14460
14461 /* Mic (rear) pin: input vref at 80% */
14462 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14463 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14464 /* Front Mic pin: input vref at 80% */
14465 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14466 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14467 /* Line In pin: input */
14468 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14469 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14470 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14471 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14472 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14473 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14474 /* CD pin widget for input */
14475 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14476
14477 { }
14478};
14479
Kailang Yangbdd148a2007-05-08 15:19:08 +020014480static struct hda_verb alc861vd_eapd_verbs[] = {
14481 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14482 { }
14483};
14484
Kailang Yangf9423e72008-05-27 12:32:25 +020014485static struct hda_verb alc660vd_eapd_verbs[] = {
14486 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14487 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14488 { }
14489};
14490
Kailang Yangbdd148a2007-05-08 15:19:08 +020014491static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14492 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14494 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14495 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014496 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014497 {}
14498};
14499
14500/* toggle speaker-output according to the hp-jack state */
14501static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14502{
14503 unsigned int present;
14504 unsigned char bits;
14505
14506 present = snd_hda_codec_read(codec, 0x1b, 0,
14507 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014508 bits = present ? HDA_AMP_MUTE : 0;
14509 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14510 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014511}
14512
14513static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14514{
14515 unsigned int present;
14516 unsigned char bits;
14517
14518 present = snd_hda_codec_read(codec, 0x18, 0,
14519 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014520 bits = present ? HDA_AMP_MUTE : 0;
14521 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14522 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014523}
14524
14525static void alc861vd_lenovo_automute(struct hda_codec *codec)
14526{
14527 alc861vd_lenovo_hp_automute(codec);
14528 alc861vd_lenovo_mic_automute(codec);
14529}
14530
14531static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14532 unsigned int res)
14533{
14534 switch (res >> 26) {
14535 case ALC880_HP_EVENT:
14536 alc861vd_lenovo_hp_automute(codec);
14537 break;
14538 case ALC880_MIC_EVENT:
14539 alc861vd_lenovo_mic_automute(codec);
14540 break;
14541 }
14542}
14543
Kailang Yang272a5272007-05-14 11:00:38 +020014544static struct hda_verb alc861vd_dallas_verbs[] = {
14545 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14546 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14547 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14548 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14549
14550 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14552 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14553 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14554 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14555 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14556 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14557 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014558
Kailang Yang272a5272007-05-14 11:00:38 +020014559 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14560 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14561 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14563 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14564 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14565 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14566 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14567
14568 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14570 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14571 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14572 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14573 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14574 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14575 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14576
14577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14580 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14581
14582 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014583 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014584 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14585
14586 { } /* end */
14587};
14588
14589/* toggle speaker-output according to the hp-jack state */
14590static void alc861vd_dallas_automute(struct hda_codec *codec)
14591{
14592 unsigned int present;
14593
14594 present = snd_hda_codec_read(codec, 0x15, 0,
14595 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014596 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14597 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014598}
14599
14600static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14601{
14602 if ((res >> 26) == ALC880_HP_EVENT)
14603 alc861vd_dallas_automute(codec);
14604}
14605
Takashi Iwaicb53c622007-08-10 17:21:45 +020014606#ifdef CONFIG_SND_HDA_POWER_SAVE
14607#define alc861vd_loopbacks alc880_loopbacks
14608#endif
14609
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014610/* pcm configuration: identiacal with ALC880 */
14611#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14612#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14613#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14614#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14615
14616/*
14617 * configuration and preset
14618 */
14619static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14620 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014621 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014622 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014623 [ALC861VD_3ST] = "3stack",
14624 [ALC861VD_3ST_DIG] = "3stack-digout",
14625 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014626 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014627 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014628 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014629 [ALC861VD_AUTO] = "auto",
14630};
14631
14632static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014633 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14634 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014635 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014636 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014637 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014638 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014639 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014640 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014641 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014642 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014643 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014644 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014645 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014646 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014647 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014648 {}
14649};
14650
14651static struct alc_config_preset alc861vd_presets[] = {
14652 [ALC660VD_3ST] = {
14653 .mixers = { alc861vd_3st_mixer },
14654 .init_verbs = { alc861vd_volume_init_verbs,
14655 alc861vd_3stack_init_verbs },
14656 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14657 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014658 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14659 .channel_mode = alc861vd_3stack_2ch_modes,
14660 .input_mux = &alc861vd_capture_source,
14661 },
Mike Crash6963f842007-06-25 12:12:51 +020014662 [ALC660VD_3ST_DIG] = {
14663 .mixers = { alc861vd_3st_mixer },
14664 .init_verbs = { alc861vd_volume_init_verbs,
14665 alc861vd_3stack_init_verbs },
14666 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14667 .dac_nids = alc660vd_dac_nids,
14668 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014669 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14670 .channel_mode = alc861vd_3stack_2ch_modes,
14671 .input_mux = &alc861vd_capture_source,
14672 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014673 [ALC861VD_3ST] = {
14674 .mixers = { alc861vd_3st_mixer },
14675 .init_verbs = { alc861vd_volume_init_verbs,
14676 alc861vd_3stack_init_verbs },
14677 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14678 .dac_nids = alc861vd_dac_nids,
14679 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14680 .channel_mode = alc861vd_3stack_2ch_modes,
14681 .input_mux = &alc861vd_capture_source,
14682 },
14683 [ALC861VD_3ST_DIG] = {
14684 .mixers = { alc861vd_3st_mixer },
14685 .init_verbs = { alc861vd_volume_init_verbs,
14686 alc861vd_3stack_init_verbs },
14687 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14688 .dac_nids = alc861vd_dac_nids,
14689 .dig_out_nid = ALC861VD_DIGOUT_NID,
14690 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14691 .channel_mode = alc861vd_3stack_2ch_modes,
14692 .input_mux = &alc861vd_capture_source,
14693 },
14694 [ALC861VD_6ST_DIG] = {
14695 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14696 .init_verbs = { alc861vd_volume_init_verbs,
14697 alc861vd_6stack_init_verbs },
14698 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14699 .dac_nids = alc861vd_dac_nids,
14700 .dig_out_nid = ALC861VD_DIGOUT_NID,
14701 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14702 .channel_mode = alc861vd_6stack_modes,
14703 .input_mux = &alc861vd_capture_source,
14704 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014705 [ALC861VD_LENOVO] = {
14706 .mixers = { alc861vd_lenovo_mixer },
14707 .init_verbs = { alc861vd_volume_init_verbs,
14708 alc861vd_3stack_init_verbs,
14709 alc861vd_eapd_verbs,
14710 alc861vd_lenovo_unsol_verbs },
14711 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14712 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014713 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14714 .channel_mode = alc861vd_3stack_2ch_modes,
14715 .input_mux = &alc861vd_capture_source,
14716 .unsol_event = alc861vd_lenovo_unsol_event,
14717 .init_hook = alc861vd_lenovo_automute,
14718 },
Kailang Yang272a5272007-05-14 11:00:38 +020014719 [ALC861VD_DALLAS] = {
14720 .mixers = { alc861vd_dallas_mixer },
14721 .init_verbs = { alc861vd_dallas_verbs },
14722 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14723 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014724 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14725 .channel_mode = alc861vd_3stack_2ch_modes,
14726 .input_mux = &alc861vd_dallas_capture_source,
14727 .unsol_event = alc861vd_dallas_unsol_event,
14728 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014729 },
14730 [ALC861VD_HP] = {
14731 .mixers = { alc861vd_hp_mixer },
14732 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14733 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14734 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014735 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014736 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14737 .channel_mode = alc861vd_3stack_2ch_modes,
14738 .input_mux = &alc861vd_hp_capture_source,
14739 .unsol_event = alc861vd_dallas_unsol_event,
14740 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014741 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014742 [ALC660VD_ASUS_V1S] = {
14743 .mixers = { alc861vd_lenovo_mixer },
14744 .init_verbs = { alc861vd_volume_init_verbs,
14745 alc861vd_3stack_init_verbs,
14746 alc861vd_eapd_verbs,
14747 alc861vd_lenovo_unsol_verbs },
14748 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14749 .dac_nids = alc660vd_dac_nids,
14750 .dig_out_nid = ALC861VD_DIGOUT_NID,
14751 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14752 .channel_mode = alc861vd_3stack_2ch_modes,
14753 .input_mux = &alc861vd_capture_source,
14754 .unsol_event = alc861vd_lenovo_unsol_event,
14755 .init_hook = alc861vd_lenovo_automute,
14756 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014757};
14758
14759/*
14760 * BIOS auto configuration
14761 */
14762static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14763 hda_nid_t nid, int pin_type, int dac_idx)
14764{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014765 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014766}
14767
14768static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14769{
14770 struct alc_spec *spec = codec->spec;
14771 int i;
14772
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014773 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014774 for (i = 0; i <= HDA_SIDE; i++) {
14775 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014776 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014777 if (nid)
14778 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014779 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014780 }
14781}
14782
14783
14784static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14785{
14786 struct alc_spec *spec = codec->spec;
14787 hda_nid_t pin;
14788
14789 pin = spec->autocfg.hp_pins[0];
14790 if (pin) /* connect to front and use dac 0 */
14791 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014792 pin = spec->autocfg.speaker_pins[0];
14793 if (pin)
14794 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014795}
14796
14797#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14798#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14799
14800static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14801{
14802 struct alc_spec *spec = codec->spec;
14803 int i;
14804
14805 for (i = 0; i < AUTO_PIN_LAST; i++) {
14806 hda_nid_t nid = spec->autocfg.input_pins[i];
14807 if (alc861vd_is_input_pin(nid)) {
14808 snd_hda_codec_write(codec, nid, 0,
14809 AC_VERB_SET_PIN_WIDGET_CONTROL,
14810 i <= AUTO_PIN_FRONT_MIC ?
14811 PIN_VREF80 : PIN_IN);
14812 if (nid != ALC861VD_PIN_CD_NID)
14813 snd_hda_codec_write(codec, nid, 0,
14814 AC_VERB_SET_AMP_GAIN_MUTE,
14815 AMP_OUT_MUTE);
14816 }
14817 }
14818}
14819
Takashi Iwaif511b012008-08-15 16:46:42 +020014820#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14821
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014822#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14823#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14824
14825/* add playback controls from the parsed DAC table */
14826/* Based on ALC880 version. But ALC861VD has separate,
14827 * different NIDs for mute/unmute switch and volume control */
14828static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14829 const struct auto_pin_cfg *cfg)
14830{
14831 char name[32];
14832 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14833 hda_nid_t nid_v, nid_s;
14834 int i, err;
14835
14836 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014837 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014838 continue;
14839 nid_v = alc861vd_idx_to_mixer_vol(
14840 alc880_dac_to_idx(
14841 spec->multiout.dac_nids[i]));
14842 nid_s = alc861vd_idx_to_mixer_switch(
14843 alc880_dac_to_idx(
14844 spec->multiout.dac_nids[i]));
14845
14846 if (i == 2) {
14847 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014848 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14849 "Center Playback Volume",
14850 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14851 HDA_OUTPUT));
14852 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014853 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014854 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14855 "LFE Playback Volume",
14856 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14857 HDA_OUTPUT));
14858 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014859 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014860 err = add_control(spec, ALC_CTL_BIND_MUTE,
14861 "Center Playback Switch",
14862 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14863 HDA_INPUT));
14864 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014865 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014866 err = add_control(spec, ALC_CTL_BIND_MUTE,
14867 "LFE Playback Switch",
14868 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14869 HDA_INPUT));
14870 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014871 return err;
14872 } else {
14873 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014874 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14875 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14876 HDA_OUTPUT));
14877 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014878 return err;
14879 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014880 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014881 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014882 HDA_INPUT));
14883 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014884 return err;
14885 }
14886 }
14887 return 0;
14888}
14889
14890/* add playback controls for speaker and HP outputs */
14891/* Based on ALC880 version. But ALC861VD has separate,
14892 * different NIDs for mute/unmute switch and volume control */
14893static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14894 hda_nid_t pin, const char *pfx)
14895{
14896 hda_nid_t nid_v, nid_s;
14897 int err;
14898 char name[32];
14899
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014900 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014901 return 0;
14902
14903 if (alc880_is_fixed_pin(pin)) {
14904 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14905 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014906 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014907 spec->multiout.hp_nid = nid_v;
14908 else
14909 spec->multiout.extra_out_nid[0] = nid_v;
14910 /* control HP volume/switch on the output mixer amp */
14911 nid_v = alc861vd_idx_to_mixer_vol(
14912 alc880_fixed_pin_idx(pin));
14913 nid_s = alc861vd_idx_to_mixer_switch(
14914 alc880_fixed_pin_idx(pin));
14915
14916 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014917 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14918 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14919 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014920 return err;
14921 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014922 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14923 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14924 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014925 return err;
14926 } else if (alc880_is_multi_pin(pin)) {
14927 /* set manual connection */
14928 /* we have only a switch on HP-out PIN */
14929 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014930 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14931 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14932 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014933 return err;
14934 }
14935 return 0;
14936}
14937
14938/* parse the BIOS configuration and set up the alc_spec
14939 * return 1 if successful, 0 if the proper config is not found,
14940 * or a negative error code
14941 * Based on ALC880 version - had to change it to override
14942 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14943static int alc861vd_parse_auto_config(struct hda_codec *codec)
14944{
14945 struct alc_spec *spec = codec->spec;
14946 int err;
14947 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14948
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014949 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14950 alc861vd_ignore);
14951 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014952 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014953 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014954 return 0; /* can't find valid BIOS pin config */
14955
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014956 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14957 if (err < 0)
14958 return err;
14959 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14960 if (err < 0)
14961 return err;
14962 err = alc861vd_auto_create_extra_out(spec,
14963 spec->autocfg.speaker_pins[0],
14964 "Speaker");
14965 if (err < 0)
14966 return err;
14967 err = alc861vd_auto_create_extra_out(spec,
14968 spec->autocfg.hp_pins[0],
14969 "Headphone");
14970 if (err < 0)
14971 return err;
14972 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14973 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014974 return err;
14975
14976 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14977
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014978 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014979 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14980
Takashi Iwai603c4012008-07-30 15:01:44 +020014981 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014982 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014983
Takashi Iwaid88897e2008-10-31 15:01:37 +010014984 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014985
14986 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014987 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014988
Takashi Iwai776e1842007-08-29 15:07:11 +020014989 err = alc_auto_add_mic_boost(codec);
14990 if (err < 0)
14991 return err;
14992
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014993 return 1;
14994}
14995
14996/* additional initialization for auto-configuration model */
14997static void alc861vd_auto_init(struct hda_codec *codec)
14998{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014999 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015000 alc861vd_auto_init_multi_out(codec);
15001 alc861vd_auto_init_hp_out(codec);
15002 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015003 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015004 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015005 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015006}
15007
15008static int patch_alc861vd(struct hda_codec *codec)
15009{
15010 struct alc_spec *spec;
15011 int err, board_config;
15012
15013 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15014 if (spec == NULL)
15015 return -ENOMEM;
15016
15017 codec->spec = spec;
15018
15019 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15020 alc861vd_models,
15021 alc861vd_cfg_tbl);
15022
15023 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15024 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
15025 "ALC861VD, trying auto-probe from BIOS...\n");
15026 board_config = ALC861VD_AUTO;
15027 }
15028
15029 if (board_config == ALC861VD_AUTO) {
15030 /* automatic parse from the BIOS config */
15031 err = alc861vd_parse_auto_config(codec);
15032 if (err < 0) {
15033 alc_free(codec);
15034 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015035 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015036 printk(KERN_INFO
15037 "hda_codec: Cannot set up configuration "
15038 "from BIOS. Using base mode...\n");
15039 board_config = ALC861VD_3ST;
15040 }
15041 }
15042
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015043 err = snd_hda_attach_beep_device(codec, 0x23);
15044 if (err < 0) {
15045 alc_free(codec);
15046 return err;
15047 }
15048
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015049 if (board_config != ALC861VD_AUTO)
15050 setup_preset(spec, &alc861vd_presets[board_config]);
15051
Kailang Yang2f893282008-05-27 12:14:47 +020015052 if (codec->vendor_id == 0x10ec0660) {
15053 spec->stream_name_analog = "ALC660-VD Analog";
15054 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020015055 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015056 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015057 } else {
15058 spec->stream_name_analog = "ALC861VD Analog";
15059 spec->stream_name_digital = "ALC861VD Digital";
15060 }
15061
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015062 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15063 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15064
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015065 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15066 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15067
15068 spec->adc_nids = alc861vd_adc_nids;
15069 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015070 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015071 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015072
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015073 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015074 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015075
Takashi Iwai2134ea42008-01-10 16:53:55 +010015076 spec->vmaster_nid = 0x02;
15077
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015078 codec->patch_ops = alc_patch_ops;
15079
15080 if (board_config == ALC861VD_AUTO)
15081 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015082#ifdef CONFIG_SND_HDA_POWER_SAVE
15083 if (!spec->loopback.amplist)
15084 spec->loopback.amplist = alc861vd_loopbacks;
15085#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015086 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015087
15088 return 0;
15089}
15090
15091/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015092 * ALC662 support
15093 *
15094 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15095 * configuration. Each pin widget can choose any input DACs and a mixer.
15096 * Each ADC is connected from a mixer of all inputs. This makes possible
15097 * 6-channel independent captures.
15098 *
15099 * In addition, an independent DAC for the multi-playback (not used in this
15100 * driver yet).
15101 */
15102#define ALC662_DIGOUT_NID 0x06
15103#define ALC662_DIGIN_NID 0x0a
15104
15105static hda_nid_t alc662_dac_nids[4] = {
15106 /* front, rear, clfe, rear_surr */
15107 0x02, 0x03, 0x04
15108};
15109
15110static hda_nid_t alc662_adc_nids[1] = {
15111 /* ADC1-2 */
15112 0x09,
15113};
Takashi Iwaie1406342008-02-11 18:32:32 +010015114
Kailang Yang77a261b2008-02-19 11:38:05 +010015115static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010015116
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015117/* input MUX */
15118/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015119static struct hda_input_mux alc662_capture_source = {
15120 .num_items = 4,
15121 .items = {
15122 { "Mic", 0x0 },
15123 { "Front Mic", 0x1 },
15124 { "Line", 0x2 },
15125 { "CD", 0x4 },
15126 },
15127};
15128
15129static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15130 .num_items = 2,
15131 .items = {
15132 { "Mic", 0x1 },
15133 { "Line", 0x2 },
15134 },
15135};
Kailang Yang291702f2007-10-16 14:28:03 +020015136
15137static struct hda_input_mux alc662_eeepc_capture_source = {
15138 .num_items = 2,
15139 .items = {
15140 { "i-Mic", 0x1 },
15141 { "e-Mic", 0x0 },
15142 },
15143};
15144
Kailang Yang6dda9f42008-05-27 12:05:31 +020015145static struct hda_input_mux alc663_capture_source = {
15146 .num_items = 3,
15147 .items = {
15148 { "Mic", 0x0 },
15149 { "Front Mic", 0x1 },
15150 { "Line", 0x2 },
15151 },
15152};
15153
15154static struct hda_input_mux alc663_m51va_capture_source = {
15155 .num_items = 2,
15156 .items = {
15157 { "Ext-Mic", 0x0 },
15158 { "D-Mic", 0x9 },
15159 },
15160};
15161
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015162/*
15163 * 2ch mode
15164 */
15165static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15166 { 2, NULL }
15167};
15168
15169/*
15170 * 2ch mode
15171 */
15172static struct hda_verb alc662_3ST_ch2_init[] = {
15173 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15174 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15175 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15176 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15177 { } /* end */
15178};
15179
15180/*
15181 * 6ch mode
15182 */
15183static struct hda_verb alc662_3ST_ch6_init[] = {
15184 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15185 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15186 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15187 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15188 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15189 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15190 { } /* end */
15191};
15192
15193static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15194 { 2, alc662_3ST_ch2_init },
15195 { 6, alc662_3ST_ch6_init },
15196};
15197
15198/*
15199 * 2ch mode
15200 */
15201static struct hda_verb alc662_sixstack_ch6_init[] = {
15202 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15203 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15204 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15205 { } /* end */
15206};
15207
15208/*
15209 * 6ch mode
15210 */
15211static struct hda_verb alc662_sixstack_ch8_init[] = {
15212 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15213 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15214 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15215 { } /* end */
15216};
15217
15218static struct hda_channel_mode alc662_5stack_modes[2] = {
15219 { 2, alc662_sixstack_ch6_init },
15220 { 6, alc662_sixstack_ch8_init },
15221};
15222
15223/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15224 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15225 */
15226
15227static struct snd_kcontrol_new alc662_base_mixer[] = {
15228 /* output mixer control */
15229 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015230 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015231 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015232 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015233 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15234 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015235 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15236 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015237 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15238
15239 /*Input mixer control */
15240 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15241 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15242 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15243 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15244 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15245 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15246 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15247 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015248 { } /* end */
15249};
15250
15251static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15252 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015253 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015254 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15255 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15256 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15257 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15258 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15259 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15260 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15261 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15262 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015263 { } /* end */
15264};
15265
15266static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15267 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015268 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015269 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015270 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015271 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15272 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015273 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15274 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15278 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15279 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15282 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15283 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015284 { } /* end */
15285};
15286
15287static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15288 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15289 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015290 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15291 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015292 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15293 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15294 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15296 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015297 { } /* end */
15298};
15299
Kailang Yang291702f2007-10-16 14:28:03 +020015300static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015301 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015302
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015303 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15304 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015305
15306 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15307 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15308 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15309
15310 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15311 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15312 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15313 { } /* end */
15314};
15315
Kailang Yang8c427222008-01-10 13:03:59 +010015316static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015317 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15318 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015319 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15320 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15321 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15322 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15323 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15324 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015325 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015326 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15327 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15328 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15329 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15330 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15331 { } /* end */
15332};
15333
Kailang Yangf1d4e282008-08-26 14:03:29 +020015334static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15335 .ops = &snd_hda_bind_vol,
15336 .values = {
15337 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15338 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15339 0
15340 },
15341};
15342
15343static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15344 .ops = &snd_hda_bind_sw,
15345 .values = {
15346 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15347 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15348 0
15349 },
15350};
15351
Kailang Yang6dda9f42008-05-27 12:05:31 +020015352static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015353 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15354 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15357 { } /* end */
15358};
15359
15360static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15361 .ops = &snd_hda_bind_sw,
15362 .values = {
15363 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15364 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15365 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15366 0
15367 },
15368};
15369
15370static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15371 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15372 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15374 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15375 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15376 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15377
15378 { } /* end */
15379};
15380
15381static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15382 .ops = &snd_hda_bind_sw,
15383 .values = {
15384 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15385 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15386 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15387 0
15388 },
15389};
15390
15391static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15392 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15393 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15396 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15397 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15398 { } /* end */
15399};
15400
15401static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015402 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15403 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015404 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15405 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15406 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15407 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15408 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15409 { } /* end */
15410};
15411
15412static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15413 .ops = &snd_hda_bind_vol,
15414 .values = {
15415 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15416 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15417 0
15418 },
15419};
15420
15421static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15422 .ops = &snd_hda_bind_sw,
15423 .values = {
15424 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15425 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15426 0
15427 },
15428};
15429
15430static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15431 HDA_BIND_VOL("Master Playback Volume",
15432 &alc663_asus_two_bind_master_vol),
15433 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15434 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015435 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15436 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15437 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015438 { } /* end */
15439};
15440
15441static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15442 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15443 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15444 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15445 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15446 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15447 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015448 { } /* end */
15449};
15450
15451static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15452 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15453 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15454 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15455 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15456 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15457
15458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15459 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15460 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15461 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15462 { } /* end */
15463};
15464
15465static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15466 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15467 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15468 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15469
15470 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15471 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15472 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15473 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15474 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15475 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15476 { } /* end */
15477};
15478
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015479static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15480 {
15481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15482 .name = "Channel Mode",
15483 .info = alc_ch_mode_info,
15484 .get = alc_ch_mode_get,
15485 .put = alc_ch_mode_put,
15486 },
15487 { } /* end */
15488};
15489
15490static struct hda_verb alc662_init_verbs[] = {
15491 /* ADC: mute amp left and right */
15492 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15493 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15494 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15495
Takashi Iwaicb53c622007-08-10 17:21:45 +020015496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15499 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015501
Kailang Yangb60dd392007-09-20 12:50:29 +020015502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15506 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015508
15509 /* Front Pin: output 0 (0x0c) */
15510 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15511 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15512
15513 /* Rear Pin: output 1 (0x0d) */
15514 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15515 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15516
15517 /* CLFE Pin: output 2 (0x0e) */
15518 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15519 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15520
15521 /* Mic (rear) pin: input vref at 80% */
15522 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15523 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15524 /* Front Mic pin: input vref at 80% */
15525 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15526 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15527 /* Line In pin: input */
15528 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15529 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15530 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15531 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15532 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15533 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15534 /* CD pin widget for input */
15535 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15536
15537 /* FIXME: use matrix-type input source selection */
15538 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15539 /* Input mixer */
15540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15543 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015544
15545 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15546 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15547 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15548 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015549
15550 /* always trun on EAPD */
15551 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15552 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15553
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015554 { }
15555};
15556
15557static struct hda_verb alc662_sue_init_verbs[] = {
15558 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15559 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015560 {}
15561};
15562
15563static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15564 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15565 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15566 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015567};
15568
Kailang Yang8c427222008-01-10 13:03:59 +010015569/* Set Unsolicited Event*/
15570static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15571 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15572 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15573 {}
15574};
15575
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015576/*
15577 * generic initialization of ADC, input mixers and output mixers
15578 */
15579static struct hda_verb alc662_auto_init_verbs[] = {
15580 /*
15581 * Unmute ADC and set the default input to mic-in
15582 */
15583 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15584 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15585
15586 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15587 * mixer widget
15588 * Note: PASD motherboards uses the Line In 2 as the input for front
15589 * panel mic (mic 2)
15590 */
15591 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015592 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15593 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15594 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15595 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15596 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015597
15598 /*
15599 * Set up output mixers (0x0c - 0x0f)
15600 */
15601 /* set vol=0 to output mixers */
15602 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15603 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15604 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15605
15606 /* set up input amps for analog loopback */
15607 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015608 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15609 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15610 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15611 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15612 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15613 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015614
15615
15616 /* FIXME: use matrix-type input source selection */
15617 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15618 /* Input mixer */
15619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015620 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015621 { }
15622};
15623
Takashi Iwai24fb9172008-09-02 14:48:20 +020015624/* additional verbs for ALC663 */
15625static struct hda_verb alc663_auto_init_verbs[] = {
15626 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15627 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15628 { }
15629};
15630
Kailang Yang6dda9f42008-05-27 12:05:31 +020015631static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015632 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15633 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015634 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15635 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015636 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15637 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015639 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15640 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15641 {}
15642};
15643
Kailang Yangf1d4e282008-08-26 14:03:29 +020015644static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15645 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15646 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15647 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15648 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15649 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15650 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15651 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15652 {}
15653};
15654
15655static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15656 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15657 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15658 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15659 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15660 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15661 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15662 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15663 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15664 {}
15665};
15666
15667static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15668 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15669 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15670 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15673 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15674 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15675 {}
15676};
15677
15678static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15679 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15680 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15681 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15682 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15683 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15686 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15687 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15688 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15689 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15690 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15691 {}
15692};
15693
15694static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15695 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15696 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15697 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15698 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15699 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15701 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15702 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15703 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15704 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15705 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15706 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15707 {}
15708};
15709
Kailang Yang6dda9f42008-05-27 12:05:31 +020015710static struct hda_verb alc663_g71v_init_verbs[] = {
15711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15712 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15713 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15714
15715 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15716 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15717 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15718
15719 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15720 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15721 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15722 {}
15723};
15724
15725static struct hda_verb alc663_g50v_init_verbs[] = {
15726 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15727 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15728 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15729
15730 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15731 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15732 {}
15733};
15734
Kailang Yangf1d4e282008-08-26 14:03:29 +020015735static struct hda_verb alc662_ecs_init_verbs[] = {
15736 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15738 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15739 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15740 {}
15741};
15742
Kailang Yangf1d4e282008-08-26 14:03:29 +020015743static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15744 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15745 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15746 { } /* end */
15747};
15748
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015749static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15750{
15751 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015752 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015753
15754 present = snd_hda_codec_read(codec, 0x14, 0,
15755 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015756 bits = present ? HDA_AMP_MUTE : 0;
15757 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15758 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015759}
15760
15761static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15762{
15763 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015764 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015765
15766 present = snd_hda_codec_read(codec, 0x1b, 0,
15767 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015768 bits = present ? HDA_AMP_MUTE : 0;
15769 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15770 HDA_AMP_MUTE, bits);
15771 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15772 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015773}
15774
15775static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15776 unsigned int res)
15777{
15778 if ((res >> 26) == ALC880_HP_EVENT)
15779 alc662_lenovo_101e_all_automute(codec);
15780 if ((res >> 26) == ALC880_FRONT_EVENT)
15781 alc662_lenovo_101e_ispeaker_automute(codec);
15782}
15783
Kailang Yang291702f2007-10-16 14:28:03 +020015784static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15785{
15786 unsigned int present;
15787
15788 present = snd_hda_codec_read(codec, 0x18, 0,
15789 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15790 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15791 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15792 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15793 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15794 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15795 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15796 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15797 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15798}
15799
15800/* unsolicited event for HP jack sensing */
15801static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15802 unsigned int res)
15803{
15804 if ((res >> 26) == ALC880_HP_EVENT)
15805 alc262_hippo1_automute( codec );
15806
15807 if ((res >> 26) == ALC880_MIC_EVENT)
15808 alc662_eeepc_mic_automute(codec);
15809}
15810
15811static void alc662_eeepc_inithook(struct hda_codec *codec)
15812{
15813 alc262_hippo1_automute( codec );
15814 alc662_eeepc_mic_automute(codec);
15815}
15816
Kailang Yang8c427222008-01-10 13:03:59 +010015817static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15818{
15819 unsigned int mute;
15820 unsigned int present;
15821
15822 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15823 present = snd_hda_codec_read(codec, 0x14, 0,
15824 AC_VERB_GET_PIN_SENSE, 0);
15825 present = (present & 0x80000000) != 0;
15826 if (present) {
15827 /* mute internal speaker */
15828 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015829 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015830 } else {
15831 /* unmute internal speaker if necessary */
15832 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15833 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015834 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015835 }
15836}
15837
15838/* unsolicited event for HP jack sensing */
15839static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15840 unsigned int res)
15841{
15842 if ((res >> 26) == ALC880_HP_EVENT)
15843 alc662_eeepc_ep20_automute(codec);
15844}
15845
15846static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15847{
15848 alc662_eeepc_ep20_automute(codec);
15849}
15850
Kailang Yang6dda9f42008-05-27 12:05:31 +020015851static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15852{
15853 unsigned int present;
15854 unsigned char bits;
15855
15856 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015857 AC_VERB_GET_PIN_SENSE, 0)
15858 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015859 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015860 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15861 AMP_IN_MUTE(0), bits);
15862 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15863 AMP_IN_MUTE(0), bits);
15864}
15865
15866static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15867{
15868 unsigned int present;
15869 unsigned char bits;
15870
15871 present = snd_hda_codec_read(codec, 0x21, 0,
15872 AC_VERB_GET_PIN_SENSE, 0)
15873 & AC_PINSENSE_PRESENCE;
15874 bits = present ? HDA_AMP_MUTE : 0;
15875 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15876 AMP_IN_MUTE(0), bits);
15877 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15878 AMP_IN_MUTE(0), bits);
15879 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15880 AMP_IN_MUTE(0), bits);
15881 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15882 AMP_IN_MUTE(0), bits);
15883}
15884
15885static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15886{
15887 unsigned int present;
15888 unsigned char bits;
15889
15890 present = snd_hda_codec_read(codec, 0x15, 0,
15891 AC_VERB_GET_PIN_SENSE, 0)
15892 & AC_PINSENSE_PRESENCE;
15893 bits = present ? HDA_AMP_MUTE : 0;
15894 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15895 AMP_IN_MUTE(0), bits);
15896 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15897 AMP_IN_MUTE(0), bits);
15898 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15899 AMP_IN_MUTE(0), bits);
15900 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15901 AMP_IN_MUTE(0), bits);
15902}
15903
15904static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15905{
15906 unsigned int present;
15907 unsigned char bits;
15908
15909 present = snd_hda_codec_read(codec, 0x1b, 0,
15910 AC_VERB_GET_PIN_SENSE, 0)
15911 & AC_PINSENSE_PRESENCE;
15912 bits = present ? 0 : PIN_OUT;
15913 snd_hda_codec_write(codec, 0x14, 0,
15914 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15915}
15916
15917static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15918{
15919 unsigned int present1, present2;
15920
15921 present1 = snd_hda_codec_read(codec, 0x21, 0,
15922 AC_VERB_GET_PIN_SENSE, 0)
15923 & AC_PINSENSE_PRESENCE;
15924 present2 = snd_hda_codec_read(codec, 0x15, 0,
15925 AC_VERB_GET_PIN_SENSE, 0)
15926 & AC_PINSENSE_PRESENCE;
15927
15928 if (present1 || present2) {
15929 snd_hda_codec_write_cache(codec, 0x14, 0,
15930 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15931 } else {
15932 snd_hda_codec_write_cache(codec, 0x14, 0,
15933 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15934 }
15935}
15936
15937static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15938{
15939 unsigned int present1, present2;
15940
15941 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15942 AC_VERB_GET_PIN_SENSE, 0)
15943 & AC_PINSENSE_PRESENCE;
15944 present2 = snd_hda_codec_read(codec, 0x15, 0,
15945 AC_VERB_GET_PIN_SENSE, 0)
15946 & AC_PINSENSE_PRESENCE;
15947
15948 if (present1 || present2) {
15949 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15950 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15951 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15952 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15953 } else {
15954 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15955 AMP_IN_MUTE(0), 0);
15956 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15957 AMP_IN_MUTE(0), 0);
15958 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015959}
15960
15961static void alc663_m51va_mic_automute(struct hda_codec *codec)
15962{
15963 unsigned int present;
15964
15965 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015966 AC_VERB_GET_PIN_SENSE, 0)
15967 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015968 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015969 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015970 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015971 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015972 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015973 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015974 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015975 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015976}
15977
15978static void alc663_m51va_unsol_event(struct hda_codec *codec,
15979 unsigned int res)
15980{
15981 switch (res >> 26) {
15982 case ALC880_HP_EVENT:
15983 alc663_m51va_speaker_automute(codec);
15984 break;
15985 case ALC880_MIC_EVENT:
15986 alc663_m51va_mic_automute(codec);
15987 break;
15988 }
15989}
15990
15991static void alc663_m51va_inithook(struct hda_codec *codec)
15992{
15993 alc663_m51va_speaker_automute(codec);
15994 alc663_m51va_mic_automute(codec);
15995}
15996
Kailang Yangf1d4e282008-08-26 14:03:29 +020015997/* ***************** Mode1 ******************************/
15998static void alc663_mode1_unsol_event(struct hda_codec *codec,
15999 unsigned int res)
16000{
16001 switch (res >> 26) {
16002 case ALC880_HP_EVENT:
16003 alc663_m51va_speaker_automute(codec);
16004 break;
16005 case ALC880_MIC_EVENT:
16006 alc662_eeepc_mic_automute(codec);
16007 break;
16008 }
16009}
16010
16011static void alc663_mode1_inithook(struct hda_codec *codec)
16012{
16013 alc663_m51va_speaker_automute(codec);
16014 alc662_eeepc_mic_automute(codec);
16015}
16016/* ***************** Mode2 ******************************/
16017static void alc662_mode2_unsol_event(struct hda_codec *codec,
16018 unsigned int res)
16019{
16020 switch (res >> 26) {
16021 case ALC880_HP_EVENT:
16022 alc662_f5z_speaker_automute(codec);
16023 break;
16024 case ALC880_MIC_EVENT:
16025 alc662_eeepc_mic_automute(codec);
16026 break;
16027 }
16028}
16029
16030static void alc662_mode2_inithook(struct hda_codec *codec)
16031{
16032 alc662_f5z_speaker_automute(codec);
16033 alc662_eeepc_mic_automute(codec);
16034}
16035/* ***************** Mode3 ******************************/
16036static void alc663_mode3_unsol_event(struct hda_codec *codec,
16037 unsigned int res)
16038{
16039 switch (res >> 26) {
16040 case ALC880_HP_EVENT:
16041 alc663_two_hp_m1_speaker_automute(codec);
16042 break;
16043 case ALC880_MIC_EVENT:
16044 alc662_eeepc_mic_automute(codec);
16045 break;
16046 }
16047}
16048
16049static void alc663_mode3_inithook(struct hda_codec *codec)
16050{
16051 alc663_two_hp_m1_speaker_automute(codec);
16052 alc662_eeepc_mic_automute(codec);
16053}
16054/* ***************** Mode4 ******************************/
16055static void alc663_mode4_unsol_event(struct hda_codec *codec,
16056 unsigned int res)
16057{
16058 switch (res >> 26) {
16059 case ALC880_HP_EVENT:
16060 alc663_21jd_two_speaker_automute(codec);
16061 break;
16062 case ALC880_MIC_EVENT:
16063 alc662_eeepc_mic_automute(codec);
16064 break;
16065 }
16066}
16067
16068static void alc663_mode4_inithook(struct hda_codec *codec)
16069{
16070 alc663_21jd_two_speaker_automute(codec);
16071 alc662_eeepc_mic_automute(codec);
16072}
16073/* ***************** Mode5 ******************************/
16074static void alc663_mode5_unsol_event(struct hda_codec *codec,
16075 unsigned int res)
16076{
16077 switch (res >> 26) {
16078 case ALC880_HP_EVENT:
16079 alc663_15jd_two_speaker_automute(codec);
16080 break;
16081 case ALC880_MIC_EVENT:
16082 alc662_eeepc_mic_automute(codec);
16083 break;
16084 }
16085}
16086
16087static void alc663_mode5_inithook(struct hda_codec *codec)
16088{
16089 alc663_15jd_two_speaker_automute(codec);
16090 alc662_eeepc_mic_automute(codec);
16091}
16092/* ***************** Mode6 ******************************/
16093static void alc663_mode6_unsol_event(struct hda_codec *codec,
16094 unsigned int res)
16095{
16096 switch (res >> 26) {
16097 case ALC880_HP_EVENT:
16098 alc663_two_hp_m2_speaker_automute(codec);
16099 break;
16100 case ALC880_MIC_EVENT:
16101 alc662_eeepc_mic_automute(codec);
16102 break;
16103 }
16104}
16105
16106static void alc663_mode6_inithook(struct hda_codec *codec)
16107{
16108 alc663_two_hp_m2_speaker_automute(codec);
16109 alc662_eeepc_mic_automute(codec);
16110}
16111
Kailang Yang6dda9f42008-05-27 12:05:31 +020016112static void alc663_g71v_hp_automute(struct hda_codec *codec)
16113{
16114 unsigned int present;
16115 unsigned char bits;
16116
16117 present = snd_hda_codec_read(codec, 0x21, 0,
16118 AC_VERB_GET_PIN_SENSE, 0)
16119 & AC_PINSENSE_PRESENCE;
16120 bits = present ? HDA_AMP_MUTE : 0;
16121 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16122 HDA_AMP_MUTE, bits);
16123 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16124 HDA_AMP_MUTE, bits);
16125}
16126
16127static void alc663_g71v_front_automute(struct hda_codec *codec)
16128{
16129 unsigned int present;
16130 unsigned char bits;
16131
16132 present = snd_hda_codec_read(codec, 0x15, 0,
16133 AC_VERB_GET_PIN_SENSE, 0)
16134 & AC_PINSENSE_PRESENCE;
16135 bits = present ? HDA_AMP_MUTE : 0;
16136 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16137 HDA_AMP_MUTE, bits);
16138}
16139
16140static void alc663_g71v_unsol_event(struct hda_codec *codec,
16141 unsigned int res)
16142{
16143 switch (res >> 26) {
16144 case ALC880_HP_EVENT:
16145 alc663_g71v_hp_automute(codec);
16146 break;
16147 case ALC880_FRONT_EVENT:
16148 alc663_g71v_front_automute(codec);
16149 break;
16150 case ALC880_MIC_EVENT:
16151 alc662_eeepc_mic_automute(codec);
16152 break;
16153 }
16154}
16155
16156static void alc663_g71v_inithook(struct hda_codec *codec)
16157{
16158 alc663_g71v_front_automute(codec);
16159 alc663_g71v_hp_automute(codec);
16160 alc662_eeepc_mic_automute(codec);
16161}
16162
16163static void alc663_g50v_unsol_event(struct hda_codec *codec,
16164 unsigned int res)
16165{
16166 switch (res >> 26) {
16167 case ALC880_HP_EVENT:
16168 alc663_m51va_speaker_automute(codec);
16169 break;
16170 case ALC880_MIC_EVENT:
16171 alc662_eeepc_mic_automute(codec);
16172 break;
16173 }
16174}
16175
16176static void alc663_g50v_inithook(struct hda_codec *codec)
16177{
16178 alc663_m51va_speaker_automute(codec);
16179 alc662_eeepc_mic_automute(codec);
16180}
16181
Kailang Yangf1d4e282008-08-26 14:03:29 +020016182/* bind hp and internal speaker mute (with plug check) */
16183static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16184 struct snd_ctl_elem_value *ucontrol)
16185{
16186 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16187 long *valp = ucontrol->value.integer.value;
16188 int change;
16189
16190 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16191 HDA_AMP_MUTE,
16192 valp[0] ? 0 : HDA_AMP_MUTE);
16193 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16194 HDA_AMP_MUTE,
16195 valp[1] ? 0 : HDA_AMP_MUTE);
16196 if (change)
16197 alc262_hippo1_automute(codec);
16198 return change;
16199}
16200
16201static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16202 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16203 {
16204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16205 .name = "Master Playback Switch",
16206 .info = snd_hda_mixer_amp_switch_info,
16207 .get = snd_hda_mixer_amp_switch_get,
16208 .put = alc662_ecs_master_sw_put,
16209 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16210 },
16211
16212 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16213 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16214 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16215
16216 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16217 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16218 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16219 { } /* end */
16220};
16221
Takashi Iwaicb53c622007-08-10 17:21:45 +020016222#ifdef CONFIG_SND_HDA_POWER_SAVE
16223#define alc662_loopbacks alc880_loopbacks
16224#endif
16225
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016226
16227/* pcm configuration: identiacal with ALC880 */
16228#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16229#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16230#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16231#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16232
16233/*
16234 * configuration and preset
16235 */
16236static const char *alc662_models[ALC662_MODEL_LAST] = {
16237 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16238 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16239 [ALC662_3ST_6ch] = "3stack-6ch",
16240 [ALC662_5ST_DIG] = "6stack-dig",
16241 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016242 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016243 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016244 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016245 [ALC663_ASUS_M51VA] = "m51va",
16246 [ALC663_ASUS_G71V] = "g71v",
16247 [ALC663_ASUS_H13] = "h13",
16248 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016249 [ALC663_ASUS_MODE1] = "asus-mode1",
16250 [ALC662_ASUS_MODE2] = "asus-mode2",
16251 [ALC663_ASUS_MODE3] = "asus-mode3",
16252 [ALC663_ASUS_MODE4] = "asus-mode4",
16253 [ALC663_ASUS_MODE5] = "asus-mode5",
16254 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016255 [ALC662_AUTO] = "auto",
16256};
16257
16258static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016259 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16260 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16261 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16262 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16263 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16264 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16265 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16266 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16267 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16268 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16269 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16270 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16271 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16272 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16273 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16274 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16275 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16276 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16277 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016278 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016279 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16280 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16281 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16282 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16283 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16284 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16285 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16286 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16287 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016288 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016289 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16290 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16291 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16292 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16293 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016294 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016295 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016296 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016297 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016298 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16299 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016300 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16301 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016302 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016303 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016304 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016305 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016306 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16307 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016308 {}
16309};
16310
16311static struct alc_config_preset alc662_presets[] = {
16312 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016313 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016314 .init_verbs = { alc662_init_verbs },
16315 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16316 .dac_nids = alc662_dac_nids,
16317 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016318 .dig_in_nid = ALC662_DIGIN_NID,
16319 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16320 .channel_mode = alc662_3ST_2ch_modes,
16321 .input_mux = &alc662_capture_source,
16322 },
16323 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016324 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016325 .init_verbs = { alc662_init_verbs },
16326 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16327 .dac_nids = alc662_dac_nids,
16328 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016329 .dig_in_nid = ALC662_DIGIN_NID,
16330 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16331 .channel_mode = alc662_3ST_6ch_modes,
16332 .need_dac_fix = 1,
16333 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016334 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016335 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016336 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016337 .init_verbs = { alc662_init_verbs },
16338 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16339 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016340 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16341 .channel_mode = alc662_3ST_6ch_modes,
16342 .need_dac_fix = 1,
16343 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016344 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016345 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016346 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016347 .init_verbs = { alc662_init_verbs },
16348 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16349 .dac_nids = alc662_dac_nids,
16350 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016351 .dig_in_nid = ALC662_DIGIN_NID,
16352 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16353 .channel_mode = alc662_5stack_modes,
16354 .input_mux = &alc662_capture_source,
16355 },
16356 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016357 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016358 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16359 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16360 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016361 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16362 .channel_mode = alc662_3ST_2ch_modes,
16363 .input_mux = &alc662_lenovo_101e_capture_source,
16364 .unsol_event = alc662_lenovo_101e_unsol_event,
16365 .init_hook = alc662_lenovo_101e_all_automute,
16366 },
Kailang Yang291702f2007-10-16 14:28:03 +020016367 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016368 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016369 .init_verbs = { alc662_init_verbs,
16370 alc662_eeepc_sue_init_verbs },
16371 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16372 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016373 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16374 .channel_mode = alc662_3ST_2ch_modes,
16375 .input_mux = &alc662_eeepc_capture_source,
16376 .unsol_event = alc662_eeepc_unsol_event,
16377 .init_hook = alc662_eeepc_inithook,
16378 },
Kailang Yang8c427222008-01-10 13:03:59 +010016379 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016380 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016381 alc662_chmode_mixer },
16382 .init_verbs = { alc662_init_verbs,
16383 alc662_eeepc_ep20_sue_init_verbs },
16384 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16385 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016386 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16387 .channel_mode = alc662_3ST_6ch_modes,
16388 .input_mux = &alc662_lenovo_101e_capture_source,
16389 .unsol_event = alc662_eeepc_ep20_unsol_event,
16390 .init_hook = alc662_eeepc_ep20_inithook,
16391 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016392 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016393 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016394 .init_verbs = { alc662_init_verbs,
16395 alc662_ecs_init_verbs },
16396 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16397 .dac_nids = alc662_dac_nids,
16398 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16399 .channel_mode = alc662_3ST_2ch_modes,
16400 .input_mux = &alc662_eeepc_capture_source,
16401 .unsol_event = alc662_eeepc_unsol_event,
16402 .init_hook = alc662_eeepc_inithook,
16403 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016404 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016405 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016406 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16407 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16408 .dac_nids = alc662_dac_nids,
16409 .dig_out_nid = ALC662_DIGOUT_NID,
16410 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16411 .channel_mode = alc662_3ST_2ch_modes,
16412 .input_mux = &alc663_m51va_capture_source,
16413 .unsol_event = alc663_m51va_unsol_event,
16414 .init_hook = alc663_m51va_inithook,
16415 },
16416 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016417 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016418 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16419 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16420 .dac_nids = alc662_dac_nids,
16421 .dig_out_nid = ALC662_DIGOUT_NID,
16422 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16423 .channel_mode = alc662_3ST_2ch_modes,
16424 .input_mux = &alc662_eeepc_capture_source,
16425 .unsol_event = alc663_g71v_unsol_event,
16426 .init_hook = alc663_g71v_inithook,
16427 },
16428 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016429 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016430 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16431 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16432 .dac_nids = alc662_dac_nids,
16433 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16434 .channel_mode = alc662_3ST_2ch_modes,
16435 .input_mux = &alc663_m51va_capture_source,
16436 .unsol_event = alc663_m51va_unsol_event,
16437 .init_hook = alc663_m51va_inithook,
16438 },
16439 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016440 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016441 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16442 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16443 .dac_nids = alc662_dac_nids,
16444 .dig_out_nid = ALC662_DIGOUT_NID,
16445 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16446 .channel_mode = alc662_3ST_6ch_modes,
16447 .input_mux = &alc663_capture_source,
16448 .unsol_event = alc663_g50v_unsol_event,
16449 .init_hook = alc663_g50v_inithook,
16450 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016451 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016452 .mixers = { alc663_m51va_mixer },
16453 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016454 .init_verbs = { alc662_init_verbs,
16455 alc663_21jd_amic_init_verbs },
16456 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16457 .hp_nid = 0x03,
16458 .dac_nids = alc662_dac_nids,
16459 .dig_out_nid = ALC662_DIGOUT_NID,
16460 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16461 .channel_mode = alc662_3ST_2ch_modes,
16462 .input_mux = &alc662_eeepc_capture_source,
16463 .unsol_event = alc663_mode1_unsol_event,
16464 .init_hook = alc663_mode1_inithook,
16465 },
16466 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016467 .mixers = { alc662_1bjd_mixer },
16468 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016469 .init_verbs = { alc662_init_verbs,
16470 alc662_1bjd_amic_init_verbs },
16471 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16472 .dac_nids = alc662_dac_nids,
16473 .dig_out_nid = ALC662_DIGOUT_NID,
16474 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16475 .channel_mode = alc662_3ST_2ch_modes,
16476 .input_mux = &alc662_eeepc_capture_source,
16477 .unsol_event = alc662_mode2_unsol_event,
16478 .init_hook = alc662_mode2_inithook,
16479 },
16480 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016481 .mixers = { alc663_two_hp_m1_mixer },
16482 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016483 .init_verbs = { alc662_init_verbs,
16484 alc663_two_hp_amic_m1_init_verbs },
16485 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16486 .hp_nid = 0x03,
16487 .dac_nids = alc662_dac_nids,
16488 .dig_out_nid = ALC662_DIGOUT_NID,
16489 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16490 .channel_mode = alc662_3ST_2ch_modes,
16491 .input_mux = &alc662_eeepc_capture_source,
16492 .unsol_event = alc663_mode3_unsol_event,
16493 .init_hook = alc663_mode3_inithook,
16494 },
16495 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016496 .mixers = { alc663_asus_21jd_clfe_mixer },
16497 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016498 .init_verbs = { alc662_init_verbs,
16499 alc663_21jd_amic_init_verbs},
16500 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16501 .hp_nid = 0x03,
16502 .dac_nids = alc662_dac_nids,
16503 .dig_out_nid = ALC662_DIGOUT_NID,
16504 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16505 .channel_mode = alc662_3ST_2ch_modes,
16506 .input_mux = &alc662_eeepc_capture_source,
16507 .unsol_event = alc663_mode4_unsol_event,
16508 .init_hook = alc663_mode4_inithook,
16509 },
16510 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016511 .mixers = { alc663_asus_15jd_clfe_mixer },
16512 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016513 .init_verbs = { alc662_init_verbs,
16514 alc663_15jd_amic_init_verbs },
16515 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16516 .hp_nid = 0x03,
16517 .dac_nids = alc662_dac_nids,
16518 .dig_out_nid = ALC662_DIGOUT_NID,
16519 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16520 .channel_mode = alc662_3ST_2ch_modes,
16521 .input_mux = &alc662_eeepc_capture_source,
16522 .unsol_event = alc663_mode5_unsol_event,
16523 .init_hook = alc663_mode5_inithook,
16524 },
16525 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016526 .mixers = { alc663_two_hp_m2_mixer },
16527 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016528 .init_verbs = { alc662_init_verbs,
16529 alc663_two_hp_amic_m2_init_verbs },
16530 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16531 .hp_nid = 0x03,
16532 .dac_nids = alc662_dac_nids,
16533 .dig_out_nid = ALC662_DIGOUT_NID,
16534 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16535 .channel_mode = alc662_3ST_2ch_modes,
16536 .input_mux = &alc662_eeepc_capture_source,
16537 .unsol_event = alc663_mode6_unsol_event,
16538 .init_hook = alc663_mode6_inithook,
16539 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016540};
16541
16542
16543/*
16544 * BIOS auto configuration
16545 */
16546
16547/* add playback controls from the parsed DAC table */
16548static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16549 const struct auto_pin_cfg *cfg)
16550{
16551 char name[32];
16552 static const char *chname[4] = {
16553 "Front", "Surround", NULL /*CLFE*/, "Side"
16554 };
16555 hda_nid_t nid;
16556 int i, err;
16557
16558 for (i = 0; i < cfg->line_outs; i++) {
16559 if (!spec->multiout.dac_nids[i])
16560 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016561 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016562 if (i == 2) {
16563 /* Center/LFE */
16564 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16565 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016566 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16567 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016568 if (err < 0)
16569 return err;
16570 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16571 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016572 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16573 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016574 if (err < 0)
16575 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016576 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016577 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016578 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016579 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016580 if (err < 0)
16581 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016582 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016583 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016584 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016585 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016586 if (err < 0)
16587 return err;
16588 } else {
16589 sprintf(name, "%s Playback Volume", chname[i]);
16590 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016591 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16592 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016593 if (err < 0)
16594 return err;
16595 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016596 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16597 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16598 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016599 if (err < 0)
16600 return err;
16601 }
16602 }
16603 return 0;
16604}
16605
16606/* add playback controls for speaker and HP outputs */
16607static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16608 const char *pfx)
16609{
16610 hda_nid_t nid;
16611 int err;
16612 char name[32];
16613
16614 if (!pin)
16615 return 0;
16616
Takashi Iwai24fb9172008-09-02 14:48:20 +020016617 if (pin == 0x17) {
16618 /* ALC663 has a mono output pin on 0x17 */
16619 sprintf(name, "%s Playback Switch", pfx);
16620 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16621 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16622 return err;
16623 }
16624
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016625 if (alc880_is_fixed_pin(pin)) {
16626 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016627 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016628 /* specify the DAC as the extra output */
16629 if (!spec->multiout.hp_nid)
16630 spec->multiout.hp_nid = nid;
16631 else
16632 spec->multiout.extra_out_nid[0] = nid;
16633 /* control HP volume/switch on the output mixer amp */
16634 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16635 sprintf(name, "%s Playback Volume", pfx);
16636 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16637 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16638 if (err < 0)
16639 return err;
16640 sprintf(name, "%s Playback Switch", pfx);
16641 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16642 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16643 if (err < 0)
16644 return err;
16645 } else if (alc880_is_multi_pin(pin)) {
16646 /* set manual connection */
16647 /* we have only a switch on HP-out PIN */
16648 sprintf(name, "%s Playback Switch", pfx);
16649 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16650 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16651 if (err < 0)
16652 return err;
16653 }
16654 return 0;
16655}
16656
16657/* create playback/capture controls for input pins */
16658static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16659 const struct auto_pin_cfg *cfg)
16660{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016661 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016662 int i, err, idx;
16663
16664 for (i = 0; i < AUTO_PIN_LAST; i++) {
16665 if (alc880_is_input_pin(cfg->input_pins[i])) {
16666 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16667 err = new_analog_input(spec, cfg->input_pins[i],
16668 auto_pin_cfg_labels[i],
16669 idx, 0x0b);
16670 if (err < 0)
16671 return err;
16672 imux->items[imux->num_items].label =
16673 auto_pin_cfg_labels[i];
16674 imux->items[imux->num_items].index =
16675 alc880_input_pin_idx(cfg->input_pins[i]);
16676 imux->num_items++;
16677 }
16678 }
16679 return 0;
16680}
16681
16682static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16683 hda_nid_t nid, int pin_type,
16684 int dac_idx)
16685{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016686 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016687 /* need the manual connection? */
16688 if (alc880_is_multi_pin(nid)) {
16689 struct alc_spec *spec = codec->spec;
16690 int idx = alc880_multi_pin_idx(nid);
16691 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16692 AC_VERB_SET_CONNECT_SEL,
16693 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16694 }
16695}
16696
16697static void alc662_auto_init_multi_out(struct hda_codec *codec)
16698{
16699 struct alc_spec *spec = codec->spec;
16700 int i;
16701
Kailang Yang8c427222008-01-10 13:03:59 +010016702 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016703 for (i = 0; i <= HDA_SIDE; i++) {
16704 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016705 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016706 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016707 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016708 i);
16709 }
16710}
16711
16712static void alc662_auto_init_hp_out(struct hda_codec *codec)
16713{
16714 struct alc_spec *spec = codec->spec;
16715 hda_nid_t pin;
16716
16717 pin = spec->autocfg.hp_pins[0];
16718 if (pin) /* connect to front */
16719 /* use dac 0 */
16720 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016721 pin = spec->autocfg.speaker_pins[0];
16722 if (pin)
16723 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016724}
16725
16726#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16727#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16728
16729static void alc662_auto_init_analog_input(struct hda_codec *codec)
16730{
16731 struct alc_spec *spec = codec->spec;
16732 int i;
16733
16734 for (i = 0; i < AUTO_PIN_LAST; i++) {
16735 hda_nid_t nid = spec->autocfg.input_pins[i];
16736 if (alc662_is_input_pin(nid)) {
16737 snd_hda_codec_write(codec, nid, 0,
16738 AC_VERB_SET_PIN_WIDGET_CONTROL,
16739 (i <= AUTO_PIN_FRONT_MIC ?
16740 PIN_VREF80 : PIN_IN));
16741 if (nid != ALC662_PIN_CD_NID)
16742 snd_hda_codec_write(codec, nid, 0,
16743 AC_VERB_SET_AMP_GAIN_MUTE,
16744 AMP_OUT_MUTE);
16745 }
16746 }
16747}
16748
Takashi Iwaif511b012008-08-15 16:46:42 +020016749#define alc662_auto_init_input_src alc882_auto_init_input_src
16750
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016751static int alc662_parse_auto_config(struct hda_codec *codec)
16752{
16753 struct alc_spec *spec = codec->spec;
16754 int err;
16755 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16756
16757 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16758 alc662_ignore);
16759 if (err < 0)
16760 return err;
16761 if (!spec->autocfg.line_outs)
16762 return 0; /* can't find valid BIOS pin config */
16763
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016764 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16765 if (err < 0)
16766 return err;
16767 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16768 if (err < 0)
16769 return err;
16770 err = alc662_auto_create_extra_out(spec,
16771 spec->autocfg.speaker_pins[0],
16772 "Speaker");
16773 if (err < 0)
16774 return err;
16775 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16776 "Headphone");
16777 if (err < 0)
16778 return err;
16779 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16780 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016781 return err;
16782
16783 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16784
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016785 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016786 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16787
Takashi Iwai603c4012008-07-30 15:01:44 +020016788 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016789 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016790
16791 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016792 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016793
Takashi Iwaid88897e2008-10-31 15:01:37 +010016794 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016795 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016796 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016797
16798 err = alc_auto_add_mic_boost(codec);
16799 if (err < 0)
16800 return err;
16801
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016802 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016803}
16804
16805/* additional initialization for auto-configuration model */
16806static void alc662_auto_init(struct hda_codec *codec)
16807{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016808 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016809 alc662_auto_init_multi_out(codec);
16810 alc662_auto_init_hp_out(codec);
16811 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016812 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016813 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016814 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016815}
16816
16817static int patch_alc662(struct hda_codec *codec)
16818{
16819 struct alc_spec *spec;
16820 int err, board_config;
16821
16822 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16823 if (!spec)
16824 return -ENOMEM;
16825
16826 codec->spec = spec;
16827
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016828 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16829
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016830 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16831 alc662_models,
16832 alc662_cfg_tbl);
16833 if (board_config < 0) {
16834 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16835 "trying auto-probe from BIOS...\n");
16836 board_config = ALC662_AUTO;
16837 }
16838
16839 if (board_config == ALC662_AUTO) {
16840 /* automatic parse from the BIOS config */
16841 err = alc662_parse_auto_config(codec);
16842 if (err < 0) {
16843 alc_free(codec);
16844 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016845 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016846 printk(KERN_INFO
16847 "hda_codec: Cannot set up configuration "
16848 "from BIOS. Using base mode...\n");
16849 board_config = ALC662_3ST_2ch_DIG;
16850 }
16851 }
16852
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016853 err = snd_hda_attach_beep_device(codec, 0x1);
16854 if (err < 0) {
16855 alc_free(codec);
16856 return err;
16857 }
16858
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016859 if (board_config != ALC662_AUTO)
16860 setup_preset(spec, &alc662_presets[board_config]);
16861
Kailang Yang6dda9f42008-05-27 12:05:31 +020016862 if (codec->vendor_id == 0x10ec0663) {
16863 spec->stream_name_analog = "ALC663 Analog";
16864 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016865 } else if (codec->vendor_id == 0x10ec0272) {
16866 spec->stream_name_analog = "ALC272 Analog";
16867 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016868 } else {
16869 spec->stream_name_analog = "ALC662 Analog";
16870 spec->stream_name_digital = "ALC662 Digital";
16871 }
16872
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016873 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16874 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16875
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016876 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16877 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16878
Takashi Iwaie1406342008-02-11 18:32:32 +010016879 spec->adc_nids = alc662_adc_nids;
16880 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16881 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016882 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016883
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016884 if (!spec->cap_mixer)
16885 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016886 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016887
Takashi Iwai2134ea42008-01-10 16:53:55 +010016888 spec->vmaster_nid = 0x02;
16889
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016890 codec->patch_ops = alc_patch_ops;
16891 if (board_config == ALC662_AUTO)
16892 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016893#ifdef CONFIG_SND_HDA_POWER_SAVE
16894 if (!spec->loopback.amplist)
16895 spec->loopback.amplist = alc662_loopbacks;
16896#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016897 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016898
16899 return 0;
16900}
16901
16902/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016903 * patch entries
16904 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016905static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016906 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016907 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016908 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016909 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016910 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016911 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016912 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016913 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016914 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16915 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16916 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016917 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16918 .patch = patch_alc883 },
16919 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16920 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016921 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016922 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016923 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016924 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016925 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16926 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016927 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016928 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016929 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016930 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016931 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16932 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016933 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016934 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016935 {} /* terminator */
16936};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016937
16938MODULE_ALIAS("snd-hda-codec-id:10ec*");
16939
16940MODULE_LICENSE("GPL");
16941MODULE_DESCRIPTION("Realtek HD-audio codec");
16942
16943static struct hda_codec_preset_list realtek_list = {
16944 .preset = snd_hda_preset_realtek,
16945 .owner = THIS_MODULE,
16946};
16947
16948static int __init patch_realtek_init(void)
16949{
16950 return snd_hda_add_codec_preset(&realtek_list);
16951}
16952
16953static void __exit patch_realtek_exit(void)
16954{
16955 snd_hda_delete_codec_preset(&realtek_list);
16956}
16957
16958module_init(patch_realtek_init)
16959module_exit(patch_realtek_exit)