blob: d670d33cfa17294fc4a35952cfceeb527fdaed71 [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),
Takashi Iwaif872a912009-02-26 00:57:01 +010010827 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10828 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010829 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010830 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010831 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010832 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010833 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010834 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010835 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10836 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010837 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010838 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010839 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010840 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010841 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010842 {}
10843};
10844
10845static struct alc_config_preset alc262_presets[] = {
10846 [ALC262_BASIC] = {
10847 .mixers = { alc262_base_mixer },
10848 .init_verbs = { alc262_init_verbs },
10849 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10850 .dac_nids = alc262_dac_nids,
10851 .hp_nid = 0x03,
10852 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10853 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010854 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010855 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010856 [ALC262_HIPPO] = {
10857 .mixers = { alc262_base_mixer },
10858 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10859 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10860 .dac_nids = alc262_dac_nids,
10861 .hp_nid = 0x03,
10862 .dig_out_nid = ALC262_DIGOUT_NID,
10863 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10864 .channel_mode = alc262_modes,
10865 .input_mux = &alc262_capture_source,
10866 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010867 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010868 },
10869 [ALC262_HIPPO_1] = {
10870 .mixers = { alc262_hippo1_mixer },
10871 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10872 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10873 .dac_nids = alc262_dac_nids,
10874 .hp_nid = 0x02,
10875 .dig_out_nid = ALC262_DIGOUT_NID,
10876 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10877 .channel_mode = alc262_modes,
10878 .input_mux = &alc262_capture_source,
10879 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010880 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010881 },
Takashi Iwai834be882006-03-01 14:16:17 +010010882 [ALC262_FUJITSU] = {
10883 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010884 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10885 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010886 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10887 .dac_nids = alc262_dac_nids,
10888 .hp_nid = 0x03,
10889 .dig_out_nid = ALC262_DIGOUT_NID,
10890 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10891 .channel_mode = alc262_modes,
10892 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010893 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010894 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010895 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010896 [ALC262_HP_BPC] = {
10897 .mixers = { alc262_HP_BPC_mixer },
10898 .init_verbs = { alc262_HP_BPC_init_verbs },
10899 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10900 .dac_nids = alc262_dac_nids,
10901 .hp_nid = 0x03,
10902 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10903 .channel_mode = alc262_modes,
10904 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010905 .unsol_event = alc262_hp_bpc_unsol_event,
10906 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010907 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010908 [ALC262_HP_BPC_D7000_WF] = {
10909 .mixers = { alc262_HP_BPC_WildWest_mixer },
10910 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10911 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10912 .dac_nids = alc262_dac_nids,
10913 .hp_nid = 0x03,
10914 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10915 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010916 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010917 .unsol_event = alc262_hp_wildwest_unsol_event,
10918 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010919 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010920 [ALC262_HP_BPC_D7000_WL] = {
10921 .mixers = { alc262_HP_BPC_WildWest_mixer,
10922 alc262_HP_BPC_WildWest_option_mixer },
10923 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10924 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10925 .dac_nids = alc262_dac_nids,
10926 .hp_nid = 0x03,
10927 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10928 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010929 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010930 .unsol_event = alc262_hp_wildwest_unsol_event,
10931 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010932 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010933 [ALC262_HP_TC_T5735] = {
10934 .mixers = { alc262_hp_t5735_mixer },
10935 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10936 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10937 .dac_nids = alc262_dac_nids,
10938 .hp_nid = 0x03,
10939 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10940 .channel_mode = alc262_modes,
10941 .input_mux = &alc262_capture_source,
10942 .unsol_event = alc262_hp_t5735_unsol_event,
10943 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010944 },
10945 [ALC262_HP_RP5700] = {
10946 .mixers = { alc262_hp_rp5700_mixer },
10947 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10948 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10949 .dac_nids = alc262_dac_nids,
10950 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10951 .channel_mode = alc262_modes,
10952 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010953 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010954 [ALC262_BENQ_ED8] = {
10955 .mixers = { alc262_base_mixer },
10956 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10957 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10958 .dac_nids = alc262_dac_nids,
10959 .hp_nid = 0x03,
10960 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10961 .channel_mode = alc262_modes,
10962 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010963 },
Kailang Yang272a5272007-05-14 11:00:38 +020010964 [ALC262_SONY_ASSAMD] = {
10965 .mixers = { alc262_sony_mixer },
10966 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10967 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10968 .dac_nids = alc262_dac_nids,
10969 .hp_nid = 0x02,
10970 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10971 .channel_mode = alc262_modes,
10972 .input_mux = &alc262_capture_source,
10973 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010974 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010975 },
10976 [ALC262_BENQ_T31] = {
10977 .mixers = { alc262_benq_t31_mixer },
10978 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10979 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10980 .dac_nids = alc262_dac_nids,
10981 .hp_nid = 0x03,
10982 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10983 .channel_mode = alc262_modes,
10984 .input_mux = &alc262_capture_source,
10985 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010986 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010987 },
Tobin Davisf651b502007-10-26 12:40:47 +020010988 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010989 .mixers = { alc262_ultra_mixer },
10990 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010991 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010992 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10993 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010994 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10995 .channel_mode = alc262_modes,
10996 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010997 .adc_nids = alc262_adc_nids, /* ADC0 */
10998 .capsrc_nids = alc262_capsrc_nids,
10999 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011000 .unsol_event = alc262_ultra_unsol_event,
11001 .init_hook = alc262_ultra_automute,
11002 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011003 [ALC262_LENOVO_3000] = {
11004 .mixers = { alc262_lenovo_3000_mixer },
11005 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11006 alc262_lenovo_3000_unsol_verbs },
11007 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11008 .dac_nids = alc262_dac_nids,
11009 .hp_nid = 0x03,
11010 .dig_out_nid = ALC262_DIGOUT_NID,
11011 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11012 .channel_mode = alc262_modes,
11013 .input_mux = &alc262_fujitsu_capture_source,
11014 .unsol_event = alc262_lenovo_3000_unsol_event,
11015 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011016 [ALC262_NEC] = {
11017 .mixers = { alc262_nec_mixer },
11018 .init_verbs = { alc262_nec_verbs },
11019 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11020 .dac_nids = alc262_dac_nids,
11021 .hp_nid = 0x03,
11022 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11023 .channel_mode = alc262_modes,
11024 .input_mux = &alc262_capture_source,
11025 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011026 [ALC262_TOSHIBA_S06] = {
11027 .mixers = { alc262_toshiba_s06_mixer },
11028 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11029 alc262_eapd_verbs },
11030 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11031 .capsrc_nids = alc262_dmic_capsrc_nids,
11032 .dac_nids = alc262_dac_nids,
11033 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11034 .dig_out_nid = ALC262_DIGOUT_NID,
11035 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11036 .channel_mode = alc262_modes,
11037 .input_mux = &alc262_dmic_capture_source,
11038 .unsol_event = alc262_toshiba_s06_unsol_event,
11039 .init_hook = alc262_toshiba_s06_init_hook,
11040 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011041 [ALC262_TOSHIBA_RX1] = {
11042 .mixers = { alc262_toshiba_rx1_mixer },
11043 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11044 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11045 .dac_nids = alc262_dac_nids,
11046 .hp_nid = 0x03,
11047 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11048 .channel_mode = alc262_modes,
11049 .input_mux = &alc262_capture_source,
11050 .unsol_event = alc262_hippo_unsol_event,
11051 .init_hook = alc262_hippo_automute,
11052 },
Tony Vroonba340e82009-02-02 19:01:30 +000011053 [ALC262_TYAN] = {
11054 .mixers = { alc262_tyan_mixer },
11055 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11056 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11057 .dac_nids = alc262_dac_nids,
11058 .hp_nid = 0x02,
11059 .dig_out_nid = ALC262_DIGOUT_NID,
11060 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11061 .channel_mode = alc262_modes,
11062 .input_mux = &alc262_capture_source,
11063 .unsol_event = alc262_tyan_unsol_event,
11064 .init_hook = alc262_tyan_automute,
11065 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011066};
11067
11068static int patch_alc262(struct hda_codec *codec)
11069{
11070 struct alc_spec *spec;
11071 int board_config;
11072 int err;
11073
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011074 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011075 if (spec == NULL)
11076 return -ENOMEM;
11077
11078 codec->spec = spec;
11079#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011080 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11081 * under-run
11082 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011083 {
11084 int tmp;
11085 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11086 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11087 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11088 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11089 }
11090#endif
11091
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011092 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11093
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011094 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11095 alc262_models,
11096 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011097
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011098 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011099 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11100 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011101 board_config = ALC262_AUTO;
11102 }
11103
11104 if (board_config == ALC262_AUTO) {
11105 /* automatic parse from the BIOS config */
11106 err = alc262_parse_auto_config(codec);
11107 if (err < 0) {
11108 alc_free(codec);
11109 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011110 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011111 printk(KERN_INFO
11112 "hda_codec: Cannot set up configuration "
11113 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011114 board_config = ALC262_BASIC;
11115 }
11116 }
11117
Takashi Iwai07eba612009-02-19 08:06:35 +010011118 if (!spec->no_analog) {
11119 err = snd_hda_attach_beep_device(codec, 0x1);
11120 if (err < 0) {
11121 alc_free(codec);
11122 return err;
11123 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011124 }
11125
Kailang Yangdf694da2005-12-05 19:42:22 +010011126 if (board_config != ALC262_AUTO)
11127 setup_preset(spec, &alc262_presets[board_config]);
11128
11129 spec->stream_name_analog = "ALC262 Analog";
11130 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11131 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011132
Kailang Yangdf694da2005-12-05 19:42:22 +010011133 spec->stream_name_digital = "ALC262 Digital";
11134 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11135 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11136
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011137 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011138 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011139 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011140 unsigned int wcap = get_wcaps(codec, 0x07);
11141
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011142 /* get type */
11143 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011144 if (wcap != AC_WID_AUD_IN) {
11145 spec->adc_nids = alc262_adc_nids_alt;
11146 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011147 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011148 } else {
11149 spec->adc_nids = alc262_adc_nids;
11150 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011151 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011152 }
11153 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011154 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011155 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011156 if (!spec->no_analog)
11157 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011158
Takashi Iwai2134ea42008-01-10 16:53:55 +010011159 spec->vmaster_nid = 0x0c;
11160
Kailang Yangdf694da2005-12-05 19:42:22 +010011161 codec->patch_ops = alc_patch_ops;
11162 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011163 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011164#ifdef CONFIG_SND_HDA_POWER_SAVE
11165 if (!spec->loopback.amplist)
11166 spec->loopback.amplist = alc262_loopbacks;
11167#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011168 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011169
Kailang Yangdf694da2005-12-05 19:42:22 +010011170 return 0;
11171}
11172
Kailang Yangdf694da2005-12-05 19:42:22 +010011173/*
Kailang Yanga361d842007-06-05 12:30:55 +020011174 * ALC268 channel source setting (2 channel)
11175 */
11176#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11177#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011178
Kailang Yanga361d842007-06-05 12:30:55 +020011179static hda_nid_t alc268_dac_nids[2] = {
11180 /* front, hp */
11181 0x02, 0x03
11182};
11183
11184static hda_nid_t alc268_adc_nids[2] = {
11185 /* ADC0-1 */
11186 0x08, 0x07
11187};
11188
11189static hda_nid_t alc268_adc_nids_alt[1] = {
11190 /* ADC0 */
11191 0x08
11192};
11193
Takashi Iwaie1406342008-02-11 18:32:32 +010011194static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11195
Kailang Yanga361d842007-06-05 12:30:55 +020011196static struct snd_kcontrol_new alc268_base_mixer[] = {
11197 /* output mixer control */
11198 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11199 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11200 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11201 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011202 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11203 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11204 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011205 { }
11206};
11207
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011208/* bind Beep switches of both NID 0x0f and 0x10 */
11209static struct hda_bind_ctls alc268_bind_beep_sw = {
11210 .ops = &snd_hda_bind_sw,
11211 .values = {
11212 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11213 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11214 0
11215 },
11216};
11217
11218static struct snd_kcontrol_new alc268_beep_mixer[] = {
11219 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11220 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11221 { }
11222};
11223
Kailang Yangd1a991a2007-08-15 16:21:59 +020011224static struct hda_verb alc268_eapd_verbs[] = {
11225 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11226 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11227 { }
11228};
11229
Takashi Iwaid2738092007-08-16 14:59:45 +020011230/* Toshiba specific */
11231#define alc268_toshiba_automute alc262_hippo_automute
11232
11233static struct hda_verb alc268_toshiba_verbs[] = {
11234 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11235 { } /* end */
11236};
11237
Kailang Yang8ef355d2008-08-26 13:10:22 +020011238static struct hda_input_mux alc268_acer_lc_capture_source = {
11239 .num_items = 2,
11240 .items = {
11241 { "i-Mic", 0x6 },
11242 { "E-Mic", 0x0 },
11243 },
11244};
11245
Takashi Iwaid2738092007-08-16 14:59:45 +020011246/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011247/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011248static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11249 .ops = &snd_hda_bind_vol,
11250 .values = {
11251 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11252 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11253 0
11254 },
11255};
11256
Takashi Iwai889c4392007-08-23 18:56:52 +020011257/* mute/unmute internal speaker according to the hp jack and mute state */
11258static void alc268_acer_automute(struct hda_codec *codec, int force)
11259{
11260 struct alc_spec *spec = codec->spec;
11261 unsigned int mute;
11262
11263 if (force || !spec->sense_updated) {
11264 unsigned int present;
11265 present = snd_hda_codec_read(codec, 0x14, 0,
11266 AC_VERB_GET_PIN_SENSE, 0);
11267 spec->jack_present = (present & 0x80000000) != 0;
11268 spec->sense_updated = 1;
11269 }
11270 if (spec->jack_present)
11271 mute = HDA_AMP_MUTE; /* mute internal speaker */
11272 else /* unmute internal speaker if necessary */
11273 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11274 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11275 HDA_AMP_MUTE, mute);
11276}
11277
11278
11279/* bind hp and internal speaker mute (with plug check) */
11280static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11281 struct snd_ctl_elem_value *ucontrol)
11282{
11283 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11284 long *valp = ucontrol->value.integer.value;
11285 int change;
11286
11287 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11288 HDA_AMP_MUTE,
11289 valp[0] ? 0 : HDA_AMP_MUTE);
11290 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11291 HDA_AMP_MUTE,
11292 valp[1] ? 0 : HDA_AMP_MUTE);
11293 if (change)
11294 alc268_acer_automute(codec, 0);
11295 return change;
11296}
Takashi Iwaid2738092007-08-16 14:59:45 +020011297
Kailang Yang8ef355d2008-08-26 13:10:22 +020011298static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11299 /* output mixer control */
11300 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11301 {
11302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11303 .name = "Master Playback Switch",
11304 .info = snd_hda_mixer_amp_switch_info,
11305 .get = snd_hda_mixer_amp_switch_get,
11306 .put = alc268_acer_master_sw_put,
11307 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11308 },
11309 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11310 { }
11311};
11312
Takashi Iwaid2738092007-08-16 14:59:45 +020011313static struct snd_kcontrol_new alc268_acer_mixer[] = {
11314 /* output mixer control */
11315 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11316 {
11317 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11318 .name = "Master Playback Switch",
11319 .info = snd_hda_mixer_amp_switch_info,
11320 .get = snd_hda_mixer_amp_switch_get,
11321 .put = alc268_acer_master_sw_put,
11322 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11323 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011324 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11325 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11326 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011327 { }
11328};
11329
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011330static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11331 /* output mixer control */
11332 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11333 {
11334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11335 .name = "Master Playback Switch",
11336 .info = snd_hda_mixer_amp_switch_info,
11337 .get = snd_hda_mixer_amp_switch_get,
11338 .put = alc268_acer_master_sw_put,
11339 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11340 },
11341 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11342 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11343 { }
11344};
11345
Kailang Yang8ef355d2008-08-26 13:10:22 +020011346static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11347 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11348 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11349 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11350 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11351 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11352 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11353 { }
11354};
11355
Takashi Iwaid2738092007-08-16 14:59:45 +020011356static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011357 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11358 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011359 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011361 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11362 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011363 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11364 { }
11365};
11366
11367/* unsolicited event for HP jack sensing */
11368static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11369 unsigned int res)
11370{
Takashi Iwai889c4392007-08-23 18:56:52 +020011371 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011372 return;
11373 alc268_toshiba_automute(codec);
11374}
11375
11376static void alc268_acer_unsol_event(struct hda_codec *codec,
11377 unsigned int res)
11378{
Takashi Iwai889c4392007-08-23 18:56:52 +020011379 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011380 return;
11381 alc268_acer_automute(codec, 1);
11382}
11383
Takashi Iwai889c4392007-08-23 18:56:52 +020011384static void alc268_acer_init_hook(struct hda_codec *codec)
11385{
11386 alc268_acer_automute(codec, 1);
11387}
11388
Kailang Yang8ef355d2008-08-26 13:10:22 +020011389/* toggle speaker-output according to the hp-jack state */
11390static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11391{
11392 unsigned int present;
11393 unsigned char bits;
11394
11395 present = snd_hda_codec_read(codec, 0x15, 0,
11396 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11397 bits = present ? AMP_IN_MUTE(0) : 0;
11398 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11399 AMP_IN_MUTE(0), bits);
11400 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11401 AMP_IN_MUTE(0), bits);
11402}
11403
11404
11405static void alc268_acer_mic_automute(struct hda_codec *codec)
11406{
11407 unsigned int present;
11408
11409 present = snd_hda_codec_read(codec, 0x18, 0,
11410 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11411 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11412 present ? 0x0 : 0x6);
11413}
11414
11415static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11416 unsigned int res)
11417{
11418 if ((res >> 26) == ALC880_HP_EVENT)
11419 alc268_aspire_one_speaker_automute(codec);
11420 if ((res >> 26) == ALC880_MIC_EVENT)
11421 alc268_acer_mic_automute(codec);
11422}
11423
11424static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11425{
11426 alc268_aspire_one_speaker_automute(codec);
11427 alc268_acer_mic_automute(codec);
11428}
11429
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011430static struct snd_kcontrol_new alc268_dell_mixer[] = {
11431 /* output mixer control */
11432 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11433 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11434 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11435 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11436 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11437 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11438 { }
11439};
11440
11441static struct hda_verb alc268_dell_verbs[] = {
11442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11444 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11445 { }
11446};
11447
11448/* mute/unmute internal speaker according to the hp jack and mute state */
11449static void alc268_dell_automute(struct hda_codec *codec)
11450{
11451 unsigned int present;
11452 unsigned int mute;
11453
11454 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11455 if (present & 0x80000000)
11456 mute = HDA_AMP_MUTE;
11457 else
11458 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11459 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11460 HDA_AMP_MUTE, mute);
11461}
11462
11463static void alc268_dell_unsol_event(struct hda_codec *codec,
11464 unsigned int res)
11465{
11466 if ((res >> 26) != ALC880_HP_EVENT)
11467 return;
11468 alc268_dell_automute(codec);
11469}
11470
11471#define alc268_dell_init_hook alc268_dell_automute
11472
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011473static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11474 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11475 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11476 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11477 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11478 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11479 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11480 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11481 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11482 { }
11483};
11484
11485static struct hda_verb alc267_quanta_il1_verbs[] = {
11486 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11487 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11488 { }
11489};
11490
11491static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11492{
11493 unsigned int present;
11494
11495 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11496 & AC_PINSENSE_PRESENCE;
11497 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11498 present ? 0 : PIN_OUT);
11499}
11500
11501static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11502{
11503 unsigned int present;
11504
11505 present = snd_hda_codec_read(codec, 0x18, 0,
11506 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11507 snd_hda_codec_write(codec, 0x23, 0,
11508 AC_VERB_SET_CONNECT_SEL,
11509 present ? 0x00 : 0x01);
11510}
11511
11512static void alc267_quanta_il1_automute(struct hda_codec *codec)
11513{
11514 alc267_quanta_il1_hp_automute(codec);
11515 alc267_quanta_il1_mic_automute(codec);
11516}
11517
11518static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11519 unsigned int res)
11520{
11521 switch (res >> 26) {
11522 case ALC880_HP_EVENT:
11523 alc267_quanta_il1_hp_automute(codec);
11524 break;
11525 case ALC880_MIC_EVENT:
11526 alc267_quanta_il1_mic_automute(codec);
11527 break;
11528 }
11529}
11530
Kailang Yanga361d842007-06-05 12:30:55 +020011531/*
11532 * generic initialization of ADC, input mixers and output mixers
11533 */
11534static struct hda_verb alc268_base_init_verbs[] = {
11535 /* Unmute DAC0-1 and set vol = 0 */
11536 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011537 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011538
11539 /*
11540 * Set up output mixers (0x0c - 0x0e)
11541 */
11542 /* set vol=0 to output mixers */
11543 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011544 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11545
11546 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11547 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11548
11549 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11550 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11551 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11552 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11554 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11555 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11556 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11557
11558 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11560 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11561 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011562 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011563
11564 /* set PCBEEP vol = 0, mute connections */
11565 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11566 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11567 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011568
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011569 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011570
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011571 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11572 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11573 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11574 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011575
Kailang Yanga361d842007-06-05 12:30:55 +020011576 { }
11577};
11578
11579/*
11580 * generic initialization of ADC, input mixers and output mixers
11581 */
11582static struct hda_verb alc268_volume_init_verbs[] = {
11583 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011584 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11585 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011586
11587 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11588 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11589 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11590 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11591 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11592
Kailang Yanga361d842007-06-05 12:30:55 +020011593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11595 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11596
11597 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011598 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011599
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011600 /* set PCBEEP vol = 0, mute connections */
11601 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11602 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11603 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011604
11605 { }
11606};
11607
Kailang Yanga361d842007-06-05 12:30:55 +020011608static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11609 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11610 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11611 {
11612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11613 /* The multiple "Capture Source" controls confuse alsamixer
11614 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011615 */
11616 /* .name = "Capture Source", */
11617 .name = "Input Source",
11618 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011619 .info = alc_mux_enum_info,
11620 .get = alc_mux_enum_get,
11621 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011622 },
11623 { } /* end */
11624};
11625
11626static struct snd_kcontrol_new alc268_capture_mixer[] = {
11627 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11628 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11629 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11630 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11631 {
11632 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11633 /* The multiple "Capture Source" controls confuse alsamixer
11634 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011635 */
11636 /* .name = "Capture Source", */
11637 .name = "Input Source",
11638 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011639 .info = alc_mux_enum_info,
11640 .get = alc_mux_enum_get,
11641 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011642 },
11643 { } /* end */
11644};
11645
11646static struct hda_input_mux alc268_capture_source = {
11647 .num_items = 4,
11648 .items = {
11649 { "Mic", 0x0 },
11650 { "Front Mic", 0x1 },
11651 { "Line", 0x2 },
11652 { "CD", 0x3 },
11653 },
11654};
11655
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011656static struct hda_input_mux alc268_acer_capture_source = {
11657 .num_items = 3,
11658 .items = {
11659 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011660 { "Internal Mic", 0x1 },
11661 { "Line", 0x2 },
11662 },
11663};
11664
11665static struct hda_input_mux alc268_acer_dmic_capture_source = {
11666 .num_items = 3,
11667 .items = {
11668 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011669 { "Internal Mic", 0x6 },
11670 { "Line", 0x2 },
11671 },
11672};
11673
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011674#ifdef CONFIG_SND_DEBUG
11675static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011676 /* Volume widgets */
11677 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11678 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11679 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11680 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11681 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11682 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11683 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11684 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11685 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11686 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11687 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11688 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11689 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011690 /* The below appears problematic on some hardwares */
11691 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011692 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11693 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11694 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11695 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11696
11697 /* Modes for retasking pin widgets */
11698 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11699 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11700 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11701 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11702
11703 /* Controls for GPIO pins, assuming they are configured as outputs */
11704 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11705 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11706 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11707 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11708
11709 /* Switches to allow the digital SPDIF output pin to be enabled.
11710 * The ALC268 does not have an SPDIF input.
11711 */
11712 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11713
11714 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11715 * this output to turn on an external amplifier.
11716 */
11717 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11718 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11719
11720 { } /* end */
11721};
11722#endif
11723
Kailang Yanga361d842007-06-05 12:30:55 +020011724/* create input playback/capture controls for the given pin */
11725static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11726 const char *ctlname, int idx)
11727{
11728 char name[32];
11729 int err;
11730
11731 sprintf(name, "%s Playback Volume", ctlname);
11732 if (nid == 0x14) {
11733 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11734 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11735 HDA_OUTPUT));
11736 if (err < 0)
11737 return err;
11738 } else if (nid == 0x15) {
11739 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11740 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11741 HDA_OUTPUT));
11742 if (err < 0)
11743 return err;
11744 } else
11745 return -1;
11746 sprintf(name, "%s Playback Switch", ctlname);
11747 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11748 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11749 if (err < 0)
11750 return err;
11751 return 0;
11752}
11753
11754/* add playback controls from the parsed DAC table */
11755static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11756 const struct auto_pin_cfg *cfg)
11757{
11758 hda_nid_t nid;
11759 int err;
11760
11761 spec->multiout.num_dacs = 2; /* only use one dac */
11762 spec->multiout.dac_nids = spec->private_dac_nids;
11763 spec->multiout.dac_nids[0] = 2;
11764 spec->multiout.dac_nids[1] = 3;
11765
11766 nid = cfg->line_out_pins[0];
11767 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011768 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011769
11770 nid = cfg->speaker_pins[0];
11771 if (nid == 0x1d) {
11772 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11773 "Speaker Playback Volume",
11774 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11775 if (err < 0)
11776 return err;
11777 }
11778 nid = cfg->hp_pins[0];
11779 if (nid)
11780 alc268_new_analog_output(spec, nid, "Headphone", 0);
11781
11782 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11783 if (nid == 0x16) {
11784 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11785 "Mono Playback Switch",
11786 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11787 if (err < 0)
11788 return err;
11789 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011790 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011791}
11792
11793/* create playback/capture controls for input pins */
11794static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11795 const struct auto_pin_cfg *cfg)
11796{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011797 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011798 int i, idx1;
11799
11800 for (i = 0; i < AUTO_PIN_LAST; i++) {
11801 switch(cfg->input_pins[i]) {
11802 case 0x18:
11803 idx1 = 0; /* Mic 1 */
11804 break;
11805 case 0x19:
11806 idx1 = 1; /* Mic 2 */
11807 break;
11808 case 0x1a:
11809 idx1 = 2; /* Line In */
11810 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011811 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011812 idx1 = 3; /* CD */
11813 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011814 case 0x12:
11815 case 0x13:
11816 idx1 = 6; /* digital mics */
11817 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011818 default:
11819 continue;
11820 }
11821 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11822 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011823 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011824 }
11825 return 0;
11826}
11827
11828static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11829{
11830 struct alc_spec *spec = codec->spec;
11831 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11832 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11833 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11834 unsigned int dac_vol1, dac_vol2;
11835
11836 if (speaker_nid) {
11837 snd_hda_codec_write(codec, speaker_nid, 0,
11838 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11839 snd_hda_codec_write(codec, 0x0f, 0,
11840 AC_VERB_SET_AMP_GAIN_MUTE,
11841 AMP_IN_UNMUTE(1));
11842 snd_hda_codec_write(codec, 0x10, 0,
11843 AC_VERB_SET_AMP_GAIN_MUTE,
11844 AMP_IN_UNMUTE(1));
11845 } else {
11846 snd_hda_codec_write(codec, 0x0f, 0,
11847 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11848 snd_hda_codec_write(codec, 0x10, 0,
11849 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11850 }
11851
11852 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011853 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011854 dac_vol2 = AMP_OUT_ZERO;
11855 else if (line_nid == 0x15)
11856 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011857 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011858 dac_vol2 = AMP_OUT_ZERO;
11859 else if (hp_nid == 0x15)
11860 dac_vol1 = AMP_OUT_ZERO;
11861 if (line_nid != 0x16 || hp_nid != 0x16 ||
11862 spec->autocfg.line_out_pins[1] != 0x16 ||
11863 spec->autocfg.line_out_pins[2] != 0x16)
11864 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11865
11866 snd_hda_codec_write(codec, 0x02, 0,
11867 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11868 snd_hda_codec_write(codec, 0x03, 0,
11869 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11870}
11871
11872/* pcm configuration: identiacal with ALC880 */
11873#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11874#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011875#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011876#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11877
11878/*
11879 * BIOS auto configuration
11880 */
11881static int alc268_parse_auto_config(struct hda_codec *codec)
11882{
11883 struct alc_spec *spec = codec->spec;
11884 int err;
11885 static hda_nid_t alc268_ignore[] = { 0 };
11886
11887 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11888 alc268_ignore);
11889 if (err < 0)
11890 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011891 if (!spec->autocfg.line_outs) {
11892 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11893 spec->multiout.max_channels = 2;
11894 spec->no_analog = 1;
11895 goto dig_only;
11896 }
Kailang Yanga361d842007-06-05 12:30:55 +020011897 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011898 }
Kailang Yanga361d842007-06-05 12:30:55 +020011899 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11900 if (err < 0)
11901 return err;
11902 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11903 if (err < 0)
11904 return err;
11905
11906 spec->multiout.max_channels = 2;
11907
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011908 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020011909 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011910 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020011911 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011912 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11913 }
Takashi Iwai603c4012008-07-30 15:01:44 +020011914 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011915 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011916
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011917 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011918 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011919
Takashi Iwaid88897e2008-10-31 15:01:37 +010011920 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011921 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011922 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011923
Takashi Iwai776e1842007-08-29 15:07:11 +020011924 err = alc_auto_add_mic_boost(codec);
11925 if (err < 0)
11926 return err;
11927
Kailang Yanga361d842007-06-05 12:30:55 +020011928 return 1;
11929}
11930
11931#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11932#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11933#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11934
11935/* init callback for auto-configuration model -- overriding the default init */
11936static void alc268_auto_init(struct hda_codec *codec)
11937{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011938 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011939 alc268_auto_init_multi_out(codec);
11940 alc268_auto_init_hp_out(codec);
11941 alc268_auto_init_mono_speaker_out(codec);
11942 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011943 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011944 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011945}
11946
11947/*
11948 * configuration and preset
11949 */
11950static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011951 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011952 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011953 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011954 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011955 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011956 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011957 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011958 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011959#ifdef CONFIG_SND_DEBUG
11960 [ALC268_TEST] = "test",
11961#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011962 [ALC268_AUTO] = "auto",
11963};
11964
11965static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011966 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011967 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011968 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011969 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011970 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011971 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11972 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011973 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011974 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011975 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011976 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011977 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011978 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011979 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011980 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011981 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011982 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011983 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011984 {}
11985};
11986
11987static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011988 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010011989 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011990 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11991 alc267_quanta_il1_verbs },
11992 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11993 .dac_nids = alc268_dac_nids,
11994 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11995 .adc_nids = alc268_adc_nids_alt,
11996 .hp_nid = 0x03,
11997 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11998 .channel_mode = alc268_modes,
11999 .input_mux = &alc268_capture_source,
12000 .unsol_event = alc267_quanta_il1_unsol_event,
12001 .init_hook = alc267_quanta_il1_automute,
12002 },
Kailang Yanga361d842007-06-05 12:30:55 +020012003 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012004 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12005 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012006 .init_verbs = { alc268_base_init_verbs },
12007 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12008 .dac_nids = alc268_dac_nids,
12009 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12010 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012011 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012012 .hp_nid = 0x03,
12013 .dig_out_nid = ALC268_DIGOUT_NID,
12014 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12015 .channel_mode = alc268_modes,
12016 .input_mux = &alc268_capture_source,
12017 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012018 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012019 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12020 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012021 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12022 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012023 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12024 .dac_nids = alc268_dac_nids,
12025 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12026 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012027 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012028 .hp_nid = 0x03,
12029 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12030 .channel_mode = alc268_modes,
12031 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012032 .unsol_event = alc268_toshiba_unsol_event,
12033 .init_hook = alc268_toshiba_automute,
12034 },
12035 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012036 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12037 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012038 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12039 alc268_acer_verbs },
12040 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12041 .dac_nids = alc268_dac_nids,
12042 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12043 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012044 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012045 .hp_nid = 0x02,
12046 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12047 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012048 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012049 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012050 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012051 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012052 [ALC268_ACER_DMIC] = {
12053 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12054 alc268_beep_mixer },
12055 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12056 alc268_acer_verbs },
12057 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12058 .dac_nids = alc268_dac_nids,
12059 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12060 .adc_nids = alc268_adc_nids_alt,
12061 .capsrc_nids = alc268_capsrc_nids,
12062 .hp_nid = 0x02,
12063 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12064 .channel_mode = alc268_modes,
12065 .input_mux = &alc268_acer_dmic_capture_source,
12066 .unsol_event = alc268_acer_unsol_event,
12067 .init_hook = alc268_acer_init_hook,
12068 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012069 [ALC268_ACER_ASPIRE_ONE] = {
12070 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012071 alc268_beep_mixer,
12072 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012073 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12074 alc268_acer_aspire_one_verbs },
12075 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12076 .dac_nids = alc268_dac_nids,
12077 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12078 .adc_nids = alc268_adc_nids_alt,
12079 .capsrc_nids = alc268_capsrc_nids,
12080 .hp_nid = 0x03,
12081 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12082 .channel_mode = alc268_modes,
12083 .input_mux = &alc268_acer_lc_capture_source,
12084 .unsol_event = alc268_acer_lc_unsol_event,
12085 .init_hook = alc268_acer_lc_init_hook,
12086 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012087 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012088 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012089 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12090 alc268_dell_verbs },
12091 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12092 .dac_nids = alc268_dac_nids,
12093 .hp_nid = 0x02,
12094 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12095 .channel_mode = alc268_modes,
12096 .unsol_event = alc268_dell_unsol_event,
12097 .init_hook = alc268_dell_init_hook,
12098 .input_mux = &alc268_capture_source,
12099 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012100 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012101 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12102 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012103 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12104 alc268_toshiba_verbs },
12105 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12106 .dac_nids = alc268_dac_nids,
12107 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12108 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012109 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012110 .hp_nid = 0x03,
12111 .dig_out_nid = ALC268_DIGOUT_NID,
12112 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12113 .channel_mode = alc268_modes,
12114 .input_mux = &alc268_capture_source,
12115 .unsol_event = alc268_toshiba_unsol_event,
12116 .init_hook = alc268_toshiba_automute
12117 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012118#ifdef CONFIG_SND_DEBUG
12119 [ALC268_TEST] = {
12120 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12121 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12122 alc268_volume_init_verbs },
12123 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12124 .dac_nids = alc268_dac_nids,
12125 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12126 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012127 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012128 .hp_nid = 0x03,
12129 .dig_out_nid = ALC268_DIGOUT_NID,
12130 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12131 .channel_mode = alc268_modes,
12132 .input_mux = &alc268_capture_source,
12133 },
12134#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012135};
12136
12137static int patch_alc268(struct hda_codec *codec)
12138{
12139 struct alc_spec *spec;
12140 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012141 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012142
12143 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12144 if (spec == NULL)
12145 return -ENOMEM;
12146
12147 codec->spec = spec;
12148
12149 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12150 alc268_models,
12151 alc268_cfg_tbl);
12152
12153 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12154 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12155 "trying auto-probe from BIOS...\n");
12156 board_config = ALC268_AUTO;
12157 }
12158
12159 if (board_config == ALC268_AUTO) {
12160 /* automatic parse from the BIOS config */
12161 err = alc268_parse_auto_config(codec);
12162 if (err < 0) {
12163 alc_free(codec);
12164 return err;
12165 } else if (!err) {
12166 printk(KERN_INFO
12167 "hda_codec: Cannot set up configuration "
12168 "from BIOS. Using base mode...\n");
12169 board_config = ALC268_3ST;
12170 }
12171 }
12172
12173 if (board_config != ALC268_AUTO)
12174 setup_preset(spec, &alc268_presets[board_config]);
12175
Kailang Yang2f893282008-05-27 12:14:47 +020012176 if (codec->vendor_id == 0x10ec0267) {
12177 spec->stream_name_analog = "ALC267 Analog";
12178 spec->stream_name_digital = "ALC267 Digital";
12179 } else {
12180 spec->stream_name_analog = "ALC268 Analog";
12181 spec->stream_name_digital = "ALC268 Digital";
12182 }
12183
Kailang Yanga361d842007-06-05 12:30:55 +020012184 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12185 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012186 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012187
Kailang Yanga361d842007-06-05 12:30:55 +020012188 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12189
Takashi Iwai22971e32009-02-10 11:56:44 +010012190 has_beep = 0;
12191 for (i = 0; i < spec->num_mixers; i++) {
12192 if (spec->mixers[i] == alc268_beep_mixer) {
12193 has_beep = 1;
12194 break;
12195 }
12196 }
12197
12198 if (has_beep) {
12199 err = snd_hda_attach_beep_device(codec, 0x1);
12200 if (err < 0) {
12201 alc_free(codec);
12202 return err;
12203 }
12204 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12205 /* override the amp caps for beep generator */
12206 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012207 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12208 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12209 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12210 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012211 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012212
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012213 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012214 /* check whether NID 0x07 is valid */
12215 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012216 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012217
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012218 /* get type */
12219 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012220 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012221 spec->adc_nids = alc268_adc_nids_alt;
12222 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012223 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012224 } else {
12225 spec->adc_nids = alc268_adc_nids;
12226 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012227 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012228 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012229 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012230 /* set default input source */
12231 for (i = 0; i < spec->num_adc_nids; i++)
12232 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12233 0, AC_VERB_SET_CONNECT_SEL,
12234 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012235 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012236
12237 spec->vmaster_nid = 0x02;
12238
Kailang Yanga361d842007-06-05 12:30:55 +020012239 codec->patch_ops = alc_patch_ops;
12240 if (board_config == ALC268_AUTO)
12241 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012242
Takashi Iwaidaead532008-11-28 12:55:36 +010012243 codec->proc_widget_hook = print_realtek_coef;
12244
Kailang Yanga361d842007-06-05 12:30:55 +020012245 return 0;
12246}
12247
12248/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012249 * ALC269 channel source setting (2 channel)
12250 */
12251#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12252
12253#define alc269_dac_nids alc260_dac_nids
12254
12255static hda_nid_t alc269_adc_nids[1] = {
12256 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012257 0x08,
12258};
12259
Takashi Iwaie01bf502008-08-21 16:25:07 +020012260static hda_nid_t alc269_capsrc_nids[1] = {
12261 0x23,
12262};
12263
12264/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12265 * not a mux!
12266 */
12267
Kailang Yangf53281e2008-07-18 12:36:43 +020012268static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12269 .num_items = 2,
12270 .items = {
12271 { "i-Mic", 0x5 },
12272 { "e-Mic", 0x0 },
12273 },
12274};
12275
12276static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12277 .num_items = 2,
12278 .items = {
12279 { "i-Mic", 0x1 },
12280 { "e-Mic", 0x0 },
12281 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012282};
12283
12284#define alc269_modes alc260_modes
12285#define alc269_capture_source alc880_lg_lw_capture_source
12286
12287static struct snd_kcontrol_new alc269_base_mixer[] = {
12288 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12289 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12290 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12291 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12292 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12293 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12294 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12295 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12296 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12297 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12298 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12299 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12300 { } /* end */
12301};
12302
Kailang Yang60db6b52008-08-26 13:13:00 +020012303static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12304 /* output mixer control */
12305 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12306 {
12307 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12308 .name = "Master Playback Switch",
12309 .info = snd_hda_mixer_amp_switch_info,
12310 .get = snd_hda_mixer_amp_switch_get,
12311 .put = alc268_acer_master_sw_put,
12312 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12313 },
12314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12315 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12316 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12317 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12318 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12319 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012320 { }
12321};
12322
Tony Vroon64154832008-11-06 15:08:49 +000012323static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12324 /* output mixer control */
12325 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12326 {
12327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12328 .name = "Master Playback Switch",
12329 .info = snd_hda_mixer_amp_switch_info,
12330 .get = snd_hda_mixer_amp_switch_get,
12331 .put = alc268_acer_master_sw_put,
12332 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12333 },
12334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12336 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12337 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12338 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12339 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12340 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12341 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12342 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012343 { }
12344};
12345
Kailang Yangf53281e2008-07-18 12:36:43 +020012346/* bind volumes of both NID 0x0c and 0x0d */
12347static struct hda_bind_ctls alc269_epc_bind_vol = {
12348 .ops = &snd_hda_bind_vol,
12349 .values = {
12350 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12351 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12352 0
12353 },
12354};
12355
12356static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12357 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12358 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12359 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12360 { } /* end */
12361};
12362
Kailang Yangf6a92242007-12-13 16:52:54 +010012363/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012364static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12365 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12366 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012367 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12368 { } /* end */
12369};
12370
12371/* FSC amilo */
12372static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12373 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12374 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12375 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012376 { } /* end */
12377};
12378
Kailang Yang60db6b52008-08-26 13:13:00 +020012379static struct hda_verb alc269_quanta_fl1_verbs[] = {
12380 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12381 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12382 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12383 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12384 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12385 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12386 { }
12387};
12388
Tony Vroon64154832008-11-06 15:08:49 +000012389static struct hda_verb alc269_lifebook_verbs[] = {
12390 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12391 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12392 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12393 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12394 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12395 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12396 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12397 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12398 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12399 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12400 { }
12401};
12402
Kailang Yang60db6b52008-08-26 13:13:00 +020012403/* toggle speaker-output according to the hp-jack state */
12404static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12405{
12406 unsigned int present;
12407 unsigned char bits;
12408
12409 present = snd_hda_codec_read(codec, 0x15, 0,
12410 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12411 bits = present ? AMP_IN_MUTE(0) : 0;
12412 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12413 AMP_IN_MUTE(0), bits);
12414 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12415 AMP_IN_MUTE(0), bits);
12416
12417 snd_hda_codec_write(codec, 0x20, 0,
12418 AC_VERB_SET_COEF_INDEX, 0x0c);
12419 snd_hda_codec_write(codec, 0x20, 0,
12420 AC_VERB_SET_PROC_COEF, 0x680);
12421
12422 snd_hda_codec_write(codec, 0x20, 0,
12423 AC_VERB_SET_COEF_INDEX, 0x0c);
12424 snd_hda_codec_write(codec, 0x20, 0,
12425 AC_VERB_SET_PROC_COEF, 0x480);
12426}
12427
Tony Vroon64154832008-11-06 15:08:49 +000012428/* toggle speaker-output according to the hp-jacks state */
12429static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12430{
12431 unsigned int present;
12432 unsigned char bits;
12433
12434 /* Check laptop headphone socket */
12435 present = snd_hda_codec_read(codec, 0x15, 0,
12436 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12437
12438 /* Check port replicator headphone socket */
12439 present |= snd_hda_codec_read(codec, 0x1a, 0,
12440 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12441
12442 bits = present ? AMP_IN_MUTE(0) : 0;
12443 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12444 AMP_IN_MUTE(0), bits);
12445 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12446 AMP_IN_MUTE(0), bits);
12447
12448 snd_hda_codec_write(codec, 0x20, 0,
12449 AC_VERB_SET_COEF_INDEX, 0x0c);
12450 snd_hda_codec_write(codec, 0x20, 0,
12451 AC_VERB_SET_PROC_COEF, 0x680);
12452
12453 snd_hda_codec_write(codec, 0x20, 0,
12454 AC_VERB_SET_COEF_INDEX, 0x0c);
12455 snd_hda_codec_write(codec, 0x20, 0,
12456 AC_VERB_SET_PROC_COEF, 0x480);
12457}
12458
Kailang Yang60db6b52008-08-26 13:13:00 +020012459static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12460{
12461 unsigned int present;
12462
12463 present = snd_hda_codec_read(codec, 0x18, 0,
12464 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12465 snd_hda_codec_write(codec, 0x23, 0,
12466 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12467}
12468
Tony Vroon64154832008-11-06 15:08:49 +000012469static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12470{
12471 unsigned int present_laptop;
12472 unsigned int present_dock;
12473
12474 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12475 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12476
12477 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12478 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12479
12480 /* Laptop mic port overrides dock mic port, design decision */
12481 if (present_dock)
12482 snd_hda_codec_write(codec, 0x23, 0,
12483 AC_VERB_SET_CONNECT_SEL, 0x3);
12484 if (present_laptop)
12485 snd_hda_codec_write(codec, 0x23, 0,
12486 AC_VERB_SET_CONNECT_SEL, 0x0);
12487 if (!present_dock && !present_laptop)
12488 snd_hda_codec_write(codec, 0x23, 0,
12489 AC_VERB_SET_CONNECT_SEL, 0x1);
12490}
12491
Kailang Yang60db6b52008-08-26 13:13:00 +020012492static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12493 unsigned int res)
12494{
12495 if ((res >> 26) == ALC880_HP_EVENT)
12496 alc269_quanta_fl1_speaker_automute(codec);
12497 if ((res >> 26) == ALC880_MIC_EVENT)
12498 alc269_quanta_fl1_mic_automute(codec);
12499}
12500
Tony Vroon64154832008-11-06 15:08:49 +000012501static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12502 unsigned int res)
12503{
12504 if ((res >> 26) == ALC880_HP_EVENT)
12505 alc269_lifebook_speaker_automute(codec);
12506 if ((res >> 26) == ALC880_MIC_EVENT)
12507 alc269_lifebook_mic_autoswitch(codec);
12508}
12509
Kailang Yang60db6b52008-08-26 13:13:00 +020012510static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12511{
12512 alc269_quanta_fl1_speaker_automute(codec);
12513 alc269_quanta_fl1_mic_automute(codec);
12514}
12515
Tony Vroon64154832008-11-06 15:08:49 +000012516static void alc269_lifebook_init_hook(struct hda_codec *codec)
12517{
12518 alc269_lifebook_speaker_automute(codec);
12519 alc269_lifebook_mic_autoswitch(codec);
12520}
12521
Kailang Yang60db6b52008-08-26 13:13:00 +020012522static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12523 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12524 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12525 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12526 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12527 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12528 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12529 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12530 {}
12531};
12532
12533static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12534 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12535 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12536 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12538 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12539 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12540 {}
12541};
12542
12543/* toggle speaker-output according to the hp-jack state */
12544static void alc269_speaker_automute(struct hda_codec *codec)
12545{
12546 unsigned int present;
12547 unsigned char bits;
12548
12549 present = snd_hda_codec_read(codec, 0x15, 0,
12550 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12551 bits = present ? AMP_IN_MUTE(0) : 0;
12552 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12553 AMP_IN_MUTE(0), bits);
12554 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12555 AMP_IN_MUTE(0), bits);
12556}
12557
12558static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12559{
12560 unsigned int present;
12561
12562 present = snd_hda_codec_read(codec, 0x18, 0,
12563 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12564 snd_hda_codec_write(codec, 0x23, 0,
12565 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12566}
12567
12568static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12569{
12570 unsigned int present;
12571
12572 present = snd_hda_codec_read(codec, 0x18, 0,
12573 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12574 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12575 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12576 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12577 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12578}
12579
12580/* unsolicited event for HP jack sensing */
12581static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12582 unsigned int res)
12583{
12584 if ((res >> 26) == ALC880_HP_EVENT)
12585 alc269_speaker_automute(codec);
12586
12587 if ((res >> 26) == ALC880_MIC_EVENT)
12588 alc269_eeepc_dmic_automute(codec);
12589}
12590
12591static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12592{
12593 alc269_speaker_automute(codec);
12594 alc269_eeepc_dmic_automute(codec);
12595}
12596
12597/* unsolicited event for HP jack sensing */
12598static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12599 unsigned int res)
12600{
12601 if ((res >> 26) == ALC880_HP_EVENT)
12602 alc269_speaker_automute(codec);
12603
12604 if ((res >> 26) == ALC880_MIC_EVENT)
12605 alc269_eeepc_amic_automute(codec);
12606}
12607
12608static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12609{
12610 alc269_speaker_automute(codec);
12611 alc269_eeepc_amic_automute(codec);
12612}
12613
Kailang Yangf6a92242007-12-13 16:52:54 +010012614/*
12615 * generic initialization of ADC, input mixers and output mixers
12616 */
12617static struct hda_verb alc269_init_verbs[] = {
12618 /*
12619 * Unmute ADC0 and set the default input to mic-in
12620 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012622
12623 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12624 * analog-loopback mixer widget
12625 * Note: PASD motherboards uses the Line In 2 as the input for
12626 * front panel mic (mic 2)
12627 */
12628 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12629 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12630 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12631 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12632 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12633 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12634
12635 /*
12636 * Set up output mixers (0x0c - 0x0e)
12637 */
12638 /* set vol=0 to output mixers */
12639 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12640 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12641
12642 /* set up input amps for analog loopback */
12643 /* Amp Indices: DAC = 0, mixer = 1 */
12644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12646 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12647 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12648 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12649 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12650
12651 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12652 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12653 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12654 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12655 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12656 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12657 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12658
12659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12661 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12662 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12663 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12664 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12665 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12666
12667 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12668 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12669
12670 /* FIXME: use matrix-type input source selection */
12671 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12672 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012673 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12674 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012675 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12676 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12677
12678 /* set EAPD */
12679 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12680 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12681 { }
12682};
12683
12684/* add playback controls from the parsed DAC table */
12685static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12686 const struct auto_pin_cfg *cfg)
12687{
12688 hda_nid_t nid;
12689 int err;
12690
12691 spec->multiout.num_dacs = 1; /* only use one dac */
12692 spec->multiout.dac_nids = spec->private_dac_nids;
12693 spec->multiout.dac_nids[0] = 2;
12694
12695 nid = cfg->line_out_pins[0];
12696 if (nid) {
12697 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12698 "Front Playback Volume",
12699 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12700 if (err < 0)
12701 return err;
12702 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12703 "Front Playback Switch",
12704 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12705 if (err < 0)
12706 return err;
12707 }
12708
12709 nid = cfg->speaker_pins[0];
12710 if (nid) {
12711 if (!cfg->line_out_pins[0]) {
12712 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12713 "Speaker Playback Volume",
12714 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12715 HDA_OUTPUT));
12716 if (err < 0)
12717 return err;
12718 }
12719 if (nid == 0x16) {
12720 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12721 "Speaker Playback Switch",
12722 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12723 HDA_OUTPUT));
12724 if (err < 0)
12725 return err;
12726 } else {
12727 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12728 "Speaker Playback Switch",
12729 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12730 HDA_OUTPUT));
12731 if (err < 0)
12732 return err;
12733 }
12734 }
12735 nid = cfg->hp_pins[0];
12736 if (nid) {
12737 /* spec->multiout.hp_nid = 2; */
12738 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12739 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12740 "Headphone Playback Volume",
12741 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12742 HDA_OUTPUT));
12743 if (err < 0)
12744 return err;
12745 }
12746 if (nid == 0x16) {
12747 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12748 "Headphone Playback Switch",
12749 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12750 HDA_OUTPUT));
12751 if (err < 0)
12752 return err;
12753 } else {
12754 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12755 "Headphone Playback Switch",
12756 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12757 HDA_OUTPUT));
12758 if (err < 0)
12759 return err;
12760 }
12761 }
12762 return 0;
12763}
12764
Takashi Iwaiee956e02008-10-31 17:16:31 +010012765static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12766 const struct auto_pin_cfg *cfg)
12767{
12768 int err;
12769
12770 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12771 if (err < 0)
12772 return err;
12773 /* digital-mic input pin is excluded in alc880_auto_create..()
12774 * because it's under 0x18
12775 */
12776 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12777 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012778 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012779 imux->items[imux->num_items].label = "Int Mic";
12780 imux->items[imux->num_items].index = 0x05;
12781 imux->num_items++;
12782 }
12783 return 0;
12784}
Kailang Yangf6a92242007-12-13 16:52:54 +010012785
12786#ifdef CONFIG_SND_HDA_POWER_SAVE
12787#define alc269_loopbacks alc880_loopbacks
12788#endif
12789
12790/* pcm configuration: identiacal with ALC880 */
12791#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12792#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12793#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12794#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12795
12796/*
12797 * BIOS auto configuration
12798 */
12799static int alc269_parse_auto_config(struct hda_codec *codec)
12800{
12801 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012802 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012803 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12804
12805 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12806 alc269_ignore);
12807 if (err < 0)
12808 return err;
12809
12810 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12811 if (err < 0)
12812 return err;
12813 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12814 if (err < 0)
12815 return err;
12816
12817 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12818
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012819 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012820 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12821
Takashi Iwai603c4012008-07-30 15:01:44 +020012822 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012823 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012824
Takashi Iwaid88897e2008-10-31 15:01:37 +010012825 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012826 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012827 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012828 /* set default input source */
12829 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12830 0, AC_VERB_SET_CONNECT_SEL,
12831 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012832
12833 err = alc_auto_add_mic_boost(codec);
12834 if (err < 0)
12835 return err;
12836
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012837 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012838 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012839
Kailang Yangf6a92242007-12-13 16:52:54 +010012840 return 1;
12841}
12842
12843#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12844#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12845#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12846
12847
12848/* init callback for auto-configuration model -- overriding the default init */
12849static void alc269_auto_init(struct hda_codec *codec)
12850{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012851 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012852 alc269_auto_init_multi_out(codec);
12853 alc269_auto_init_hp_out(codec);
12854 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012855 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012856 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012857}
12858
12859/*
12860 * configuration and preset
12861 */
12862static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012863 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012864 [ALC269_QUANTA_FL1] = "quanta",
12865 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012866 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012867 [ALC269_FUJITSU] = "fujitsu",
12868 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012869};
12870
12871static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012872 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012873 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12874 ALC269_ASUS_EEEPC_P703),
12875 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12876 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012877 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12878 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012879 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012880 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012881 {}
12882};
12883
12884static struct alc_config_preset alc269_presets[] = {
12885 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012886 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012887 .init_verbs = { alc269_init_verbs },
12888 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12889 .dac_nids = alc269_dac_nids,
12890 .hp_nid = 0x03,
12891 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12892 .channel_mode = alc269_modes,
12893 .input_mux = &alc269_capture_source,
12894 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012895 [ALC269_QUANTA_FL1] = {
12896 .mixers = { alc269_quanta_fl1_mixer },
12897 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12898 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12899 .dac_nids = alc269_dac_nids,
12900 .hp_nid = 0x03,
12901 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12902 .channel_mode = alc269_modes,
12903 .input_mux = &alc269_capture_source,
12904 .unsol_event = alc269_quanta_fl1_unsol_event,
12905 .init_hook = alc269_quanta_fl1_init_hook,
12906 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012907 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012908 .mixers = { alc269_eeepc_mixer },
12909 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012910 .init_verbs = { alc269_init_verbs,
12911 alc269_eeepc_amic_init_verbs },
12912 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12913 .dac_nids = alc269_dac_nids,
12914 .hp_nid = 0x03,
12915 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12916 .channel_mode = alc269_modes,
12917 .input_mux = &alc269_eeepc_amic_capture_source,
12918 .unsol_event = alc269_eeepc_amic_unsol_event,
12919 .init_hook = alc269_eeepc_amic_inithook,
12920 },
12921 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012922 .mixers = { alc269_eeepc_mixer },
12923 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012924 .init_verbs = { alc269_init_verbs,
12925 alc269_eeepc_dmic_init_verbs },
12926 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12927 .dac_nids = alc269_dac_nids,
12928 .hp_nid = 0x03,
12929 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12930 .channel_mode = alc269_modes,
12931 .input_mux = &alc269_eeepc_dmic_capture_source,
12932 .unsol_event = alc269_eeepc_dmic_unsol_event,
12933 .init_hook = alc269_eeepc_dmic_inithook,
12934 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012935 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012936 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012937 .cap_mixer = alc269_epc_capture_mixer,
12938 .init_verbs = { alc269_init_verbs,
12939 alc269_eeepc_dmic_init_verbs },
12940 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12941 .dac_nids = alc269_dac_nids,
12942 .hp_nid = 0x03,
12943 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12944 .channel_mode = alc269_modes,
12945 .input_mux = &alc269_eeepc_dmic_capture_source,
12946 .unsol_event = alc269_eeepc_dmic_unsol_event,
12947 .init_hook = alc269_eeepc_dmic_inithook,
12948 },
Tony Vroon64154832008-11-06 15:08:49 +000012949 [ALC269_LIFEBOOK] = {
12950 .mixers = { alc269_lifebook_mixer },
12951 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12952 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12953 .dac_nids = alc269_dac_nids,
12954 .hp_nid = 0x03,
12955 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12956 .channel_mode = alc269_modes,
12957 .input_mux = &alc269_capture_source,
12958 .unsol_event = alc269_lifebook_unsol_event,
12959 .init_hook = alc269_lifebook_init_hook,
12960 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012961};
12962
12963static int patch_alc269(struct hda_codec *codec)
12964{
12965 struct alc_spec *spec;
12966 int board_config;
12967 int err;
12968
12969 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12970 if (spec == NULL)
12971 return -ENOMEM;
12972
12973 codec->spec = spec;
12974
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012975 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12976
Kailang Yangf6a92242007-12-13 16:52:54 +010012977 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12978 alc269_models,
12979 alc269_cfg_tbl);
12980
12981 if (board_config < 0) {
12982 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12983 "trying auto-probe from BIOS...\n");
12984 board_config = ALC269_AUTO;
12985 }
12986
12987 if (board_config == ALC269_AUTO) {
12988 /* automatic parse from the BIOS config */
12989 err = alc269_parse_auto_config(codec);
12990 if (err < 0) {
12991 alc_free(codec);
12992 return err;
12993 } else if (!err) {
12994 printk(KERN_INFO
12995 "hda_codec: Cannot set up configuration "
12996 "from BIOS. Using base mode...\n");
12997 board_config = ALC269_BASIC;
12998 }
12999 }
13000
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013001 err = snd_hda_attach_beep_device(codec, 0x1);
13002 if (err < 0) {
13003 alc_free(codec);
13004 return err;
13005 }
13006
Kailang Yangf6a92242007-12-13 16:52:54 +010013007 if (board_config != ALC269_AUTO)
13008 setup_preset(spec, &alc269_presets[board_config]);
13009
13010 spec->stream_name_analog = "ALC269 Analog";
13011 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13012 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13013
13014 spec->stream_name_digital = "ALC269 Digital";
13015 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13016 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13017
13018 spec->adc_nids = alc269_adc_nids;
13019 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013020 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013021 if (!spec->cap_mixer)
13022 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013023 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013024
13025 codec->patch_ops = alc_patch_ops;
13026 if (board_config == ALC269_AUTO)
13027 spec->init_hook = alc269_auto_init;
13028#ifdef CONFIG_SND_HDA_POWER_SAVE
13029 if (!spec->loopback.amplist)
13030 spec->loopback.amplist = alc269_loopbacks;
13031#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013032 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013033
13034 return 0;
13035}
13036
13037/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013038 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13039 */
13040
13041/*
13042 * set the path ways for 2 channel output
13043 * need to set the codec line out and mic 1 pin widgets to inputs
13044 */
13045static struct hda_verb alc861_threestack_ch2_init[] = {
13046 /* set pin widget 1Ah (line in) for input */
13047 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013048 /* set pin widget 18h (mic1/2) for input, for mic also enable
13049 * the vref
13050 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013051 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13052
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013053 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13054#if 0
13055 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13056 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13057#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013058 { } /* end */
13059};
13060/*
13061 * 6ch mode
13062 * need to set the codec line out and mic 1 pin widgets to outputs
13063 */
13064static struct hda_verb alc861_threestack_ch6_init[] = {
13065 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13066 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13067 /* set pin widget 18h (mic1) for output (CLFE)*/
13068 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13069
13070 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013071 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013072
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013073 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13074#if 0
13075 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13076 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13077#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013078 { } /* end */
13079};
13080
13081static struct hda_channel_mode alc861_threestack_modes[2] = {
13082 { 2, alc861_threestack_ch2_init },
13083 { 6, alc861_threestack_ch6_init },
13084};
Takashi Iwai22309c32006-08-09 16:57:28 +020013085/* Set mic1 as input and unmute the mixer */
13086static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13087 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13088 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13089 { } /* end */
13090};
13091/* Set mic1 as output and mute mixer */
13092static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13093 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13094 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13095 { } /* end */
13096};
13097
13098static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13099 { 2, alc861_uniwill_m31_ch2_init },
13100 { 4, alc861_uniwill_m31_ch4_init },
13101};
Kailang Yangdf694da2005-12-05 19:42:22 +010013102
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013103/* Set mic1 and line-in as input and unmute the mixer */
13104static struct hda_verb alc861_asus_ch2_init[] = {
13105 /* set pin widget 1Ah (line in) for input */
13106 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013107 /* set pin widget 18h (mic1/2) for input, for mic also enable
13108 * the vref
13109 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013110 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13111
13112 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13113#if 0
13114 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13115 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13116#endif
13117 { } /* end */
13118};
13119/* Set mic1 nad line-in as output and mute mixer */
13120static struct hda_verb alc861_asus_ch6_init[] = {
13121 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13122 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13123 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13124 /* set pin widget 18h (mic1) for output (CLFE)*/
13125 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13126 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13127 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13128 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13129
13130 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13131#if 0
13132 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13133 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13134#endif
13135 { } /* end */
13136};
13137
13138static struct hda_channel_mode alc861_asus_modes[2] = {
13139 { 2, alc861_asus_ch2_init },
13140 { 6, alc861_asus_ch6_init },
13141};
13142
Kailang Yangdf694da2005-12-05 19:42:22 +010013143/* patch-ALC861 */
13144
13145static struct snd_kcontrol_new alc861_base_mixer[] = {
13146 /* output mixer control */
13147 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13148 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13149 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13150 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13151 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13152
13153 /*Input mixer control */
13154 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13155 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13156 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13157 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13158 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13159 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13160 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13161 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13162 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13163 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013164
Kailang Yangdf694da2005-12-05 19:42:22 +010013165 { } /* end */
13166};
13167
13168static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13169 /* output mixer control */
13170 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13171 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13172 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13173 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13174 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13175
13176 /* Input mixer control */
13177 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13178 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13179 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13180 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13181 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13182 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13183 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13184 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13185 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13186 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013187
Kailang Yangdf694da2005-12-05 19:42:22 +010013188 {
13189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13190 .name = "Channel Mode",
13191 .info = alc_ch_mode_info,
13192 .get = alc_ch_mode_get,
13193 .put = alc_ch_mode_put,
13194 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13195 },
13196 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013197};
13198
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013199static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013200 /* output mixer control */
13201 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13203 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013204
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013205 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013206};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013207
Takashi Iwai22309c32006-08-09 16:57:28 +020013208static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13209 /* output mixer control */
13210 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13211 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13212 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13213 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13214 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13215
13216 /* Input mixer control */
13217 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13218 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13219 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13220 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13221 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13222 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13224 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13225 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013227
Takashi Iwai22309c32006-08-09 16:57:28 +020013228 {
13229 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13230 .name = "Channel Mode",
13231 .info = alc_ch_mode_info,
13232 .get = alc_ch_mode_get,
13233 .put = alc_ch_mode_put,
13234 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13235 },
13236 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013237};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013238
13239static struct snd_kcontrol_new alc861_asus_mixer[] = {
13240 /* output mixer control */
13241 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13242 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13243 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13244 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13245 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13246
13247 /* Input mixer control */
13248 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13249 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13250 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13251 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13252 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13253 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13254 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13255 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13256 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013257 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13258
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013259 {
13260 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13261 .name = "Channel Mode",
13262 .info = alc_ch_mode_info,
13263 .get = alc_ch_mode_get,
13264 .put = alc_ch_mode_put,
13265 .private_value = ARRAY_SIZE(alc861_asus_modes),
13266 },
13267 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013268};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013269
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013270/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013271static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013272 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13273 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013274 { }
13275};
13276
Kailang Yangdf694da2005-12-05 19:42:22 +010013277/*
13278 * generic initialization of ADC, input mixers and output mixers
13279 */
13280static struct hda_verb alc861_base_init_verbs[] = {
13281 /*
13282 * Unmute ADC0 and set the default input to mic-in
13283 */
13284 /* port-A for surround (rear panel) */
13285 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13286 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13287 /* port-B for mic-in (rear panel) with vref */
13288 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13289 /* port-C for line-in (rear panel) */
13290 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13291 /* port-D for Front */
13292 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13293 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13294 /* port-E for HP out (front panel) */
13295 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13296 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013297 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013298 /* port-F for mic-in (front panel) with vref */
13299 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13300 /* port-G for CLFE (rear panel) */
13301 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13302 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13303 /* port-H for side (rear panel) */
13304 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13305 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13306 /* CD-in */
13307 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13308 /* route front mic to ADC1*/
13309 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13310 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013311
Kailang Yangdf694da2005-12-05 19:42:22 +010013312 /* Unmute DAC0~3 & spdif out*/
13313 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13314 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13315 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13316 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13317 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013318
Kailang Yangdf694da2005-12-05 19:42:22 +010013319 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13320 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13321 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13322 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13323 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013324
Kailang Yangdf694da2005-12-05 19:42:22 +010013325 /* Unmute Stereo Mixer 15 */
13326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13328 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013329 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013330
13331 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13332 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13333 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13334 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13335 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13336 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13337 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13338 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013339 /* hp used DAC 3 (Front) */
13340 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013341 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13342
13343 { }
13344};
13345
13346static struct hda_verb alc861_threestack_init_verbs[] = {
13347 /*
13348 * Unmute ADC0 and set the default input to mic-in
13349 */
13350 /* port-A for surround (rear panel) */
13351 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13352 /* port-B for mic-in (rear panel) with vref */
13353 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13354 /* port-C for line-in (rear panel) */
13355 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13356 /* port-D for Front */
13357 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13358 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13359 /* port-E for HP out (front panel) */
13360 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13361 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013362 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013363 /* port-F for mic-in (front panel) with vref */
13364 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13365 /* port-G for CLFE (rear panel) */
13366 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13367 /* port-H for side (rear panel) */
13368 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13369 /* CD-in */
13370 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13371 /* route front mic to ADC1*/
13372 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13373 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13374 /* Unmute DAC0~3 & spdif out*/
13375 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13376 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13377 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13378 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013380
Kailang Yangdf694da2005-12-05 19:42:22 +010013381 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13382 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13383 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13384 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13385 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013386
Kailang Yangdf694da2005-12-05 19:42:22 +010013387 /* Unmute Stereo Mixer 15 */
13388 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13389 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013391 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013392
13393 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13394 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13395 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13396 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13397 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13398 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13399 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13400 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013401 /* hp used DAC 3 (Front) */
13402 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013403 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13404 { }
13405};
Takashi Iwai22309c32006-08-09 16:57:28 +020013406
13407static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13408 /*
13409 * Unmute ADC0 and set the default input to mic-in
13410 */
13411 /* port-A for surround (rear panel) */
13412 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13413 /* port-B for mic-in (rear panel) with vref */
13414 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13415 /* port-C for line-in (rear panel) */
13416 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13417 /* port-D for Front */
13418 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13419 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13420 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013421 /* this has to be set to VREF80 */
13422 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013423 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013424 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013425 /* port-F for mic-in (front panel) with vref */
13426 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13427 /* port-G for CLFE (rear panel) */
13428 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13429 /* port-H for side (rear panel) */
13430 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13431 /* CD-in */
13432 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13433 /* route front mic to ADC1*/
13434 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13435 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13436 /* Unmute DAC0~3 & spdif out*/
13437 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13438 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13439 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13440 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13441 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013442
Takashi Iwai22309c32006-08-09 16:57:28 +020013443 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13444 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13445 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13446 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13447 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013448
Takashi Iwai22309c32006-08-09 16:57:28 +020013449 /* Unmute Stereo Mixer 15 */
13450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013453 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013454
13455 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13456 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13457 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13458 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13459 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13460 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13462 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013463 /* hp used DAC 3 (Front) */
13464 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013465 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13466 { }
13467};
13468
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013469static struct hda_verb alc861_asus_init_verbs[] = {
13470 /*
13471 * Unmute ADC0 and set the default input to mic-in
13472 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013473 /* port-A for surround (rear panel)
13474 * according to codec#0 this is the HP jack
13475 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013476 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13477 /* route front PCM to HP */
13478 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13479 /* port-B for mic-in (rear panel) with vref */
13480 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13481 /* port-C for line-in (rear panel) */
13482 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13483 /* port-D for Front */
13484 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13485 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13486 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013487 /* this has to be set to VREF80 */
13488 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013489 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013490 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013491 /* port-F for mic-in (front panel) with vref */
13492 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13493 /* port-G for CLFE (rear panel) */
13494 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13495 /* port-H for side (rear panel) */
13496 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13497 /* CD-in */
13498 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13499 /* route front mic to ADC1*/
13500 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13501 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13502 /* Unmute DAC0~3 & spdif out*/
13503 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13504 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13505 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13506 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13508 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13509 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13510 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13511 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13512 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013513
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013514 /* Unmute Stereo Mixer 15 */
13515 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13516 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13517 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013518 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013519
13520 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13521 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13522 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13523 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13524 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13525 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13526 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13527 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013528 /* hp used DAC 3 (Front) */
13529 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013530 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13531 { }
13532};
13533
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013534/* additional init verbs for ASUS laptops */
13535static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13536 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13537 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13538 { }
13539};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013540
Kailang Yangdf694da2005-12-05 19:42:22 +010013541/*
13542 * generic initialization of ADC, input mixers and output mixers
13543 */
13544static struct hda_verb alc861_auto_init_verbs[] = {
13545 /*
13546 * Unmute ADC0 and set the default input to mic-in
13547 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013548 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013550
Kailang Yangdf694da2005-12-05 19:42:22 +010013551 /* Unmute DAC0~3 & spdif out*/
13552 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13553 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13554 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13555 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013557
Kailang Yangdf694da2005-12-05 19:42:22 +010013558 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13559 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13560 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13561 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13562 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013563
Kailang Yangdf694da2005-12-05 19:42:22 +010013564 /* Unmute Stereo Mixer 15 */
13565 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13566 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13567 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13568 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13569
13570 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13571 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13572 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13573 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13574 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13575 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13576 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13577 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13578
13579 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13580 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013581 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13582 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013583 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13584 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013585 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13586 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013587
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013588 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013589
13590 { }
13591};
13592
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013593static struct hda_verb alc861_toshiba_init_verbs[] = {
13594 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013595
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013596 { }
13597};
13598
13599/* toggle speaker-output according to the hp-jack state */
13600static void alc861_toshiba_automute(struct hda_codec *codec)
13601{
13602 unsigned int present;
13603
13604 present = snd_hda_codec_read(codec, 0x0f, 0,
13605 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013606 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13607 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13608 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13609 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013610}
13611
13612static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13613 unsigned int res)
13614{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013615 if ((res >> 26) == ALC880_HP_EVENT)
13616 alc861_toshiba_automute(codec);
13617}
13618
Kailang Yangdf694da2005-12-05 19:42:22 +010013619/* pcm configuration: identiacal with ALC880 */
13620#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13621#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13622#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13623#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13624
13625
13626#define ALC861_DIGOUT_NID 0x07
13627
13628static struct hda_channel_mode alc861_8ch_modes[1] = {
13629 { 8, NULL }
13630};
13631
13632static hda_nid_t alc861_dac_nids[4] = {
13633 /* front, surround, clfe, side */
13634 0x03, 0x06, 0x05, 0x04
13635};
13636
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013637static hda_nid_t alc660_dac_nids[3] = {
13638 /* front, clfe, surround */
13639 0x03, 0x05, 0x06
13640};
13641
Kailang Yangdf694da2005-12-05 19:42:22 +010013642static hda_nid_t alc861_adc_nids[1] = {
13643 /* ADC0-2 */
13644 0x08,
13645};
13646
13647static struct hda_input_mux alc861_capture_source = {
13648 .num_items = 5,
13649 .items = {
13650 { "Mic", 0x0 },
13651 { "Front Mic", 0x3 },
13652 { "Line", 0x1 },
13653 { "CD", 0x4 },
13654 { "Mixer", 0x5 },
13655 },
13656};
13657
13658/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013659static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13660 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013661{
13662 int i;
13663 hda_nid_t nid;
13664
13665 spec->multiout.dac_nids = spec->private_dac_nids;
13666 for (i = 0; i < cfg->line_outs; i++) {
13667 nid = cfg->line_out_pins[i];
13668 if (nid) {
13669 if (i >= ARRAY_SIZE(alc861_dac_nids))
13670 continue;
13671 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13672 }
13673 }
13674 spec->multiout.num_dacs = cfg->line_outs;
13675 return 0;
13676}
13677
13678/* add playback controls from the parsed DAC table */
13679static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13680 const struct auto_pin_cfg *cfg)
13681{
13682 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013683 static const char *chname[4] = {
13684 "Front", "Surround", NULL /*CLFE*/, "Side"
13685 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013686 hda_nid_t nid;
13687 int i, idx, err;
13688
13689 for (i = 0; i < cfg->line_outs; i++) {
13690 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013691 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013692 continue;
13693 if (nid == 0x05) {
13694 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013695 err = add_control(spec, ALC_CTL_BIND_MUTE,
13696 "Center Playback Switch",
13697 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13698 HDA_OUTPUT));
13699 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013700 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013701 err = add_control(spec, ALC_CTL_BIND_MUTE,
13702 "LFE Playback Switch",
13703 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13704 HDA_OUTPUT));
13705 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013706 return err;
13707 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013708 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13709 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013710 if (nid == alc861_dac_nids[idx])
13711 break;
13712 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013713 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13714 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13715 HDA_OUTPUT));
13716 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013717 return err;
13718 }
13719 }
13720 return 0;
13721}
13722
13723static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13724{
13725 int err;
13726 hda_nid_t nid;
13727
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013728 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013729 return 0;
13730
13731 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13732 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013733 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13734 "Headphone Playback Switch",
13735 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13736 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013737 return err;
13738 spec->multiout.hp_nid = nid;
13739 }
13740 return 0;
13741}
13742
13743/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013744static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13745 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013746{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013747 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013748 int i, err, idx, idx1;
13749
13750 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013751 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013752 case 0x0c:
13753 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013754 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013755 break;
13756 case 0x0f:
13757 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013758 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013759 break;
13760 case 0x0d:
13761 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013762 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013763 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013764 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013765 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013766 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013767 break;
13768 case 0x11:
13769 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013770 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013771 break;
13772 default:
13773 continue;
13774 }
13775
Takashi Iwai4a471b72005-12-07 13:56:29 +010013776 err = new_analog_input(spec, cfg->input_pins[i],
13777 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013778 if (err < 0)
13779 return err;
13780
Takashi Iwai4a471b72005-12-07 13:56:29 +010013781 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013782 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013783 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013784 }
13785 return 0;
13786}
13787
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013788static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13789 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013790 int pin_type, int dac_idx)
13791{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013792 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13793 pin_type);
13794 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13795 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013796}
13797
13798static void alc861_auto_init_multi_out(struct hda_codec *codec)
13799{
13800 struct alc_spec *spec = codec->spec;
13801 int i;
13802
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013803 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013804 for (i = 0; i < spec->autocfg.line_outs; i++) {
13805 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013806 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013807 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013808 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013809 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013810 }
13811}
13812
13813static void alc861_auto_init_hp_out(struct hda_codec *codec)
13814{
13815 struct alc_spec *spec = codec->spec;
13816 hda_nid_t pin;
13817
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013818 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013819 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013820 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13821 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013822 pin = spec->autocfg.speaker_pins[0];
13823 if (pin)
13824 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013825}
13826
13827static void alc861_auto_init_analog_input(struct hda_codec *codec)
13828{
13829 struct alc_spec *spec = codec->spec;
13830 int i;
13831
13832 for (i = 0; i < AUTO_PIN_LAST; i++) {
13833 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013834 if (nid >= 0x0c && nid <= 0x11) {
13835 snd_hda_codec_write(codec, nid, 0,
13836 AC_VERB_SET_PIN_WIDGET_CONTROL,
13837 i <= AUTO_PIN_FRONT_MIC ?
13838 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013839 }
13840 }
13841}
13842
13843/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013844/* return 1 if successful, 0 if the proper config is not found,
13845 * or a negative error code
13846 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013847static int alc861_parse_auto_config(struct hda_codec *codec)
13848{
13849 struct alc_spec *spec = codec->spec;
13850 int err;
13851 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13852
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013853 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13854 alc861_ignore);
13855 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013856 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013857 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013858 return 0; /* can't find valid BIOS pin config */
13859
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013860 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13861 if (err < 0)
13862 return err;
13863 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13864 if (err < 0)
13865 return err;
13866 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13867 if (err < 0)
13868 return err;
13869 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13870 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013871 return err;
13872
13873 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13874
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013875 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013876 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13877
Takashi Iwai603c4012008-07-30 15:01:44 +020013878 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013879 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013880
Takashi Iwaid88897e2008-10-31 15:01:37 +010013881 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013882
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013883 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013884 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013885
13886 spec->adc_nids = alc861_adc_nids;
13887 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013888 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013889
13890 return 1;
13891}
13892
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013893/* additional initialization for auto-configuration model */
13894static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013895{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013896 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013897 alc861_auto_init_multi_out(codec);
13898 alc861_auto_init_hp_out(codec);
13899 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013900 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013901 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013902}
13903
Takashi Iwaicb53c622007-08-10 17:21:45 +020013904#ifdef CONFIG_SND_HDA_POWER_SAVE
13905static struct hda_amp_list alc861_loopbacks[] = {
13906 { 0x15, HDA_INPUT, 0 },
13907 { 0x15, HDA_INPUT, 1 },
13908 { 0x15, HDA_INPUT, 2 },
13909 { 0x15, HDA_INPUT, 3 },
13910 { } /* end */
13911};
13912#endif
13913
Kailang Yangdf694da2005-12-05 19:42:22 +010013914
13915/*
13916 * configuration and preset
13917 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013918static const char *alc861_models[ALC861_MODEL_LAST] = {
13919 [ALC861_3ST] = "3stack",
13920 [ALC660_3ST] = "3stack-660",
13921 [ALC861_3ST_DIG] = "3stack-dig",
13922 [ALC861_6ST_DIG] = "6stack-dig",
13923 [ALC861_UNIWILL_M31] = "uniwill-m31",
13924 [ALC861_TOSHIBA] = "toshiba",
13925 [ALC861_ASUS] = "asus",
13926 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13927 [ALC861_AUTO] = "auto",
13928};
13929
13930static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013931 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013932 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13933 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13934 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013935 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013936 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013937 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013938 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13939 * Any other models that need this preset?
13940 */
13941 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013942 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13943 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013944 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13945 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13946 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13947 /* FIXME: the below seems conflict */
13948 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13949 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13950 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013951 {}
13952};
13953
13954static struct alc_config_preset alc861_presets[] = {
13955 [ALC861_3ST] = {
13956 .mixers = { alc861_3ST_mixer },
13957 .init_verbs = { alc861_threestack_init_verbs },
13958 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13959 .dac_nids = alc861_dac_nids,
13960 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13961 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013962 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013963 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13964 .adc_nids = alc861_adc_nids,
13965 .input_mux = &alc861_capture_source,
13966 },
13967 [ALC861_3ST_DIG] = {
13968 .mixers = { alc861_base_mixer },
13969 .init_verbs = { alc861_threestack_init_verbs },
13970 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13971 .dac_nids = alc861_dac_nids,
13972 .dig_out_nid = ALC861_DIGOUT_NID,
13973 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13974 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013975 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013976 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13977 .adc_nids = alc861_adc_nids,
13978 .input_mux = &alc861_capture_source,
13979 },
13980 [ALC861_6ST_DIG] = {
13981 .mixers = { alc861_base_mixer },
13982 .init_verbs = { alc861_base_init_verbs },
13983 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13984 .dac_nids = alc861_dac_nids,
13985 .dig_out_nid = ALC861_DIGOUT_NID,
13986 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13987 .channel_mode = alc861_8ch_modes,
13988 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13989 .adc_nids = alc861_adc_nids,
13990 .input_mux = &alc861_capture_source,
13991 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013992 [ALC660_3ST] = {
13993 .mixers = { alc861_3ST_mixer },
13994 .init_verbs = { alc861_threestack_init_verbs },
13995 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13996 .dac_nids = alc660_dac_nids,
13997 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13998 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013999 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014000 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14001 .adc_nids = alc861_adc_nids,
14002 .input_mux = &alc861_capture_source,
14003 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014004 [ALC861_UNIWILL_M31] = {
14005 .mixers = { alc861_uniwill_m31_mixer },
14006 .init_verbs = { alc861_uniwill_m31_init_verbs },
14007 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14008 .dac_nids = alc861_dac_nids,
14009 .dig_out_nid = ALC861_DIGOUT_NID,
14010 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14011 .channel_mode = alc861_uniwill_m31_modes,
14012 .need_dac_fix = 1,
14013 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14014 .adc_nids = alc861_adc_nids,
14015 .input_mux = &alc861_capture_source,
14016 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014017 [ALC861_TOSHIBA] = {
14018 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014019 .init_verbs = { alc861_base_init_verbs,
14020 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014021 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14022 .dac_nids = alc861_dac_nids,
14023 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14024 .channel_mode = alc883_3ST_2ch_modes,
14025 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14026 .adc_nids = alc861_adc_nids,
14027 .input_mux = &alc861_capture_source,
14028 .unsol_event = alc861_toshiba_unsol_event,
14029 .init_hook = alc861_toshiba_automute,
14030 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014031 [ALC861_ASUS] = {
14032 .mixers = { alc861_asus_mixer },
14033 .init_verbs = { alc861_asus_init_verbs },
14034 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14035 .dac_nids = alc861_dac_nids,
14036 .dig_out_nid = ALC861_DIGOUT_NID,
14037 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14038 .channel_mode = alc861_asus_modes,
14039 .need_dac_fix = 1,
14040 .hp_nid = 0x06,
14041 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14042 .adc_nids = alc861_adc_nids,
14043 .input_mux = &alc861_capture_source,
14044 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014045 [ALC861_ASUS_LAPTOP] = {
14046 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14047 .init_verbs = { alc861_asus_init_verbs,
14048 alc861_asus_laptop_init_verbs },
14049 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14050 .dac_nids = alc861_dac_nids,
14051 .dig_out_nid = ALC861_DIGOUT_NID,
14052 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14053 .channel_mode = alc883_3ST_2ch_modes,
14054 .need_dac_fix = 1,
14055 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14056 .adc_nids = alc861_adc_nids,
14057 .input_mux = &alc861_capture_source,
14058 },
14059};
Kailang Yangdf694da2005-12-05 19:42:22 +010014060
14061
14062static int patch_alc861(struct hda_codec *codec)
14063{
14064 struct alc_spec *spec;
14065 int board_config;
14066 int err;
14067
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014068 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014069 if (spec == NULL)
14070 return -ENOMEM;
14071
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014072 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014073
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014074 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14075 alc861_models,
14076 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014077
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014078 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014079 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14080 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014081 board_config = ALC861_AUTO;
14082 }
14083
14084 if (board_config == ALC861_AUTO) {
14085 /* automatic parse from the BIOS config */
14086 err = alc861_parse_auto_config(codec);
14087 if (err < 0) {
14088 alc_free(codec);
14089 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014090 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014091 printk(KERN_INFO
14092 "hda_codec: Cannot set up configuration "
14093 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014094 board_config = ALC861_3ST_DIG;
14095 }
14096 }
14097
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014098 err = snd_hda_attach_beep_device(codec, 0x23);
14099 if (err < 0) {
14100 alc_free(codec);
14101 return err;
14102 }
14103
Kailang Yangdf694da2005-12-05 19:42:22 +010014104 if (board_config != ALC861_AUTO)
14105 setup_preset(spec, &alc861_presets[board_config]);
14106
14107 spec->stream_name_analog = "ALC861 Analog";
14108 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14109 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14110
14111 spec->stream_name_digital = "ALC861 Digital";
14112 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14113 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14114
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014115 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14116
Takashi Iwai2134ea42008-01-10 16:53:55 +010014117 spec->vmaster_nid = 0x03;
14118
Kailang Yangdf694da2005-12-05 19:42:22 +010014119 codec->patch_ops = alc_patch_ops;
14120 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014121 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014122#ifdef CONFIG_SND_HDA_POWER_SAVE
14123 if (!spec->loopback.amplist)
14124 spec->loopback.amplist = alc861_loopbacks;
14125#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014126 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014127
Kailang Yangdf694da2005-12-05 19:42:22 +010014128 return 0;
14129}
14130
14131/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014132 * ALC861-VD support
14133 *
14134 * Based on ALC882
14135 *
14136 * In addition, an independent DAC
14137 */
14138#define ALC861VD_DIGOUT_NID 0x06
14139
14140static hda_nid_t alc861vd_dac_nids[4] = {
14141 /* front, surr, clfe, side surr */
14142 0x02, 0x03, 0x04, 0x05
14143};
14144
14145/* dac_nids for ALC660vd are in a different order - according to
14146 * Realtek's driver.
14147 * This should probably tesult in a different mixer for 6stack models
14148 * of ALC660vd codecs, but for now there is only 3stack mixer
14149 * - and it is the same as in 861vd.
14150 * adc_nids in ALC660vd are (is) the same as in 861vd
14151 */
14152static hda_nid_t alc660vd_dac_nids[3] = {
14153 /* front, rear, clfe, rear_surr */
14154 0x02, 0x04, 0x03
14155};
14156
14157static hda_nid_t alc861vd_adc_nids[1] = {
14158 /* ADC0 */
14159 0x09,
14160};
14161
Takashi Iwaie1406342008-02-11 18:32:32 +010014162static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14163
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014164/* input MUX */
14165/* FIXME: should be a matrix-type input source selection */
14166static struct hda_input_mux alc861vd_capture_source = {
14167 .num_items = 4,
14168 .items = {
14169 { "Mic", 0x0 },
14170 { "Front Mic", 0x1 },
14171 { "Line", 0x2 },
14172 { "CD", 0x4 },
14173 },
14174};
14175
Kailang Yang272a5272007-05-14 11:00:38 +020014176static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014177 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014178 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014179 { "Ext Mic", 0x0 },
14180 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014181 },
14182};
14183
Kailang Yangd1a991a2007-08-15 16:21:59 +020014184static struct hda_input_mux alc861vd_hp_capture_source = {
14185 .num_items = 2,
14186 .items = {
14187 { "Front Mic", 0x0 },
14188 { "ATAPI Mic", 0x1 },
14189 },
14190};
14191
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014192/*
14193 * 2ch mode
14194 */
14195static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14196 { 2, NULL }
14197};
14198
14199/*
14200 * 6ch mode
14201 */
14202static struct hda_verb alc861vd_6stack_ch6_init[] = {
14203 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14204 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14205 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14206 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14207 { } /* end */
14208};
14209
14210/*
14211 * 8ch mode
14212 */
14213static struct hda_verb alc861vd_6stack_ch8_init[] = {
14214 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14215 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14216 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14217 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14218 { } /* end */
14219};
14220
14221static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14222 { 6, alc861vd_6stack_ch6_init },
14223 { 8, alc861vd_6stack_ch8_init },
14224};
14225
14226static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14227 {
14228 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14229 .name = "Channel Mode",
14230 .info = alc_ch_mode_info,
14231 .get = alc_ch_mode_get,
14232 .put = alc_ch_mode_put,
14233 },
14234 { } /* end */
14235};
14236
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014237/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14238 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14239 */
14240static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14241 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14242 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14243
14244 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14245 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14246
14247 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14248 HDA_OUTPUT),
14249 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14250 HDA_OUTPUT),
14251 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14252 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14253
14254 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14255 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14256
14257 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14258
14259 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14260 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14261 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14262
14263 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14264 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14265 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14266
14267 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14268 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14269
14270 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14271 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14272
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014273 { } /* end */
14274};
14275
14276static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14277 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14278 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14279
14280 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14281
14282 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14283 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14284 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14285
14286 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14287 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14288 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14289
14290 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14291 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14292
14293 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14294 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14295
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014296 { } /* end */
14297};
14298
Kailang Yangbdd148a2007-05-08 15:19:08 +020014299static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14300 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14301 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14302 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14303
14304 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14305
14306 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14307 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14308 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14309
14310 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14311 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14312 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14313
14314 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14315 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14316
14317 { } /* end */
14318};
14319
Tobin Davisb419f342008-03-07 11:57:51 +010014320/* Pin assignment: Speaker=0x14, HP = 0x15,
14321 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014322 */
14323static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014324 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14325 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014326 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14327 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014328 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14329 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14330 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14331 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14332 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14333 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014334 { } /* end */
14335};
14336
Kailang Yangd1a991a2007-08-15 16:21:59 +020014337/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14338 * Front Mic=0x18, ATAPI Mic = 0x19,
14339 */
14340static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14341 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14342 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14343 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14344 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14345 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14346 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14347 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14348 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014349
Kailang Yangd1a991a2007-08-15 16:21:59 +020014350 { } /* end */
14351};
14352
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014353/*
14354 * generic initialization of ADC, input mixers and output mixers
14355 */
14356static struct hda_verb alc861vd_volume_init_verbs[] = {
14357 /*
14358 * Unmute ADC0 and set the default input to mic-in
14359 */
14360 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14361 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14362
14363 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14364 * the analog-loopback mixer widget
14365 */
14366 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014372
14373 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014378
14379 /*
14380 * Set up output mixers (0x02 - 0x05)
14381 */
14382 /* set vol=0 to output mixers */
14383 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14384 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14385 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14386 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14387
14388 /* set up input amps for analog loopback */
14389 /* Amp Indices: DAC = 0, mixer = 1 */
14390 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14391 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14392 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14394 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14395 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14396 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14397 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14398
14399 { }
14400};
14401
14402/*
14403 * 3-stack pin configuration:
14404 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14405 */
14406static struct hda_verb alc861vd_3stack_init_verbs[] = {
14407 /*
14408 * Set pin mode and muting
14409 */
14410 /* set front pin widgets 0x14 for output */
14411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14412 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14413 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14414
14415 /* Mic (rear) pin: input vref at 80% */
14416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14417 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14418 /* Front Mic pin: input vref at 80% */
14419 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14420 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14421 /* Line In pin: input */
14422 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14423 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14424 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14425 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14426 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14427 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14428 /* CD pin widget for input */
14429 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14430
14431 { }
14432};
14433
14434/*
14435 * 6-stack pin configuration:
14436 */
14437static struct hda_verb alc861vd_6stack_init_verbs[] = {
14438 /*
14439 * Set pin mode and muting
14440 */
14441 /* set front pin widgets 0x14 for output */
14442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14443 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14444 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14445
14446 /* Rear Pin: output 1 (0x0d) */
14447 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14449 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14450 /* CLFE Pin: output 2 (0x0e) */
14451 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14452 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14453 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14454 /* Side Pin: output 3 (0x0f) */
14455 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14456 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14457 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14458
14459 /* Mic (rear) pin: input vref at 80% */
14460 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14461 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14462 /* Front Mic pin: input vref at 80% */
14463 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14464 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14465 /* Line In pin: input */
14466 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14467 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14468 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14469 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14470 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14471 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14472 /* CD pin widget for input */
14473 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14474
14475 { }
14476};
14477
Kailang Yangbdd148a2007-05-08 15:19:08 +020014478static struct hda_verb alc861vd_eapd_verbs[] = {
14479 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14480 { }
14481};
14482
Kailang Yangf9423e72008-05-27 12:32:25 +020014483static struct hda_verb alc660vd_eapd_verbs[] = {
14484 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14485 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14486 { }
14487};
14488
Kailang Yangbdd148a2007-05-08 15:19:08 +020014489static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14492 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14493 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014494 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014495 {}
14496};
14497
14498/* toggle speaker-output according to the hp-jack state */
14499static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14500{
14501 unsigned int present;
14502 unsigned char bits;
14503
14504 present = snd_hda_codec_read(codec, 0x1b, 0,
14505 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014506 bits = present ? HDA_AMP_MUTE : 0;
14507 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14508 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014509}
14510
14511static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14512{
14513 unsigned int present;
14514 unsigned char bits;
14515
14516 present = snd_hda_codec_read(codec, 0x18, 0,
14517 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014518 bits = present ? HDA_AMP_MUTE : 0;
14519 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14520 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014521}
14522
14523static void alc861vd_lenovo_automute(struct hda_codec *codec)
14524{
14525 alc861vd_lenovo_hp_automute(codec);
14526 alc861vd_lenovo_mic_automute(codec);
14527}
14528
14529static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14530 unsigned int res)
14531{
14532 switch (res >> 26) {
14533 case ALC880_HP_EVENT:
14534 alc861vd_lenovo_hp_automute(codec);
14535 break;
14536 case ALC880_MIC_EVENT:
14537 alc861vd_lenovo_mic_automute(codec);
14538 break;
14539 }
14540}
14541
Kailang Yang272a5272007-05-14 11:00:38 +020014542static struct hda_verb alc861vd_dallas_verbs[] = {
14543 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14544 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14545 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14546 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14547
14548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14549 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14550 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14551 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14552 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14553 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14554 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14555 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014556
Kailang Yang272a5272007-05-14 11:00:38 +020014557 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14558 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14559 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14561 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14562 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14563 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14564 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14565
14566 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14567 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14568 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14569 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14570 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14571 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14572 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14573 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14574
14575 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14579
14580 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014581 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014582 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14583
14584 { } /* end */
14585};
14586
14587/* toggle speaker-output according to the hp-jack state */
14588static void alc861vd_dallas_automute(struct hda_codec *codec)
14589{
14590 unsigned int present;
14591
14592 present = snd_hda_codec_read(codec, 0x15, 0,
14593 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014594 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14595 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014596}
14597
14598static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14599{
14600 if ((res >> 26) == ALC880_HP_EVENT)
14601 alc861vd_dallas_automute(codec);
14602}
14603
Takashi Iwaicb53c622007-08-10 17:21:45 +020014604#ifdef CONFIG_SND_HDA_POWER_SAVE
14605#define alc861vd_loopbacks alc880_loopbacks
14606#endif
14607
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014608/* pcm configuration: identiacal with ALC880 */
14609#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14610#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14611#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14612#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14613
14614/*
14615 * configuration and preset
14616 */
14617static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14618 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014619 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014620 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014621 [ALC861VD_3ST] = "3stack",
14622 [ALC861VD_3ST_DIG] = "3stack-digout",
14623 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014624 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014625 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014626 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014627 [ALC861VD_AUTO] = "auto",
14628};
14629
14630static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014631 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14632 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014633 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014634 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014635 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014636 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014637 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014638 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014639 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014640 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014641 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014642 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014643 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014644 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014645 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014646 {}
14647};
14648
14649static struct alc_config_preset alc861vd_presets[] = {
14650 [ALC660VD_3ST] = {
14651 .mixers = { alc861vd_3st_mixer },
14652 .init_verbs = { alc861vd_volume_init_verbs,
14653 alc861vd_3stack_init_verbs },
14654 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14655 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014656 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14657 .channel_mode = alc861vd_3stack_2ch_modes,
14658 .input_mux = &alc861vd_capture_source,
14659 },
Mike Crash6963f842007-06-25 12:12:51 +020014660 [ALC660VD_3ST_DIG] = {
14661 .mixers = { alc861vd_3st_mixer },
14662 .init_verbs = { alc861vd_volume_init_verbs,
14663 alc861vd_3stack_init_verbs },
14664 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14665 .dac_nids = alc660vd_dac_nids,
14666 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014667 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14668 .channel_mode = alc861vd_3stack_2ch_modes,
14669 .input_mux = &alc861vd_capture_source,
14670 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014671 [ALC861VD_3ST] = {
14672 .mixers = { alc861vd_3st_mixer },
14673 .init_verbs = { alc861vd_volume_init_verbs,
14674 alc861vd_3stack_init_verbs },
14675 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14676 .dac_nids = alc861vd_dac_nids,
14677 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14678 .channel_mode = alc861vd_3stack_2ch_modes,
14679 .input_mux = &alc861vd_capture_source,
14680 },
14681 [ALC861VD_3ST_DIG] = {
14682 .mixers = { alc861vd_3st_mixer },
14683 .init_verbs = { alc861vd_volume_init_verbs,
14684 alc861vd_3stack_init_verbs },
14685 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14686 .dac_nids = alc861vd_dac_nids,
14687 .dig_out_nid = ALC861VD_DIGOUT_NID,
14688 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14689 .channel_mode = alc861vd_3stack_2ch_modes,
14690 .input_mux = &alc861vd_capture_source,
14691 },
14692 [ALC861VD_6ST_DIG] = {
14693 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14694 .init_verbs = { alc861vd_volume_init_verbs,
14695 alc861vd_6stack_init_verbs },
14696 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14697 .dac_nids = alc861vd_dac_nids,
14698 .dig_out_nid = ALC861VD_DIGOUT_NID,
14699 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14700 .channel_mode = alc861vd_6stack_modes,
14701 .input_mux = &alc861vd_capture_source,
14702 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014703 [ALC861VD_LENOVO] = {
14704 .mixers = { alc861vd_lenovo_mixer },
14705 .init_verbs = { alc861vd_volume_init_verbs,
14706 alc861vd_3stack_init_verbs,
14707 alc861vd_eapd_verbs,
14708 alc861vd_lenovo_unsol_verbs },
14709 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14710 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014711 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14712 .channel_mode = alc861vd_3stack_2ch_modes,
14713 .input_mux = &alc861vd_capture_source,
14714 .unsol_event = alc861vd_lenovo_unsol_event,
14715 .init_hook = alc861vd_lenovo_automute,
14716 },
Kailang Yang272a5272007-05-14 11:00:38 +020014717 [ALC861VD_DALLAS] = {
14718 .mixers = { alc861vd_dallas_mixer },
14719 .init_verbs = { alc861vd_dallas_verbs },
14720 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14721 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014722 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14723 .channel_mode = alc861vd_3stack_2ch_modes,
14724 .input_mux = &alc861vd_dallas_capture_source,
14725 .unsol_event = alc861vd_dallas_unsol_event,
14726 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014727 },
14728 [ALC861VD_HP] = {
14729 .mixers = { alc861vd_hp_mixer },
14730 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14731 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14732 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014733 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014734 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14735 .channel_mode = alc861vd_3stack_2ch_modes,
14736 .input_mux = &alc861vd_hp_capture_source,
14737 .unsol_event = alc861vd_dallas_unsol_event,
14738 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014739 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014740 [ALC660VD_ASUS_V1S] = {
14741 .mixers = { alc861vd_lenovo_mixer },
14742 .init_verbs = { alc861vd_volume_init_verbs,
14743 alc861vd_3stack_init_verbs,
14744 alc861vd_eapd_verbs,
14745 alc861vd_lenovo_unsol_verbs },
14746 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14747 .dac_nids = alc660vd_dac_nids,
14748 .dig_out_nid = ALC861VD_DIGOUT_NID,
14749 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14750 .channel_mode = alc861vd_3stack_2ch_modes,
14751 .input_mux = &alc861vd_capture_source,
14752 .unsol_event = alc861vd_lenovo_unsol_event,
14753 .init_hook = alc861vd_lenovo_automute,
14754 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014755};
14756
14757/*
14758 * BIOS auto configuration
14759 */
14760static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14761 hda_nid_t nid, int pin_type, int dac_idx)
14762{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014763 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014764}
14765
14766static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14767{
14768 struct alc_spec *spec = codec->spec;
14769 int i;
14770
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014771 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014772 for (i = 0; i <= HDA_SIDE; i++) {
14773 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014774 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014775 if (nid)
14776 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014777 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014778 }
14779}
14780
14781
14782static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14783{
14784 struct alc_spec *spec = codec->spec;
14785 hda_nid_t pin;
14786
14787 pin = spec->autocfg.hp_pins[0];
14788 if (pin) /* connect to front and use dac 0 */
14789 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014790 pin = spec->autocfg.speaker_pins[0];
14791 if (pin)
14792 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014793}
14794
14795#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14796#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14797
14798static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14799{
14800 struct alc_spec *spec = codec->spec;
14801 int i;
14802
14803 for (i = 0; i < AUTO_PIN_LAST; i++) {
14804 hda_nid_t nid = spec->autocfg.input_pins[i];
14805 if (alc861vd_is_input_pin(nid)) {
14806 snd_hda_codec_write(codec, nid, 0,
14807 AC_VERB_SET_PIN_WIDGET_CONTROL,
14808 i <= AUTO_PIN_FRONT_MIC ?
14809 PIN_VREF80 : PIN_IN);
14810 if (nid != ALC861VD_PIN_CD_NID)
14811 snd_hda_codec_write(codec, nid, 0,
14812 AC_VERB_SET_AMP_GAIN_MUTE,
14813 AMP_OUT_MUTE);
14814 }
14815 }
14816}
14817
Takashi Iwaif511b012008-08-15 16:46:42 +020014818#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14819
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014820#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14821#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14822
14823/* add playback controls from the parsed DAC table */
14824/* Based on ALC880 version. But ALC861VD has separate,
14825 * different NIDs for mute/unmute switch and volume control */
14826static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14827 const struct auto_pin_cfg *cfg)
14828{
14829 char name[32];
14830 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14831 hda_nid_t nid_v, nid_s;
14832 int i, err;
14833
14834 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014835 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014836 continue;
14837 nid_v = alc861vd_idx_to_mixer_vol(
14838 alc880_dac_to_idx(
14839 spec->multiout.dac_nids[i]));
14840 nid_s = alc861vd_idx_to_mixer_switch(
14841 alc880_dac_to_idx(
14842 spec->multiout.dac_nids[i]));
14843
14844 if (i == 2) {
14845 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014846 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14847 "Center Playback Volume",
14848 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14849 HDA_OUTPUT));
14850 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014851 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014852 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14853 "LFE Playback Volume",
14854 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14855 HDA_OUTPUT));
14856 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014857 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014858 err = add_control(spec, ALC_CTL_BIND_MUTE,
14859 "Center Playback Switch",
14860 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14861 HDA_INPUT));
14862 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014863 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014864 err = add_control(spec, ALC_CTL_BIND_MUTE,
14865 "LFE Playback Switch",
14866 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14867 HDA_INPUT));
14868 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014869 return err;
14870 } else {
14871 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014872 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14873 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14874 HDA_OUTPUT));
14875 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014876 return err;
14877 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014878 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014879 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014880 HDA_INPUT));
14881 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014882 return err;
14883 }
14884 }
14885 return 0;
14886}
14887
14888/* add playback controls for speaker and HP outputs */
14889/* Based on ALC880 version. But ALC861VD has separate,
14890 * different NIDs for mute/unmute switch and volume control */
14891static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14892 hda_nid_t pin, const char *pfx)
14893{
14894 hda_nid_t nid_v, nid_s;
14895 int err;
14896 char name[32];
14897
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014898 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014899 return 0;
14900
14901 if (alc880_is_fixed_pin(pin)) {
14902 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14903 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014904 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014905 spec->multiout.hp_nid = nid_v;
14906 else
14907 spec->multiout.extra_out_nid[0] = nid_v;
14908 /* control HP volume/switch on the output mixer amp */
14909 nid_v = alc861vd_idx_to_mixer_vol(
14910 alc880_fixed_pin_idx(pin));
14911 nid_s = alc861vd_idx_to_mixer_switch(
14912 alc880_fixed_pin_idx(pin));
14913
14914 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014915 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14916 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14917 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014918 return err;
14919 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014920 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14921 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14922 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014923 return err;
14924 } else if (alc880_is_multi_pin(pin)) {
14925 /* set manual connection */
14926 /* we have only a switch on HP-out PIN */
14927 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014928 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14929 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14930 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014931 return err;
14932 }
14933 return 0;
14934}
14935
14936/* parse the BIOS configuration and set up the alc_spec
14937 * return 1 if successful, 0 if the proper config is not found,
14938 * or a negative error code
14939 * Based on ALC880 version - had to change it to override
14940 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14941static int alc861vd_parse_auto_config(struct hda_codec *codec)
14942{
14943 struct alc_spec *spec = codec->spec;
14944 int err;
14945 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14946
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014947 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14948 alc861vd_ignore);
14949 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014950 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014951 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014952 return 0; /* can't find valid BIOS pin config */
14953
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014954 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14955 if (err < 0)
14956 return err;
14957 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14958 if (err < 0)
14959 return err;
14960 err = alc861vd_auto_create_extra_out(spec,
14961 spec->autocfg.speaker_pins[0],
14962 "Speaker");
14963 if (err < 0)
14964 return err;
14965 err = alc861vd_auto_create_extra_out(spec,
14966 spec->autocfg.hp_pins[0],
14967 "Headphone");
14968 if (err < 0)
14969 return err;
14970 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14971 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014972 return err;
14973
14974 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14975
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014976 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014977 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14978
Takashi Iwai603c4012008-07-30 15:01:44 +020014979 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014980 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014981
Takashi Iwaid88897e2008-10-31 15:01:37 +010014982 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014983
14984 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014985 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014986
Takashi Iwai776e1842007-08-29 15:07:11 +020014987 err = alc_auto_add_mic_boost(codec);
14988 if (err < 0)
14989 return err;
14990
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014991 return 1;
14992}
14993
14994/* additional initialization for auto-configuration model */
14995static void alc861vd_auto_init(struct hda_codec *codec)
14996{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014997 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014998 alc861vd_auto_init_multi_out(codec);
14999 alc861vd_auto_init_hp_out(codec);
15000 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015001 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015002 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015003 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015004}
15005
15006static int patch_alc861vd(struct hda_codec *codec)
15007{
15008 struct alc_spec *spec;
15009 int err, board_config;
15010
15011 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15012 if (spec == NULL)
15013 return -ENOMEM;
15014
15015 codec->spec = spec;
15016
15017 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15018 alc861vd_models,
15019 alc861vd_cfg_tbl);
15020
15021 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15022 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
15023 "ALC861VD, trying auto-probe from BIOS...\n");
15024 board_config = ALC861VD_AUTO;
15025 }
15026
15027 if (board_config == ALC861VD_AUTO) {
15028 /* automatic parse from the BIOS config */
15029 err = alc861vd_parse_auto_config(codec);
15030 if (err < 0) {
15031 alc_free(codec);
15032 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015033 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015034 printk(KERN_INFO
15035 "hda_codec: Cannot set up configuration "
15036 "from BIOS. Using base mode...\n");
15037 board_config = ALC861VD_3ST;
15038 }
15039 }
15040
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015041 err = snd_hda_attach_beep_device(codec, 0x23);
15042 if (err < 0) {
15043 alc_free(codec);
15044 return err;
15045 }
15046
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015047 if (board_config != ALC861VD_AUTO)
15048 setup_preset(spec, &alc861vd_presets[board_config]);
15049
Kailang Yang2f893282008-05-27 12:14:47 +020015050 if (codec->vendor_id == 0x10ec0660) {
15051 spec->stream_name_analog = "ALC660-VD Analog";
15052 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020015053 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015054 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015055 } else {
15056 spec->stream_name_analog = "ALC861VD Analog";
15057 spec->stream_name_digital = "ALC861VD Digital";
15058 }
15059
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015060 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15061 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15062
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015063 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15064 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15065
15066 spec->adc_nids = alc861vd_adc_nids;
15067 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015068 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015069 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015070
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015071 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015072 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015073
Takashi Iwai2134ea42008-01-10 16:53:55 +010015074 spec->vmaster_nid = 0x02;
15075
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015076 codec->patch_ops = alc_patch_ops;
15077
15078 if (board_config == ALC861VD_AUTO)
15079 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015080#ifdef CONFIG_SND_HDA_POWER_SAVE
15081 if (!spec->loopback.amplist)
15082 spec->loopback.amplist = alc861vd_loopbacks;
15083#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015084 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015085
15086 return 0;
15087}
15088
15089/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015090 * ALC662 support
15091 *
15092 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15093 * configuration. Each pin widget can choose any input DACs and a mixer.
15094 * Each ADC is connected from a mixer of all inputs. This makes possible
15095 * 6-channel independent captures.
15096 *
15097 * In addition, an independent DAC for the multi-playback (not used in this
15098 * driver yet).
15099 */
15100#define ALC662_DIGOUT_NID 0x06
15101#define ALC662_DIGIN_NID 0x0a
15102
15103static hda_nid_t alc662_dac_nids[4] = {
15104 /* front, rear, clfe, rear_surr */
15105 0x02, 0x03, 0x04
15106};
15107
15108static hda_nid_t alc662_adc_nids[1] = {
15109 /* ADC1-2 */
15110 0x09,
15111};
Takashi Iwaie1406342008-02-11 18:32:32 +010015112
Kailang Yang77a261b2008-02-19 11:38:05 +010015113static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010015114
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015115/* input MUX */
15116/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015117static struct hda_input_mux alc662_capture_source = {
15118 .num_items = 4,
15119 .items = {
15120 { "Mic", 0x0 },
15121 { "Front Mic", 0x1 },
15122 { "Line", 0x2 },
15123 { "CD", 0x4 },
15124 },
15125};
15126
15127static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15128 .num_items = 2,
15129 .items = {
15130 { "Mic", 0x1 },
15131 { "Line", 0x2 },
15132 },
15133};
Kailang Yang291702f2007-10-16 14:28:03 +020015134
15135static struct hda_input_mux alc662_eeepc_capture_source = {
15136 .num_items = 2,
15137 .items = {
15138 { "i-Mic", 0x1 },
15139 { "e-Mic", 0x0 },
15140 },
15141};
15142
Kailang Yang6dda9f42008-05-27 12:05:31 +020015143static struct hda_input_mux alc663_capture_source = {
15144 .num_items = 3,
15145 .items = {
15146 { "Mic", 0x0 },
15147 { "Front Mic", 0x1 },
15148 { "Line", 0x2 },
15149 },
15150};
15151
15152static struct hda_input_mux alc663_m51va_capture_source = {
15153 .num_items = 2,
15154 .items = {
15155 { "Ext-Mic", 0x0 },
15156 { "D-Mic", 0x9 },
15157 },
15158};
15159
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015160/*
15161 * 2ch mode
15162 */
15163static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15164 { 2, NULL }
15165};
15166
15167/*
15168 * 2ch mode
15169 */
15170static struct hda_verb alc662_3ST_ch2_init[] = {
15171 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15172 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15173 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15174 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15175 { } /* end */
15176};
15177
15178/*
15179 * 6ch mode
15180 */
15181static struct hda_verb alc662_3ST_ch6_init[] = {
15182 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15183 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15184 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15185 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15186 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15187 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15188 { } /* end */
15189};
15190
15191static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15192 { 2, alc662_3ST_ch2_init },
15193 { 6, alc662_3ST_ch6_init },
15194};
15195
15196/*
15197 * 2ch mode
15198 */
15199static struct hda_verb alc662_sixstack_ch6_init[] = {
15200 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15201 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15202 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15203 { } /* end */
15204};
15205
15206/*
15207 * 6ch mode
15208 */
15209static struct hda_verb alc662_sixstack_ch8_init[] = {
15210 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15211 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15212 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15213 { } /* end */
15214};
15215
15216static struct hda_channel_mode alc662_5stack_modes[2] = {
15217 { 2, alc662_sixstack_ch6_init },
15218 { 6, alc662_sixstack_ch8_init },
15219};
15220
15221/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15222 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15223 */
15224
15225static struct snd_kcontrol_new alc662_base_mixer[] = {
15226 /* output mixer control */
15227 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015228 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015229 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015230 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015231 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15232 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015233 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15234 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015235 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15236
15237 /*Input mixer control */
15238 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15239 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15240 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15241 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15242 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15243 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15244 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15245 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015246 { } /* end */
15247};
15248
15249static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15250 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015251 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015252 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15253 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15254 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15255 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15256 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15257 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15258 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15259 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15260 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015261 { } /* end */
15262};
15263
15264static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15265 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015266 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015267 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015268 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015269 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15270 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015271 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15272 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015273 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15274 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15275 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15276 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15277 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15278 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15279 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15280 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15281 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015282 { } /* end */
15283};
15284
15285static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15286 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15287 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015288 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15289 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015290 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15291 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15292 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15293 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15294 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015295 { } /* end */
15296};
15297
Kailang Yang291702f2007-10-16 14:28:03 +020015298static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015299 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015300
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015301 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15302 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015303
15304 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15305 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15306 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15307
15308 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15309 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15310 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15311 { } /* end */
15312};
15313
Kailang Yang8c427222008-01-10 13:03:59 +010015314static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015315 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15316 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015317 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15318 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15319 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15320 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15321 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15322 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015323 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015324 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15325 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15326 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15327 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15328 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15329 { } /* end */
15330};
15331
Kailang Yangf1d4e282008-08-26 14:03:29 +020015332static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15333 .ops = &snd_hda_bind_vol,
15334 .values = {
15335 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15336 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15337 0
15338 },
15339};
15340
15341static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15342 .ops = &snd_hda_bind_sw,
15343 .values = {
15344 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15345 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15346 0
15347 },
15348};
15349
Kailang Yang6dda9f42008-05-27 12:05:31 +020015350static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015351 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15352 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15354 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15355 { } /* end */
15356};
15357
15358static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15359 .ops = &snd_hda_bind_sw,
15360 .values = {
15361 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15362 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15363 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15364 0
15365 },
15366};
15367
15368static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15369 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15370 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15371 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15372 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15373 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15374 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15375
15376 { } /* end */
15377};
15378
15379static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15380 .ops = &snd_hda_bind_sw,
15381 .values = {
15382 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15383 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15384 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15385 0
15386 },
15387};
15388
15389static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15390 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15391 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15393 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15394 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15395 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15396 { } /* end */
15397};
15398
15399static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015400 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15401 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015402 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15403 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15404 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15405 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15406 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15407 { } /* end */
15408};
15409
15410static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15411 .ops = &snd_hda_bind_vol,
15412 .values = {
15413 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15414 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15415 0
15416 },
15417};
15418
15419static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15420 .ops = &snd_hda_bind_sw,
15421 .values = {
15422 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15423 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15424 0
15425 },
15426};
15427
15428static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15429 HDA_BIND_VOL("Master Playback Volume",
15430 &alc663_asus_two_bind_master_vol),
15431 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15432 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015433 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15434 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15435 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015436 { } /* end */
15437};
15438
15439static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15440 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15441 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15442 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15443 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15445 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015446 { } /* end */
15447};
15448
15449static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15450 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15451 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15452 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15453 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15455
15456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15457 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15458 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15459 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15460 { } /* end */
15461};
15462
15463static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15464 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15465 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15466 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15467
15468 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15469 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15470 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15471 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15472 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15473 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15474 { } /* end */
15475};
15476
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015477static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15478 {
15479 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15480 .name = "Channel Mode",
15481 .info = alc_ch_mode_info,
15482 .get = alc_ch_mode_get,
15483 .put = alc_ch_mode_put,
15484 },
15485 { } /* end */
15486};
15487
15488static struct hda_verb alc662_init_verbs[] = {
15489 /* ADC: mute amp left and right */
15490 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15491 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15492 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15493
Takashi Iwaicb53c622007-08-10 17:21:45 +020015494 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15495 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015499
Kailang Yangb60dd392007-09-20 12:50:29 +020015500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15505 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015506
15507 /* Front Pin: output 0 (0x0c) */
15508 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15509 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15510
15511 /* Rear Pin: output 1 (0x0d) */
15512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15513 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15514
15515 /* CLFE Pin: output 2 (0x0e) */
15516 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15517 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15518
15519 /* Mic (rear) pin: input vref at 80% */
15520 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15521 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15522 /* Front Mic pin: input vref at 80% */
15523 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15524 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15525 /* Line In pin: input */
15526 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15527 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15528 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15529 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15530 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15531 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15532 /* CD pin widget for input */
15533 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15534
15535 /* FIXME: use matrix-type input source selection */
15536 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15537 /* Input mixer */
15538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15539 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015542
15543 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15544 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15545 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15546 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015547
15548 /* always trun on EAPD */
15549 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15550 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15551
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015552 { }
15553};
15554
15555static struct hda_verb alc662_sue_init_verbs[] = {
15556 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15557 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015558 {}
15559};
15560
15561static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15562 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15563 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15564 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015565};
15566
Kailang Yang8c427222008-01-10 13:03:59 +010015567/* Set Unsolicited Event*/
15568static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15569 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15570 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15571 {}
15572};
15573
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015574/*
15575 * generic initialization of ADC, input mixers and output mixers
15576 */
15577static struct hda_verb alc662_auto_init_verbs[] = {
15578 /*
15579 * Unmute ADC and set the default input to mic-in
15580 */
15581 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15582 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15583
15584 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15585 * mixer widget
15586 * Note: PASD motherboards uses the Line In 2 as the input for front
15587 * panel mic (mic 2)
15588 */
15589 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015590 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15591 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15592 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15593 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15594 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015595
15596 /*
15597 * Set up output mixers (0x0c - 0x0f)
15598 */
15599 /* set vol=0 to output mixers */
15600 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15601 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15602 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15603
15604 /* set up input amps for analog loopback */
15605 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015606 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15607 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15608 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15609 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15610 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15611 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015612
15613
15614 /* FIXME: use matrix-type input source selection */
15615 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15616 /* Input mixer */
15617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015618 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015619 { }
15620};
15621
Takashi Iwai24fb9172008-09-02 14:48:20 +020015622/* additional verbs for ALC663 */
15623static struct hda_verb alc663_auto_init_verbs[] = {
15624 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15625 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15626 { }
15627};
15628
Kailang Yang6dda9f42008-05-27 12:05:31 +020015629static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015630 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15631 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015632 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15633 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015634 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15635 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15636 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015637 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15638 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15639 {}
15640};
15641
Kailang Yangf1d4e282008-08-26 14:03:29 +020015642static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15643 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15644 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15645 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15646 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15647 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15648 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15649 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15650 {}
15651};
15652
15653static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15654 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15655 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15656 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15657 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15658 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15660 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15661 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15662 {}
15663};
15664
15665static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15666 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15667 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15668 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15671 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15672 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15673 {}
15674};
15675
15676static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15677 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15678 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15679 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15680 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15681 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15682 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15683 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15685 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15686 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15687 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15688 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15689 {}
15690};
15691
15692static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15693 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15694 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15695 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15696 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15697 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15698 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15699 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15700 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15701 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15702 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15703 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15704 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15705 {}
15706};
15707
Kailang Yang6dda9f42008-05-27 12:05:31 +020015708static struct hda_verb alc663_g71v_init_verbs[] = {
15709 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15710 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15711 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15712
15713 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15714 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15715 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15716
15717 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15718 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15719 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15720 {}
15721};
15722
15723static struct hda_verb alc663_g50v_init_verbs[] = {
15724 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15725 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15726 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15727
15728 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15729 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15730 {}
15731};
15732
Kailang Yangf1d4e282008-08-26 14:03:29 +020015733static struct hda_verb alc662_ecs_init_verbs[] = {
15734 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15736 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15737 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15738 {}
15739};
15740
Kailang Yangf1d4e282008-08-26 14:03:29 +020015741static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15742 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15743 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15744 { } /* end */
15745};
15746
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015747static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15748{
15749 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015750 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015751
15752 present = snd_hda_codec_read(codec, 0x14, 0,
15753 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015754 bits = present ? HDA_AMP_MUTE : 0;
15755 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15756 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015757}
15758
15759static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15760{
15761 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015762 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015763
15764 present = snd_hda_codec_read(codec, 0x1b, 0,
15765 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015766 bits = present ? HDA_AMP_MUTE : 0;
15767 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15768 HDA_AMP_MUTE, bits);
15769 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15770 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015771}
15772
15773static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15774 unsigned int res)
15775{
15776 if ((res >> 26) == ALC880_HP_EVENT)
15777 alc662_lenovo_101e_all_automute(codec);
15778 if ((res >> 26) == ALC880_FRONT_EVENT)
15779 alc662_lenovo_101e_ispeaker_automute(codec);
15780}
15781
Kailang Yang291702f2007-10-16 14:28:03 +020015782static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15783{
15784 unsigned int present;
15785
15786 present = snd_hda_codec_read(codec, 0x18, 0,
15787 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15788 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15789 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15790 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15791 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15792 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15793 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15794 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15795 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15796}
15797
15798/* unsolicited event for HP jack sensing */
15799static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15800 unsigned int res)
15801{
15802 if ((res >> 26) == ALC880_HP_EVENT)
15803 alc262_hippo1_automute( codec );
15804
15805 if ((res >> 26) == ALC880_MIC_EVENT)
15806 alc662_eeepc_mic_automute(codec);
15807}
15808
15809static void alc662_eeepc_inithook(struct hda_codec *codec)
15810{
15811 alc262_hippo1_automute( codec );
15812 alc662_eeepc_mic_automute(codec);
15813}
15814
Kailang Yang8c427222008-01-10 13:03:59 +010015815static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15816{
15817 unsigned int mute;
15818 unsigned int present;
15819
15820 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15821 present = snd_hda_codec_read(codec, 0x14, 0,
15822 AC_VERB_GET_PIN_SENSE, 0);
15823 present = (present & 0x80000000) != 0;
15824 if (present) {
15825 /* mute internal speaker */
15826 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015827 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015828 } else {
15829 /* unmute internal speaker if necessary */
15830 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15831 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015832 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015833 }
15834}
15835
15836/* unsolicited event for HP jack sensing */
15837static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15838 unsigned int res)
15839{
15840 if ((res >> 26) == ALC880_HP_EVENT)
15841 alc662_eeepc_ep20_automute(codec);
15842}
15843
15844static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15845{
15846 alc662_eeepc_ep20_automute(codec);
15847}
15848
Kailang Yang6dda9f42008-05-27 12:05:31 +020015849static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15850{
15851 unsigned int present;
15852 unsigned char bits;
15853
15854 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015855 AC_VERB_GET_PIN_SENSE, 0)
15856 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015857 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015858 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15859 AMP_IN_MUTE(0), bits);
15860 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15861 AMP_IN_MUTE(0), bits);
15862}
15863
15864static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15865{
15866 unsigned int present;
15867 unsigned char bits;
15868
15869 present = snd_hda_codec_read(codec, 0x21, 0,
15870 AC_VERB_GET_PIN_SENSE, 0)
15871 & AC_PINSENSE_PRESENCE;
15872 bits = present ? HDA_AMP_MUTE : 0;
15873 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15874 AMP_IN_MUTE(0), bits);
15875 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15876 AMP_IN_MUTE(0), bits);
15877 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15878 AMP_IN_MUTE(0), bits);
15879 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15880 AMP_IN_MUTE(0), bits);
15881}
15882
15883static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15884{
15885 unsigned int present;
15886 unsigned char bits;
15887
15888 present = snd_hda_codec_read(codec, 0x15, 0,
15889 AC_VERB_GET_PIN_SENSE, 0)
15890 & AC_PINSENSE_PRESENCE;
15891 bits = present ? HDA_AMP_MUTE : 0;
15892 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15893 AMP_IN_MUTE(0), bits);
15894 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15895 AMP_IN_MUTE(0), bits);
15896 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15897 AMP_IN_MUTE(0), bits);
15898 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15899 AMP_IN_MUTE(0), bits);
15900}
15901
15902static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15903{
15904 unsigned int present;
15905 unsigned char bits;
15906
15907 present = snd_hda_codec_read(codec, 0x1b, 0,
15908 AC_VERB_GET_PIN_SENSE, 0)
15909 & AC_PINSENSE_PRESENCE;
15910 bits = present ? 0 : PIN_OUT;
15911 snd_hda_codec_write(codec, 0x14, 0,
15912 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15913}
15914
15915static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15916{
15917 unsigned int present1, present2;
15918
15919 present1 = snd_hda_codec_read(codec, 0x21, 0,
15920 AC_VERB_GET_PIN_SENSE, 0)
15921 & AC_PINSENSE_PRESENCE;
15922 present2 = snd_hda_codec_read(codec, 0x15, 0,
15923 AC_VERB_GET_PIN_SENSE, 0)
15924 & AC_PINSENSE_PRESENCE;
15925
15926 if (present1 || present2) {
15927 snd_hda_codec_write_cache(codec, 0x14, 0,
15928 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15929 } else {
15930 snd_hda_codec_write_cache(codec, 0x14, 0,
15931 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15932 }
15933}
15934
15935static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15936{
15937 unsigned int present1, present2;
15938
15939 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15940 AC_VERB_GET_PIN_SENSE, 0)
15941 & AC_PINSENSE_PRESENCE;
15942 present2 = snd_hda_codec_read(codec, 0x15, 0,
15943 AC_VERB_GET_PIN_SENSE, 0)
15944 & AC_PINSENSE_PRESENCE;
15945
15946 if (present1 || present2) {
15947 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15948 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15949 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15950 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15951 } else {
15952 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15953 AMP_IN_MUTE(0), 0);
15954 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15955 AMP_IN_MUTE(0), 0);
15956 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015957}
15958
15959static void alc663_m51va_mic_automute(struct hda_codec *codec)
15960{
15961 unsigned int present;
15962
15963 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015964 AC_VERB_GET_PIN_SENSE, 0)
15965 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015966 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015967 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015968 snd_hda_codec_write_cache(codec, 0x23, 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, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015971 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015972 snd_hda_codec_write_cache(codec, 0x23, 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}
15975
15976static void alc663_m51va_unsol_event(struct hda_codec *codec,
15977 unsigned int res)
15978{
15979 switch (res >> 26) {
15980 case ALC880_HP_EVENT:
15981 alc663_m51va_speaker_automute(codec);
15982 break;
15983 case ALC880_MIC_EVENT:
15984 alc663_m51va_mic_automute(codec);
15985 break;
15986 }
15987}
15988
15989static void alc663_m51va_inithook(struct hda_codec *codec)
15990{
15991 alc663_m51va_speaker_automute(codec);
15992 alc663_m51va_mic_automute(codec);
15993}
15994
Kailang Yangf1d4e282008-08-26 14:03:29 +020015995/* ***************** Mode1 ******************************/
15996static void alc663_mode1_unsol_event(struct hda_codec *codec,
15997 unsigned int res)
15998{
15999 switch (res >> 26) {
16000 case ALC880_HP_EVENT:
16001 alc663_m51va_speaker_automute(codec);
16002 break;
16003 case ALC880_MIC_EVENT:
16004 alc662_eeepc_mic_automute(codec);
16005 break;
16006 }
16007}
16008
16009static void alc663_mode1_inithook(struct hda_codec *codec)
16010{
16011 alc663_m51va_speaker_automute(codec);
16012 alc662_eeepc_mic_automute(codec);
16013}
16014/* ***************** Mode2 ******************************/
16015static void alc662_mode2_unsol_event(struct hda_codec *codec,
16016 unsigned int res)
16017{
16018 switch (res >> 26) {
16019 case ALC880_HP_EVENT:
16020 alc662_f5z_speaker_automute(codec);
16021 break;
16022 case ALC880_MIC_EVENT:
16023 alc662_eeepc_mic_automute(codec);
16024 break;
16025 }
16026}
16027
16028static void alc662_mode2_inithook(struct hda_codec *codec)
16029{
16030 alc662_f5z_speaker_automute(codec);
16031 alc662_eeepc_mic_automute(codec);
16032}
16033/* ***************** Mode3 ******************************/
16034static void alc663_mode3_unsol_event(struct hda_codec *codec,
16035 unsigned int res)
16036{
16037 switch (res >> 26) {
16038 case ALC880_HP_EVENT:
16039 alc663_two_hp_m1_speaker_automute(codec);
16040 break;
16041 case ALC880_MIC_EVENT:
16042 alc662_eeepc_mic_automute(codec);
16043 break;
16044 }
16045}
16046
16047static void alc663_mode3_inithook(struct hda_codec *codec)
16048{
16049 alc663_two_hp_m1_speaker_automute(codec);
16050 alc662_eeepc_mic_automute(codec);
16051}
16052/* ***************** Mode4 ******************************/
16053static void alc663_mode4_unsol_event(struct hda_codec *codec,
16054 unsigned int res)
16055{
16056 switch (res >> 26) {
16057 case ALC880_HP_EVENT:
16058 alc663_21jd_two_speaker_automute(codec);
16059 break;
16060 case ALC880_MIC_EVENT:
16061 alc662_eeepc_mic_automute(codec);
16062 break;
16063 }
16064}
16065
16066static void alc663_mode4_inithook(struct hda_codec *codec)
16067{
16068 alc663_21jd_two_speaker_automute(codec);
16069 alc662_eeepc_mic_automute(codec);
16070}
16071/* ***************** Mode5 ******************************/
16072static void alc663_mode5_unsol_event(struct hda_codec *codec,
16073 unsigned int res)
16074{
16075 switch (res >> 26) {
16076 case ALC880_HP_EVENT:
16077 alc663_15jd_two_speaker_automute(codec);
16078 break;
16079 case ALC880_MIC_EVENT:
16080 alc662_eeepc_mic_automute(codec);
16081 break;
16082 }
16083}
16084
16085static void alc663_mode5_inithook(struct hda_codec *codec)
16086{
16087 alc663_15jd_two_speaker_automute(codec);
16088 alc662_eeepc_mic_automute(codec);
16089}
16090/* ***************** Mode6 ******************************/
16091static void alc663_mode6_unsol_event(struct hda_codec *codec,
16092 unsigned int res)
16093{
16094 switch (res >> 26) {
16095 case ALC880_HP_EVENT:
16096 alc663_two_hp_m2_speaker_automute(codec);
16097 break;
16098 case ALC880_MIC_EVENT:
16099 alc662_eeepc_mic_automute(codec);
16100 break;
16101 }
16102}
16103
16104static void alc663_mode6_inithook(struct hda_codec *codec)
16105{
16106 alc663_two_hp_m2_speaker_automute(codec);
16107 alc662_eeepc_mic_automute(codec);
16108}
16109
Kailang Yang6dda9f42008-05-27 12:05:31 +020016110static void alc663_g71v_hp_automute(struct hda_codec *codec)
16111{
16112 unsigned int present;
16113 unsigned char bits;
16114
16115 present = snd_hda_codec_read(codec, 0x21, 0,
16116 AC_VERB_GET_PIN_SENSE, 0)
16117 & AC_PINSENSE_PRESENCE;
16118 bits = present ? HDA_AMP_MUTE : 0;
16119 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16120 HDA_AMP_MUTE, bits);
16121 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16122 HDA_AMP_MUTE, bits);
16123}
16124
16125static void alc663_g71v_front_automute(struct hda_codec *codec)
16126{
16127 unsigned int present;
16128 unsigned char bits;
16129
16130 present = snd_hda_codec_read(codec, 0x15, 0,
16131 AC_VERB_GET_PIN_SENSE, 0)
16132 & AC_PINSENSE_PRESENCE;
16133 bits = present ? HDA_AMP_MUTE : 0;
16134 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16135 HDA_AMP_MUTE, bits);
16136}
16137
16138static void alc663_g71v_unsol_event(struct hda_codec *codec,
16139 unsigned int res)
16140{
16141 switch (res >> 26) {
16142 case ALC880_HP_EVENT:
16143 alc663_g71v_hp_automute(codec);
16144 break;
16145 case ALC880_FRONT_EVENT:
16146 alc663_g71v_front_automute(codec);
16147 break;
16148 case ALC880_MIC_EVENT:
16149 alc662_eeepc_mic_automute(codec);
16150 break;
16151 }
16152}
16153
16154static void alc663_g71v_inithook(struct hda_codec *codec)
16155{
16156 alc663_g71v_front_automute(codec);
16157 alc663_g71v_hp_automute(codec);
16158 alc662_eeepc_mic_automute(codec);
16159}
16160
16161static void alc663_g50v_unsol_event(struct hda_codec *codec,
16162 unsigned int res)
16163{
16164 switch (res >> 26) {
16165 case ALC880_HP_EVENT:
16166 alc663_m51va_speaker_automute(codec);
16167 break;
16168 case ALC880_MIC_EVENT:
16169 alc662_eeepc_mic_automute(codec);
16170 break;
16171 }
16172}
16173
16174static void alc663_g50v_inithook(struct hda_codec *codec)
16175{
16176 alc663_m51va_speaker_automute(codec);
16177 alc662_eeepc_mic_automute(codec);
16178}
16179
Kailang Yangf1d4e282008-08-26 14:03:29 +020016180/* bind hp and internal speaker mute (with plug check) */
16181static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16182 struct snd_ctl_elem_value *ucontrol)
16183{
16184 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16185 long *valp = ucontrol->value.integer.value;
16186 int change;
16187
16188 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16189 HDA_AMP_MUTE,
16190 valp[0] ? 0 : HDA_AMP_MUTE);
16191 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16192 HDA_AMP_MUTE,
16193 valp[1] ? 0 : HDA_AMP_MUTE);
16194 if (change)
16195 alc262_hippo1_automute(codec);
16196 return change;
16197}
16198
16199static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16200 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16201 {
16202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16203 .name = "Master Playback Switch",
16204 .info = snd_hda_mixer_amp_switch_info,
16205 .get = snd_hda_mixer_amp_switch_get,
16206 .put = alc662_ecs_master_sw_put,
16207 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16208 },
16209
16210 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16211 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16212 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16213
16214 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16215 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16216 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16217 { } /* end */
16218};
16219
Takashi Iwaicb53c622007-08-10 17:21:45 +020016220#ifdef CONFIG_SND_HDA_POWER_SAVE
16221#define alc662_loopbacks alc880_loopbacks
16222#endif
16223
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016224
16225/* pcm configuration: identiacal with ALC880 */
16226#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16227#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16228#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16229#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16230
16231/*
16232 * configuration and preset
16233 */
16234static const char *alc662_models[ALC662_MODEL_LAST] = {
16235 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16236 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16237 [ALC662_3ST_6ch] = "3stack-6ch",
16238 [ALC662_5ST_DIG] = "6stack-dig",
16239 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016240 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016241 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016242 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016243 [ALC663_ASUS_M51VA] = "m51va",
16244 [ALC663_ASUS_G71V] = "g71v",
16245 [ALC663_ASUS_H13] = "h13",
16246 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016247 [ALC663_ASUS_MODE1] = "asus-mode1",
16248 [ALC662_ASUS_MODE2] = "asus-mode2",
16249 [ALC663_ASUS_MODE3] = "asus-mode3",
16250 [ALC663_ASUS_MODE4] = "asus-mode4",
16251 [ALC663_ASUS_MODE5] = "asus-mode5",
16252 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016253 [ALC662_AUTO] = "auto",
16254};
16255
16256static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016257 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16258 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16259 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16260 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16261 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16262 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16263 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16264 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16265 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16266 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16267 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16268 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16269 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16270 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16271 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16272 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16273 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16274 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16275 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016276 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016277 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16278 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16279 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16280 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16281 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16282 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16283 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16284 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16285 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016286 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016287 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16288 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16289 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16290 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16291 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016292 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016293 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016294 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016295 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016296 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16297 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016298 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16299 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016300 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016301 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016302 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016303 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016304 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16305 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016306 {}
16307};
16308
16309static struct alc_config_preset alc662_presets[] = {
16310 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016311 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016312 .init_verbs = { alc662_init_verbs },
16313 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16314 .dac_nids = alc662_dac_nids,
16315 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016316 .dig_in_nid = ALC662_DIGIN_NID,
16317 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16318 .channel_mode = alc662_3ST_2ch_modes,
16319 .input_mux = &alc662_capture_source,
16320 },
16321 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016322 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016323 .init_verbs = { alc662_init_verbs },
16324 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16325 .dac_nids = alc662_dac_nids,
16326 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016327 .dig_in_nid = ALC662_DIGIN_NID,
16328 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16329 .channel_mode = alc662_3ST_6ch_modes,
16330 .need_dac_fix = 1,
16331 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016332 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016333 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016334 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016335 .init_verbs = { alc662_init_verbs },
16336 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16337 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016338 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16339 .channel_mode = alc662_3ST_6ch_modes,
16340 .need_dac_fix = 1,
16341 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016342 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016343 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016344 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016345 .init_verbs = { alc662_init_verbs },
16346 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16347 .dac_nids = alc662_dac_nids,
16348 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016349 .dig_in_nid = ALC662_DIGIN_NID,
16350 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16351 .channel_mode = alc662_5stack_modes,
16352 .input_mux = &alc662_capture_source,
16353 },
16354 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016355 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016356 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16357 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16358 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016359 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16360 .channel_mode = alc662_3ST_2ch_modes,
16361 .input_mux = &alc662_lenovo_101e_capture_source,
16362 .unsol_event = alc662_lenovo_101e_unsol_event,
16363 .init_hook = alc662_lenovo_101e_all_automute,
16364 },
Kailang Yang291702f2007-10-16 14:28:03 +020016365 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016366 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016367 .init_verbs = { alc662_init_verbs,
16368 alc662_eeepc_sue_init_verbs },
16369 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16370 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016371 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16372 .channel_mode = alc662_3ST_2ch_modes,
16373 .input_mux = &alc662_eeepc_capture_source,
16374 .unsol_event = alc662_eeepc_unsol_event,
16375 .init_hook = alc662_eeepc_inithook,
16376 },
Kailang Yang8c427222008-01-10 13:03:59 +010016377 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016378 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016379 alc662_chmode_mixer },
16380 .init_verbs = { alc662_init_verbs,
16381 alc662_eeepc_ep20_sue_init_verbs },
16382 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16383 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016384 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16385 .channel_mode = alc662_3ST_6ch_modes,
16386 .input_mux = &alc662_lenovo_101e_capture_source,
16387 .unsol_event = alc662_eeepc_ep20_unsol_event,
16388 .init_hook = alc662_eeepc_ep20_inithook,
16389 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016390 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016391 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016392 .init_verbs = { alc662_init_verbs,
16393 alc662_ecs_init_verbs },
16394 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16395 .dac_nids = alc662_dac_nids,
16396 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16397 .channel_mode = alc662_3ST_2ch_modes,
16398 .input_mux = &alc662_eeepc_capture_source,
16399 .unsol_event = alc662_eeepc_unsol_event,
16400 .init_hook = alc662_eeepc_inithook,
16401 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016402 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016403 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016404 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16405 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16406 .dac_nids = alc662_dac_nids,
16407 .dig_out_nid = ALC662_DIGOUT_NID,
16408 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16409 .channel_mode = alc662_3ST_2ch_modes,
16410 .input_mux = &alc663_m51va_capture_source,
16411 .unsol_event = alc663_m51va_unsol_event,
16412 .init_hook = alc663_m51va_inithook,
16413 },
16414 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016415 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016416 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16417 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16418 .dac_nids = alc662_dac_nids,
16419 .dig_out_nid = ALC662_DIGOUT_NID,
16420 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16421 .channel_mode = alc662_3ST_2ch_modes,
16422 .input_mux = &alc662_eeepc_capture_source,
16423 .unsol_event = alc663_g71v_unsol_event,
16424 .init_hook = alc663_g71v_inithook,
16425 },
16426 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016427 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016428 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16429 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16430 .dac_nids = alc662_dac_nids,
16431 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16432 .channel_mode = alc662_3ST_2ch_modes,
16433 .input_mux = &alc663_m51va_capture_source,
16434 .unsol_event = alc663_m51va_unsol_event,
16435 .init_hook = alc663_m51va_inithook,
16436 },
16437 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016438 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016439 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16440 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16441 .dac_nids = alc662_dac_nids,
16442 .dig_out_nid = ALC662_DIGOUT_NID,
16443 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16444 .channel_mode = alc662_3ST_6ch_modes,
16445 .input_mux = &alc663_capture_source,
16446 .unsol_event = alc663_g50v_unsol_event,
16447 .init_hook = alc663_g50v_inithook,
16448 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016449 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016450 .mixers = { alc663_m51va_mixer },
16451 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016452 .init_verbs = { alc662_init_verbs,
16453 alc663_21jd_amic_init_verbs },
16454 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16455 .hp_nid = 0x03,
16456 .dac_nids = alc662_dac_nids,
16457 .dig_out_nid = ALC662_DIGOUT_NID,
16458 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16459 .channel_mode = alc662_3ST_2ch_modes,
16460 .input_mux = &alc662_eeepc_capture_source,
16461 .unsol_event = alc663_mode1_unsol_event,
16462 .init_hook = alc663_mode1_inithook,
16463 },
16464 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016465 .mixers = { alc662_1bjd_mixer },
16466 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016467 .init_verbs = { alc662_init_verbs,
16468 alc662_1bjd_amic_init_verbs },
16469 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16470 .dac_nids = alc662_dac_nids,
16471 .dig_out_nid = ALC662_DIGOUT_NID,
16472 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16473 .channel_mode = alc662_3ST_2ch_modes,
16474 .input_mux = &alc662_eeepc_capture_source,
16475 .unsol_event = alc662_mode2_unsol_event,
16476 .init_hook = alc662_mode2_inithook,
16477 },
16478 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016479 .mixers = { alc663_two_hp_m1_mixer },
16480 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016481 .init_verbs = { alc662_init_verbs,
16482 alc663_two_hp_amic_m1_init_verbs },
16483 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16484 .hp_nid = 0x03,
16485 .dac_nids = alc662_dac_nids,
16486 .dig_out_nid = ALC662_DIGOUT_NID,
16487 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16488 .channel_mode = alc662_3ST_2ch_modes,
16489 .input_mux = &alc662_eeepc_capture_source,
16490 .unsol_event = alc663_mode3_unsol_event,
16491 .init_hook = alc663_mode3_inithook,
16492 },
16493 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016494 .mixers = { alc663_asus_21jd_clfe_mixer },
16495 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016496 .init_verbs = { alc662_init_verbs,
16497 alc663_21jd_amic_init_verbs},
16498 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16499 .hp_nid = 0x03,
16500 .dac_nids = alc662_dac_nids,
16501 .dig_out_nid = ALC662_DIGOUT_NID,
16502 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16503 .channel_mode = alc662_3ST_2ch_modes,
16504 .input_mux = &alc662_eeepc_capture_source,
16505 .unsol_event = alc663_mode4_unsol_event,
16506 .init_hook = alc663_mode4_inithook,
16507 },
16508 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016509 .mixers = { alc663_asus_15jd_clfe_mixer },
16510 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016511 .init_verbs = { alc662_init_verbs,
16512 alc663_15jd_amic_init_verbs },
16513 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16514 .hp_nid = 0x03,
16515 .dac_nids = alc662_dac_nids,
16516 .dig_out_nid = ALC662_DIGOUT_NID,
16517 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16518 .channel_mode = alc662_3ST_2ch_modes,
16519 .input_mux = &alc662_eeepc_capture_source,
16520 .unsol_event = alc663_mode5_unsol_event,
16521 .init_hook = alc663_mode5_inithook,
16522 },
16523 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016524 .mixers = { alc663_two_hp_m2_mixer },
16525 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016526 .init_verbs = { alc662_init_verbs,
16527 alc663_two_hp_amic_m2_init_verbs },
16528 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16529 .hp_nid = 0x03,
16530 .dac_nids = alc662_dac_nids,
16531 .dig_out_nid = ALC662_DIGOUT_NID,
16532 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16533 .channel_mode = alc662_3ST_2ch_modes,
16534 .input_mux = &alc662_eeepc_capture_source,
16535 .unsol_event = alc663_mode6_unsol_event,
16536 .init_hook = alc663_mode6_inithook,
16537 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016538};
16539
16540
16541/*
16542 * BIOS auto configuration
16543 */
16544
16545/* add playback controls from the parsed DAC table */
16546static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16547 const struct auto_pin_cfg *cfg)
16548{
16549 char name[32];
16550 static const char *chname[4] = {
16551 "Front", "Surround", NULL /*CLFE*/, "Side"
16552 };
16553 hda_nid_t nid;
16554 int i, err;
16555
16556 for (i = 0; i < cfg->line_outs; i++) {
16557 if (!spec->multiout.dac_nids[i])
16558 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016559 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016560 if (i == 2) {
16561 /* Center/LFE */
16562 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16563 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016564 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16565 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016566 if (err < 0)
16567 return err;
16568 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16569 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016570 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16571 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016572 if (err < 0)
16573 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016574 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016575 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016576 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016577 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016578 if (err < 0)
16579 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016580 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016581 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016582 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016583 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016584 if (err < 0)
16585 return err;
16586 } else {
16587 sprintf(name, "%s Playback Volume", chname[i]);
16588 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016589 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16590 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016591 if (err < 0)
16592 return err;
16593 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016594 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16595 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16596 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016597 if (err < 0)
16598 return err;
16599 }
16600 }
16601 return 0;
16602}
16603
16604/* add playback controls for speaker and HP outputs */
16605static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16606 const char *pfx)
16607{
16608 hda_nid_t nid;
16609 int err;
16610 char name[32];
16611
16612 if (!pin)
16613 return 0;
16614
Takashi Iwai24fb9172008-09-02 14:48:20 +020016615 if (pin == 0x17) {
16616 /* ALC663 has a mono output pin on 0x17 */
16617 sprintf(name, "%s Playback Switch", pfx);
16618 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16619 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16620 return err;
16621 }
16622
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016623 if (alc880_is_fixed_pin(pin)) {
16624 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016625 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016626 /* specify the DAC as the extra output */
16627 if (!spec->multiout.hp_nid)
16628 spec->multiout.hp_nid = nid;
16629 else
16630 spec->multiout.extra_out_nid[0] = nid;
16631 /* control HP volume/switch on the output mixer amp */
16632 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16633 sprintf(name, "%s Playback Volume", pfx);
16634 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16635 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16636 if (err < 0)
16637 return err;
16638 sprintf(name, "%s Playback Switch", pfx);
16639 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16640 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16641 if (err < 0)
16642 return err;
16643 } else if (alc880_is_multi_pin(pin)) {
16644 /* set manual connection */
16645 /* we have only a switch on HP-out PIN */
16646 sprintf(name, "%s Playback Switch", pfx);
16647 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16648 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16649 if (err < 0)
16650 return err;
16651 }
16652 return 0;
16653}
16654
16655/* create playback/capture controls for input pins */
16656static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16657 const struct auto_pin_cfg *cfg)
16658{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016659 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016660 int i, err, idx;
16661
16662 for (i = 0; i < AUTO_PIN_LAST; i++) {
16663 if (alc880_is_input_pin(cfg->input_pins[i])) {
16664 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16665 err = new_analog_input(spec, cfg->input_pins[i],
16666 auto_pin_cfg_labels[i],
16667 idx, 0x0b);
16668 if (err < 0)
16669 return err;
16670 imux->items[imux->num_items].label =
16671 auto_pin_cfg_labels[i];
16672 imux->items[imux->num_items].index =
16673 alc880_input_pin_idx(cfg->input_pins[i]);
16674 imux->num_items++;
16675 }
16676 }
16677 return 0;
16678}
16679
16680static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16681 hda_nid_t nid, int pin_type,
16682 int dac_idx)
16683{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016684 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016685 /* need the manual connection? */
16686 if (alc880_is_multi_pin(nid)) {
16687 struct alc_spec *spec = codec->spec;
16688 int idx = alc880_multi_pin_idx(nid);
16689 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16690 AC_VERB_SET_CONNECT_SEL,
16691 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16692 }
16693}
16694
16695static void alc662_auto_init_multi_out(struct hda_codec *codec)
16696{
16697 struct alc_spec *spec = codec->spec;
16698 int i;
16699
Kailang Yang8c427222008-01-10 13:03:59 +010016700 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016701 for (i = 0; i <= HDA_SIDE; i++) {
16702 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016703 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016704 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016705 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016706 i);
16707 }
16708}
16709
16710static void alc662_auto_init_hp_out(struct hda_codec *codec)
16711{
16712 struct alc_spec *spec = codec->spec;
16713 hda_nid_t pin;
16714
16715 pin = spec->autocfg.hp_pins[0];
16716 if (pin) /* connect to front */
16717 /* use dac 0 */
16718 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016719 pin = spec->autocfg.speaker_pins[0];
16720 if (pin)
16721 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016722}
16723
16724#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16725#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16726
16727static void alc662_auto_init_analog_input(struct hda_codec *codec)
16728{
16729 struct alc_spec *spec = codec->spec;
16730 int i;
16731
16732 for (i = 0; i < AUTO_PIN_LAST; i++) {
16733 hda_nid_t nid = spec->autocfg.input_pins[i];
16734 if (alc662_is_input_pin(nid)) {
16735 snd_hda_codec_write(codec, nid, 0,
16736 AC_VERB_SET_PIN_WIDGET_CONTROL,
16737 (i <= AUTO_PIN_FRONT_MIC ?
16738 PIN_VREF80 : PIN_IN));
16739 if (nid != ALC662_PIN_CD_NID)
16740 snd_hda_codec_write(codec, nid, 0,
16741 AC_VERB_SET_AMP_GAIN_MUTE,
16742 AMP_OUT_MUTE);
16743 }
16744 }
16745}
16746
Takashi Iwaif511b012008-08-15 16:46:42 +020016747#define alc662_auto_init_input_src alc882_auto_init_input_src
16748
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016749static int alc662_parse_auto_config(struct hda_codec *codec)
16750{
16751 struct alc_spec *spec = codec->spec;
16752 int err;
16753 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16754
16755 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16756 alc662_ignore);
16757 if (err < 0)
16758 return err;
16759 if (!spec->autocfg.line_outs)
16760 return 0; /* can't find valid BIOS pin config */
16761
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016762 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16763 if (err < 0)
16764 return err;
16765 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16766 if (err < 0)
16767 return err;
16768 err = alc662_auto_create_extra_out(spec,
16769 spec->autocfg.speaker_pins[0],
16770 "Speaker");
16771 if (err < 0)
16772 return err;
16773 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16774 "Headphone");
16775 if (err < 0)
16776 return err;
16777 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16778 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016779 return err;
16780
16781 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16782
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016783 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016784 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16785
Takashi Iwai603c4012008-07-30 15:01:44 +020016786 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016787 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016788
16789 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016790 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016791
Takashi Iwaid88897e2008-10-31 15:01:37 +010016792 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016793 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016794 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016795
16796 err = alc_auto_add_mic_boost(codec);
16797 if (err < 0)
16798 return err;
16799
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016800 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016801}
16802
16803/* additional initialization for auto-configuration model */
16804static void alc662_auto_init(struct hda_codec *codec)
16805{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016806 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016807 alc662_auto_init_multi_out(codec);
16808 alc662_auto_init_hp_out(codec);
16809 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016810 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016811 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016812 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016813}
16814
16815static int patch_alc662(struct hda_codec *codec)
16816{
16817 struct alc_spec *spec;
16818 int err, board_config;
16819
16820 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16821 if (!spec)
16822 return -ENOMEM;
16823
16824 codec->spec = spec;
16825
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016826 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16827
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016828 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16829 alc662_models,
16830 alc662_cfg_tbl);
16831 if (board_config < 0) {
16832 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16833 "trying auto-probe from BIOS...\n");
16834 board_config = ALC662_AUTO;
16835 }
16836
16837 if (board_config == ALC662_AUTO) {
16838 /* automatic parse from the BIOS config */
16839 err = alc662_parse_auto_config(codec);
16840 if (err < 0) {
16841 alc_free(codec);
16842 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016843 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016844 printk(KERN_INFO
16845 "hda_codec: Cannot set up configuration "
16846 "from BIOS. Using base mode...\n");
16847 board_config = ALC662_3ST_2ch_DIG;
16848 }
16849 }
16850
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016851 err = snd_hda_attach_beep_device(codec, 0x1);
16852 if (err < 0) {
16853 alc_free(codec);
16854 return err;
16855 }
16856
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016857 if (board_config != ALC662_AUTO)
16858 setup_preset(spec, &alc662_presets[board_config]);
16859
Kailang Yang6dda9f42008-05-27 12:05:31 +020016860 if (codec->vendor_id == 0x10ec0663) {
16861 spec->stream_name_analog = "ALC663 Analog";
16862 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016863 } else if (codec->vendor_id == 0x10ec0272) {
16864 spec->stream_name_analog = "ALC272 Analog";
16865 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016866 } else {
16867 spec->stream_name_analog = "ALC662 Analog";
16868 spec->stream_name_digital = "ALC662 Digital";
16869 }
16870
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016871 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16872 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16873
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016874 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16875 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16876
Takashi Iwaie1406342008-02-11 18:32:32 +010016877 spec->adc_nids = alc662_adc_nids;
16878 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16879 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016880 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016881
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016882 if (!spec->cap_mixer)
16883 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016884 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016885
Takashi Iwai2134ea42008-01-10 16:53:55 +010016886 spec->vmaster_nid = 0x02;
16887
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016888 codec->patch_ops = alc_patch_ops;
16889 if (board_config == ALC662_AUTO)
16890 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016891#ifdef CONFIG_SND_HDA_POWER_SAVE
16892 if (!spec->loopback.amplist)
16893 spec->loopback.amplist = alc662_loopbacks;
16894#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016895 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016896
16897 return 0;
16898}
16899
16900/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016901 * patch entries
16902 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016903static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016904 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016905 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016906 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016907 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016908 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016909 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016910 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016911 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016912 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16913 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16914 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016915 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16916 .patch = patch_alc883 },
16917 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16918 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016919 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016920 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016921 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016922 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016923 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16924 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016925 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016926 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016927 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016928 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016929 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16930 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016931 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016932 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016933 {} /* terminator */
16934};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016935
16936MODULE_ALIAS("snd-hda-codec-id:10ec*");
16937
16938MODULE_LICENSE("GPL");
16939MODULE_DESCRIPTION("Realtek HD-audio codec");
16940
16941static struct hda_codec_preset_list realtek_list = {
16942 .preset = snd_hda_preset_realtek,
16943 .owner = THIS_MODULE,
16944};
16945
16946static int __init patch_realtek_init(void)
16947{
16948 return snd_hda_add_codec_preset(&realtek_list);
16949}
16950
16951static void __exit patch_realtek_exit(void)
16952{
16953 snd_hda_delete_codec_preset(&realtek_list);
16954}
16955
16956module_init(patch_realtek_init)
16957module_exit(patch_realtek_exit)