blob: 98a02fd1097ed4b00a356cc488d0bdd44ec13422 [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"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010033#include "hda_patch.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,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010081#ifdef CONFIG_SND_DEBUG
82 ALC260_TEST,
83#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010084 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020085 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
Kailang Yangdf694da2005-12-05 19:42:22 +010088/* ALC262 models */
89enum {
90 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020091 ALC262_HIPPO,
92 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010093 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020094 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010095 ALC262_HP_BPC_D7000_WL,
96 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010097 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010098 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020099 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200100 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200101 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200102 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100103 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200104 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200105 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200106 ALC262_TOSHIBA_RX1,
Kailang Yangdf694da2005-12-05 19:42:22 +0100107 ALC262_AUTO,
108 ALC262_MODEL_LAST /* last tag */
109};
110
Kailang Yanga361d842007-06-05 12:30:55 +0200111/* ALC268 models */
112enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200113 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200114 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200115 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200116 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100117 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200118 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100119 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100120 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100121#ifdef CONFIG_SND_DEBUG
122 ALC268_TEST,
123#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200124 ALC268_AUTO,
125 ALC268_MODEL_LAST /* last tag */
126};
127
Kailang Yangf6a92242007-12-13 16:52:54 +0100128/* ALC269 models */
129enum {
130 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200131 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200132 ALC269_ASUS_EEEPC_P703,
133 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100134 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000135 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100136 ALC269_AUTO,
137 ALC269_MODEL_LAST /* last tag */
138};
139
Kailang Yangdf694da2005-12-05 19:42:22 +0100140/* ALC861 models */
141enum {
142 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200143 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100144 ALC861_3ST_DIG,
145 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200146 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200147 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200148 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100149 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_AUTO,
151 ALC861_MODEL_LAST,
152};
153
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100154/* ALC861-VD models */
155enum {
156 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200157 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100158 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100159 ALC861VD_3ST,
160 ALC861VD_3ST_DIG,
161 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200162 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200163 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200164 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_AUTO,
166 ALC861VD_MODEL_LAST,
167};
168
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200169/* ALC662 models */
170enum {
171 ALC662_3ST_2ch_DIG,
172 ALC662_3ST_6ch_DIG,
173 ALC662_3ST_6ch,
174 ALC662_5ST_DIG,
175 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200176 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100177 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200178 ALC663_ASUS_M51VA,
179 ALC663_ASUS_G71V,
180 ALC663_ASUS_H13,
181 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200182 ALC662_ECS,
183 ALC663_ASUS_MODE1,
184 ALC662_ASUS_MODE2,
185 ALC663_ASUS_MODE3,
186 ALC663_ASUS_MODE4,
187 ALC663_ASUS_MODE5,
188 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200189 ALC662_AUTO,
190 ALC662_MODEL_LAST,
191};
192
Kailang Yangdf694da2005-12-05 19:42:22 +0100193/* ALC882 models */
194enum {
195 ALC882_3ST_DIG,
196 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200197 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200198 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200199 ALC882_TARGA,
200 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200201 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100202 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200203 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200204 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200205 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100206 ALC882_MODEL_LAST,
207};
208
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200209/* ALC883 models */
210enum {
211 ALC883_3ST_2ch_DIG,
212 ALC883_3ST_6ch_DIG,
213 ALC883_3ST_6ch,
214 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200215 ALC883_TARGA_DIG,
216 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200217 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200218 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200219 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200220 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100221 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200222 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200223 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200224 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200225 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200226 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200227 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100228 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100229 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100230 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100231 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200232 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200233 ALC888_ASUS_M90V,
234 ALC888_ASUS_EEE1601,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200235 ALC883_AUTO,
236 ALC883_MODEL_LAST,
237};
238
Kailang Yangdf694da2005-12-05 19:42:22 +0100239/* for GPIO Poll */
240#define GPIO_MASK 0x03
241
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242struct alc_spec {
243 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100244 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100246 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
Kailang Yangdf694da2005-12-05 19:42:22 +0100248 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200249 * don't forget NULL
250 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200251 */
252 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
Takashi Iwai16ded522005-06-10 19:58:24 +0200254 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 struct hda_pcm_stream *stream_analog_playback;
256 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100257 struct hda_pcm_stream *stream_analog_alt_playback;
258 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200260 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 struct hda_pcm_stream *stream_digital_playback;
262 struct hda_pcm_stream *stream_digital_capture;
263
264 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200265 struct hda_multi_out multiout; /* playback set-up
266 * max_channels, dacs must be set
267 * dig_out_nid and hp_nid are optional
268 */
Takashi Iwai63300792008-01-24 15:31:36 +0100269 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
271 /* capture */
272 unsigned int num_adc_nids;
273 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100274 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200275 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100276 unsigned char is_mix_capture; /* matrix-style capture (non-mux) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
278 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200279 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 const struct hda_input_mux *input_mux;
281 unsigned int cur_mux[3];
282
283 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100284 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200286 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
288 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100289 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200290
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200291 /* dynamic controls, init_verbs and input_mux */
292 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200293 struct snd_array kctls;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200294 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200295 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100296
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100297 /* hooks */
298 void (*init_hook)(struct hda_codec *codec);
299 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
300
Takashi Iwai834be882006-03-01 14:16:17 +0100301 /* for pin sensing */
302 unsigned int sense_updated: 1;
303 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100304 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200305
Takashi Iwai2134ea42008-01-10 16:53:55 +0100306 /* for virtual master */
307 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200308#ifdef CONFIG_SND_HDA_POWER_SAVE
309 struct hda_loopback_check loopback;
310#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200311
312 /* for PLL fix */
313 hda_nid_t pll_nid;
314 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaie044c392008-10-27 16:56:24 +0100315
316#ifdef SND_HDA_NEEDS_RESUME
317#define ALC_MAX_PINS 16
318 unsigned int num_pins;
319 hda_nid_t pin_nids[ALC_MAX_PINS];
320 unsigned int pin_cfgs[ALC_MAX_PINS];
321#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100322};
323
324/*
325 * configuration template - to be copied to the spec instance
326 */
327struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200328 struct snd_kcontrol_new *mixers[5]; /* should be identical size
329 * with spec
330 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100331 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100332 const struct hda_verb *init_verbs[5];
333 unsigned int num_dacs;
334 hda_nid_t *dac_nids;
335 hda_nid_t dig_out_nid; /* optional */
336 hda_nid_t hp_nid; /* optional */
337 unsigned int num_adc_nids;
338 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100339 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100340 hda_nid_t dig_in_nid;
341 unsigned int num_channel_mode;
342 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200343 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200344 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100345 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100346 void (*unsol_event)(struct hda_codec *, unsigned int);
347 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200348#ifdef CONFIG_SND_HDA_POWER_SAVE
349 struct hda_amp_list *loopbacks;
350#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351};
352
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
354/*
355 * input MUX handling
356 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200357static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
358 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359{
360 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
361 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200362 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
363 if (mux_idx >= spec->num_mux_defs)
364 mux_idx = 0;
365 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366}
367
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200368static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
369 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370{
371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
372 struct alc_spec *spec = codec->spec;
373 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
374
375 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
376 return 0;
377}
378
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200379static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
380 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381{
382 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
383 struct alc_spec *spec = codec->spec;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100384 const struct hda_input_mux *imux = spec->input_mux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaie1406342008-02-11 18:32:32 +0100386 hda_nid_t nid = spec->capsrc_nids ?
387 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100389 if (spec->is_mix_capture) {
390 /* Matrix-mixer style (e.g. ALC882) */
391 unsigned int *cur_val = &spec->cur_mux[adc_idx];
392 unsigned int i, idx;
393
394 idx = ucontrol->value.enumerated.item[0];
395 if (idx >= imux->num_items)
396 idx = imux->num_items - 1;
397 if (*cur_val == idx)
398 return 0;
399 for (i = 0; i < imux->num_items; i++) {
400 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
401 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
402 imux->items[i].index,
403 HDA_AMP_MUTE, v);
404 }
405 *cur_val = idx;
406 return 1;
407 } else {
408 /* MUX style (e.g. ALC880) */
409 unsigned int mux_idx;
410 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
411 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx],
412 ucontrol, nid,
413 &spec->cur_mux[adc_idx]);
414 }
415}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200416
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417/*
418 * channel mode setting
419 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200420static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
421 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422{
423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
424 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100425 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
426 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427}
428
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200429static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
430 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431{
432 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
433 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100434 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200435 spec->num_channel_mode,
436 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437}
438
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200439static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
440 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441{
442 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
443 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200444 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
445 spec->num_channel_mode,
446 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200447 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200448 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
449 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450}
451
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100453 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200454 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100455 * being part of a format specifier. Maximum allowed length of a value is
456 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100457 *
458 * Note: some retasking pin complexes seem to ignore requests for input
459 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
460 * are requested. Therefore order this list so that this behaviour will not
461 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200462 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
463 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200464 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100465static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100466 "Mic 50pc bias", "Mic 80pc bias",
467 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100468};
469static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100470 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100471};
472/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200473 * in the pin being assumed to be exclusively an input or an output pin. In
474 * addition, "input" pins may or may not process the mic bias option
475 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
476 * accept requests for bias as of chip versions up to March 2006) and/or
477 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100478 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200479#define ALC_PIN_DIR_IN 0x00
480#define ALC_PIN_DIR_OUT 0x01
481#define ALC_PIN_DIR_INOUT 0x02
482#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
483#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100484
Kailang Yangea1fb292008-08-26 12:58:38 +0200485/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100486 * For each direction the minimum and maximum values are given.
487 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200488static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100489 { 0, 2 }, /* ALC_PIN_DIR_IN */
490 { 3, 4 }, /* ALC_PIN_DIR_OUT */
491 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200492 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
493 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100494};
495#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
496#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
497#define alc_pin_mode_n_items(_dir) \
498 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
499
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200500static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
501 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200502{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100503 unsigned int item_num = uinfo->value.enumerated.item;
504 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
505
506 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200507 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100508 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
509
510 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
511 item_num = alc_pin_mode_min(dir);
512 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200513 return 0;
514}
515
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200516static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200518{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100519 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
521 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200523 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200524 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
525 AC_VERB_GET_PIN_WIDGET_CONTROL,
526 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200527
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100528 /* Find enumerated value for current pinctl setting */
529 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200532 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533 return 0;
534}
535
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200536static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100538{
539 signed int change;
540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
541 hda_nid_t nid = kcontrol->private_value & 0xffff;
542 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
543 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200544 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
545 AC_VERB_GET_PIN_WIDGET_CONTROL,
546 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100547
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200548 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100549 val = alc_pin_mode_min(dir);
550
551 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100552 if (change) {
553 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200554 snd_hda_codec_write_cache(codec, nid, 0,
555 AC_VERB_SET_PIN_WIDGET_CONTROL,
556 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100557
Kailang Yangea1fb292008-08-26 12:58:38 +0200558 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100559 * for the requested pin mode. Enum values of 2 or less are
560 * input modes.
561 *
562 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200563 * reduces noise slightly (particularly on input) so we'll
564 * do it. However, having both input and output buffers
565 * enabled simultaneously doesn't seem to be problematic if
566 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100567 */
568 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200569 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
570 HDA_AMP_MUTE, HDA_AMP_MUTE);
571 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
572 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100573 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200574 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
575 HDA_AMP_MUTE, HDA_AMP_MUTE);
576 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
577 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100578 }
579 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200580 return change;
581}
582
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100583#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200584 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100585 .info = alc_pin_mode_info, \
586 .get = alc_pin_mode_get, \
587 .put = alc_pin_mode_put, \
588 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100589
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100590/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
591 * together using a mask with more than one bit set. This control is
592 * currently used only by the ALC260 test model. At this stage they are not
593 * needed for any "production" models.
594 */
595#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200596#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200597
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200598static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
599 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100600{
601 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
602 hda_nid_t nid = kcontrol->private_value & 0xffff;
603 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
604 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200605 unsigned int val = snd_hda_codec_read(codec, nid, 0,
606 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100607
608 *valp = (val & mask) != 0;
609 return 0;
610}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200611static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
612 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100613{
614 signed int change;
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 val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200619 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
620 AC_VERB_GET_GPIO_DATA,
621 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100622
623 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200624 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
625 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100626 gpio_data &= ~mask;
627 else
628 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200629 snd_hda_codec_write_cache(codec, nid, 0,
630 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100631
632 return change;
633}
634#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
635 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
636 .info = alc_gpio_data_info, \
637 .get = alc_gpio_data_get, \
638 .put = alc_gpio_data_put, \
639 .private_value = nid | (mask<<16) }
640#endif /* CONFIG_SND_DEBUG */
641
Jonathan Woithe92621f12006-02-28 11:47:47 +0100642/* A switch control to allow the enabling of the digital IO pins on the
643 * ALC260. This is incredibly simplistic; the intention of this control is
644 * to provide something in the test model allowing digital outputs to be
645 * identified if present. If models are found which can utilise these
646 * outputs a more complete mixer control can be devised for those models if
647 * necessary.
648 */
649#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200650#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200651
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200652static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100654{
655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
656 hda_nid_t nid = kcontrol->private_value & 0xffff;
657 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
658 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200659 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100660 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100661
662 *valp = (val & mask) != 0;
663 return 0;
664}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200665static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
666 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100667{
668 signed int change;
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 val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200673 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100674 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200675 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100676
677 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200678 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100679 if (val==0)
680 ctrl_data &= ~mask;
681 else
682 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200683 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
684 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100685
686 return change;
687}
688#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
689 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
690 .info = alc_spdif_ctrl_info, \
691 .get = alc_spdif_ctrl_get, \
692 .put = alc_spdif_ctrl_put, \
693 .private_value = nid | (mask<<16) }
694#endif /* CONFIG_SND_DEBUG */
695
Jonathan Woithef8225f62008-01-08 12:16:54 +0100696/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
697 * Again, this is only used in the ALC26x test models to help identify when
698 * the EAPD line must be asserted for features to work.
699 */
700#ifdef CONFIG_SND_DEBUG
701#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
702
703static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
704 struct snd_ctl_elem_value *ucontrol)
705{
706 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
707 hda_nid_t nid = kcontrol->private_value & 0xffff;
708 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
709 long *valp = ucontrol->value.integer.value;
710 unsigned int val = snd_hda_codec_read(codec, nid, 0,
711 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
712
713 *valp = (val & mask) != 0;
714 return 0;
715}
716
717static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
718 struct snd_ctl_elem_value *ucontrol)
719{
720 int change;
721 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
722 hda_nid_t nid = kcontrol->private_value & 0xffff;
723 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
724 long val = *ucontrol->value.integer.value;
725 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
726 AC_VERB_GET_EAPD_BTLENABLE,
727 0x00);
728
729 /* Set/unset the masked control bit(s) as needed */
730 change = (!val ? 0 : mask) != (ctrl_data & mask);
731 if (!val)
732 ctrl_data &= ~mask;
733 else
734 ctrl_data |= mask;
735 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
736 ctrl_data);
737
738 return change;
739}
740
741#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
742 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
743 .info = alc_eapd_ctrl_info, \
744 .get = alc_eapd_ctrl_get, \
745 .put = alc_eapd_ctrl_put, \
746 .private_value = nid | (mask<<16) }
747#endif /* CONFIG_SND_DEBUG */
748
Kailang Yangdf694da2005-12-05 19:42:22 +0100749/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100750 */
751static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
752{
753 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
754 return;
755 spec->mixers[spec->num_mixers++] = mix;
756}
757
758static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
759{
760 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
761 return;
762 spec->init_verbs[spec->num_init_verbs++] = verb;
763}
764
765/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100766 * set up from the preset table
767 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200768static void setup_preset(struct alc_spec *spec,
769 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100770{
771 int i;
772
773 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100774 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100775 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200776 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
777 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100778 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200779
Kailang Yangdf694da2005-12-05 19:42:22 +0100780 spec->channel_mode = preset->channel_mode;
781 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200782 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100783
784 spec->multiout.max_channels = spec->channel_mode[0].channels;
785
786 spec->multiout.num_dacs = preset->num_dacs;
787 spec->multiout.dac_nids = preset->dac_nids;
788 spec->multiout.dig_out_nid = preset->dig_out_nid;
789 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200790
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200791 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200792 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200793 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100794 spec->input_mux = preset->input_mux;
795
796 spec->num_adc_nids = preset->num_adc_nids;
797 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100798 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100799 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100800
801 spec->unsol_event = preset->unsol_event;
802 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200803#ifdef CONFIG_SND_HDA_POWER_SAVE
804 spec->loopback.amplist = preset->loopbacks;
805#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100806}
807
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200808/* Enable GPIO mask and set output */
809static struct hda_verb alc_gpio1_init_verbs[] = {
810 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
811 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
812 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
813 { }
814};
815
816static struct hda_verb alc_gpio2_init_verbs[] = {
817 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
818 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
819 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
820 { }
821};
822
Kailang Yangbdd148a2007-05-08 15:19:08 +0200823static struct hda_verb alc_gpio3_init_verbs[] = {
824 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
825 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
826 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
827 { }
828};
829
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200830/*
831 * Fix hardware PLL issue
832 * On some codecs, the analog PLL gating control must be off while
833 * the default value is 1.
834 */
835static void alc_fix_pll(struct hda_codec *codec)
836{
837 struct alc_spec *spec = codec->spec;
838 unsigned int val;
839
840 if (!spec->pll_nid)
841 return;
842 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
843 spec->pll_coef_idx);
844 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
845 AC_VERB_GET_PROC_COEF, 0);
846 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
847 spec->pll_coef_idx);
848 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
849 val & ~(1 << spec->pll_coef_bit));
850}
851
852static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
853 unsigned int coef_idx, unsigned int coef_bit)
854{
855 struct alc_spec *spec = codec->spec;
856 spec->pll_nid = nid;
857 spec->pll_coef_idx = coef_idx;
858 spec->pll_coef_bit = coef_bit;
859 alc_fix_pll(codec);
860}
861
Kailang Yangc9b58002007-10-16 14:30:01 +0200862static void alc_sku_automute(struct hda_codec *codec)
863{
864 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200865 unsigned int present;
866 unsigned int hp_nid = spec->autocfg.hp_pins[0];
867 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
868
869 /* need to execute and sync at first */
870 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
871 present = snd_hda_codec_read(codec, hp_nid, 0,
872 AC_VERB_GET_PIN_SENSE, 0);
873 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100874 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
875 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200876}
877
Takashi Iwai4605b712008-10-31 14:18:24 +0100878#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200879static void alc_mic_automute(struct hda_codec *codec)
880{
881 struct alc_spec *spec = codec->spec;
882 unsigned int present;
883 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
884 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
885 unsigned int mix_nid = spec->capsrc_nids[0];
886 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
887
888 capsrc_idx_mic = mic_nid - 0x18;
889 capsrc_idx_fmic = fmic_nid - 0x18;
890 present = snd_hda_codec_read(codec, mic_nid, 0,
891 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
892 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
893 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
894 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
895 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
896 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
897 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
898}
Takashi Iwai4605b712008-10-31 14:18:24 +0100899#else
900#define alc_mic_automute(codec) /* NOP */
901#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200902
Kailang Yangc9b58002007-10-16 14:30:01 +0200903/* unsolicited event for HP jack sensing */
904static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
905{
906 if (codec->vendor_id == 0x10ec0880)
907 res >>= 28;
908 else
909 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200910 if (res == ALC880_HP_EVENT)
911 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200912
Kailang Yang7fb0d782008-10-15 11:12:35 +0200913 if (res == ALC880_MIC_EVENT)
914 alc_mic_automute(codec);
915}
916
917static void alc_inithook(struct hda_codec *codec)
918{
Kailang Yangc9b58002007-10-16 14:30:01 +0200919 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200920 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200921}
922
Kailang Yangf9423e72008-05-27 12:32:25 +0200923/* additional initialization for ALC888 variants */
924static void alc888_coef_init(struct hda_codec *codec)
925{
926 unsigned int tmp;
927
928 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
929 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
930 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
931 if ((tmp & 0xf0) == 2)
932 /* alc888S-VC */
933 snd_hda_codec_read(codec, 0x20, 0,
934 AC_VERB_SET_PROC_COEF, 0x830);
935 else
936 /* alc888-VB */
937 snd_hda_codec_read(codec, 0x20, 0,
938 AC_VERB_SET_PROC_COEF, 0x3030);
939}
940
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200941/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
942 * 31 ~ 16 : Manufacture ID
943 * 15 ~ 8 : SKU ID
944 * 7 ~ 0 : Assembly ID
945 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
946 */
947static void alc_subsystem_id(struct hda_codec *codec,
948 unsigned int porta, unsigned int porte,
949 unsigned int portd)
950{
Kailang Yangc9b58002007-10-16 14:30:01 +0200951 unsigned int ass, tmp, i;
952 unsigned nid;
953 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200954
Kailang Yangc9b58002007-10-16 14:30:01 +0200955 ass = codec->subsystem_id & 0xffff;
956 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
957 goto do_sku;
958
Kailang Yangea1fb292008-08-26 12:58:38 +0200959 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200960 * 31~30 : port conetcivity
961 * 29~21 : reserve
962 * 20 : PCBEEP input
963 * 19~16 : Check sum (15:1)
964 * 15~1 : Custom
965 * 0 : override
966 */
967 nid = 0x1d;
968 if (codec->vendor_id == 0x10ec0260)
969 nid = 0x17;
970 ass = snd_hda_codec_read(codec, nid, 0,
971 AC_VERB_GET_CONFIG_DEFAULT, 0);
972 if (!(ass & 1) && !(ass & 0x100000))
973 return;
974 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200975 return;
976
Kailang Yangc9b58002007-10-16 14:30:01 +0200977 /* check sum */
978 tmp = 0;
979 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100980 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200981 tmp++;
982 }
983 if (((ass >> 16) & 0xf) != tmp)
984 return;
985do_sku:
986 /*
987 * 0 : override
988 * 1 : Swap Jack
989 * 2 : 0 --> Desktop, 1 --> Laptop
990 * 3~5 : External Amplifier control
991 * 7~6 : Reserved
992 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200993 tmp = (ass & 0x38) >> 3; /* external Amp control */
994 switch (tmp) {
995 case 1:
996 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
997 break;
998 case 3:
999 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1000 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001001 case 7:
1002 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1003 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001004 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001005 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001006 case 0x10ec0260:
1007 snd_hda_codec_write(codec, 0x0f, 0,
1008 AC_VERB_SET_EAPD_BTLENABLE, 2);
1009 snd_hda_codec_write(codec, 0x10, 0,
1010 AC_VERB_SET_EAPD_BTLENABLE, 2);
1011 break;
1012 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001013 case 0x10ec0267:
1014 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001015 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +02001016 case 0x10ec0660:
1017 case 0x10ec0662:
1018 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001019 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001020 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001021 snd_hda_codec_write(codec, 0x14, 0,
1022 AC_VERB_SET_EAPD_BTLENABLE, 2);
1023 snd_hda_codec_write(codec, 0x15, 0,
1024 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001025 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001026 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001027 switch (codec->vendor_id) {
1028 case 0x10ec0260:
1029 snd_hda_codec_write(codec, 0x1a, 0,
1030 AC_VERB_SET_COEF_INDEX, 7);
1031 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1032 AC_VERB_GET_PROC_COEF, 0);
1033 snd_hda_codec_write(codec, 0x1a, 0,
1034 AC_VERB_SET_COEF_INDEX, 7);
1035 snd_hda_codec_write(codec, 0x1a, 0,
1036 AC_VERB_SET_PROC_COEF,
1037 tmp | 0x2010);
1038 break;
1039 case 0x10ec0262:
1040 case 0x10ec0880:
1041 case 0x10ec0882:
1042 case 0x10ec0883:
1043 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001044 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001045 snd_hda_codec_write(codec, 0x20, 0,
1046 AC_VERB_SET_COEF_INDEX, 7);
1047 tmp = snd_hda_codec_read(codec, 0x20, 0,
1048 AC_VERB_GET_PROC_COEF, 0);
1049 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001050 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001051 snd_hda_codec_write(codec, 0x20, 0,
1052 AC_VERB_SET_PROC_COEF,
1053 tmp | 0x2010);
1054 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001055 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001056 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001057 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001058 case 0x10ec0267:
1059 case 0x10ec0268:
1060 snd_hda_codec_write(codec, 0x20, 0,
1061 AC_VERB_SET_COEF_INDEX, 7);
1062 tmp = snd_hda_codec_read(codec, 0x20, 0,
1063 AC_VERB_GET_PROC_COEF, 0);
1064 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001065 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001066 snd_hda_codec_write(codec, 0x20, 0,
1067 AC_VERB_SET_PROC_COEF,
1068 tmp | 0x3000);
1069 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001070 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001071 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001072 break;
1073 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001074
Kailang Yang8c427222008-01-10 13:03:59 +01001075 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001076 * when the external headphone out jack is plugged"
1077 */
Kailang Yang8c427222008-01-10 13:03:59 +01001078 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001079 return;
1080 /*
1081 * 10~8 : Jack location
1082 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1083 * 14~13: Resvered
1084 * 15 : 1 --> enable the function "Mute internal speaker
1085 * when the external headphone out jack is plugged"
1086 */
1087 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001088 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001089 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001090 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001091 else
1092 return;
1093 }
1094
1095 if (!spec->autocfg.hp_pins[0]) {
1096 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1097 if (tmp == 0)
1098 spec->autocfg.hp_pins[0] = porta;
1099 else if (tmp == 1)
1100 spec->autocfg.hp_pins[0] = porte;
1101 else if (tmp == 2)
1102 spec->autocfg.hp_pins[0] = portd;
1103 else
1104 return;
1105 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001106 if (spec->autocfg.hp_pins[0])
1107 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1108 AC_VERB_SET_UNSOLICITED_ENABLE,
1109 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001110
Takashi Iwai4605b712008-10-31 14:18:24 +01001111#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001112 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1113 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1114 snd_hda_codec_write(codec,
1115 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1116 AC_VERB_SET_UNSOLICITED_ENABLE,
1117 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001118#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001119
Kailang Yangc9b58002007-10-16 14:30:01 +02001120 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001121}
1122
Takashi Iwai41e41f12005-06-08 14:48:49 +02001123/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001124 * Fix-up pin default configurations
1125 */
1126
1127struct alc_pincfg {
1128 hda_nid_t nid;
1129 u32 val;
1130};
1131
1132static void alc_fix_pincfg(struct hda_codec *codec,
1133 const struct snd_pci_quirk *quirk,
1134 const struct alc_pincfg **pinfix)
1135{
1136 const struct alc_pincfg *cfg;
1137
1138 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1139 if (!quirk)
1140 return;
1141
1142 cfg = pinfix[quirk->value];
1143 for (; cfg->nid; cfg++) {
1144 int i;
1145 u32 val = cfg->val;
1146 for (i = 0; i < 4; i++) {
1147 snd_hda_codec_write(codec, cfg->nid, 0,
1148 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1149 val & 0xff);
1150 val >>= 8;
1151 }
1152 }
1153}
1154
1155/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001156 * ALC880 3-stack model
1157 *
1158 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001159 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1160 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 */
1162
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001163static hda_nid_t alc880_dac_nids[4] = {
1164 /* front, rear, clfe, rear_surr */
1165 0x02, 0x05, 0x04, 0x03
1166};
1167
1168static hda_nid_t alc880_adc_nids[3] = {
1169 /* ADC0-2 */
1170 0x07, 0x08, 0x09,
1171};
1172
1173/* The datasheet says the node 0x07 is connected from inputs,
1174 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001175 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001177static hda_nid_t alc880_adc_nids_alt[2] = {
1178 /* ADC1-2 */
1179 0x08, 0x09,
1180};
1181
1182#define ALC880_DIGOUT_NID 0x06
1183#define ALC880_DIGIN_NID 0x0a
1184
1185static struct hda_input_mux alc880_capture_source = {
1186 .num_items = 4,
1187 .items = {
1188 { "Mic", 0x0 },
1189 { "Front Mic", 0x3 },
1190 { "Line", 0x2 },
1191 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001193};
1194
1195/* channel source setting (2/6 channel selection for 3-stack) */
1196/* 2ch mode */
1197static struct hda_verb alc880_threestack_ch2_init[] = {
1198 /* set line-in to input, mute it */
1199 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1200 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1201 /* set mic-in to input vref 80%, mute it */
1202 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1203 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204 { } /* end */
1205};
1206
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001207/* 6ch mode */
1208static struct hda_verb alc880_threestack_ch6_init[] = {
1209 /* set line-in to output, unmute it */
1210 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1211 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1212 /* set mic-in to output, unmute it */
1213 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1214 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1215 { } /* end */
1216};
1217
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001218static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001219 { 2, alc880_threestack_ch2_init },
1220 { 6, alc880_threestack_ch6_init },
1221};
1222
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001223static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001224 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001225 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001226 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001227 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001228 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1229 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001230 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1231 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1233 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1234 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1235 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1236 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1237 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1238 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1239 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1240 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1241 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001242 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001243 {
1244 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1245 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001246 .info = alc_ch_mode_info,
1247 .get = alc_ch_mode_get,
1248 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001249 },
1250 { } /* end */
1251};
1252
1253/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001254static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1255 struct snd_ctl_elem_info *uinfo)
1256{
1257 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1258 struct alc_spec *spec = codec->spec;
1259 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001260
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001261 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1262 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1263 HDA_INPUT);
1264 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1265 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1266 return err;
1267}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001269static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1270 unsigned int size, unsigned int __user *tlv)
1271{
1272 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1273 struct alc_spec *spec = codec->spec;
1274 int err;
1275
1276 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1277 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1278 HDA_INPUT);
1279 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1280 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1281 return err;
1282}
1283
1284typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1285 struct snd_ctl_elem_value *ucontrol);
1286
1287static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1288 struct snd_ctl_elem_value *ucontrol,
1289 getput_call_t func)
1290{
1291 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1292 struct alc_spec *spec = codec->spec;
1293 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1294 int err;
1295
1296 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1297 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1298 3, 0, HDA_INPUT);
1299 err = func(kcontrol, ucontrol);
1300 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1301 return err;
1302}
1303
1304static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1305 struct snd_ctl_elem_value *ucontrol)
1306{
1307 return alc_cap_getput_caller(kcontrol, ucontrol,
1308 snd_hda_mixer_amp_volume_get);
1309}
1310
1311static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1312 struct snd_ctl_elem_value *ucontrol)
1313{
1314 return alc_cap_getput_caller(kcontrol, ucontrol,
1315 snd_hda_mixer_amp_volume_put);
1316}
1317
1318/* capture mixer elements */
1319#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1320
1321static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1322 struct snd_ctl_elem_value *ucontrol)
1323{
1324 return alc_cap_getput_caller(kcontrol, ucontrol,
1325 snd_hda_mixer_amp_switch_get);
1326}
1327
1328static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1329 struct snd_ctl_elem_value *ucontrol)
1330{
1331 return alc_cap_getput_caller(kcontrol, ucontrol,
1332 snd_hda_mixer_amp_switch_put);
1333}
1334
1335#define DEFINE_CAPMIX(num) \
1336static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1337 { \
1338 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1339 .name = "Capture Switch", \
1340 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1341 .count = num, \
1342 .info = alc_cap_sw_info, \
1343 .get = alc_cap_sw_get, \
1344 .put = alc_cap_sw_put, \
1345 }, \
1346 { \
1347 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1348 .name = "Capture Volume", \
1349 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1350 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1351 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1352 .count = num, \
1353 .info = alc_cap_vol_info, \
1354 .get = alc_cap_vol_get, \
1355 .put = alc_cap_vol_put, \
1356 .tlv = { .c = alc_cap_vol_tlv }, \
1357 }, \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001358 { \
1359 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1360 /* .name = "Capture Source", */ \
1361 .name = "Input Source", \
1362 .count = num, \
1363 .info = alc_mux_enum_info, \
1364 .get = alc_mux_enum_get, \
1365 .put = alc_mux_enum_put, \
1366 }, \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001367 { } /* end */ \
1368}
1369
1370/* up to three ADCs */
1371DEFINE_CAPMIX(1);
1372DEFINE_CAPMIX(2);
1373DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001374
1375
1376/*
1377 * ALC880 5-stack model
1378 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001379 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1380 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001381 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1382 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1383 */
1384
1385/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001386static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001387 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001388 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389 { } /* end */
1390};
1391
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001392/* channel source setting (6/8 channel selection for 5-stack) */
1393/* 6ch mode */
1394static struct hda_verb alc880_fivestack_ch6_init[] = {
1395 /* set line-in to input, mute it */
1396 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1397 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001398 { } /* end */
1399};
1400
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001401/* 8ch mode */
1402static struct hda_verb alc880_fivestack_ch8_init[] = {
1403 /* set line-in to output, unmute it */
1404 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1405 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1406 { } /* end */
1407};
1408
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001409static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001410 { 6, alc880_fivestack_ch6_init },
1411 { 8, alc880_fivestack_ch8_init },
1412};
1413
1414
1415/*
1416 * ALC880 6-stack model
1417 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001418 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1419 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001420 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1421 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1422 */
1423
1424static hda_nid_t alc880_6st_dac_nids[4] = {
1425 /* front, rear, clfe, rear_surr */
1426 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001427};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001428
1429static struct hda_input_mux alc880_6stack_capture_source = {
1430 .num_items = 4,
1431 .items = {
1432 { "Mic", 0x0 },
1433 { "Front Mic", 0x1 },
1434 { "Line", 0x2 },
1435 { "CD", 0x4 },
1436 },
1437};
1438
1439/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001440static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001441 { 8, NULL },
1442};
1443
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001444static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001445 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001446 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001447 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001448 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001449 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1450 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001451 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1452 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001453 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001454 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001455 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1456 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1457 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1458 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1460 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1461 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1462 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1463 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1464 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001465 {
1466 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1467 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001468 .info = alc_ch_mode_info,
1469 .get = alc_ch_mode_get,
1470 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001471 },
1472 { } /* end */
1473};
1474
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001475
1476/*
1477 * ALC880 W810 model
1478 *
1479 * W810 has rear IO for:
1480 * Front (DAC 02)
1481 * Surround (DAC 03)
1482 * Center/LFE (DAC 04)
1483 * Digital out (06)
1484 *
1485 * The system also has a pair of internal speakers, and a headphone jack.
1486 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001487 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001488 * There is a variable resistor to control the speaker or headphone
1489 * volume. This is a hardware-only device without a software API.
1490 *
1491 * Plugging headphones in will disable the internal speakers. This is
1492 * implemented in hardware, not via the driver using jack sense. In
1493 * a similar fashion, plugging into the rear socket marked "front" will
1494 * disable both the speakers and headphones.
1495 *
1496 * For input, there's a microphone jack, and an "audio in" jack.
1497 * These may not do anything useful with this driver yet, because I
1498 * haven't setup any initialization verbs for these yet...
1499 */
1500
1501static hda_nid_t alc880_w810_dac_nids[3] = {
1502 /* front, rear/surround, clfe */
1503 0x02, 0x03, 0x04
1504};
1505
1506/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001507static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001508 { 6, NULL }
1509};
1510
1511/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001512static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001513 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001514 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001515 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001516 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001517 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1518 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001519 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1520 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001521 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1522 { } /* end */
1523};
1524
1525
1526/*
1527 * Z710V model
1528 *
1529 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001530 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1531 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001532 */
1533
1534static hda_nid_t alc880_z71v_dac_nids[1] = {
1535 0x02
1536};
1537#define ALC880_Z71V_HP_DAC 0x03
1538
1539/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001540static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001541 { 2, NULL }
1542};
1543
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001544static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001545 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001546 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001547 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001548 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001549 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1550 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1553 { } /* end */
1554};
1555
1556
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001557/*
1558 * ALC880 F1734 model
1559 *
1560 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1561 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1562 */
1563
1564static hda_nid_t alc880_f1734_dac_nids[1] = {
1565 0x03
1566};
1567#define ALC880_F1734_HP_DAC 0x02
1568
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001569static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001570 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001571 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001572 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1573 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001574 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1575 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001576 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1577 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001578 { } /* end */
1579};
1580
Takashi Iwai937b4162008-02-11 14:52:36 +01001581static struct hda_input_mux alc880_f1734_capture_source = {
1582 .num_items = 2,
1583 .items = {
1584 { "Mic", 0x1 },
1585 { "CD", 0x4 },
1586 },
1587};
1588
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001589
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001590/*
1591 * ALC880 ASUS model
1592 *
1593 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1594 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1595 * Mic = 0x18, Line = 0x1a
1596 */
1597
1598#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1599#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1600
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001601static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001602 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001603 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001604 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001605 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001606 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1607 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001608 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1609 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001610 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1611 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1612 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1613 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1615 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001616 {
1617 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1618 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001619 .info = alc_ch_mode_info,
1620 .get = alc_ch_mode_get,
1621 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001622 },
1623 { } /* end */
1624};
1625
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001626/*
1627 * ALC880 ASUS W1V model
1628 *
1629 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1630 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1631 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1632 */
1633
1634/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001635static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001636 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1637 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001638 { } /* end */
1639};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001640
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001641/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001642static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001643 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1644 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1645 { } /* end */
1646};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001647
Kailang Yangdf694da2005-12-05 19:42:22 +01001648/* TCL S700 */
1649static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1650 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1651 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1652 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1653 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1654 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1655 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1656 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1657 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1658 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001659 { } /* end */
1660};
1661
Kailang Yangccc656c2006-10-17 12:32:26 +02001662/* Uniwill */
1663static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001664 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1665 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1666 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1667 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001668 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1669 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1670 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1671 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1672 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1673 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1674 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1675 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1677 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1678 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1679 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1680 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1681 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1682 {
1683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1684 .name = "Channel Mode",
1685 .info = alc_ch_mode_info,
1686 .get = alc_ch_mode_get,
1687 .put = alc_ch_mode_put,
1688 },
1689 { } /* end */
1690};
1691
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001692static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1693 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1694 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1695 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1696 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1697 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1698 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1699 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1700 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1701 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1702 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1703 { } /* end */
1704};
1705
Kailang Yangccc656c2006-10-17 12:32:26 +02001706static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001707 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1708 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1709 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1710 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001711 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1712 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1713 { } /* end */
1714};
1715
Linus Torvalds1da177e2005-04-16 15:20:36 -07001716/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001717 * virtual master controls
1718 */
1719
1720/*
1721 * slave controls for virtual master
1722 */
1723static const char *alc_slave_vols[] = {
1724 "Front Playback Volume",
1725 "Surround Playback Volume",
1726 "Center Playback Volume",
1727 "LFE Playback Volume",
1728 "Side Playback Volume",
1729 "Headphone Playback Volume",
1730 "Speaker Playback Volume",
1731 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001732 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001733 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001734 NULL,
1735};
1736
1737static const char *alc_slave_sws[] = {
1738 "Front Playback Switch",
1739 "Surround Playback Switch",
1740 "Center Playback Switch",
1741 "LFE Playback Switch",
1742 "Side Playback Switch",
1743 "Headphone Playback Switch",
1744 "Speaker Playback Switch",
1745 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001746 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001747 NULL,
1748};
1749
1750/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001751 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001752 */
Takashi Iwai603c4012008-07-30 15:01:44 +02001753
1754static void alc_free_kctls(struct hda_codec *codec);
1755
Linus Torvalds1da177e2005-04-16 15:20:36 -07001756static int alc_build_controls(struct hda_codec *codec)
1757{
1758 struct alc_spec *spec = codec->spec;
1759 int err;
1760 int i;
1761
1762 for (i = 0; i < spec->num_mixers; i++) {
1763 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1764 if (err < 0)
1765 return err;
1766 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001767 if (spec->cap_mixer) {
1768 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
1769 if (err < 0)
1770 return err;
1771 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001772 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001773 err = snd_hda_create_spdif_out_ctls(codec,
1774 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001775 if (err < 0)
1776 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001777 err = snd_hda_create_spdif_share_sw(codec,
1778 &spec->multiout);
1779 if (err < 0)
1780 return err;
1781 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001782 }
1783 if (spec->dig_in_nid) {
1784 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1785 if (err < 0)
1786 return err;
1787 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001788
1789 /* if we have no master control, let's create it */
1790 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001791 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001792 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001793 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001794 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001795 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001796 if (err < 0)
1797 return err;
1798 }
1799 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1800 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1801 NULL, alc_slave_sws);
1802 if (err < 0)
1803 return err;
1804 }
1805
Takashi Iwai603c4012008-07-30 15:01:44 +02001806 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001807 return 0;
1808}
1809
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001810
Linus Torvalds1da177e2005-04-16 15:20:36 -07001811/*
1812 * initialize the codec volumes, etc
1813 */
1814
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001815/*
1816 * generic initialization of ADC, input mixers and output mixers
1817 */
1818static struct hda_verb alc880_volume_init_verbs[] = {
1819 /*
1820 * Unmute ADC0-2 and set the default input to mic-in
1821 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001822 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001824 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001825 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001826 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001827 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001828
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001829 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1830 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001831 * Note: PASD motherboards uses the Line In 2 as the input for front
1832 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001833 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001834 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001842
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001843 /*
1844 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001845 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001846 /* set vol=0 to output mixers */
1847 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1848 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1849 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1850 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1851 /* set up input amps for analog loopback */
1852 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1854 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001855 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1856 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1858 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001859 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1860 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001861
1862 { }
1863};
1864
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001865/*
1866 * 3-stack pin configuration:
1867 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1868 */
1869static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1870 /*
1871 * preset connection lists of input pins
1872 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1873 */
1874 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1875 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1876 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1877
1878 /*
1879 * Set pin mode and muting
1880 */
1881 /* set front pin widgets 0x14 for output */
1882 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1883 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1884 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1885 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1886 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1887 /* Mic2 (as headphone out) for HP output */
1888 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1889 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1890 /* Line In pin widget for input */
1891 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1892 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1893 /* Line2 (as front mic) pin widget for input and vref at 80% */
1894 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1895 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1896 /* CD pin widget for input */
1897 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1898
1899 { }
1900};
1901
1902/*
1903 * 5-stack pin configuration:
1904 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1905 * line-in/side = 0x1a, f-mic = 0x1b
1906 */
1907static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1908 /*
1909 * preset connection lists of input pins
1910 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1911 */
1912 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1913 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1914
1915 /*
1916 * Set pin mode and muting
1917 */
1918 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1920 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1921 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1922 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001923 /* unmute pins for output (no gain on this amp) */
1924 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1926 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1927 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1928
Linus Torvalds1da177e2005-04-16 15:20:36 -07001929 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001930 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001931 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1932 /* Mic2 (as headphone out) for HP output */
1933 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001934 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001935 /* Line In pin widget for input */
1936 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1937 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1938 /* Line2 (as front mic) pin widget for input and vref at 80% */
1939 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1940 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1941 /* CD pin widget for input */
1942 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001943
1944 { }
1945};
1946
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001947/*
1948 * W810 pin configuration:
1949 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1950 */
1951static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001952 /* hphone/speaker input selector: front DAC */
1953 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1954
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001955 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1956 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1957 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1958 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1959 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1960 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1961
1962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001964
Linus Torvalds1da177e2005-04-16 15:20:36 -07001965 { }
1966};
1967
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001968/*
1969 * Z71V pin configuration:
1970 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1971 */
1972static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001973 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001974 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001976 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001977
Takashi Iwai16ded522005-06-10 19:58:24 +02001978 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001979 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001980 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001981 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001982
1983 { }
1984};
1985
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001986/*
1987 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001988 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1989 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001990 */
1991static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1992 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1993
Takashi Iwai16ded522005-06-10 19:58:24 +02001994 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001995 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001996 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001997 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001998 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001999 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002000 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002001 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2002
Takashi Iwai16ded522005-06-10 19:58:24 +02002003 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002004 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002005 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002006 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002007 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002008 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002009 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002010 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002011 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002012
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002013 { }
2014};
Takashi Iwai16ded522005-06-10 19:58:24 +02002015
Kailang Yangccc656c2006-10-17 12:32:26 +02002016/*
2017 * Uniwill pin configuration:
2018 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2019 * line = 0x1a
2020 */
2021static struct hda_verb alc880_uniwill_init_verbs[] = {
2022 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2023
2024 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2025 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2026 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2027 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2028 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2029 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2030 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2031 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2032 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2033 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2034 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2035 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2036 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2037 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2038
2039 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2040 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2041 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2042 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2043 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2044 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2045 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2046 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2047 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2048
2049 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2050 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2051
2052 { }
2053};
2054
2055/*
2056* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002057* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002058 */
2059static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2060 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2061
2062 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2063 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2064 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2066 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2067 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2069 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2071 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2072 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2073 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2074
2075 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2076 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2077 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2078 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2079 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2080 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2081
2082 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2083 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2084
2085 { }
2086};
2087
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002088static struct hda_verb alc880_beep_init_verbs[] = {
2089 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2090 { }
2091};
2092
Kailang Yangccc656c2006-10-17 12:32:26 +02002093/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002094static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002095{
2096 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002097 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002098
2099 present = snd_hda_codec_read(codec, 0x14, 0,
2100 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002101 bits = present ? HDA_AMP_MUTE : 0;
2102 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2103 HDA_AMP_MUTE, bits);
2104 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2105 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002106}
2107
2108/* auto-toggle front mic */
2109static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2110{
2111 unsigned int present;
2112 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002113
2114 present = snd_hda_codec_read(codec, 0x18, 0,
2115 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002116 bits = present ? HDA_AMP_MUTE : 0;
2117 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002118}
2119
2120static void alc880_uniwill_automute(struct hda_codec *codec)
2121{
2122 alc880_uniwill_hp_automute(codec);
2123 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002124}
2125
2126static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2127 unsigned int res)
2128{
2129 /* Looks like the unsol event is incompatible with the standard
2130 * definition. 4bit tag is placed at 28 bit!
2131 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002132 switch (res >> 28) {
2133 case ALC880_HP_EVENT:
2134 alc880_uniwill_hp_automute(codec);
2135 break;
2136 case ALC880_MIC_EVENT:
2137 alc880_uniwill_mic_automute(codec);
2138 break;
2139 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002140}
2141
2142static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2143{
2144 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002145 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002146
2147 present = snd_hda_codec_read(codec, 0x14, 0,
2148 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002149 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002150 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002151}
2152
2153static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2154{
2155 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002156
Kailang Yangccc656c2006-10-17 12:32:26 +02002157 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002158 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2159 present &= HDA_AMP_VOLMASK;
2160 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2161 HDA_AMP_VOLMASK, present);
2162 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2163 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002164}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002165
Kailang Yangccc656c2006-10-17 12:32:26 +02002166static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2167 unsigned int res)
2168{
2169 /* Looks like the unsol event is incompatible with the standard
2170 * definition. 4bit tag is placed at 28 bit!
2171 */
2172 if ((res >> 28) == ALC880_HP_EVENT)
2173 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002174 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002175 alc880_uniwill_p53_dcvol_automute(codec);
2176}
2177
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002178/*
2179 * F1734 pin configuration:
2180 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2181 */
2182static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002183 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002184 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2185 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2186 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2187 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2188
2189 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2190 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2193
2194 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2195 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002196 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002197 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2198 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2200 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2201 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2202 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002203
Takashi Iwai937b4162008-02-11 14:52:36 +01002204 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2205 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2206
Takashi Iwai16ded522005-06-10 19:58:24 +02002207 { }
2208};
2209
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002210/*
2211 * ASUS pin configuration:
2212 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2213 */
2214static struct hda_verb alc880_pin_asus_init_verbs[] = {
2215 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2216 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2217 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2218 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2219
2220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2223 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2224 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2225 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2226 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2227 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2228
2229 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2230 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2231 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2233 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2234 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2235 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2237 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002238
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002239 { }
2240};
2241
2242/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002243#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2244#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002245
Kailang Yangdf694da2005-12-05 19:42:22 +01002246/* Clevo m520g init */
2247static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2248 /* headphone output */
2249 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2250 /* line-out */
2251 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2252 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2253 /* Line-in */
2254 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2256 /* CD */
2257 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2258 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2259 /* Mic1 (rear panel) */
2260 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2261 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2262 /* Mic2 (front panel) */
2263 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2264 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2265 /* headphone */
2266 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2267 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2268 /* change to EAPD mode */
2269 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2270 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2271
2272 { }
2273};
2274
2275static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002276 /* change to EAPD mode */
2277 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2278 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2279
Kailang Yangdf694da2005-12-05 19:42:22 +01002280 /* Headphone output */
2281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2282 /* Front output*/
2283 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2284 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2285
2286 /* Line In pin widget for input */
2287 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2288 /* CD pin widget for input */
2289 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2290 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2291 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2292
2293 /* change to EAPD mode */
2294 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2295 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2296
2297 { }
2298};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002299
2300/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002301 * LG m1 express dual
2302 *
2303 * Pin assignment:
2304 * Rear Line-In/Out (blue): 0x14
2305 * Build-in Mic-In: 0x15
2306 * Speaker-out: 0x17
2307 * HP-Out (green): 0x1b
2308 * Mic-In/Out (red): 0x19
2309 * SPDIF-Out: 0x1e
2310 */
2311
2312/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2313static hda_nid_t alc880_lg_dac_nids[3] = {
2314 0x05, 0x02, 0x03
2315};
2316
2317/* seems analog CD is not working */
2318static struct hda_input_mux alc880_lg_capture_source = {
2319 .num_items = 3,
2320 .items = {
2321 { "Mic", 0x1 },
2322 { "Line", 0x5 },
2323 { "Internal Mic", 0x6 },
2324 },
2325};
2326
2327/* 2,4,6 channel modes */
2328static struct hda_verb alc880_lg_ch2_init[] = {
2329 /* set line-in and mic-in to input */
2330 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2331 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2332 { }
2333};
2334
2335static struct hda_verb alc880_lg_ch4_init[] = {
2336 /* set line-in to out and mic-in to input */
2337 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2338 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2339 { }
2340};
2341
2342static struct hda_verb alc880_lg_ch6_init[] = {
2343 /* set line-in and mic-in to output */
2344 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2345 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2346 { }
2347};
2348
2349static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2350 { 2, alc880_lg_ch2_init },
2351 { 4, alc880_lg_ch4_init },
2352 { 6, alc880_lg_ch6_init },
2353};
2354
2355static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002356 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2357 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002358 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2359 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2360 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2361 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2362 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2363 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2364 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2365 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2366 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2367 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2368 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2369 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2370 {
2371 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2372 .name = "Channel Mode",
2373 .info = alc_ch_mode_info,
2374 .get = alc_ch_mode_get,
2375 .put = alc_ch_mode_put,
2376 },
2377 { } /* end */
2378};
2379
2380static struct hda_verb alc880_lg_init_verbs[] = {
2381 /* set capture source to mic-in */
2382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2383 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2384 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2385 /* mute all amp mixer inputs */
2386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002389 /* line-in to input */
2390 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2391 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2392 /* built-in mic */
2393 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2394 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2395 /* speaker-out */
2396 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2397 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2398 /* mic-in to input */
2399 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2400 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2401 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2402 /* HP-out */
2403 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2404 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2405 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2406 /* jack sense */
2407 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2408 { }
2409};
2410
2411/* toggle speaker-output according to the hp-jack state */
2412static void alc880_lg_automute(struct hda_codec *codec)
2413{
2414 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002415 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002416
2417 present = snd_hda_codec_read(codec, 0x1b, 0,
2418 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002419 bits = present ? HDA_AMP_MUTE : 0;
2420 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2421 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002422}
2423
2424static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2425{
2426 /* Looks like the unsol event is incompatible with the standard
2427 * definition. 4bit tag is placed at 28 bit!
2428 */
2429 if ((res >> 28) == 0x01)
2430 alc880_lg_automute(codec);
2431}
2432
2433/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002434 * LG LW20
2435 *
2436 * Pin assignment:
2437 * Speaker-out: 0x14
2438 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002439 * Built-in Mic-In: 0x19
2440 * Line-In: 0x1b
2441 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002442 * SPDIF-Out: 0x1e
2443 */
2444
Takashi Iwaid6815182006-03-23 16:06:23 +01002445static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002446 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002447 .items = {
2448 { "Mic", 0x0 },
2449 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002450 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002451 },
2452};
2453
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002454#define alc880_lg_lw_modes alc880_threestack_modes
2455
Takashi Iwaid6815182006-03-23 16:06:23 +01002456static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002457 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2458 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2459 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2460 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2461 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2462 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2463 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2464 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2465 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2466 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2469 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2470 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002471 {
2472 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2473 .name = "Channel Mode",
2474 .info = alc_ch_mode_info,
2475 .get = alc_ch_mode_get,
2476 .put = alc_ch_mode_put,
2477 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002478 { } /* end */
2479};
2480
2481static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002482 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2483 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2484 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2485
Takashi Iwaid6815182006-03-23 16:06:23 +01002486 /* set capture source to mic-in */
2487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2488 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2489 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002490 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002491 /* speaker-out */
2492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2494 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002495 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2496 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2497 /* mic-in to input */
2498 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2499 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2500 /* built-in mic */
2501 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2502 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2503 /* jack sense */
2504 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2505 { }
2506};
2507
2508/* toggle speaker-output according to the hp-jack state */
2509static void alc880_lg_lw_automute(struct hda_codec *codec)
2510{
2511 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002512 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002513
2514 present = snd_hda_codec_read(codec, 0x1b, 0,
2515 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002516 bits = present ? HDA_AMP_MUTE : 0;
2517 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2518 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002519}
2520
2521static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2522{
2523 /* Looks like the unsol event is incompatible with the standard
2524 * definition. 4bit tag is placed at 28 bit!
2525 */
2526 if ((res >> 28) == 0x01)
2527 alc880_lg_lw_automute(codec);
2528}
2529
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002530static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2531 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2532 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2534 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2535 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2536 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2537 { } /* end */
2538};
2539
2540static struct hda_input_mux alc880_medion_rim_capture_source = {
2541 .num_items = 2,
2542 .items = {
2543 { "Mic", 0x0 },
2544 { "Internal Mic", 0x1 },
2545 },
2546};
2547
2548static struct hda_verb alc880_medion_rim_init_verbs[] = {
2549 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2550
2551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2552 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2553
2554 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2555 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2556 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2557 /* Mic2 (as headphone out) for HP output */
2558 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2559 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2560 /* Internal Speaker */
2561 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2562 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2563
2564 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2565 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2566
2567 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2568 { }
2569};
2570
2571/* toggle speaker-output according to the hp-jack state */
2572static void alc880_medion_rim_automute(struct hda_codec *codec)
2573{
2574 unsigned int present;
2575 unsigned char bits;
2576
2577 present = snd_hda_codec_read(codec, 0x14, 0,
2578 AC_VERB_GET_PIN_SENSE, 0)
2579 & AC_PINSENSE_PRESENCE;
2580 bits = present ? HDA_AMP_MUTE : 0;
2581 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2582 HDA_AMP_MUTE, bits);
2583 if (present)
2584 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2585 else
2586 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2587}
2588
2589static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2590 unsigned int res)
2591{
2592 /* Looks like the unsol event is incompatible with the standard
2593 * definition. 4bit tag is placed at 28 bit!
2594 */
2595 if ((res >> 28) == ALC880_HP_EVENT)
2596 alc880_medion_rim_automute(codec);
2597}
2598
Takashi Iwaicb53c622007-08-10 17:21:45 +02002599#ifdef CONFIG_SND_HDA_POWER_SAVE
2600static struct hda_amp_list alc880_loopbacks[] = {
2601 { 0x0b, HDA_INPUT, 0 },
2602 { 0x0b, HDA_INPUT, 1 },
2603 { 0x0b, HDA_INPUT, 2 },
2604 { 0x0b, HDA_INPUT, 3 },
2605 { 0x0b, HDA_INPUT, 4 },
2606 { } /* end */
2607};
2608
2609static struct hda_amp_list alc880_lg_loopbacks[] = {
2610 { 0x0b, HDA_INPUT, 1 },
2611 { 0x0b, HDA_INPUT, 6 },
2612 { 0x0b, HDA_INPUT, 7 },
2613 { } /* end */
2614};
2615#endif
2616
Takashi Iwaid6815182006-03-23 16:06:23 +01002617/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002618 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002619 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002620
Linus Torvalds1da177e2005-04-16 15:20:36 -07002621static int alc_init(struct hda_codec *codec)
2622{
2623 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002624 unsigned int i;
2625
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002626 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002627 if (codec->vendor_id == 0x10ec0888)
2628 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630 for (i = 0; i < spec->num_init_verbs; i++)
2631 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002632
2633 if (spec->init_hook)
2634 spec->init_hook(codec);
2635
Linus Torvalds1da177e2005-04-16 15:20:36 -07002636 return 0;
2637}
2638
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002639static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2640{
2641 struct alc_spec *spec = codec->spec;
2642
2643 if (spec->unsol_event)
2644 spec->unsol_event(codec, res);
2645}
2646
Takashi Iwaicb53c622007-08-10 17:21:45 +02002647#ifdef CONFIG_SND_HDA_POWER_SAVE
2648static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2649{
2650 struct alc_spec *spec = codec->spec;
2651 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2652}
2653#endif
2654
Linus Torvalds1da177e2005-04-16 15:20:36 -07002655/*
2656 * Analog playback callbacks
2657 */
2658static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2659 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002660 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661{
2662 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002663 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2664 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002665}
2666
2667static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2668 struct hda_codec *codec,
2669 unsigned int stream_tag,
2670 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002671 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002672{
2673 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002674 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2675 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002676}
2677
2678static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2679 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002680 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002681{
2682 struct alc_spec *spec = codec->spec;
2683 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2684}
2685
2686/*
2687 * Digital out
2688 */
2689static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2690 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002691 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002692{
2693 struct alc_spec *spec = codec->spec;
2694 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2695}
2696
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002697static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2698 struct hda_codec *codec,
2699 unsigned int stream_tag,
2700 unsigned int format,
2701 struct snd_pcm_substream *substream)
2702{
2703 struct alc_spec *spec = codec->spec;
2704 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2705 stream_tag, format, substream);
2706}
2707
Linus Torvalds1da177e2005-04-16 15:20:36 -07002708static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2709 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002710 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002711{
2712 struct alc_spec *spec = codec->spec;
2713 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2714}
2715
2716/*
2717 * Analog capture
2718 */
Takashi Iwai63300792008-01-24 15:31:36 +01002719static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002720 struct hda_codec *codec,
2721 unsigned int stream_tag,
2722 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002723 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002724{
2725 struct alc_spec *spec = codec->spec;
2726
Takashi Iwai63300792008-01-24 15:31:36 +01002727 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002728 stream_tag, 0, format);
2729 return 0;
2730}
2731
Takashi Iwai63300792008-01-24 15:31:36 +01002732static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002733 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002734 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002735{
2736 struct alc_spec *spec = codec->spec;
2737
Takashi Iwai888afa12008-03-18 09:57:50 +01002738 snd_hda_codec_cleanup_stream(codec,
2739 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002740 return 0;
2741}
2742
2743
2744/*
2745 */
2746static struct hda_pcm_stream alc880_pcm_analog_playback = {
2747 .substreams = 1,
2748 .channels_min = 2,
2749 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002750 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002751 .ops = {
2752 .open = alc880_playback_pcm_open,
2753 .prepare = alc880_playback_pcm_prepare,
2754 .cleanup = alc880_playback_pcm_cleanup
2755 },
2756};
2757
2758static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002759 .substreams = 1,
2760 .channels_min = 2,
2761 .channels_max = 2,
2762 /* NID is set in alc_build_pcms */
2763};
2764
2765static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2766 .substreams = 1,
2767 .channels_min = 2,
2768 .channels_max = 2,
2769 /* NID is set in alc_build_pcms */
2770};
2771
2772static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2773 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002774 .channels_min = 2,
2775 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002777 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002778 .prepare = alc880_alt_capture_pcm_prepare,
2779 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002780 },
2781};
2782
2783static struct hda_pcm_stream alc880_pcm_digital_playback = {
2784 .substreams = 1,
2785 .channels_min = 2,
2786 .channels_max = 2,
2787 /* NID is set in alc_build_pcms */
2788 .ops = {
2789 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002790 .close = alc880_dig_playback_pcm_close,
2791 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002792 },
2793};
2794
2795static struct hda_pcm_stream alc880_pcm_digital_capture = {
2796 .substreams = 1,
2797 .channels_min = 2,
2798 .channels_max = 2,
2799 /* NID is set in alc_build_pcms */
2800};
2801
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002802/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002803static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002804 .substreams = 0,
2805 .channels_min = 0,
2806 .channels_max = 0,
2807};
2808
Linus Torvalds1da177e2005-04-16 15:20:36 -07002809static int alc_build_pcms(struct hda_codec *codec)
2810{
2811 struct alc_spec *spec = codec->spec;
2812 struct hda_pcm *info = spec->pcm_rec;
2813 int i;
2814
2815 codec->num_pcms = 1;
2816 codec->pcm_info = info;
2817
2818 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002819 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002820 if (snd_BUG_ON(!spec->multiout.dac_nids))
2821 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002822 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2823 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2824 }
2825 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002826 if (snd_BUG_ON(!spec->adc_nids))
2827 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002828 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2829 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2830 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002831
Takashi Iwai4a471b72005-12-07 13:56:29 +01002832 if (spec->channel_mode) {
2833 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2834 for (i = 0; i < spec->num_channel_mode; i++) {
2835 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2836 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2837 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002838 }
2839 }
2840
Takashi Iwaie08a0072006-09-07 17:52:14 +02002841 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002842 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002843 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002844 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002845 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002846 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002847 if (spec->multiout.dig_out_nid &&
2848 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002849 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2850 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2851 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002852 if (spec->dig_in_nid &&
2853 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002854 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2855 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2856 }
Takashi Iwai963f8032008-08-11 10:04:40 +02002857 /* FIXME: do we need this for all Realtek codec models? */
2858 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002859 }
2860
Takashi Iwaie08a0072006-09-07 17:52:14 +02002861 /* If the use of more than one ADC is requested for the current
2862 * model, configure a second analog capture-only PCM.
2863 */
2864 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002865 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2866 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002867 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002868 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002869 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002870 if (spec->alt_dac_nid) {
2871 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2872 *spec->stream_analog_alt_playback;
2873 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2874 spec->alt_dac_nid;
2875 } else {
2876 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2877 alc_pcm_null_stream;
2878 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2879 }
2880 if (spec->num_adc_nids > 1) {
2881 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2882 *spec->stream_analog_alt_capture;
2883 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2884 spec->adc_nids[1];
2885 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2886 spec->num_adc_nids - 1;
2887 } else {
2888 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2889 alc_pcm_null_stream;
2890 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002891 }
2892 }
2893
Linus Torvalds1da177e2005-04-16 15:20:36 -07002894 return 0;
2895}
2896
Takashi Iwai603c4012008-07-30 15:01:44 +02002897static void alc_free_kctls(struct hda_codec *codec)
2898{
2899 struct alc_spec *spec = codec->spec;
2900
2901 if (spec->kctls.list) {
2902 struct snd_kcontrol_new *kctl = spec->kctls.list;
2903 int i;
2904 for (i = 0; i < spec->kctls.used; i++)
2905 kfree(kctl[i].name);
2906 }
2907 snd_array_free(&spec->kctls);
2908}
2909
Linus Torvalds1da177e2005-04-16 15:20:36 -07002910static void alc_free(struct hda_codec *codec)
2911{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002912 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002913
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002914 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002915 return;
2916
Takashi Iwai603c4012008-07-30 15:01:44 +02002917 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002918 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002919 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002920}
2921
Takashi Iwaie044c392008-10-27 16:56:24 +01002922#ifdef SND_HDA_NEEDS_RESUME
2923static void store_pin_configs(struct hda_codec *codec)
2924{
2925 struct alc_spec *spec = codec->spec;
2926 hda_nid_t nid, end_nid;
2927
2928 end_nid = codec->start_nid + codec->num_nodes;
2929 for (nid = codec->start_nid; nid < end_nid; nid++) {
2930 unsigned int wid_caps = get_wcaps(codec, nid);
2931 unsigned int wid_type =
2932 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2933 if (wid_type != AC_WID_PIN)
2934 continue;
2935 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
2936 break;
2937 spec->pin_nids[spec->num_pins] = nid;
2938 spec->pin_cfgs[spec->num_pins] =
2939 snd_hda_codec_read(codec, nid, 0,
2940 AC_VERB_GET_CONFIG_DEFAULT, 0);
2941 spec->num_pins++;
2942 }
2943}
2944
2945static void resume_pin_configs(struct hda_codec *codec)
2946{
2947 struct alc_spec *spec = codec->spec;
2948 int i;
2949
2950 for (i = 0; i < spec->num_pins; i++) {
2951 hda_nid_t pin_nid = spec->pin_nids[i];
2952 unsigned int pin_config = spec->pin_cfgs[i];
2953 snd_hda_codec_write(codec, pin_nid, 0,
2954 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2955 pin_config & 0x000000ff);
2956 snd_hda_codec_write(codec, pin_nid, 0,
2957 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2958 (pin_config & 0x0000ff00) >> 8);
2959 snd_hda_codec_write(codec, pin_nid, 0,
2960 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2961 (pin_config & 0x00ff0000) >> 16);
2962 snd_hda_codec_write(codec, pin_nid, 0,
2963 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2964 pin_config >> 24);
2965 }
2966}
2967
2968static int alc_resume(struct hda_codec *codec)
2969{
2970 resume_pin_configs(codec);
2971 codec->patch_ops.init(codec);
2972 snd_hda_codec_resume_amp(codec);
2973 snd_hda_codec_resume_cache(codec);
2974 return 0;
2975}
2976#else
2977#define store_pin_configs(codec)
2978#endif
2979
Linus Torvalds1da177e2005-04-16 15:20:36 -07002980/*
2981 */
2982static struct hda_codec_ops alc_patch_ops = {
2983 .build_controls = alc_build_controls,
2984 .build_pcms = alc_build_pcms,
2985 .init = alc_init,
2986 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002987 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01002988#ifdef SND_HDA_NEEDS_RESUME
2989 .resume = alc_resume,
2990#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02002991#ifdef CONFIG_SND_HDA_POWER_SAVE
2992 .check_power_status = alc_check_power_status,
2993#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002994};
2995
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002996
2997/*
2998 * Test configuration for debugging
2999 *
3000 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3001 * enum controls.
3002 */
3003#ifdef CONFIG_SND_DEBUG
3004static hda_nid_t alc880_test_dac_nids[4] = {
3005 0x02, 0x03, 0x04, 0x05
3006};
3007
3008static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003009 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003010 .items = {
3011 { "In-1", 0x0 },
3012 { "In-2", 0x1 },
3013 { "In-3", 0x2 },
3014 { "In-4", 0x3 },
3015 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003016 { "Front", 0x5 },
3017 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003018 },
3019};
3020
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003021static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003022 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003023 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003024 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003025 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003026};
3027
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003028static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3029 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003030{
3031 static char *texts[] = {
3032 "N/A", "Line Out", "HP Out",
3033 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3034 };
3035 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3036 uinfo->count = 1;
3037 uinfo->value.enumerated.items = 8;
3038 if (uinfo->value.enumerated.item >= 8)
3039 uinfo->value.enumerated.item = 7;
3040 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3041 return 0;
3042}
3043
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003044static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3045 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003046{
3047 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3048 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3049 unsigned int pin_ctl, item = 0;
3050
3051 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3052 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3053 if (pin_ctl & AC_PINCTL_OUT_EN) {
3054 if (pin_ctl & AC_PINCTL_HP_EN)
3055 item = 2;
3056 else
3057 item = 1;
3058 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3059 switch (pin_ctl & AC_PINCTL_VREFEN) {
3060 case AC_PINCTL_VREF_HIZ: item = 3; break;
3061 case AC_PINCTL_VREF_50: item = 4; break;
3062 case AC_PINCTL_VREF_GRD: item = 5; break;
3063 case AC_PINCTL_VREF_80: item = 6; break;
3064 case AC_PINCTL_VREF_100: item = 7; break;
3065 }
3066 }
3067 ucontrol->value.enumerated.item[0] = item;
3068 return 0;
3069}
3070
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003071static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3072 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003073{
3074 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3075 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3076 static unsigned int ctls[] = {
3077 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3078 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3079 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3080 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3081 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3082 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3083 };
3084 unsigned int old_ctl, new_ctl;
3085
3086 old_ctl = snd_hda_codec_read(codec, nid, 0,
3087 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3088 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3089 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003090 int val;
3091 snd_hda_codec_write_cache(codec, nid, 0,
3092 AC_VERB_SET_PIN_WIDGET_CONTROL,
3093 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003094 val = ucontrol->value.enumerated.item[0] >= 3 ?
3095 HDA_AMP_MUTE : 0;
3096 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3097 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003098 return 1;
3099 }
3100 return 0;
3101}
3102
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003103static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3104 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003105{
3106 static char *texts[] = {
3107 "Front", "Surround", "CLFE", "Side"
3108 };
3109 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3110 uinfo->count = 1;
3111 uinfo->value.enumerated.items = 4;
3112 if (uinfo->value.enumerated.item >= 4)
3113 uinfo->value.enumerated.item = 3;
3114 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3115 return 0;
3116}
3117
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003118static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3119 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003120{
3121 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3122 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3123 unsigned int sel;
3124
3125 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3126 ucontrol->value.enumerated.item[0] = sel & 3;
3127 return 0;
3128}
3129
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003130static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3131 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003132{
3133 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3134 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3135 unsigned int sel;
3136
3137 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3138 if (ucontrol->value.enumerated.item[0] != sel) {
3139 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003140 snd_hda_codec_write_cache(codec, nid, 0,
3141 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003142 return 1;
3143 }
3144 return 0;
3145}
3146
3147#define PIN_CTL_TEST(xname,nid) { \
3148 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3149 .name = xname, \
3150 .info = alc_test_pin_ctl_info, \
3151 .get = alc_test_pin_ctl_get, \
3152 .put = alc_test_pin_ctl_put, \
3153 .private_value = nid \
3154 }
3155
3156#define PIN_SRC_TEST(xname,nid) { \
3157 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3158 .name = xname, \
3159 .info = alc_test_pin_src_info, \
3160 .get = alc_test_pin_src_get, \
3161 .put = alc_test_pin_src_put, \
3162 .private_value = nid \
3163 }
3164
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003165static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003166 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3167 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3168 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3169 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003170 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3171 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3172 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3173 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003174 PIN_CTL_TEST("Front Pin Mode", 0x14),
3175 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3176 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3177 PIN_CTL_TEST("Side Pin Mode", 0x17),
3178 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3179 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3180 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3181 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3182 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3183 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3184 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3185 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3186 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3187 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3188 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3189 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3190 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3191 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3192 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3193 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3194 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3195 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003196 {
3197 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3198 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003199 .info = alc_ch_mode_info,
3200 .get = alc_ch_mode_get,
3201 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003202 },
3203 { } /* end */
3204};
3205
3206static struct hda_verb alc880_test_init_verbs[] = {
3207 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003208 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3209 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3210 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3211 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3212 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3213 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3214 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3215 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003216 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3218 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3219 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3220 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003221 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003222 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3224 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3225 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003226 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003227 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3228 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3229 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3230 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003231 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003232 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3233 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003234 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3235 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3236 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003237 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003238 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3239 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3240 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3241 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003242 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003244 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003245 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003246 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003247 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003248 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003249 /* Analog input/passthru */
3250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3253 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3254 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003255 { }
3256};
3257#endif
3258
Linus Torvalds1da177e2005-04-16 15:20:36 -07003259/*
3260 */
3261
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003262static const char *alc880_models[ALC880_MODEL_LAST] = {
3263 [ALC880_3ST] = "3stack",
3264 [ALC880_TCL_S700] = "tcl",
3265 [ALC880_3ST_DIG] = "3stack-digout",
3266 [ALC880_CLEVO] = "clevo",
3267 [ALC880_5ST] = "5stack",
3268 [ALC880_5ST_DIG] = "5stack-digout",
3269 [ALC880_W810] = "w810",
3270 [ALC880_Z71V] = "z71v",
3271 [ALC880_6ST] = "6stack",
3272 [ALC880_6ST_DIG] = "6stack-digout",
3273 [ALC880_ASUS] = "asus",
3274 [ALC880_ASUS_W1V] = "asus-w1v",
3275 [ALC880_ASUS_DIG] = "asus-dig",
3276 [ALC880_ASUS_DIG2] = "asus-dig2",
3277 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003278 [ALC880_UNIWILL_P53] = "uniwill-p53",
3279 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003280 [ALC880_F1734] = "F1734",
3281 [ALC880_LG] = "lg",
3282 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003283 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003284#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003285 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003286#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003287 [ALC880_AUTO] = "auto",
3288};
3289
3290static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003291 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003292 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3293 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3294 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3295 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3296 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3297 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3298 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3299 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003300 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3301 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003302 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3303 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3304 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3305 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3306 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3307 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3308 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3309 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3310 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3311 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003312 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003313 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3314 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3315 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003316 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003317 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003318 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3319 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003320 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3321 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003322 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3323 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3324 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3325 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003326 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3327 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003328 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003329 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003330 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003331 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003332 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3333 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003334 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003335 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003336 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003337 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003338 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003339 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003340 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003341 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003342 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003343 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3344 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003345 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003346 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3347 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3348 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3349 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003350 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3351 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003352 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003353 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003354 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3355 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003356 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3357 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3358 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003359 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3360 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3361 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003362 {}
3363};
3364
Takashi Iwai16ded522005-06-10 19:58:24 +02003365/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003366 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003367 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003368static struct alc_config_preset alc880_presets[] = {
3369 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003370 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003371 .init_verbs = { alc880_volume_init_verbs,
3372 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003373 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003374 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003375 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3376 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003377 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003378 .input_mux = &alc880_capture_source,
3379 },
3380 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003381 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003382 .init_verbs = { alc880_volume_init_verbs,
3383 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003384 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003385 .dac_nids = alc880_dac_nids,
3386 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003387 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3388 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003389 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003390 .input_mux = &alc880_capture_source,
3391 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003392 [ALC880_TCL_S700] = {
3393 .mixers = { alc880_tcl_s700_mixer },
3394 .init_verbs = { alc880_volume_init_verbs,
3395 alc880_pin_tcl_S700_init_verbs,
3396 alc880_gpio2_init_verbs },
3397 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3398 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003399 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3400 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003401 .hp_nid = 0x03,
3402 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3403 .channel_mode = alc880_2_jack_modes,
3404 .input_mux = &alc880_capture_source,
3405 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003406 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003407 .mixers = { alc880_three_stack_mixer,
3408 alc880_five_stack_mixer},
3409 .init_verbs = { alc880_volume_init_verbs,
3410 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003411 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3412 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003413 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3414 .channel_mode = alc880_fivestack_modes,
3415 .input_mux = &alc880_capture_source,
3416 },
3417 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003418 .mixers = { alc880_three_stack_mixer,
3419 alc880_five_stack_mixer },
3420 .init_verbs = { alc880_volume_init_verbs,
3421 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003422 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3423 .dac_nids = alc880_dac_nids,
3424 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003425 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3426 .channel_mode = alc880_fivestack_modes,
3427 .input_mux = &alc880_capture_source,
3428 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003429 [ALC880_6ST] = {
3430 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003431 .init_verbs = { alc880_volume_init_verbs,
3432 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003433 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3434 .dac_nids = alc880_6st_dac_nids,
3435 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3436 .channel_mode = alc880_sixstack_modes,
3437 .input_mux = &alc880_6stack_capture_source,
3438 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003439 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003440 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003441 .init_verbs = { alc880_volume_init_verbs,
3442 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003443 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3444 .dac_nids = alc880_6st_dac_nids,
3445 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003446 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3447 .channel_mode = alc880_sixstack_modes,
3448 .input_mux = &alc880_6stack_capture_source,
3449 },
3450 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003451 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003452 .init_verbs = { alc880_volume_init_verbs,
3453 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003454 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003455 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3456 .dac_nids = alc880_w810_dac_nids,
3457 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003458 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3459 .channel_mode = alc880_w810_modes,
3460 .input_mux = &alc880_capture_source,
3461 },
3462 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003463 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003464 .init_verbs = { alc880_volume_init_verbs,
3465 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003466 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3467 .dac_nids = alc880_z71v_dac_nids,
3468 .dig_out_nid = ALC880_DIGOUT_NID,
3469 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003470 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3471 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003472 .input_mux = &alc880_capture_source,
3473 },
3474 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003475 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003476 .init_verbs = { alc880_volume_init_verbs,
3477 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003478 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3479 .dac_nids = alc880_f1734_dac_nids,
3480 .hp_nid = 0x02,
3481 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3482 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003483 .input_mux = &alc880_f1734_capture_source,
3484 .unsol_event = alc880_uniwill_p53_unsol_event,
3485 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003486 },
3487 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003488 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003489 .init_verbs = { alc880_volume_init_verbs,
3490 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003491 alc880_gpio1_init_verbs },
3492 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3493 .dac_nids = alc880_asus_dac_nids,
3494 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3495 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003496 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003497 .input_mux = &alc880_capture_source,
3498 },
3499 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003500 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003501 .init_verbs = { alc880_volume_init_verbs,
3502 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003503 alc880_gpio1_init_verbs },
3504 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3505 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003506 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003507 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3508 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003509 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003510 .input_mux = &alc880_capture_source,
3511 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003512 [ALC880_ASUS_DIG2] = {
3513 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003514 .init_verbs = { alc880_volume_init_verbs,
3515 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003516 alc880_gpio2_init_verbs }, /* use GPIO2 */
3517 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3518 .dac_nids = alc880_asus_dac_nids,
3519 .dig_out_nid = ALC880_DIGOUT_NID,
3520 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3521 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003522 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003523 .input_mux = &alc880_capture_source,
3524 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003525 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003526 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003527 .init_verbs = { alc880_volume_init_verbs,
3528 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003529 alc880_gpio1_init_verbs },
3530 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3531 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003532 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003533 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3534 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003535 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003536 .input_mux = &alc880_capture_source,
3537 },
3538 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003539 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003540 .init_verbs = { alc880_volume_init_verbs,
3541 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003542 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3543 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003544 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003545 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3546 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003547 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003548 .input_mux = &alc880_capture_source,
3549 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003550 [ALC880_UNIWILL] = {
3551 .mixers = { alc880_uniwill_mixer },
3552 .init_verbs = { alc880_volume_init_verbs,
3553 alc880_uniwill_init_verbs },
3554 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3555 .dac_nids = alc880_asus_dac_nids,
3556 .dig_out_nid = ALC880_DIGOUT_NID,
3557 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3558 .channel_mode = alc880_threestack_modes,
3559 .need_dac_fix = 1,
3560 .input_mux = &alc880_capture_source,
3561 .unsol_event = alc880_uniwill_unsol_event,
3562 .init_hook = alc880_uniwill_automute,
3563 },
3564 [ALC880_UNIWILL_P53] = {
3565 .mixers = { alc880_uniwill_p53_mixer },
3566 .init_verbs = { alc880_volume_init_verbs,
3567 alc880_uniwill_p53_init_verbs },
3568 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3569 .dac_nids = alc880_asus_dac_nids,
3570 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003571 .channel_mode = alc880_threestack_modes,
3572 .input_mux = &alc880_capture_source,
3573 .unsol_event = alc880_uniwill_p53_unsol_event,
3574 .init_hook = alc880_uniwill_p53_hp_automute,
3575 },
3576 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003577 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003578 alc880_pcbeep_mixer, },
3579 .init_verbs = { alc880_volume_init_verbs,
3580 alc880_uniwill_p53_init_verbs,
3581 alc880_beep_init_verbs },
3582 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3583 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003584 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003585 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3586 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003587 .input_mux = &alc880_capture_source,
3588 .unsol_event = alc880_uniwill_p53_unsol_event,
3589 .init_hook = alc880_uniwill_p53_hp_automute,
3590 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003591 [ALC880_CLEVO] = {
3592 .mixers = { alc880_three_stack_mixer },
3593 .init_verbs = { alc880_volume_init_verbs,
3594 alc880_pin_clevo_init_verbs },
3595 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3596 .dac_nids = alc880_dac_nids,
3597 .hp_nid = 0x03,
3598 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3599 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003600 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003601 .input_mux = &alc880_capture_source,
3602 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003603 [ALC880_LG] = {
3604 .mixers = { alc880_lg_mixer },
3605 .init_verbs = { alc880_volume_init_verbs,
3606 alc880_lg_init_verbs },
3607 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3608 .dac_nids = alc880_lg_dac_nids,
3609 .dig_out_nid = ALC880_DIGOUT_NID,
3610 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3611 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003612 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003613 .input_mux = &alc880_lg_capture_source,
3614 .unsol_event = alc880_lg_unsol_event,
3615 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003616#ifdef CONFIG_SND_HDA_POWER_SAVE
3617 .loopbacks = alc880_lg_loopbacks,
3618#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003619 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003620 [ALC880_LG_LW] = {
3621 .mixers = { alc880_lg_lw_mixer },
3622 .init_verbs = { alc880_volume_init_verbs,
3623 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003624 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003625 .dac_nids = alc880_dac_nids,
3626 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003627 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3628 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003629 .input_mux = &alc880_lg_lw_capture_source,
3630 .unsol_event = alc880_lg_lw_unsol_event,
3631 .init_hook = alc880_lg_lw_automute,
3632 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003633 [ALC880_MEDION_RIM] = {
3634 .mixers = { alc880_medion_rim_mixer },
3635 .init_verbs = { alc880_volume_init_verbs,
3636 alc880_medion_rim_init_verbs,
3637 alc_gpio2_init_verbs },
3638 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3639 .dac_nids = alc880_dac_nids,
3640 .dig_out_nid = ALC880_DIGOUT_NID,
3641 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3642 .channel_mode = alc880_2_jack_modes,
3643 .input_mux = &alc880_medion_rim_capture_source,
3644 .unsol_event = alc880_medion_rim_unsol_event,
3645 .init_hook = alc880_medion_rim_automute,
3646 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003647#ifdef CONFIG_SND_DEBUG
3648 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003649 .mixers = { alc880_test_mixer },
3650 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003651 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3652 .dac_nids = alc880_test_dac_nids,
3653 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003654 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3655 .channel_mode = alc880_test_modes,
3656 .input_mux = &alc880_test_capture_source,
3657 },
3658#endif
3659};
3660
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003661/*
3662 * Automatic parse of I/O pins from the BIOS configuration
3663 */
3664
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003665enum {
3666 ALC_CTL_WIDGET_VOL,
3667 ALC_CTL_WIDGET_MUTE,
3668 ALC_CTL_BIND_MUTE,
3669};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003670static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003671 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3672 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003673 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003674};
3675
3676/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003677static int add_control(struct alc_spec *spec, int type, const char *name,
3678 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003679{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003680 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003681
Takashi Iwai603c4012008-07-30 15:01:44 +02003682 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3683 knew = snd_array_new(&spec->kctls);
3684 if (!knew)
3685 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003686 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003687 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003688 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003689 return -ENOMEM;
3690 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003691 return 0;
3692}
3693
3694#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3695#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3696#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3697#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3698#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3699#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3700#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3701#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3702#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3703#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3704#define ALC880_PIN_CD_NID 0x1c
3705
3706/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003707static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3708 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003709{
3710 hda_nid_t nid;
3711 int assigned[4];
3712 int i, j;
3713
3714 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003715 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003716
3717 /* check the pins hardwired to audio widget */
3718 for (i = 0; i < cfg->line_outs; i++) {
3719 nid = cfg->line_out_pins[i];
3720 if (alc880_is_fixed_pin(nid)) {
3721 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003722 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003723 assigned[idx] = 1;
3724 }
3725 }
3726 /* left pins can be connect to any audio widget */
3727 for (i = 0; i < cfg->line_outs; i++) {
3728 nid = cfg->line_out_pins[i];
3729 if (alc880_is_fixed_pin(nid))
3730 continue;
3731 /* search for an empty channel */
3732 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003733 if (!assigned[j]) {
3734 spec->multiout.dac_nids[i] =
3735 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003736 assigned[j] = 1;
3737 break;
3738 }
3739 }
3740 }
3741 spec->multiout.num_dacs = cfg->line_outs;
3742 return 0;
3743}
3744
3745/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003746static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3747 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003748{
3749 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003750 static const char *chname[4] = {
3751 "Front", "Surround", NULL /*CLFE*/, "Side"
3752 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003753 hda_nid_t nid;
3754 int i, err;
3755
3756 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003757 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003758 continue;
3759 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3760 if (i == 2) {
3761 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003762 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3763 "Center Playback Volume",
3764 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3765 HDA_OUTPUT));
3766 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003767 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003768 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3769 "LFE Playback Volume",
3770 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3771 HDA_OUTPUT));
3772 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003773 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003774 err = add_control(spec, ALC_CTL_BIND_MUTE,
3775 "Center Playback Switch",
3776 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3777 HDA_INPUT));
3778 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003779 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003780 err = add_control(spec, ALC_CTL_BIND_MUTE,
3781 "LFE Playback Switch",
3782 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3783 HDA_INPUT));
3784 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003785 return err;
3786 } else {
3787 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003788 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3789 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3790 HDA_OUTPUT));
3791 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003792 return err;
3793 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003794 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3795 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3796 HDA_INPUT));
3797 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003798 return err;
3799 }
3800 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003801 return 0;
3802}
3803
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003804/* add playback controls for speaker and HP outputs */
3805static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3806 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003807{
3808 hda_nid_t nid;
3809 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003810 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003811
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003812 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003813 return 0;
3814
3815 if (alc880_is_fixed_pin(pin)) {
3816 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003817 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003818 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003819 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003820 else
3821 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003822 /* control HP volume/switch on the output mixer amp */
3823 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003824 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003825 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3826 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3827 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003828 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003829 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003830 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3831 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3832 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003833 return err;
3834 } else if (alc880_is_multi_pin(pin)) {
3835 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003836 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003837 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003838 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3839 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3840 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003841 return err;
3842 }
3843 return 0;
3844}
3845
3846/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003847static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3848 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003849 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003850{
3851 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003852 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003853
3854 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003855 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3856 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3857 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003858 return err;
3859 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003860 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3861 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3862 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003863 return err;
3864 return 0;
3865}
3866
3867/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003868static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3869 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003870{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003871 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003872 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003873
3874 for (i = 0; i < AUTO_PIN_LAST; i++) {
3875 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003876 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003877 err = new_analog_input(spec, cfg->input_pins[i],
3878 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003879 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003880 if (err < 0)
3881 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003882 imux->items[imux->num_items].label =
3883 auto_pin_cfg_labels[i];
3884 imux->items[imux->num_items].index =
3885 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003886 imux->num_items++;
3887 }
3888 }
3889 return 0;
3890}
3891
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003892static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3893 unsigned int pin_type)
3894{
3895 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3896 pin_type);
3897 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003898 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3899 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003900}
3901
Kailang Yangdf694da2005-12-05 19:42:22 +01003902static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3903 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003904 int dac_idx)
3905{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003906 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003907 /* need the manual connection? */
3908 if (alc880_is_multi_pin(nid)) {
3909 struct alc_spec *spec = codec->spec;
3910 int idx = alc880_multi_pin_idx(nid);
3911 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3912 AC_VERB_SET_CONNECT_SEL,
3913 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3914 }
3915}
3916
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003917static int get_pin_type(int line_out_type)
3918{
3919 if (line_out_type == AUTO_PIN_HP_OUT)
3920 return PIN_HP;
3921 else
3922 return PIN_OUT;
3923}
3924
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003925static void alc880_auto_init_multi_out(struct hda_codec *codec)
3926{
3927 struct alc_spec *spec = codec->spec;
3928 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02003929
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003930 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003931 for (i = 0; i < spec->autocfg.line_outs; i++) {
3932 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003933 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3934 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003935 }
3936}
3937
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003938static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003939{
3940 struct alc_spec *spec = codec->spec;
3941 hda_nid_t pin;
3942
Takashi Iwai82bc9552006-03-21 11:24:42 +01003943 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003944 if (pin) /* connect to front */
3945 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003946 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003947 if (pin) /* connect to front */
3948 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3949}
3950
3951static void alc880_auto_init_analog_input(struct hda_codec *codec)
3952{
3953 struct alc_spec *spec = codec->spec;
3954 int i;
3955
3956 for (i = 0; i < AUTO_PIN_LAST; i++) {
3957 hda_nid_t nid = spec->autocfg.input_pins[i];
3958 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003959 snd_hda_codec_write(codec, nid, 0,
3960 AC_VERB_SET_PIN_WIDGET_CONTROL,
3961 i <= AUTO_PIN_FRONT_MIC ?
3962 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003963 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003964 snd_hda_codec_write(codec, nid, 0,
3965 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003966 AMP_OUT_MUTE);
3967 }
3968 }
3969}
3970
3971/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003972/* return 1 if successful, 0 if the proper config is not found,
3973 * or a negative error code
3974 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003975static int alc880_parse_auto_config(struct hda_codec *codec)
3976{
3977 struct alc_spec *spec = codec->spec;
3978 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003979 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003980
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003981 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3982 alc880_ignore);
3983 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003984 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003985 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003986 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003987
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003988 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3989 if (err < 0)
3990 return err;
3991 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3992 if (err < 0)
3993 return err;
3994 err = alc880_auto_create_extra_out(spec,
3995 spec->autocfg.speaker_pins[0],
3996 "Speaker");
3997 if (err < 0)
3998 return err;
3999 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4000 "Headphone");
4001 if (err < 0)
4002 return err;
4003 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4004 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004005 return err;
4006
4007 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4008
4009 if (spec->autocfg.dig_out_pin)
4010 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
4011 if (spec->autocfg.dig_in_pin)
4012 spec->dig_in_nid = ALC880_DIGIN_NID;
4013
Takashi Iwai603c4012008-07-30 15:01:44 +02004014 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004015 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004016
Takashi Iwaid88897e2008-10-31 15:01:37 +01004017 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004018
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004019 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004020 spec->input_mux = &spec->private_imux;
4021
Takashi Iwaie044c392008-10-27 16:56:24 +01004022 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004023 return 1;
4024}
4025
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004026/* additional initialization for auto-configuration model */
4027static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004028{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004029 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004030 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004031 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004032 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004033 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004034 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004035}
4036
4037/*
4038 * OK, here we have finally the patch for ALC880
4039 */
4040
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004041static void set_capture_mixer(struct alc_spec *spec)
4042{
4043 static struct snd_kcontrol_new *caps[3] = {
4044 alc_capture_mixer1,
4045 alc_capture_mixer2,
4046 alc_capture_mixer3,
4047 };
4048 if (spec->num_adc_nids > 0 && spec->num_adc_nids < 3)
4049 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4050}
4051
Linus Torvalds1da177e2005-04-16 15:20:36 -07004052static int patch_alc880(struct hda_codec *codec)
4053{
4054 struct alc_spec *spec;
4055 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004056 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004057
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004058 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004059 if (spec == NULL)
4060 return -ENOMEM;
4061
4062 codec->spec = spec;
4063
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004064 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4065 alc880_models,
4066 alc880_cfg_tbl);
4067 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004068 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4069 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004070 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004071 }
4072
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004073 if (board_config == ALC880_AUTO) {
4074 /* automatic parse from the BIOS config */
4075 err = alc880_parse_auto_config(codec);
4076 if (err < 0) {
4077 alc_free(codec);
4078 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004079 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004080 printk(KERN_INFO
4081 "hda_codec: Cannot set up configuration "
4082 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004083 board_config = ALC880_3ST;
4084 }
4085 }
4086
Kailang Yangdf694da2005-12-05 19:42:22 +01004087 if (board_config != ALC880_AUTO)
4088 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004089
4090 spec->stream_name_analog = "ALC880 Analog";
4091 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4092 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004093 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004094
4095 spec->stream_name_digital = "ALC880 Digital";
4096 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4097 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4098
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004099 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004100 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004101 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004102 /* get type */
4103 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004104 if (wcap != AC_WID_AUD_IN) {
4105 spec->adc_nids = alc880_adc_nids_alt;
4106 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004107 } else {
4108 spec->adc_nids = alc880_adc_nids;
4109 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004110 }
4111 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004112 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004113
Takashi Iwai2134ea42008-01-10 16:53:55 +01004114 spec->vmaster_nid = 0x0c;
4115
Linus Torvalds1da177e2005-04-16 15:20:36 -07004116 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004117 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004118 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004119#ifdef CONFIG_SND_HDA_POWER_SAVE
4120 if (!spec->loopback.amplist)
4121 spec->loopback.amplist = alc880_loopbacks;
4122#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07004123
4124 return 0;
4125}
4126
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004127
Linus Torvalds1da177e2005-04-16 15:20:36 -07004128/*
4129 * ALC260 support
4130 */
4131
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004132static hda_nid_t alc260_dac_nids[1] = {
4133 /* front */
4134 0x02,
4135};
4136
4137static hda_nid_t alc260_adc_nids[1] = {
4138 /* ADC0 */
4139 0x04,
4140};
4141
Kailang Yangdf694da2005-12-05 19:42:22 +01004142static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004143 /* ADC1 */
4144 0x05,
4145};
4146
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004147/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4148 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4149 */
4150static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004151 /* ADC0, ADC1 */
4152 0x04, 0x05
4153};
4154
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004155#define ALC260_DIGOUT_NID 0x03
4156#define ALC260_DIGIN_NID 0x06
4157
4158static struct hda_input_mux alc260_capture_source = {
4159 .num_items = 4,
4160 .items = {
4161 { "Mic", 0x0 },
4162 { "Front Mic", 0x1 },
4163 { "Line", 0x2 },
4164 { "CD", 0x4 },
4165 },
4166};
4167
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004168/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004169 * headphone jack and the internal CD lines since these are the only pins at
4170 * which audio can appear. For flexibility, also allow the option of
4171 * recording the mixer output on the second ADC (ADC0 doesn't have a
4172 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004173 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004174static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4175 {
4176 .num_items = 3,
4177 .items = {
4178 { "Mic/Line", 0x0 },
4179 { "CD", 0x4 },
4180 { "Headphone", 0x2 },
4181 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004182 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004183 {
4184 .num_items = 4,
4185 .items = {
4186 { "Mic/Line", 0x0 },
4187 { "CD", 0x4 },
4188 { "Headphone", 0x2 },
4189 { "Mixer", 0x5 },
4190 },
4191 },
4192
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004193};
4194
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004195/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4196 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004197 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004198static struct hda_input_mux alc260_acer_capture_sources[2] = {
4199 {
4200 .num_items = 4,
4201 .items = {
4202 { "Mic", 0x0 },
4203 { "Line", 0x2 },
4204 { "CD", 0x4 },
4205 { "Headphone", 0x5 },
4206 },
4207 },
4208 {
4209 .num_items = 5,
4210 .items = {
4211 { "Mic", 0x0 },
4212 { "Line", 0x2 },
4213 { "CD", 0x4 },
4214 { "Headphone", 0x6 },
4215 { "Mixer", 0x5 },
4216 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004217 },
4218};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004219/*
4220 * This is just place-holder, so there's something for alc_build_pcms to look
4221 * at when it calculates the maximum number of channels. ALC260 has no mixer
4222 * element which allows changing the channel mode, so the verb list is
4223 * never used.
4224 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004225static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004226 { 2, NULL },
4227};
4228
Kailang Yangdf694da2005-12-05 19:42:22 +01004229
4230/* Mixer combinations
4231 *
4232 * basic: base_output + input + pc_beep + capture
4233 * HP: base_output + input + capture_alt
4234 * HP_3013: hp_3013 + input + capture
4235 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004236 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004237 */
4238
4239static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004240 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004241 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004242 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4243 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4244 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4245 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4246 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004247};
Kailang Yangdf694da2005-12-05 19:42:22 +01004248
4249static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004250 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4251 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4252 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4253 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4254 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4255 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4256 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4257 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004258 { } /* end */
4259};
4260
Kailang Yangdf694da2005-12-05 19:42:22 +01004261static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4262 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4263 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4264 { } /* end */
4265};
4266
Takashi Iwaibec15c32008-01-28 18:16:30 +01004267/* update HP, line and mono out pins according to the master switch */
4268static void alc260_hp_master_update(struct hda_codec *codec,
4269 hda_nid_t hp, hda_nid_t line,
4270 hda_nid_t mono)
4271{
4272 struct alc_spec *spec = codec->spec;
4273 unsigned int val = spec->master_sw ? PIN_HP : 0;
4274 /* change HP and line-out pins */
4275 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4276 val);
4277 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4278 val);
4279 /* mono (speaker) depending on the HP jack sense */
4280 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4281 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4282 val);
4283}
4284
4285static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4286 struct snd_ctl_elem_value *ucontrol)
4287{
4288 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4289 struct alc_spec *spec = codec->spec;
4290 *ucontrol->value.integer.value = spec->master_sw;
4291 return 0;
4292}
4293
4294static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4295 struct snd_ctl_elem_value *ucontrol)
4296{
4297 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4298 struct alc_spec *spec = codec->spec;
4299 int val = !!*ucontrol->value.integer.value;
4300 hda_nid_t hp, line, mono;
4301
4302 if (val == spec->master_sw)
4303 return 0;
4304 spec->master_sw = val;
4305 hp = (kcontrol->private_value >> 16) & 0xff;
4306 line = (kcontrol->private_value >> 8) & 0xff;
4307 mono = kcontrol->private_value & 0xff;
4308 alc260_hp_master_update(codec, hp, line, mono);
4309 return 1;
4310}
4311
4312static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4313 {
4314 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4315 .name = "Master Playback Switch",
4316 .info = snd_ctl_boolean_mono_info,
4317 .get = alc260_hp_master_sw_get,
4318 .put = alc260_hp_master_sw_put,
4319 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4320 },
4321 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4322 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4323 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4324 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4325 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4326 HDA_OUTPUT),
4327 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4328 { } /* end */
4329};
4330
4331static struct hda_verb alc260_hp_unsol_verbs[] = {
4332 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4333 {},
4334};
4335
4336static void alc260_hp_automute(struct hda_codec *codec)
4337{
4338 struct alc_spec *spec = codec->spec;
4339 unsigned int present;
4340
4341 present = snd_hda_codec_read(codec, 0x10, 0,
4342 AC_VERB_GET_PIN_SENSE, 0);
4343 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4344 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4345}
4346
4347static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4348{
4349 if ((res >> 26) == ALC880_HP_EVENT)
4350 alc260_hp_automute(codec);
4351}
4352
Kailang Yangdf694da2005-12-05 19:42:22 +01004353static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004354 {
4355 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4356 .name = "Master Playback Switch",
4357 .info = snd_ctl_boolean_mono_info,
4358 .get = alc260_hp_master_sw_get,
4359 .put = alc260_hp_master_sw_put,
4360 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4361 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004362 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4363 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4364 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4365 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4366 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4367 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004368 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4369 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004370 { } /* end */
4371};
4372
Kailang Yang3f878302008-08-26 13:02:23 +02004373static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4374 .ops = &snd_hda_bind_vol,
4375 .values = {
4376 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4377 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4378 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4379 0
4380 },
4381};
4382
4383static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4384 .ops = &snd_hda_bind_sw,
4385 .values = {
4386 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4387 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4388 0
4389 },
4390};
4391
4392static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4393 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4394 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4395 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4396 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4397 { } /* end */
4398};
4399
Takashi Iwaibec15c32008-01-28 18:16:30 +01004400static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4401 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4402 {},
4403};
4404
4405static void alc260_hp_3013_automute(struct hda_codec *codec)
4406{
4407 struct alc_spec *spec = codec->spec;
4408 unsigned int present;
4409
4410 present = snd_hda_codec_read(codec, 0x15, 0,
4411 AC_VERB_GET_PIN_SENSE, 0);
4412 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4413 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4414}
4415
4416static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4417 unsigned int res)
4418{
4419 if ((res >> 26) == ALC880_HP_EVENT)
4420 alc260_hp_3013_automute(codec);
4421}
4422
Kailang Yang3f878302008-08-26 13:02:23 +02004423static void alc260_hp_3012_automute(struct hda_codec *codec)
4424{
4425 unsigned int present, bits;
4426
4427 present = snd_hda_codec_read(codec, 0x10, 0,
4428 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4429
4430 bits = present ? 0 : PIN_OUT;
4431 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4432 bits);
4433 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4434 bits);
4435 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4436 bits);
4437}
4438
4439static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4440 unsigned int res)
4441{
4442 if ((res >> 26) == ALC880_HP_EVENT)
4443 alc260_hp_3012_automute(codec);
4444}
4445
4446/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004447 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4448 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004449static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004450 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004451 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004452 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004453 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4454 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4455 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4456 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004457 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004458 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4459 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004460 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4461 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004462 { } /* end */
4463};
4464
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004465/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4466 * versions of the ALC260 don't act on requests to enable mic bias from NID
4467 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4468 * datasheet doesn't mention this restriction. At this stage it's not clear
4469 * whether this behaviour is intentional or is a hardware bug in chip
4470 * revisions available in early 2006. Therefore for now allow the
4471 * "Headphone Jack Mode" control to span all choices, but if it turns out
4472 * that the lack of mic bias for this NID is intentional we could change the
4473 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4474 *
4475 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4476 * don't appear to make the mic bias available from the "line" jack, even
4477 * though the NID used for this jack (0x14) can supply it. The theory is
4478 * that perhaps Acer have included blocking capacitors between the ALC260
4479 * and the output jack. If this turns out to be the case for all such
4480 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4481 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004482 *
4483 * The C20x Tablet series have a mono internal speaker which is controlled
4484 * via the chip's Mono sum widget and pin complex, so include the necessary
4485 * controls for such models. On models without a "mono speaker" the control
4486 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004487 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004488static struct snd_kcontrol_new alc260_acer_mixer[] = {
4489 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4490 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004491 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004492 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004493 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004494 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004495 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004496 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4497 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4499 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4500 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4501 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4502 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4503 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4504 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4505 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4506 { } /* end */
4507};
4508
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004509/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4510 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4511 */
4512static struct snd_kcontrol_new alc260_will_mixer[] = {
4513 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4514 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4515 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4516 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4517 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4518 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4519 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4520 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4521 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4522 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4523 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4524 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4525 { } /* end */
4526};
4527
4528/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4529 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4530 */
4531static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4532 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4533 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4534 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4535 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4536 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4537 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4538 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4539 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4540 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4541 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4542 { } /* end */
4543};
4544
Kailang Yangdf694da2005-12-05 19:42:22 +01004545/*
4546 * initialization verbs
4547 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004548static struct hda_verb alc260_init_verbs[] = {
4549 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004551 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004552 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004553 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004554 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004555 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004556 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004557 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004558 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004559 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004560 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004561 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004562 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004563 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004564 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004565 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004566 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4567 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004568 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004569 /* set connection select to line in (default select for this ADC) */
4570 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004571 /* mute capture amp left and right */
4572 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4573 /* set connection select to line in (default select for this ADC) */
4574 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004575 /* set vol=0 Line-Out mixer amp left and right */
4576 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4577 /* unmute pin widget amp left and right (no gain on this amp) */
4578 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4579 /* set vol=0 HP mixer amp left and right */
4580 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4581 /* unmute pin widget amp left and right (no gain on this amp) */
4582 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4583 /* set vol=0 Mono mixer amp left and right */
4584 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4585 /* unmute pin widget amp left and right (no gain on this amp) */
4586 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4587 /* unmute LINE-2 out pin */
4588 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004589 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4590 * Line In 2 = 0x03
4591 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004592 /* mute analog inputs */
4593 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4596 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4597 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004598 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004599 /* mute Front out path */
4600 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4601 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4602 /* mute Headphone out path */
4603 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4604 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4605 /* mute Mono out path */
4606 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4607 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004608 { }
4609};
4610
Takashi Iwai474167d2006-05-17 17:17:43 +02004611#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004612static struct hda_verb alc260_hp_init_verbs[] = {
4613 /* Headphone and output */
4614 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4615 /* mono output */
4616 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4617 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4618 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4619 /* Mic2 (front panel) pin widget for input and vref at 80% */
4620 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4621 /* Line In pin widget for input */
4622 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4623 /* Line-2 pin widget for output */
4624 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4625 /* CD pin widget for input */
4626 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4627 /* unmute amp left and right */
4628 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4629 /* set connection select to line in (default select for this ADC) */
4630 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4631 /* unmute Line-Out mixer amp left and right (volume = 0) */
4632 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4633 /* mute pin widget amp left and right (no gain on this amp) */
4634 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4635 /* unmute HP mixer amp left and right (volume = 0) */
4636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4637 /* mute pin widget amp left and right (no gain on this amp) */
4638 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004639 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4640 * Line In 2 = 0x03
4641 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004642 /* mute analog inputs */
4643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4645 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004648 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4649 /* Unmute Front out path */
4650 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4651 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4652 /* Unmute Headphone out path */
4653 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4654 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4655 /* Unmute Mono out path */
4656 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4657 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4658 { }
4659};
Takashi Iwai474167d2006-05-17 17:17:43 +02004660#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004661
4662static struct hda_verb alc260_hp_3013_init_verbs[] = {
4663 /* Line out and output */
4664 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4665 /* mono output */
4666 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4667 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4668 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4669 /* Mic2 (front panel) pin widget for input and vref at 80% */
4670 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4671 /* Line In pin widget for input */
4672 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4673 /* Headphone pin widget for output */
4674 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4675 /* CD pin widget for input */
4676 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4677 /* unmute amp left and right */
4678 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4679 /* set connection select to line in (default select for this ADC) */
4680 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4681 /* unmute Line-Out mixer amp left and right (volume = 0) */
4682 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4683 /* mute pin widget amp left and right (no gain on this amp) */
4684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4685 /* unmute HP mixer amp left and right (volume = 0) */
4686 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4687 /* mute pin widget amp left and right (no gain on this amp) */
4688 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004689 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4690 * Line In 2 = 0x03
4691 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004692 /* mute analog inputs */
4693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4697 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004698 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4699 /* Unmute Front out path */
4700 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4701 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4702 /* Unmute Headphone out path */
4703 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4704 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4705 /* Unmute Mono out path */
4706 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4707 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4708 { }
4709};
4710
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004711/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004712 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4713 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004714 */
4715static struct hda_verb alc260_fujitsu_init_verbs[] = {
4716 /* Disable all GPIOs */
4717 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4718 /* Internal speaker is connected to headphone pin */
4719 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4720 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4721 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004722 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4723 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4724 /* Ensure all other unused pins are disabled and muted. */
4725 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4726 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004727 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004728 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004729 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004730 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004733
Jonathan Woithef7ace402006-02-28 11:46:14 +01004734 /* Disable digital (SPDIF) pins */
4735 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4736 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004737
Kailang Yangea1fb292008-08-26 12:58:38 +02004738 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004739 * when acting as an output.
4740 */
4741 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4742
4743 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004744 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4745 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4746 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4747 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4748 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4749 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4750 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4751 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4752 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004753
Jonathan Woithef7ace402006-02-28 11:46:14 +01004754 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4755 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4756 /* Unmute Line1 pin widget output buffer since it starts as an output.
4757 * If the pin mode is changed by the user the pin mode control will
4758 * take care of enabling the pin's input/output buffers as needed.
4759 * Therefore there's no need to enable the input buffer at this
4760 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004761 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004762 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02004763 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004764 * mixer ctrl)
4765 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004766 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004767
Jonathan Woithef7ace402006-02-28 11:46:14 +01004768 /* Mute capture amp left and right */
4769 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02004770 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01004771 * in (on mic1 pin)
4772 */
4773 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004774
Jonathan Woithef7ace402006-02-28 11:46:14 +01004775 /* Do the same for the second ADC: mute capture input amp and
4776 * set ADC connection to line in (on mic1 pin)
4777 */
4778 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4779 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004780
Jonathan Woithef7ace402006-02-28 11:46:14 +01004781 /* Mute all inputs to mixer widget (even unconnected ones) */
4782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4785 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4786 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4788 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4789 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004790
4791 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004792};
4793
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004794/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4795 * similar laptops (adapted from Fujitsu init verbs).
4796 */
4797static struct hda_verb alc260_acer_init_verbs[] = {
4798 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4799 * the headphone jack. Turn this on and rely on the standard mute
4800 * methods whenever the user wants to turn these outputs off.
4801 */
4802 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4803 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4804 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4805 /* Internal speaker/Headphone jack is connected to Line-out pin */
4806 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4807 /* Internal microphone/Mic jack is connected to Mic1 pin */
4808 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4809 /* Line In jack is connected to Line1 pin */
4810 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004811 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4812 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004813 /* Ensure all other unused pins are disabled and muted. */
4814 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4815 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004816 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4817 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4818 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4819 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4820 /* Disable digital (SPDIF) pins */
4821 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4822 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4823
Kailang Yangea1fb292008-08-26 12:58:38 +02004824 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004825 * bus when acting as outputs.
4826 */
4827 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4828 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4829
4830 /* Start with output sum widgets muted and their output gains at min */
4831 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4832 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4833 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4834 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4835 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4836 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4837 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4838 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4839 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4840
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004841 /* Unmute Line-out pin widget amp left and right
4842 * (no equiv mixer ctrl)
4843 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004844 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004845 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4846 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004847 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4848 * inputs. If the pin mode is changed by the user the pin mode control
4849 * will take care of enabling the pin's input/output buffers as needed.
4850 * Therefore there's no need to enable the input buffer at this
4851 * stage.
4852 */
4853 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4854 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4855
4856 /* Mute capture amp left and right */
4857 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4858 /* Set ADC connection select to match default mixer setting - mic
4859 * (on mic1 pin)
4860 */
4861 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4862
4863 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004864 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004865 */
4866 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004867 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004868
4869 /* Mute all inputs to mixer widget (even unconnected ones) */
4870 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4871 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4872 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4873 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4876 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4877 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4878
4879 { }
4880};
4881
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004882static struct hda_verb alc260_will_verbs[] = {
4883 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4884 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4885 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4886 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4887 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4888 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4889 {}
4890};
4891
4892static struct hda_verb alc260_replacer_672v_verbs[] = {
4893 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4894 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4895 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4896
4897 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4898 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4899 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4900
4901 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4902 {}
4903};
4904
4905/* toggle speaker-output according to the hp-jack state */
4906static void alc260_replacer_672v_automute(struct hda_codec *codec)
4907{
4908 unsigned int present;
4909
4910 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4911 present = snd_hda_codec_read(codec, 0x0f, 0,
4912 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4913 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004914 snd_hda_codec_write_cache(codec, 0x01, 0,
4915 AC_VERB_SET_GPIO_DATA, 1);
4916 snd_hda_codec_write_cache(codec, 0x0f, 0,
4917 AC_VERB_SET_PIN_WIDGET_CONTROL,
4918 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004919 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004920 snd_hda_codec_write_cache(codec, 0x01, 0,
4921 AC_VERB_SET_GPIO_DATA, 0);
4922 snd_hda_codec_write_cache(codec, 0x0f, 0,
4923 AC_VERB_SET_PIN_WIDGET_CONTROL,
4924 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004925 }
4926}
4927
4928static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4929 unsigned int res)
4930{
4931 if ((res >> 26) == ALC880_HP_EVENT)
4932 alc260_replacer_672v_automute(codec);
4933}
4934
Kailang Yang3f878302008-08-26 13:02:23 +02004935static struct hda_verb alc260_hp_dc7600_verbs[] = {
4936 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
4937 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4938 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4939 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4940 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4941 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4942 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4943 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4944 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4945 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4946 {}
4947};
4948
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004949/* Test configuration for debugging, modelled after the ALC880 test
4950 * configuration.
4951 */
4952#ifdef CONFIG_SND_DEBUG
4953static hda_nid_t alc260_test_dac_nids[1] = {
4954 0x02,
4955};
4956static hda_nid_t alc260_test_adc_nids[2] = {
4957 0x04, 0x05,
4958};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004959/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02004960 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004961 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004962 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004963static struct hda_input_mux alc260_test_capture_sources[2] = {
4964 {
4965 .num_items = 7,
4966 .items = {
4967 { "MIC1 pin", 0x0 },
4968 { "MIC2 pin", 0x1 },
4969 { "LINE1 pin", 0x2 },
4970 { "LINE2 pin", 0x3 },
4971 { "CD pin", 0x4 },
4972 { "LINE-OUT pin", 0x5 },
4973 { "HP-OUT pin", 0x6 },
4974 },
4975 },
4976 {
4977 .num_items = 8,
4978 .items = {
4979 { "MIC1 pin", 0x0 },
4980 { "MIC2 pin", 0x1 },
4981 { "LINE1 pin", 0x2 },
4982 { "LINE2 pin", 0x3 },
4983 { "CD pin", 0x4 },
4984 { "Mixer", 0x5 },
4985 { "LINE-OUT pin", 0x6 },
4986 { "HP-OUT pin", 0x7 },
4987 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004988 },
4989};
4990static struct snd_kcontrol_new alc260_test_mixer[] = {
4991 /* Output driver widgets */
4992 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4993 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4994 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4995 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4996 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4997 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4998
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004999 /* Modes for retasking pin widgets
5000 * Note: the ALC260 doesn't seem to act on requests to enable mic
5001 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5002 * mention this restriction. At this stage it's not clear whether
5003 * this behaviour is intentional or is a hardware bug in chip
5004 * revisions available at least up until early 2006. Therefore for
5005 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5006 * choices, but if it turns out that the lack of mic bias for these
5007 * NIDs is intentional we could change their modes from
5008 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5009 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005010 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5011 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5012 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5013 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5014 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5015 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5016
5017 /* Loopback mixer controls */
5018 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5019 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5020 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5021 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5022 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5023 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5024 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5025 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5026 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5027 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5028 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
5029 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
5030 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5031 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5032 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5033 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005034
5035 /* Controls for GPIO pins, assuming they are configured as outputs */
5036 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5037 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5038 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5039 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5040
Jonathan Woithe92621f12006-02-28 11:47:47 +01005041 /* Switches to allow the digital IO pins to be enabled. The datasheet
5042 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005043 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005044 */
5045 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5046 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5047
Jonathan Woithef8225f62008-01-08 12:16:54 +01005048 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5049 * this output to turn on an external amplifier.
5050 */
5051 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5052 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5053
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005054 { } /* end */
5055};
5056static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005057 /* Enable all GPIOs as outputs with an initial value of 0 */
5058 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5059 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5060 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5061
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005062 /* Enable retasking pins as output, initially without power amp */
5063 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5064 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5066 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5067 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5068 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5069
Jonathan Woithe92621f12006-02-28 11:47:47 +01005070 /* Disable digital (SPDIF) pins initially, but users can enable
5071 * them via a mixer switch. In the case of SPDIF-out, this initverb
5072 * payload also sets the generation to 0, output to be in "consumer"
5073 * PCM format, copyright asserted, no pre-emphasis and no validity
5074 * control.
5075 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005076 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5077 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5078
Kailang Yangea1fb292008-08-26 12:58:38 +02005079 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005080 * OUT1 sum bus when acting as an output.
5081 */
5082 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5083 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5084 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5085 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5086
5087 /* Start with output sum widgets muted and their output gains at min */
5088 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5089 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5090 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5092 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5093 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5094 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5095 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5096 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5097
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005098 /* Unmute retasking pin widget output buffers since the default
5099 * state appears to be output. As the pin mode is changed by the
5100 * user the pin mode control will take care of enabling the pin's
5101 * input/output buffers as needed.
5102 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005103 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5104 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5105 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5106 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5107 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5108 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5109 /* Also unmute the mono-out pin widget */
5110 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5111
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005112 /* Mute capture amp left and right */
5113 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005114 /* Set ADC connection select to match default mixer setting (mic1
5115 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005116 */
5117 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5118
5119 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005120 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005121 */
5122 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5123 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5124
5125 /* Mute all inputs to mixer widget (even unconnected ones) */
5126 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5127 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5134
5135 { }
5136};
5137#endif
5138
Takashi Iwai63300792008-01-24 15:31:36 +01005139#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5140#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005141
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005142#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5143#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5144
Kailang Yangdf694da2005-12-05 19:42:22 +01005145/*
5146 * for BIOS auto-configuration
5147 */
5148
5149static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005150 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005151{
5152 hda_nid_t nid_vol;
5153 unsigned long vol_val, sw_val;
5154 char name[32];
5155 int err;
5156
5157 if (nid >= 0x0f && nid < 0x11) {
5158 nid_vol = nid - 0x7;
5159 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5160 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5161 } else if (nid == 0x11) {
5162 nid_vol = nid - 0x7;
5163 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5164 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5165 } else if (nid >= 0x12 && nid <= 0x15) {
5166 nid_vol = 0x08;
5167 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5168 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5169 } else
5170 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005171
Takashi Iwai863b4512008-10-21 17:01:47 +02005172 if (!(*vol_bits & (1 << nid_vol))) {
5173 /* first control for the volume widget */
5174 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5175 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5176 if (err < 0)
5177 return err;
5178 *vol_bits |= (1 << nid_vol);
5179 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005180 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005181 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5182 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005183 return err;
5184 return 1;
5185}
5186
5187/* add playback controls from the parsed DAC table */
5188static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5189 const struct auto_pin_cfg *cfg)
5190{
5191 hda_nid_t nid;
5192 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005193 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005194
5195 spec->multiout.num_dacs = 1;
5196 spec->multiout.dac_nids = spec->private_dac_nids;
5197 spec->multiout.dac_nids[0] = 0x02;
5198
5199 nid = cfg->line_out_pins[0];
5200 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005201 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005202 if (err < 0)
5203 return err;
5204 }
5205
Takashi Iwai82bc9552006-03-21 11:24:42 +01005206 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005207 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005208 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005209 if (err < 0)
5210 return err;
5211 }
5212
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005213 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005214 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005215 err = alc260_add_playback_controls(spec, nid, "Headphone",
5216 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005217 if (err < 0)
5218 return err;
5219 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005220 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005221}
5222
5223/* create playback/capture controls for input pins */
5224static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5225 const struct auto_pin_cfg *cfg)
5226{
Kailang Yangdf694da2005-12-05 19:42:22 +01005227 struct hda_input_mux *imux = &spec->private_imux;
5228 int i, err, idx;
5229
5230 for (i = 0; i < AUTO_PIN_LAST; i++) {
5231 if (cfg->input_pins[i] >= 0x12) {
5232 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005233 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005234 auto_pin_cfg_labels[i], idx,
5235 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005236 if (err < 0)
5237 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005238 imux->items[imux->num_items].label =
5239 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005240 imux->items[imux->num_items].index = idx;
5241 imux->num_items++;
5242 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005243 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005244 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005245 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005246 auto_pin_cfg_labels[i], idx,
5247 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005248 if (err < 0)
5249 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005250 imux->items[imux->num_items].label =
5251 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005252 imux->items[imux->num_items].index = idx;
5253 imux->num_items++;
5254 }
5255 }
5256 return 0;
5257}
5258
5259static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5260 hda_nid_t nid, int pin_type,
5261 int sel_idx)
5262{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005263 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005264 /* need the manual connection? */
5265 if (nid >= 0x12) {
5266 int idx = nid - 0x12;
5267 snd_hda_codec_write(codec, idx + 0x0b, 0,
5268 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005269 }
5270}
5271
5272static void alc260_auto_init_multi_out(struct hda_codec *codec)
5273{
5274 struct alc_spec *spec = codec->spec;
5275 hda_nid_t nid;
5276
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005277 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005278 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005279 if (nid) {
5280 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5281 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5282 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005283
Takashi Iwai82bc9552006-03-21 11:24:42 +01005284 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005285 if (nid)
5286 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5287
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005288 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005289 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005290 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005291}
Kailang Yangdf694da2005-12-05 19:42:22 +01005292
5293#define ALC260_PIN_CD_NID 0x16
5294static void alc260_auto_init_analog_input(struct hda_codec *codec)
5295{
5296 struct alc_spec *spec = codec->spec;
5297 int i;
5298
5299 for (i = 0; i < AUTO_PIN_LAST; i++) {
5300 hda_nid_t nid = spec->autocfg.input_pins[i];
5301 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005302 snd_hda_codec_write(codec, nid, 0,
5303 AC_VERB_SET_PIN_WIDGET_CONTROL,
5304 i <= AUTO_PIN_FRONT_MIC ?
5305 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005306 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005307 snd_hda_codec_write(codec, nid, 0,
5308 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005309 AMP_OUT_MUTE);
5310 }
5311 }
5312}
5313
5314/*
5315 * generic initialization of ADC, input mixers and output mixers
5316 */
5317static struct hda_verb alc260_volume_init_verbs[] = {
5318 /*
5319 * Unmute ADC0-1 and set the default input to mic-in
5320 */
5321 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5322 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5323 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5324 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005325
Kailang Yangdf694da2005-12-05 19:42:22 +01005326 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5327 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005328 * Note: PASD motherboards uses the Line In 2 as the input for
5329 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005330 */
5331 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005332 /* mute analog inputs */
5333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005338
5339 /*
5340 * Set up output mixers (0x08 - 0x0a)
5341 */
5342 /* set vol=0 to output mixers */
5343 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5344 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5346 /* set up input amps for analog loopback */
5347 /* Amp Indices: DAC = 0, mixer = 1 */
5348 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5349 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5350 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5351 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5352 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5353 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005354
Kailang Yangdf694da2005-12-05 19:42:22 +01005355 { }
5356};
5357
5358static int alc260_parse_auto_config(struct hda_codec *codec)
5359{
5360 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005361 int err;
5362 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5363
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005364 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5365 alc260_ignore);
5366 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005367 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005368 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5369 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005370 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005371 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005372 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005373 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5374 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005375 return err;
5376
5377 spec->multiout.max_channels = 2;
5378
5379 if (spec->autocfg.dig_out_pin)
5380 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005381 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005382 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005383
Takashi Iwaid88897e2008-10-31 15:01:37 +01005384 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005385
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005386 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005387 spec->input_mux = &spec->private_imux;
5388
Takashi Iwaie044c392008-10-27 16:56:24 +01005389 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005390 return 1;
5391}
5392
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005393/* additional initialization for auto-configuration model */
5394static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005395{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005396 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005397 alc260_auto_init_multi_out(codec);
5398 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005399 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005400 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005401}
5402
Takashi Iwaicb53c622007-08-10 17:21:45 +02005403#ifdef CONFIG_SND_HDA_POWER_SAVE
5404static struct hda_amp_list alc260_loopbacks[] = {
5405 { 0x07, HDA_INPUT, 0 },
5406 { 0x07, HDA_INPUT, 1 },
5407 { 0x07, HDA_INPUT, 2 },
5408 { 0x07, HDA_INPUT, 3 },
5409 { 0x07, HDA_INPUT, 4 },
5410 { } /* end */
5411};
5412#endif
5413
Kailang Yangdf694da2005-12-05 19:42:22 +01005414/*
5415 * ALC260 configurations
5416 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005417static const char *alc260_models[ALC260_MODEL_LAST] = {
5418 [ALC260_BASIC] = "basic",
5419 [ALC260_HP] = "hp",
5420 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005421 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005422 [ALC260_FUJITSU_S702X] = "fujitsu",
5423 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005424 [ALC260_WILL] = "will",
5425 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005426#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005427 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005428#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005429 [ALC260_AUTO] = "auto",
5430};
5431
5432static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005433 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005434 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005435 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005436 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005437 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005438 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005439 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005440 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5441 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5442 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5443 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5444 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5445 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5446 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5447 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5448 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005449 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005450 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005451 {}
5452};
5453
Kailang Yangdf694da2005-12-05 19:42:22 +01005454static struct alc_config_preset alc260_presets[] = {
5455 [ALC260_BASIC] = {
5456 .mixers = { alc260_base_output_mixer,
5457 alc260_input_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005458 alc260_pc_beep_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005459 .init_verbs = { alc260_init_verbs },
5460 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5461 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005462 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005463 .adc_nids = alc260_adc_nids,
5464 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5465 .channel_mode = alc260_modes,
5466 .input_mux = &alc260_capture_source,
5467 },
5468 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005469 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005470 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005471 .init_verbs = { alc260_init_verbs,
5472 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005473 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5474 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005475 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5476 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005477 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5478 .channel_mode = alc260_modes,
5479 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005480 .unsol_event = alc260_hp_unsol_event,
5481 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005482 },
Kailang Yang3f878302008-08-26 13:02:23 +02005483 [ALC260_HP_DC7600] = {
5484 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005485 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005486 .init_verbs = { alc260_init_verbs,
5487 alc260_hp_dc7600_verbs },
5488 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5489 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005490 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5491 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005492 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5493 .channel_mode = alc260_modes,
5494 .input_mux = &alc260_capture_source,
5495 .unsol_event = alc260_hp_3012_unsol_event,
5496 .init_hook = alc260_hp_3012_automute,
5497 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005498 [ALC260_HP_3013] = {
5499 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005500 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005501 .init_verbs = { alc260_hp_3013_init_verbs,
5502 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005503 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5504 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005505 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5506 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005507 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5508 .channel_mode = alc260_modes,
5509 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005510 .unsol_event = alc260_hp_3013_unsol_event,
5511 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005512 },
5513 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005514 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005515 .init_verbs = { alc260_fujitsu_init_verbs },
5516 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5517 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005518 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5519 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005520 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5521 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005522 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5523 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005524 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005525 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005526 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005527 .init_verbs = { alc260_acer_init_verbs },
5528 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5529 .dac_nids = alc260_dac_nids,
5530 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5531 .adc_nids = alc260_dual_adc_nids,
5532 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5533 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005534 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5535 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005536 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005537 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005538 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005539 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5540 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5541 .dac_nids = alc260_dac_nids,
5542 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5543 .adc_nids = alc260_adc_nids,
5544 .dig_out_nid = ALC260_DIGOUT_NID,
5545 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5546 .channel_mode = alc260_modes,
5547 .input_mux = &alc260_capture_source,
5548 },
5549 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005550 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005551 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5552 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5553 .dac_nids = alc260_dac_nids,
5554 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5555 .adc_nids = alc260_adc_nids,
5556 .dig_out_nid = ALC260_DIGOUT_NID,
5557 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5558 .channel_mode = alc260_modes,
5559 .input_mux = &alc260_capture_source,
5560 .unsol_event = alc260_replacer_672v_unsol_event,
5561 .init_hook = alc260_replacer_672v_automute,
5562 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005563#ifdef CONFIG_SND_DEBUG
5564 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005565 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005566 .init_verbs = { alc260_test_init_verbs },
5567 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5568 .dac_nids = alc260_test_dac_nids,
5569 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5570 .adc_nids = alc260_test_adc_nids,
5571 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5572 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005573 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5574 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005575 },
5576#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005577};
5578
Linus Torvalds1da177e2005-04-16 15:20:36 -07005579static int patch_alc260(struct hda_codec *codec)
5580{
5581 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005582 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005583
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005584 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005585 if (spec == NULL)
5586 return -ENOMEM;
5587
5588 codec->spec = spec;
5589
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005590 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5591 alc260_models,
5592 alc260_cfg_tbl);
5593 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005594 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5595 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005596 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005597 }
5598
Kailang Yangdf694da2005-12-05 19:42:22 +01005599 if (board_config == ALC260_AUTO) {
5600 /* automatic parse from the BIOS config */
5601 err = alc260_parse_auto_config(codec);
5602 if (err < 0) {
5603 alc_free(codec);
5604 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005605 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005606 printk(KERN_INFO
5607 "hda_codec: Cannot set up configuration "
5608 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005609 board_config = ALC260_BASIC;
5610 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005611 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005612
Kailang Yangdf694da2005-12-05 19:42:22 +01005613 if (board_config != ALC260_AUTO)
5614 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005615
5616 spec->stream_name_analog = "ALC260 Analog";
5617 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5618 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5619
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005620 spec->stream_name_digital = "ALC260 Digital";
5621 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5622 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5623
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01005624 if (!spec->adc_nids && spec->input_mux) {
5625 /* check whether NID 0x04 is valid */
5626 unsigned int wcap = get_wcaps(codec, 0x04);
5627 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5628 /* get type */
5629 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5630 spec->adc_nids = alc260_adc_nids_alt;
5631 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5632 } else {
5633 spec->adc_nids = alc260_adc_nids;
5634 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5635 }
5636 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005637 set_capture_mixer(spec);
5638
Takashi Iwai2134ea42008-01-10 16:53:55 +01005639 spec->vmaster_nid = 0x08;
5640
Linus Torvalds1da177e2005-04-16 15:20:36 -07005641 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005642 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005643 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005644#ifdef CONFIG_SND_HDA_POWER_SAVE
5645 if (!spec->loopback.amplist)
5646 spec->loopback.amplist = alc260_loopbacks;
5647#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005648
5649 return 0;
5650}
5651
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005652
Linus Torvalds1da177e2005-04-16 15:20:36 -07005653/*
5654 * ALC882 support
5655 *
5656 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5657 * configuration. Each pin widget can choose any input DACs and a mixer.
5658 * Each ADC is connected from a mixer of all inputs. This makes possible
5659 * 6-channel independent captures.
5660 *
5661 * In addition, an independent DAC for the multi-playback (not used in this
5662 * driver yet).
5663 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005664#define ALC882_DIGOUT_NID 0x06
5665#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005666
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005667static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005668 { 8, NULL }
5669};
5670
5671static hda_nid_t alc882_dac_nids[4] = {
5672 /* front, rear, clfe, rear_surr */
5673 0x02, 0x03, 0x04, 0x05
5674};
5675
Kailang Yangdf694da2005-12-05 19:42:22 +01005676/* identical with ALC880 */
5677#define alc882_adc_nids alc880_adc_nids
5678#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005679
Takashi Iwaie1406342008-02-11 18:32:32 +01005680static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5681static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5682
Linus Torvalds1da177e2005-04-16 15:20:36 -07005683/* input MUX */
5684/* FIXME: should be a matrix-type input source selection */
5685
5686static struct hda_input_mux alc882_capture_source = {
5687 .num_items = 4,
5688 .items = {
5689 { "Mic", 0x0 },
5690 { "Front Mic", 0x1 },
5691 { "Line", 0x2 },
5692 { "CD", 0x4 },
5693 },
5694};
Kailang Yangdf694da2005-12-05 19:42:22 +01005695/*
Kailang Yang272a5272007-05-14 11:00:38 +02005696 * 2ch mode
5697 */
5698static struct hda_verb alc882_3ST_ch2_init[] = {
5699 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5700 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5701 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5702 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5703 { } /* end */
5704};
5705
5706/*
5707 * 6ch mode
5708 */
5709static struct hda_verb alc882_3ST_ch6_init[] = {
5710 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5711 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5712 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5713 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5714 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5715 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5716 { } /* end */
5717};
5718
5719static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5720 { 2, alc882_3ST_ch2_init },
5721 { 6, alc882_3ST_ch6_init },
5722};
5723
5724/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005725 * 6ch mode
5726 */
5727static struct hda_verb alc882_sixstack_ch6_init[] = {
5728 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5729 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5730 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5731 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5732 { } /* end */
5733};
5734
5735/*
5736 * 8ch mode
5737 */
5738static struct hda_verb alc882_sixstack_ch8_init[] = {
5739 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5740 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5741 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5742 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5743 { } /* end */
5744};
5745
5746static struct hda_channel_mode alc882_sixstack_modes[2] = {
5747 { 6, alc882_sixstack_ch6_init },
5748 { 8, alc882_sixstack_ch8_init },
5749};
5750
Takashi Iwai87350ad2007-08-16 18:19:38 +02005751/*
5752 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5753 */
5754
5755/*
5756 * 2ch mode
5757 */
5758static struct hda_verb alc885_mbp_ch2_init[] = {
5759 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5760 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5761 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5762 { } /* end */
5763};
5764
5765/*
5766 * 6ch mode
5767 */
5768static struct hda_verb alc885_mbp_ch6_init[] = {
5769 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5770 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5771 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5772 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5773 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5774 { } /* end */
5775};
5776
5777static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5778 { 2, alc885_mbp_ch2_init },
5779 { 6, alc885_mbp_ch6_init },
5780};
5781
5782
Linus Torvalds1da177e2005-04-16 15:20:36 -07005783/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5784 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5785 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005786static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005787 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005788 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005789 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005790 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005791 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5792 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005793 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5794 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005795 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005796 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005797 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5798 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5799 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5800 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5801 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005803 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5805 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005806 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005807 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5808 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5809 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005810 { } /* end */
5811};
5812
Takashi Iwai87350ad2007-08-16 18:19:38 +02005813static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005814 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5815 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5816 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5817 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5819 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5821 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005822 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005823 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5824 { } /* end */
5825};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005826static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5827 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5828 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5829 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5830 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5831 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5832 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5834 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5836 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5837 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5838 { } /* end */
5839};
5840
Kailang Yang272a5272007-05-14 11:00:38 +02005841static struct snd_kcontrol_new alc882_targa_mixer[] = {
5842 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5843 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5845 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5846 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5847 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5848 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005851 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005852 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5853 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005854 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005855 { } /* end */
5856};
5857
5858/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5859 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5860 */
5861static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5862 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5863 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5864 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5865 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5866 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5867 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5868 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5869 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5870 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5871 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5873 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005874 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005875 { } /* end */
5876};
5877
Takashi Iwai914759b2007-09-06 14:52:04 +02005878static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5881 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5882 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5883 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5884 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5885 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5886 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5887 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5888 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5889 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5890 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5891 { } /* end */
5892};
5893
Kailang Yangdf694da2005-12-05 19:42:22 +01005894static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5895 {
5896 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5897 .name = "Channel Mode",
5898 .info = alc_ch_mode_info,
5899 .get = alc_ch_mode_get,
5900 .put = alc_ch_mode_put,
5901 },
5902 { } /* end */
5903};
5904
Linus Torvalds1da177e2005-04-16 15:20:36 -07005905static struct hda_verb alc882_init_verbs[] = {
5906 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005907 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5908 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5909 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005910 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005911 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5912 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5913 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005914 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005915 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5916 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5917 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005918 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005919 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5920 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5921 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005922
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005923 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005924 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005926 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005927 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005928 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005929 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005930 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005931 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005932 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005933 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005934 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005935 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005936 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005937 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005938 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005939 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005940 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005941 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5942 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005943 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005944 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5945 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005946 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005947 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5948 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5949 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5950 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5951 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005952 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005953 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005954
5955 /* FIXME: use matrix-type input source selection */
5956 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5957 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005958 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5959 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5960 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5961 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005962 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005963 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5964 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5965 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5966 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005967 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005968 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5972 /* ADC1: mute amp left and right */
5973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005974 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005975 /* ADC2: mute amp left and right */
5976 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005977 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005978 /* ADC3: mute amp left and right */
5979 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005980 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005981
5982 { }
5983};
5984
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005985static struct hda_verb alc882_eapd_verbs[] = {
5986 /* change to EAPD mode */
5987 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005988 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005989 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005990};
5991
Tobin Davis9102cd12006-12-15 10:02:12 +01005992/* Mac Pro test */
5993static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5994 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5995 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5996 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5997 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5998 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5999 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6000 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
6001 { } /* end */
6002};
6003
6004static struct hda_verb alc882_macpro_init_verbs[] = {
6005 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6006 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6007 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6008 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6009 /* Front Pin: output 0 (0x0c) */
6010 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6012 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6013 /* Front Mic pin: input vref at 80% */
6014 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6015 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6016 /* Speaker: output */
6017 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6018 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6019 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6020 /* Headphone output (output 0 - 0x0c) */
6021 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6022 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6023 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6024
6025 /* FIXME: use matrix-type input source selection */
6026 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6027 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6029 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6030 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6031 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6032 /* Input mixer2 */
6033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6034 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6035 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6036 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6037 /* Input mixer3 */
6038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6041 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6042 /* ADC1: mute amp left and right */
6043 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6044 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6045 /* ADC2: mute amp left and right */
6046 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6047 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6048 /* ADC3: mute amp left and right */
6049 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6050 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6051
6052 { }
6053};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006054
Takashi Iwai87350ad2007-08-16 18:19:38 +02006055/* Macbook Pro rev3 */
6056static struct hda_verb alc885_mbp3_init_verbs[] = {
6057 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6058 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6060 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6061 /* Rear mixer */
6062 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6063 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6064 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6065 /* Front Pin: output 0 (0x0c) */
6066 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6067 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6068 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6069 /* HP Pin: output 0 (0x0d) */
6070 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6071 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6072 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6073 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6074 /* Mic (rear) pin: input vref at 80% */
6075 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6076 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6077 /* Front Mic pin: input vref at 80% */
6078 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6079 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6080 /* Line In pin: use output 1 when in LineOut mode */
6081 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6082 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6083 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6084
6085 /* FIXME: use matrix-type input source selection */
6086 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6087 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6088 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6089 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6090 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6091 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6092 /* Input mixer2 */
6093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6094 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6096 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6097 /* Input mixer3 */
6098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6102 /* ADC1: mute amp left and right */
6103 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6104 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6105 /* ADC2: mute amp left and right */
6106 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6107 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6108 /* ADC3: mute amp left and right */
6109 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6110 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6111
6112 { }
6113};
6114
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006115/* iMac 24 mixer. */
6116static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6117 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6118 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6119 { } /* end */
6120};
6121
6122/* iMac 24 init verbs. */
6123static struct hda_verb alc885_imac24_init_verbs[] = {
6124 /* Internal speakers: output 0 (0x0c) */
6125 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6126 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6127 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6128 /* Internal speakers: output 0 (0x0c) */
6129 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6130 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6131 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6132 /* Headphone: output 0 (0x0c) */
6133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6134 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6135 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6136 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6137 /* Front Mic: input vref at 80% */
6138 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6139 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6140 { }
6141};
6142
6143/* Toggle speaker-output according to the hp-jack state */
6144static void alc885_imac24_automute(struct hda_codec *codec)
6145{
6146 unsigned int present;
6147
6148 present = snd_hda_codec_read(codec, 0x14, 0,
6149 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006150 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6151 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6152 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6153 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006154}
6155
6156/* Processes unsolicited events. */
6157static void alc885_imac24_unsol_event(struct hda_codec *codec,
6158 unsigned int res)
6159{
6160 /* Headphone insertion or removal. */
6161 if ((res >> 26) == ALC880_HP_EVENT)
6162 alc885_imac24_automute(codec);
6163}
6164
Takashi Iwai87350ad2007-08-16 18:19:38 +02006165static void alc885_mbp3_automute(struct hda_codec *codec)
6166{
6167 unsigned int present;
6168
6169 present = snd_hda_codec_read(codec, 0x15, 0,
6170 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6171 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6172 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6173 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6174 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6175
6176}
6177static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6178 unsigned int res)
6179{
6180 /* Headphone insertion or removal. */
6181 if ((res >> 26) == ALC880_HP_EVENT)
6182 alc885_mbp3_automute(codec);
6183}
6184
6185
Kailang Yang272a5272007-05-14 11:00:38 +02006186static struct hda_verb alc882_targa_verbs[] = {
6187 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6188 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6189
6190 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6191 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006192
Kailang Yang272a5272007-05-14 11:00:38 +02006193 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6194 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6195 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6196
6197 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6198 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6199 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6200 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6201 { } /* end */
6202};
6203
6204/* toggle speaker-output according to the hp-jack state */
6205static void alc882_targa_automute(struct hda_codec *codec)
6206{
6207 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006208
Kailang Yang272a5272007-05-14 11:00:38 +02006209 present = snd_hda_codec_read(codec, 0x14, 0,
6210 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006211 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6212 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006213 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6214 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006215}
6216
6217static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6218{
6219 /* Looks like the unsol event is incompatible with the standard
6220 * definition. 4bit tag is placed at 26 bit!
6221 */
6222 if (((res >> 26) == ALC880_HP_EVENT)) {
6223 alc882_targa_automute(codec);
6224 }
6225}
6226
6227static struct hda_verb alc882_asus_a7j_verbs[] = {
6228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6230
6231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6232 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6233 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006234
Kailang Yang272a5272007-05-14 11:00:38 +02006235 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6236 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6237 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6238
6239 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6240 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6241 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6242 { } /* end */
6243};
6244
Takashi Iwai914759b2007-09-06 14:52:04 +02006245static struct hda_verb alc882_asus_a7m_verbs[] = {
6246 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6247 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6248
6249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6250 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6251 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006252
Takashi Iwai914759b2007-09-06 14:52:04 +02006253 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6254 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6255 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6256
6257 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6258 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6259 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6260 { } /* end */
6261};
6262
Tobin Davis9102cd12006-12-15 10:02:12 +01006263static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6264{
6265 unsigned int gpiostate, gpiomask, gpiodir;
6266
6267 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6268 AC_VERB_GET_GPIO_DATA, 0);
6269
6270 if (!muted)
6271 gpiostate |= (1 << pin);
6272 else
6273 gpiostate &= ~(1 << pin);
6274
6275 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6276 AC_VERB_GET_GPIO_MASK, 0);
6277 gpiomask |= (1 << pin);
6278
6279 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6280 AC_VERB_GET_GPIO_DIRECTION, 0);
6281 gpiodir |= (1 << pin);
6282
6283
6284 snd_hda_codec_write(codec, codec->afg, 0,
6285 AC_VERB_SET_GPIO_MASK, gpiomask);
6286 snd_hda_codec_write(codec, codec->afg, 0,
6287 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6288
6289 msleep(1);
6290
6291 snd_hda_codec_write(codec, codec->afg, 0,
6292 AC_VERB_SET_GPIO_DATA, gpiostate);
6293}
6294
Takashi Iwai7debbe52007-08-16 15:01:03 +02006295/* set up GPIO at initialization */
6296static void alc885_macpro_init_hook(struct hda_codec *codec)
6297{
6298 alc882_gpio_mute(codec, 0, 0);
6299 alc882_gpio_mute(codec, 1, 0);
6300}
6301
6302/* set up GPIO and update auto-muting at initialization */
6303static void alc885_imac24_init_hook(struct hda_codec *codec)
6304{
6305 alc885_macpro_init_hook(codec);
6306 alc885_imac24_automute(codec);
6307}
6308
Kailang Yangdf694da2005-12-05 19:42:22 +01006309/*
6310 * generic initialization of ADC, input mixers and output mixers
6311 */
6312static struct hda_verb alc882_auto_init_verbs[] = {
6313 /*
6314 * Unmute ADC0-2 and set the default input to mic-in
6315 */
6316 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6317 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6318 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6320 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6321 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6322
Takashi Iwaicb53c622007-08-10 17:21:45 +02006323 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006324 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006325 * Note: PASD motherboards uses the Line In 2 as the input for
6326 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006327 */
6328 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006334
6335 /*
6336 * Set up output mixers (0x0c - 0x0f)
6337 */
6338 /* set vol=0 to output mixers */
6339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6340 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6341 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6342 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6343 /* set up input amps for analog loopback */
6344 /* Amp Indices: DAC = 0, mixer = 1 */
6345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6350 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6353 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6354 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6355
6356 /* FIXME: use matrix-type input source selection */
6357 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6358 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6363 /* Input mixer2 */
6364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6365 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6368 /* Input mixer3 */
6369 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6373
6374 { }
6375};
6376
Takashi Iwaicb53c622007-08-10 17:21:45 +02006377#ifdef CONFIG_SND_HDA_POWER_SAVE
6378#define alc882_loopbacks alc880_loopbacks
6379#endif
6380
Kailang Yangdf694da2005-12-05 19:42:22 +01006381/* pcm configuration: identiacal with ALC880 */
6382#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6383#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6384#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6385#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6386
6387/*
6388 * configuration and preset
6389 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006390static const char *alc882_models[ALC882_MODEL_LAST] = {
6391 [ALC882_3ST_DIG] = "3stack-dig",
6392 [ALC882_6ST_DIG] = "6stack-dig",
6393 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006394 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006395 [ALC882_TARGA] = "targa",
6396 [ALC882_ASUS_A7J] = "asus-a7j",
6397 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006398 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006399 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006400 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006401 [ALC882_AUTO] = "auto",
6402};
6403
6404static struct snd_pci_quirk alc882_cfg_tbl[] = {
6405 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006406 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006407 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006408 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006409 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006410 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006411 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006412 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006413 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006414 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6415 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6416 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006417 {}
6418};
6419
6420static struct alc_config_preset alc882_presets[] = {
6421 [ALC882_3ST_DIG] = {
6422 .mixers = { alc882_base_mixer },
6423 .init_verbs = { alc882_init_verbs },
6424 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6425 .dac_nids = alc882_dac_nids,
6426 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006427 .dig_in_nid = ALC882_DIGIN_NID,
6428 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6429 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006430 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006431 .input_mux = &alc882_capture_source,
6432 },
6433 [ALC882_6ST_DIG] = {
6434 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6435 .init_verbs = { alc882_init_verbs },
6436 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6437 .dac_nids = alc882_dac_nids,
6438 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006439 .dig_in_nid = ALC882_DIGIN_NID,
6440 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6441 .channel_mode = alc882_sixstack_modes,
6442 .input_mux = &alc882_capture_source,
6443 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006444 [ALC882_ARIMA] = {
6445 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6446 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6447 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6448 .dac_nids = alc882_dac_nids,
6449 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6450 .channel_mode = alc882_sixstack_modes,
6451 .input_mux = &alc882_capture_source,
6452 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006453 [ALC882_W2JC] = {
6454 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6455 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6456 alc880_gpio1_init_verbs },
6457 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6458 .dac_nids = alc882_dac_nids,
6459 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6460 .channel_mode = alc880_threestack_modes,
6461 .need_dac_fix = 1,
6462 .input_mux = &alc882_capture_source,
6463 .dig_out_nid = ALC882_DIGOUT_NID,
6464 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006465 [ALC885_MBP3] = {
6466 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6467 .init_verbs = { alc885_mbp3_init_verbs,
6468 alc880_gpio1_init_verbs },
6469 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6470 .dac_nids = alc882_dac_nids,
6471 .channel_mode = alc885_mbp_6ch_modes,
6472 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6473 .input_mux = &alc882_capture_source,
6474 .dig_out_nid = ALC882_DIGOUT_NID,
6475 .dig_in_nid = ALC882_DIGIN_NID,
6476 .unsol_event = alc885_mbp3_unsol_event,
6477 .init_hook = alc885_mbp3_automute,
6478 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006479 [ALC885_MACPRO] = {
6480 .mixers = { alc882_macpro_mixer },
6481 .init_verbs = { alc882_macpro_init_verbs },
6482 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6483 .dac_nids = alc882_dac_nids,
6484 .dig_out_nid = ALC882_DIGOUT_NID,
6485 .dig_in_nid = ALC882_DIGIN_NID,
6486 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6487 .channel_mode = alc882_ch_modes,
6488 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006489 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006490 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006491 [ALC885_IMAC24] = {
6492 .mixers = { alc885_imac24_mixer },
6493 .init_verbs = { alc885_imac24_init_verbs },
6494 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6495 .dac_nids = alc882_dac_nids,
6496 .dig_out_nid = ALC882_DIGOUT_NID,
6497 .dig_in_nid = ALC882_DIGIN_NID,
6498 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6499 .channel_mode = alc882_ch_modes,
6500 .input_mux = &alc882_capture_source,
6501 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006502 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006503 },
Kailang Yang272a5272007-05-14 11:00:38 +02006504 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006505 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006506 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6507 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6508 .dac_nids = alc882_dac_nids,
6509 .dig_out_nid = ALC882_DIGOUT_NID,
6510 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6511 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006512 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006513 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6514 .channel_mode = alc882_3ST_6ch_modes,
6515 .need_dac_fix = 1,
6516 .input_mux = &alc882_capture_source,
6517 .unsol_event = alc882_targa_unsol_event,
6518 .init_hook = alc882_targa_automute,
6519 },
6520 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006521 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006522 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6523 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6524 .dac_nids = alc882_dac_nids,
6525 .dig_out_nid = ALC882_DIGOUT_NID,
6526 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6527 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006528 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006529 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6530 .channel_mode = alc882_3ST_6ch_modes,
6531 .need_dac_fix = 1,
6532 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006533 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006534 [ALC882_ASUS_A7M] = {
6535 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6536 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6537 alc880_gpio1_init_verbs,
6538 alc882_asus_a7m_verbs },
6539 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6540 .dac_nids = alc882_dac_nids,
6541 .dig_out_nid = ALC882_DIGOUT_NID,
6542 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6543 .channel_mode = alc880_threestack_modes,
6544 .need_dac_fix = 1,
6545 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006546 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006547};
6548
6549
6550/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006551 * Pin config fixes
6552 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006553enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006554 PINFIX_ABIT_AW9D_MAX
6555};
6556
6557static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6558 { 0x15, 0x01080104 }, /* side */
6559 { 0x16, 0x01011012 }, /* rear */
6560 { 0x17, 0x01016011 }, /* clfe */
6561 { }
6562};
6563
6564static const struct alc_pincfg *alc882_pin_fixes[] = {
6565 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6566};
6567
6568static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6569 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6570 {}
6571};
6572
6573/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006574 * BIOS auto configuration
6575 */
6576static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6577 hda_nid_t nid, int pin_type,
6578 int dac_idx)
6579{
6580 /* set as output */
6581 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006582 int idx;
6583
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006584 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006585 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6586 idx = 4;
6587 else
6588 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006589 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6590
6591}
6592
6593static void alc882_auto_init_multi_out(struct hda_codec *codec)
6594{
6595 struct alc_spec *spec = codec->spec;
6596 int i;
6597
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006598 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006599 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006600 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006601 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006602 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006603 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006604 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006605 }
6606}
6607
6608static void alc882_auto_init_hp_out(struct hda_codec *codec)
6609{
6610 struct alc_spec *spec = codec->spec;
6611 hda_nid_t pin;
6612
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006613 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006614 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006615 /* use dac 0 */
6616 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006617 pin = spec->autocfg.speaker_pins[0];
6618 if (pin)
6619 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006620}
6621
6622#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6623#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6624
6625static void alc882_auto_init_analog_input(struct hda_codec *codec)
6626{
6627 struct alc_spec *spec = codec->spec;
6628 int i;
6629
6630 for (i = 0; i < AUTO_PIN_LAST; i++) {
6631 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006632 unsigned int vref;
6633 if (!nid)
6634 continue;
6635 vref = PIN_IN;
6636 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006637 unsigned int pincap;
6638 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6639 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006640 AC_PINCAP_VREF_80)
6641 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006642 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006643 snd_hda_codec_write(codec, nid, 0,
6644 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6645 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6646 snd_hda_codec_write(codec, nid, 0,
6647 AC_VERB_SET_AMP_GAIN_MUTE,
6648 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006649 }
6650}
6651
Takashi Iwaif511b012008-08-15 16:46:42 +02006652static void alc882_auto_init_input_src(struct hda_codec *codec)
6653{
6654 struct alc_spec *spec = codec->spec;
6655 const struct hda_input_mux *imux = spec->input_mux;
6656 int c;
6657
6658 for (c = 0; c < spec->num_adc_nids; c++) {
6659 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6660 hda_nid_t nid = spec->capsrc_nids[c];
6661 int conns, mute, idx, item;
6662
6663 conns = snd_hda_get_connections(codec, nid, conn_list,
6664 ARRAY_SIZE(conn_list));
6665 if (conns < 0)
6666 continue;
6667 for (idx = 0; idx < conns; idx++) {
6668 /* if the current connection is the selected one,
6669 * unmute it as default - otherwise mute it
6670 */
6671 mute = AMP_IN_MUTE(idx);
6672 for (item = 0; item < imux->num_items; item++) {
6673 if (imux->items[item].index == idx) {
6674 if (spec->cur_mux[c] == item)
6675 mute = AMP_IN_UNMUTE(idx);
6676 break;
6677 }
6678 }
6679 snd_hda_codec_write(codec, nid, 0,
6680 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6681 }
6682 }
6683}
6684
Takashi Iwai776e1842007-08-29 15:07:11 +02006685/* add mic boosts if needed */
6686static int alc_auto_add_mic_boost(struct hda_codec *codec)
6687{
6688 struct alc_spec *spec = codec->spec;
6689 int err;
6690 hda_nid_t nid;
6691
6692 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006693 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006694 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6695 "Mic Boost",
6696 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6697 if (err < 0)
6698 return err;
6699 }
6700 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006701 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006702 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6703 "Front Mic Boost",
6704 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6705 if (err < 0)
6706 return err;
6707 }
6708 return 0;
6709}
6710
Kailang Yangdf694da2005-12-05 19:42:22 +01006711/* almost identical with ALC880 parser... */
6712static int alc882_parse_auto_config(struct hda_codec *codec)
6713{
6714 struct alc_spec *spec = codec->spec;
6715 int err = alc880_parse_auto_config(codec);
6716
6717 if (err < 0)
6718 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006719 else if (!err)
6720 return 0; /* no config found */
6721
6722 err = alc_auto_add_mic_boost(codec);
6723 if (err < 0)
6724 return err;
6725
6726 /* hack - override the init verbs */
6727 spec->init_verbs[0] = alc882_auto_init_verbs;
6728
6729 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006730}
6731
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006732/* additional initialization for auto-configuration model */
6733static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006734{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006735 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006736 alc882_auto_init_multi_out(codec);
6737 alc882_auto_init_hp_out(codec);
6738 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006739 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006740 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006741 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006742}
6743
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006744static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6745
Linus Torvalds1da177e2005-04-16 15:20:36 -07006746static int patch_alc882(struct hda_codec *codec)
6747{
6748 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006749 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006750
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006751 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006752 if (spec == NULL)
6753 return -ENOMEM;
6754
Linus Torvalds1da177e2005-04-16 15:20:36 -07006755 codec->spec = spec;
6756
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006757 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6758 alc882_models,
6759 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006760
Kailang Yangdf694da2005-12-05 19:42:22 +01006761 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006762 /* Pick up systems that don't supply PCI SSID */
6763 switch (codec->subsystem_id) {
6764 case 0x106b0c00: /* Mac Pro */
6765 board_config = ALC885_MACPRO;
6766 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006767 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02006768 case 0x106b2800: /* AppleTV */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006769 board_config = ALC885_IMAC24;
6770 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006771 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07006772 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006773 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006774 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006775 board_config = ALC885_MBP3;
6776 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006777 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006778 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02006779 if (codec->revision_id == 0x100101 ||
6780 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006781 alc_free(codec);
6782 return patch_alc883(codec);
6783 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006784 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6785 "trying auto-probe from BIOS...\n");
6786 board_config = ALC882_AUTO;
6787 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006788 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006789
Takashi Iwaif95474e2007-07-10 00:47:43 +02006790 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6791
Kailang Yangdf694da2005-12-05 19:42:22 +01006792 if (board_config == ALC882_AUTO) {
6793 /* automatic parse from the BIOS config */
6794 err = alc882_parse_auto_config(codec);
6795 if (err < 0) {
6796 alc_free(codec);
6797 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006798 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006799 printk(KERN_INFO
6800 "hda_codec: Cannot set up configuration "
6801 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006802 board_config = ALC882_3ST_DIG;
6803 }
6804 }
6805
6806 if (board_config != ALC882_AUTO)
6807 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006808
Kailang Yang2f893282008-05-27 12:14:47 +02006809 if (codec->vendor_id == 0x10ec0885) {
6810 spec->stream_name_analog = "ALC885 Analog";
6811 spec->stream_name_digital = "ALC885 Digital";
6812 } else {
6813 spec->stream_name_analog = "ALC882 Analog";
6814 spec->stream_name_digital = "ALC882 Digital";
6815 }
6816
Kailang Yangdf694da2005-12-05 19:42:22 +01006817 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6818 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006819 /* FIXME: setup DAC5 */
6820 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6821 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006822
Kailang Yangdf694da2005-12-05 19:42:22 +01006823 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6824 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006825
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01006826 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006827 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006828 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006829 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006830 /* get type */
6831 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006832 if (wcap != AC_WID_AUD_IN) {
6833 spec->adc_nids = alc882_adc_nids_alt;
6834 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006835 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01006836 } else {
6837 spec->adc_nids = alc882_adc_nids;
6838 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006839 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006840 }
6841 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006842 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006843
Takashi Iwai2134ea42008-01-10 16:53:55 +01006844 spec->vmaster_nid = 0x0c;
6845
Linus Torvalds1da177e2005-04-16 15:20:36 -07006846 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006847 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006848 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006849#ifdef CONFIG_SND_HDA_POWER_SAVE
6850 if (!spec->loopback.amplist)
6851 spec->loopback.amplist = alc882_loopbacks;
6852#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006853
6854 return 0;
6855}
6856
6857/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006858 * ALC883 support
6859 *
6860 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6861 * configuration. Each pin widget can choose any input DACs and a mixer.
6862 * Each ADC is connected from a mixer of all inputs. This makes possible
6863 * 6-channel independent captures.
6864 *
6865 * In addition, an independent DAC for the multi-playback (not used in this
6866 * driver yet).
6867 */
6868#define ALC883_DIGOUT_NID 0x06
6869#define ALC883_DIGIN_NID 0x0a
6870
6871static hda_nid_t alc883_dac_nids[4] = {
6872 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006873 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006874};
6875
6876static hda_nid_t alc883_adc_nids[2] = {
6877 /* ADC1-2 */
6878 0x08, 0x09,
6879};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006880
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006881static hda_nid_t alc883_adc_nids_alt[1] = {
6882 /* ADC1 */
6883 0x08,
6884};
6885
Takashi Iwaie1406342008-02-11 18:32:32 +01006886static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6887
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006888/* input MUX */
6889/* FIXME: should be a matrix-type input source selection */
6890
6891static struct hda_input_mux alc883_capture_source = {
6892 .num_items = 4,
6893 .items = {
6894 { "Mic", 0x0 },
6895 { "Front Mic", 0x1 },
6896 { "Line", 0x2 },
6897 { "CD", 0x4 },
6898 },
6899};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006900
Jiang zhe17bba1b2008-06-04 12:11:07 +02006901static struct hda_input_mux alc883_3stack_6ch_intel = {
6902 .num_items = 4,
6903 .items = {
6904 { "Mic", 0x1 },
6905 { "Front Mic", 0x0 },
6906 { "Line", 0x2 },
6907 { "CD", 0x4 },
6908 },
6909};
6910
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006911static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6912 .num_items = 2,
6913 .items = {
6914 { "Mic", 0x1 },
6915 { "Line", 0x2 },
6916 },
6917};
6918
Kailang Yang272a5272007-05-14 11:00:38 +02006919static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6920 .num_items = 4,
6921 .items = {
6922 { "Mic", 0x0 },
6923 { "iMic", 0x1 },
6924 { "Line", 0x2 },
6925 { "CD", 0x4 },
6926 },
6927};
6928
Jiang zhefb97dc62008-03-06 11:07:11 +01006929static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6930 .num_items = 2,
6931 .items = {
6932 { "Mic", 0x0 },
6933 { "Int Mic", 0x1 },
6934 },
6935};
6936
Kailang Yange2757d52008-08-26 13:17:46 +02006937static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6938 .num_items = 3,
6939 .items = {
6940 { "Mic", 0x0 },
6941 { "Front Mic", 0x1 },
6942 { "Line", 0x4 },
6943 },
6944};
6945
6946static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6947 .num_items = 2,
6948 .items = {
6949 { "Mic", 0x0 },
6950 { "Line", 0x2 },
6951 },
6952};
6953
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006954/*
6955 * 2ch mode
6956 */
6957static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6958 { 2, NULL }
6959};
6960
6961/*
6962 * 2ch mode
6963 */
6964static struct hda_verb alc883_3ST_ch2_init[] = {
6965 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6966 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6967 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6968 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6969 { } /* end */
6970};
6971
6972/*
Tobin Davisb2011312007-09-17 12:45:11 +02006973 * 4ch mode
6974 */
6975static struct hda_verb alc883_3ST_ch4_init[] = {
6976 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6977 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6978 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6979 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6980 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6981 { } /* end */
6982};
6983
6984/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006985 * 6ch mode
6986 */
6987static struct hda_verb alc883_3ST_ch6_init[] = {
6988 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6989 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6990 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6991 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6992 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6993 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6994 { } /* end */
6995};
6996
Tobin Davisb2011312007-09-17 12:45:11 +02006997static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006998 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006999 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007000 { 6, alc883_3ST_ch6_init },
7001};
7002
7003/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007004 * 2ch mode
7005 */
7006static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7007 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7008 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7009 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7010 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7011 { } /* end */
7012};
7013
7014/*
7015 * 4ch mode
7016 */
7017static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7018 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7019 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7020 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7021 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7022 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7023 { } /* end */
7024};
7025
7026/*
7027 * 6ch mode
7028 */
7029static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7030 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7031 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7032 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7033 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7034 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7035 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7036 { } /* end */
7037};
7038
7039static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7040 { 2, alc883_3ST_ch2_intel_init },
7041 { 4, alc883_3ST_ch4_intel_init },
7042 { 6, alc883_3ST_ch6_intel_init },
7043};
7044
7045/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007046 * 6ch mode
7047 */
7048static struct hda_verb alc883_sixstack_ch6_init[] = {
7049 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7050 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7051 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7052 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7053 { } /* end */
7054};
7055
7056/*
7057 * 8ch mode
7058 */
7059static struct hda_verb alc883_sixstack_ch8_init[] = {
7060 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7061 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7062 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7063 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7064 { } /* end */
7065};
7066
7067static struct hda_channel_mode alc883_sixstack_modes[2] = {
7068 { 6, alc883_sixstack_ch6_init },
7069 { 8, alc883_sixstack_ch8_init },
7070};
7071
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007072static struct hda_verb alc883_medion_eapd_verbs[] = {
7073 /* eanable EAPD on medion laptop */
7074 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7075 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7076 { }
7077};
7078
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007079/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7080 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7081 */
7082
7083static struct snd_kcontrol_new alc883_base_mixer[] = {
7084 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7085 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7086 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7087 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7088 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7089 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7090 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7091 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7092 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7093 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7095 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7096 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007100 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7102 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007103 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007104 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7105 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7106 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007107 { } /* end */
7108};
7109
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007110static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7111 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7112 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7113 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7114 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7115 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7116 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7117 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7118 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7119 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7120 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7121 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7122 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7123 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007124 { } /* end */
7125};
7126
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007127static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007128 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7129 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7130 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7131 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7132 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7133 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7134 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7135 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7136 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7137 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007138 { } /* end */
7139};
7140
Jiang zhefb97dc62008-03-06 11:07:11 +01007141static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7142 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7143 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7144 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7145 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7147 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7148 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7149 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7150 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7151 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007152 { } /* end */
7153};
7154
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007155static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7156 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7157 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7158 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7159 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7160 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7161 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7162 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007164 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007165 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7166 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007167 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007168 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7169 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7170 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007171 { } /* end */
7172};
7173
7174static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7175 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7176 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7177 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7178 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7179 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7180 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7181 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7182 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7183 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7184 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7185 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7186 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7187 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7188 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007189 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007190 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7191 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007192 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007193 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7194 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7195 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007196 { } /* end */
7197};
7198
Jiang zhe17bba1b2008-06-04 12:11:07 +02007199static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7200 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7201 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7202 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7203 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7204 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7205 HDA_OUTPUT),
7206 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7207 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7208 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7210 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7211 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7212 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7213 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7215 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7217 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7218 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7219 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7220 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7221 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007222 { } /* end */
7223};
7224
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007225static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007226 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007227 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007228 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007229 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007230 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7231 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007232 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7233 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007234 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7235 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7236 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7237 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7238 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7239 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007240 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007241 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7242 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007243 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007244 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7245 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7246 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007247 { } /* end */
7248};
7249
Kailang Yangccc656c2006-10-17 12:32:26 +02007250static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7252 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7253 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7254 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7255 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7256 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7257 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7258 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7259 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7260 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7261 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7262 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7263 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007266 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007267 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007268};
Kailang Yangccc656c2006-10-17 12:32:26 +02007269
7270static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7271 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7272 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7273 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7274 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7275 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7276 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007277 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007278 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007279 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7280 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7281 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007282 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007283};
Kailang Yangccc656c2006-10-17 12:32:26 +02007284
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007285static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7286 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7287 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007288 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7289 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007290 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7292 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7293 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007294 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007295};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007296
Kailang Yang272a5272007-05-14 11:00:38 +02007297static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7298 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7299 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7300 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7301 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7302 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7303 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7304 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7305 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7306 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007307 { } /* end */
7308};
7309
7310static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7311 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7313 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7314 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7315 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7318 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7319 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007320 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007321};
Kailang Yang272a5272007-05-14 11:00:38 +02007322
Tobin Davis2880a862007-08-07 11:50:26 +02007323static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007324 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7325 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007326 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007327 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7328 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007329 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7330 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7331 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007332 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007333};
Tobin Davis2880a862007-08-07 11:50:26 +02007334
Kailang Yange2757d52008-08-26 13:17:46 +02007335static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7336 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7337 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7338 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7339 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7340 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7341 0x0d, 1, 0x0, HDA_OUTPUT),
7342 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7343 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7344 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7345 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7346 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7347 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7348 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7349 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7350 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7351 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7352 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7354 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7356 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7357 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7358 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007359 { } /* end */
7360};
7361
7362static struct hda_bind_ctls alc883_bind_cap_vol = {
7363 .ops = &snd_hda_bind_vol,
7364 .values = {
7365 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7366 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7367 0
7368 },
7369};
7370
7371static struct hda_bind_ctls alc883_bind_cap_switch = {
7372 .ops = &snd_hda_bind_sw,
7373 .values = {
7374 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7375 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7376 0
7377 },
7378};
7379
7380static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7381 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7382 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7383 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7384 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7385 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7387 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7388 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007389 { } /* end */
7390};
7391
7392static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007393 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7394 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7395 {
7396 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7397 /* .name = "Capture Source", */
7398 .name = "Input Source",
7399 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007400 .info = alc_mux_enum_info,
7401 .get = alc_mux_enum_get,
7402 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007403 },
7404 { } /* end */
7405};
7406
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007407static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7408 {
7409 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7410 .name = "Channel Mode",
7411 .info = alc_ch_mode_info,
7412 .get = alc_ch_mode_get,
7413 .put = alc_ch_mode_put,
7414 },
7415 { } /* end */
7416};
7417
7418static struct hda_verb alc883_init_verbs[] = {
7419 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007420 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007421 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7422 /* ADC2: mute amp left and right */
7423 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7424 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7425 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7427 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7428 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7429 /* Rear mixer */
7430 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7431 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7432 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7433 /* CLFE mixer */
7434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7435 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7436 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7437 /* Side mixer */
7438 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7439 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7440 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7441
Takashi Iwaicb53c622007-08-10 17:21:45 +02007442 /* mute analog input loopbacks */
7443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007448
7449 /* Front Pin: output 0 (0x0c) */
7450 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7451 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7452 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7453 /* Rear Pin: output 1 (0x0d) */
7454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7455 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7456 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7457 /* CLFE Pin: output 2 (0x0e) */
7458 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7459 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7460 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7461 /* Side Pin: output 3 (0x0f) */
7462 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7463 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7464 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7465 /* Mic (rear) pin: input vref at 80% */
7466 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7467 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7468 /* Front Mic pin: input vref at 80% */
7469 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7470 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7471 /* Line In pin: input */
7472 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7473 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7474 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7475 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7476 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7477 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7478 /* CD pin widget for input */
7479 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7480
7481 /* FIXME: use matrix-type input source selection */
7482 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7483 /* Input mixer2 */
7484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007488 /* Input mixer3 */
7489 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007490 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007493 { }
7494};
7495
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007496/* toggle speaker-output according to the hp-jack state */
7497static void alc883_mitac_hp_automute(struct hda_codec *codec)
7498{
7499 unsigned int present;
7500
7501 present = snd_hda_codec_read(codec, 0x15, 0,
7502 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7503 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7504 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7505 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7506 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7507}
7508
7509/* auto-toggle front mic */
7510/*
7511static void alc883_mitac_mic_automute(struct hda_codec *codec)
7512{
7513 unsigned int present;
7514 unsigned char bits;
7515
7516 present = snd_hda_codec_read(codec, 0x18, 0,
7517 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7518 bits = present ? HDA_AMP_MUTE : 0;
7519 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7520}
7521*/
7522
7523static void alc883_mitac_automute(struct hda_codec *codec)
7524{
7525 alc883_mitac_hp_automute(codec);
7526 /* alc883_mitac_mic_automute(codec); */
7527}
7528
7529static void alc883_mitac_unsol_event(struct hda_codec *codec,
7530 unsigned int res)
7531{
7532 switch (res >> 26) {
7533 case ALC880_HP_EVENT:
7534 alc883_mitac_hp_automute(codec);
7535 break;
7536 case ALC880_MIC_EVENT:
7537 /* alc883_mitac_mic_automute(codec); */
7538 break;
7539 }
7540}
7541
7542static struct hda_verb alc883_mitac_verbs[] = {
7543 /* HP */
7544 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7545 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7546 /* Subwoofer */
7547 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7548 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7549
7550 /* enable unsolicited event */
7551 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7552 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7553
7554 { } /* end */
7555};
7556
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007557static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007558 /* HP */
7559 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7560 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7561 /* Int speaker */
7562 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7563 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7564
7565 /* enable unsolicited event */
7566 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007567 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007568
7569 { } /* end */
7570};
7571
Jiang zhefb97dc62008-03-06 11:07:11 +01007572static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7573 /* HP */
7574 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7575 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7576 /* Subwoofer */
7577 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7578 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7579
7580 /* enable unsolicited event */
7581 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7582
7583 { } /* end */
7584};
7585
Kailang Yangccc656c2006-10-17 12:32:26 +02007586static struct hda_verb alc883_tagra_verbs[] = {
7587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7589
7590 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7591 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007592
Kailang Yangccc656c2006-10-17 12:32:26 +02007593 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7594 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7595 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7596
7597 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007598 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7599 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7600 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007601
7602 { } /* end */
7603};
7604
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007605static struct hda_verb alc883_lenovo_101e_verbs[] = {
7606 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7607 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7608 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7609 { } /* end */
7610};
7611
Kailang Yang272a5272007-05-14 11:00:38 +02007612static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7613 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7614 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7615 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7616 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7617 { } /* end */
7618};
7619
7620static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7621 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7623 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7624 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7625 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7626 { } /* end */
7627};
7628
Kailang Yang189609a2007-08-20 11:31:23 +02007629static struct hda_verb alc883_haier_w66_verbs[] = {
7630 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7631 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7632
7633 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7634
7635 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7636 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7637 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7638 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7639 { } /* end */
7640};
7641
Kailang Yange2757d52008-08-26 13:17:46 +02007642static struct hda_verb alc888_lenovo_sky_verbs[] = {
7643 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7645 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7646 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7647 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7648 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7649 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7650 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7651 { } /* end */
7652};
7653
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007654static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007655 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007656 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7657 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007658 { }
7659};
7660
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007661static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007662 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7663 { }
7664};
7665
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007666static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007667 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7668 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7669 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7670 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7671 { }
7672};
7673
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007674static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007675 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7676 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7677 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7678 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7679 { }
7680};
7681
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007682static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7683 { 2, alc888_3st_hp_2ch_init },
7684 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007685};
7686
Kailang Yang272a5272007-05-14 11:00:38 +02007687/* toggle front-jack and RCA according to the hp-jack state */
7688static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7689{
7690 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007691
Kailang Yang272a5272007-05-14 11:00:38 +02007692 present = snd_hda_codec_read(codec, 0x1b, 0,
7693 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007694 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7695 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7696 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7697 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007698}
7699
7700/* toggle RCA according to the front-jack state */
7701static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7702{
7703 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007704
Kailang Yang272a5272007-05-14 11:00:38 +02007705 present = snd_hda_codec_read(codec, 0x14, 0,
7706 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007707 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7708 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007709}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007710
Kailang Yang272a5272007-05-14 11:00:38 +02007711static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7712 unsigned int res)
7713{
7714 if ((res >> 26) == ALC880_HP_EVENT)
7715 alc888_lenovo_ms7195_front_automute(codec);
7716 if ((res >> 26) == ALC880_FRONT_EVENT)
7717 alc888_lenovo_ms7195_rca_automute(codec);
7718}
7719
7720static struct hda_verb alc883_medion_md2_verbs[] = {
7721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7723
7724 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7725
7726 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7727 { } /* end */
7728};
7729
7730/* toggle speaker-output according to the hp-jack state */
7731static void alc883_medion_md2_automute(struct hda_codec *codec)
7732{
7733 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007734
Kailang Yang272a5272007-05-14 11:00:38 +02007735 present = snd_hda_codec_read(codec, 0x14, 0,
7736 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007737 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7738 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007739}
7740
7741static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7742 unsigned int res)
7743{
7744 if ((res >> 26) == ALC880_HP_EVENT)
7745 alc883_medion_md2_automute(codec);
7746}
7747
Kailang Yangccc656c2006-10-17 12:32:26 +02007748/* toggle speaker-output according to the hp-jack state */
7749static void alc883_tagra_automute(struct hda_codec *codec)
7750{
7751 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007752 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007753
7754 present = snd_hda_codec_read(codec, 0x14, 0,
7755 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007756 bits = present ? HDA_AMP_MUTE : 0;
7757 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7758 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007759 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7760 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007761}
7762
7763static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7764{
7765 if ((res >> 26) == ALC880_HP_EVENT)
7766 alc883_tagra_automute(codec);
7767}
7768
Jiang zhe368c7a92008-03-04 11:20:33 +01007769/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007770static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007771{
7772 unsigned int present;
7773 unsigned char bits;
7774
7775 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7776 & AC_PINSENSE_PRESENCE;
7777 bits = present ? HDA_AMP_MUTE : 0;
7778 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7779 HDA_AMP_MUTE, bits);
7780}
7781
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007782static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7783{
7784 unsigned int present;
7785
7786 present = snd_hda_codec_read(codec, 0x18, 0,
7787 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7788 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7789 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7790}
7791
7792static void alc883_clevo_m720_automute(struct hda_codec *codec)
7793{
7794 alc883_clevo_m720_hp_automute(codec);
7795 alc883_clevo_m720_mic_automute(codec);
7796}
7797
7798static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007799 unsigned int res)
7800{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007801 switch (res >> 26) {
7802 case ALC880_HP_EVENT:
7803 alc883_clevo_m720_hp_automute(codec);
7804 break;
7805 case ALC880_MIC_EVENT:
7806 alc883_clevo_m720_mic_automute(codec);
7807 break;
7808 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007809}
7810
Jiang zhefb97dc62008-03-06 11:07:11 +01007811/* toggle speaker-output according to the hp-jack state */
7812static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7813{
7814 unsigned int present;
7815 unsigned char bits;
7816
7817 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7818 & AC_PINSENSE_PRESENCE;
7819 bits = present ? HDA_AMP_MUTE : 0;
7820 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7821 HDA_AMP_MUTE, bits);
7822}
7823
7824static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7825 unsigned int res)
7826{
7827 if ((res >> 26) == ALC880_HP_EVENT)
7828 alc883_2ch_fujitsu_pi2515_automute(codec);
7829}
7830
Kailang Yang189609a2007-08-20 11:31:23 +02007831static void alc883_haier_w66_automute(struct hda_codec *codec)
7832{
7833 unsigned int present;
7834 unsigned char bits;
7835
7836 present = snd_hda_codec_read(codec, 0x1b, 0,
7837 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7838 bits = present ? 0x80 : 0;
7839 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7840 0x80, bits);
7841}
7842
7843static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7844 unsigned int res)
7845{
7846 if ((res >> 26) == ALC880_HP_EVENT)
7847 alc883_haier_w66_automute(codec);
7848}
7849
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007850static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7851{
7852 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007853 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007854
7855 present = snd_hda_codec_read(codec, 0x14, 0,
7856 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007857 bits = present ? HDA_AMP_MUTE : 0;
7858 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7859 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007860}
7861
7862static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7863{
7864 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007865 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007866
7867 present = snd_hda_codec_read(codec, 0x1b, 0,
7868 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007869 bits = present ? HDA_AMP_MUTE : 0;
7870 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7871 HDA_AMP_MUTE, bits);
7872 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7873 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007874}
7875
7876static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7877 unsigned int res)
7878{
7879 if ((res >> 26) == ALC880_HP_EVENT)
7880 alc883_lenovo_101e_all_automute(codec);
7881 if ((res >> 26) == ALC880_FRONT_EVENT)
7882 alc883_lenovo_101e_ispeaker_automute(codec);
7883}
7884
Takashi Iwai676a9b52007-08-16 15:23:35 +02007885/* toggle speaker-output according to the hp-jack state */
7886static void alc883_acer_aspire_automute(struct hda_codec *codec)
7887{
7888 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007889
Takashi Iwai676a9b52007-08-16 15:23:35 +02007890 present = snd_hda_codec_read(codec, 0x14, 0,
7891 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7892 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7893 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7894 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7895 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7896}
7897
7898static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7899 unsigned int res)
7900{
7901 if ((res >> 26) == ALC880_HP_EVENT)
7902 alc883_acer_aspire_automute(codec);
7903}
7904
Kailang Yangd1a991a2007-08-15 16:21:59 +02007905static struct hda_verb alc883_acer_eapd_verbs[] = {
7906 /* HP Pin: output 0 (0x0c) */
7907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7909 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7910 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7912 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007913 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007914 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7915 /* eanable EAPD on medion laptop */
7916 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7917 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007918 /* enable unsolicited event */
7919 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007920 { }
7921};
7922
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007923static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7924{
7925 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007926
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007927 present = snd_hda_codec_read(codec, 0x1b, 0,
7928 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7929 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7930 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7931 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7932 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7933 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7934 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7935 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7936 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7937}
7938
7939static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7940 unsigned int res)
7941{
7942 switch (res >> 26) {
7943 case ALC880_HP_EVENT:
7944 printk("hp_event\n");
7945 alc888_6st_dell_front_automute(codec);
7946 break;
7947 }
7948}
7949
Kailang Yange2757d52008-08-26 13:17:46 +02007950static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
7951{
7952 unsigned int mute;
7953 unsigned int present;
7954
7955 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7956 present = snd_hda_codec_read(codec, 0x1b, 0,
7957 AC_VERB_GET_PIN_SENSE, 0);
7958 present = (present & 0x80000000) != 0;
7959 if (present) {
7960 /* mute internal speaker */
7961 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7962 HDA_AMP_MUTE, HDA_AMP_MUTE);
7963 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7964 HDA_AMP_MUTE, HDA_AMP_MUTE);
7965 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7966 HDA_AMP_MUTE, HDA_AMP_MUTE);
7967 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7968 HDA_AMP_MUTE, HDA_AMP_MUTE);
7969 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7970 HDA_AMP_MUTE, HDA_AMP_MUTE);
7971 } else {
7972 /* unmute internal speaker if necessary */
7973 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7974 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7975 HDA_AMP_MUTE, mute);
7976 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7977 HDA_AMP_MUTE, mute);
7978 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7979 HDA_AMP_MUTE, mute);
7980 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7981 HDA_AMP_MUTE, mute);
7982 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7983 HDA_AMP_MUTE, mute);
7984 }
7985}
7986
7987static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
7988 unsigned int res)
7989{
7990 if ((res >> 26) == ALC880_HP_EVENT)
7991 alc888_lenovo_sky_front_automute(codec);
7992}
7993
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007994/*
7995 * generic initialization of ADC, input mixers and output mixers
7996 */
7997static struct hda_verb alc883_auto_init_verbs[] = {
7998 /*
7999 * Unmute ADC0-2 and set the default input to mic-in
8000 */
8001 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8002 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8003 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8004 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8005
Takashi Iwaicb53c622007-08-10 17:21:45 +02008006 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008007 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008008 * Note: PASD motherboards uses the Line In 2 as the input for
8009 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008010 */
8011 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8015 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008017
8018 /*
8019 * Set up output mixers (0x0c - 0x0f)
8020 */
8021 /* set vol=0 to output mixers */
8022 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8023 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8024 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8025 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8026 /* set up input amps for analog loopback */
8027 /* Amp Indices: DAC = 0, mixer = 1 */
8028 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8029 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8030 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8031 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8032 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8034 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8035 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8036 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8037 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8038
8039 /* FIXME: use matrix-type input source selection */
8040 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8041 /* Input mixer1 */
8042 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8043 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008045 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008046 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8047 /* Input mixer2 */
8048 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8049 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8050 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008051 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008053
8054 { }
8055};
8056
Kailang Yange2757d52008-08-26 13:17:46 +02008057static struct hda_verb alc888_asus_m90v_verbs[] = {
8058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8059 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8060 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8061 /* enable unsolicited event */
8062 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8063 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8064 { } /* end */
8065};
8066
8067static void alc883_nb_mic_automute(struct hda_codec *codec)
8068{
8069 unsigned int present;
8070
8071 present = snd_hda_codec_read(codec, 0x18, 0,
8072 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8073 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8074 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8075 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8076 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8077}
8078
8079static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8080{
8081 unsigned int present;
8082 unsigned char bits;
8083
8084 present = snd_hda_codec_read(codec, 0x1b, 0,
8085 AC_VERB_GET_PIN_SENSE, 0)
8086 & AC_PINSENSE_PRESENCE;
8087 bits = present ? 0 : PIN_OUT;
8088 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8089 bits);
8090 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8091 bits);
8092 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8093 bits);
8094}
8095
8096static void alc883_mode2_unsol_event(struct hda_codec *codec,
8097 unsigned int res)
8098{
8099 switch (res >> 26) {
8100 case ALC880_HP_EVENT:
8101 alc883_M90V_speaker_automute(codec);
8102 break;
8103 case ALC880_MIC_EVENT:
8104 alc883_nb_mic_automute(codec);
8105 break;
8106 }
8107}
8108
8109static void alc883_mode2_inithook(struct hda_codec *codec)
8110{
8111 alc883_M90V_speaker_automute(codec);
8112 alc883_nb_mic_automute(codec);
8113}
8114
8115static struct hda_verb alc888_asus_eee1601_verbs[] = {
8116 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8117 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8119 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8120 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8121 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8122 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8123 /* enable unsolicited event */
8124 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8125 { } /* end */
8126};
8127
8128static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8129{
8130 unsigned int present;
8131 unsigned char bits;
8132
8133 present = snd_hda_codec_read(codec, 0x14, 0,
8134 AC_VERB_GET_PIN_SENSE, 0)
8135 & AC_PINSENSE_PRESENCE;
8136 bits = present ? 0 : PIN_OUT;
8137 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8138 bits);
8139}
8140
8141static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8142 unsigned int res)
8143{
8144 switch (res >> 26) {
8145 case ALC880_HP_EVENT:
8146 alc883_eee1601_speaker_automute(codec);
8147 break;
8148 }
8149}
8150
8151static void alc883_eee1601_inithook(struct hda_codec *codec)
8152{
8153 alc883_eee1601_speaker_automute(codec);
8154}
8155
Takashi Iwaicb53c622007-08-10 17:21:45 +02008156#ifdef CONFIG_SND_HDA_POWER_SAVE
8157#define alc883_loopbacks alc880_loopbacks
8158#endif
8159
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008160/* pcm configuration: identiacal with ALC880 */
8161#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8162#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008163#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008164#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8165#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8166
8167/*
8168 * configuration and preset
8169 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008170static const char *alc883_models[ALC883_MODEL_LAST] = {
8171 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8172 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8173 [ALC883_3ST_6ch] = "3stack-6ch",
8174 [ALC883_6ST_DIG] = "6stack-dig",
8175 [ALC883_TARGA_DIG] = "targa-dig",
8176 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008177 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008178 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008179 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008180 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008181 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008182 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008183 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8184 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008185 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008186 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008187 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008188 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008189 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008190 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008191 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008192 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008193 [ALC883_AUTO] = "auto",
8194};
8195
8196static struct snd_pci_quirk alc883_cfg_tbl[] = {
8197 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008198 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8199 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8200 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008201 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008202 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008203 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008204 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008205 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8206 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008207 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008208 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008209 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Kailang Yange2757d52008-08-26 13:17:46 +02008210 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008211 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008212 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008213 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8214 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008215 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008216 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008217 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008218 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8219 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8220 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008221 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008222 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008223 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008224 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8225 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8226 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8227 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8228 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8229 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8230 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8231 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8232 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008233 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8234 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008235 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008236 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008237 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008238 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008239 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008240 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008241 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8242 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008243 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008244 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008245 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008246 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02008247 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008248 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008249 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8250 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008251 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008252 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008253 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008254 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008255 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8256 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008257 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008258 {}
8259};
8260
8261static struct alc_config_preset alc883_presets[] = {
8262 [ALC883_3ST_2ch_DIG] = {
8263 .mixers = { alc883_3ST_2ch_mixer },
8264 .init_verbs = { alc883_init_verbs },
8265 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8266 .dac_nids = alc883_dac_nids,
8267 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008268 .dig_in_nid = ALC883_DIGIN_NID,
8269 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8270 .channel_mode = alc883_3ST_2ch_modes,
8271 .input_mux = &alc883_capture_source,
8272 },
8273 [ALC883_3ST_6ch_DIG] = {
8274 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8275 .init_verbs = { alc883_init_verbs },
8276 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8277 .dac_nids = alc883_dac_nids,
8278 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008279 .dig_in_nid = ALC883_DIGIN_NID,
8280 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8281 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008282 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008283 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008284 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008285 [ALC883_3ST_6ch] = {
8286 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8287 .init_verbs = { alc883_init_verbs },
8288 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8289 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008290 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8291 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008292 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008293 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008294 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008295 [ALC883_3ST_6ch_INTEL] = {
8296 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8297 .init_verbs = { alc883_init_verbs },
8298 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8299 .dac_nids = alc883_dac_nids,
8300 .dig_out_nid = ALC883_DIGOUT_NID,
8301 .dig_in_nid = ALC883_DIGIN_NID,
8302 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8303 .channel_mode = alc883_3ST_6ch_intel_modes,
8304 .need_dac_fix = 1,
8305 .input_mux = &alc883_3stack_6ch_intel,
8306 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008307 [ALC883_6ST_DIG] = {
8308 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8309 .init_verbs = { alc883_init_verbs },
8310 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8311 .dac_nids = alc883_dac_nids,
8312 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008313 .dig_in_nid = ALC883_DIGIN_NID,
8314 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8315 .channel_mode = alc883_sixstack_modes,
8316 .input_mux = &alc883_capture_source,
8317 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008318 [ALC883_TARGA_DIG] = {
8319 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8320 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8321 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8322 .dac_nids = alc883_dac_nids,
8323 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008324 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8325 .channel_mode = alc883_3ST_6ch_modes,
8326 .need_dac_fix = 1,
8327 .input_mux = &alc883_capture_source,
8328 .unsol_event = alc883_tagra_unsol_event,
8329 .init_hook = alc883_tagra_automute,
8330 },
8331 [ALC883_TARGA_2ch_DIG] = {
8332 .mixers = { alc883_tagra_2ch_mixer},
8333 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8334 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8335 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008336 .adc_nids = alc883_adc_nids_alt,
8337 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008338 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008339 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8340 .channel_mode = alc883_3ST_2ch_modes,
8341 .input_mux = &alc883_capture_source,
8342 .unsol_event = alc883_tagra_unsol_event,
8343 .init_hook = alc883_tagra_automute,
8344 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008345 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008346 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008347 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8348 * and the headphone jack. Turn this on and rely on the
8349 * standard mute methods whenever the user wants to turn
8350 * these outputs off.
8351 */
8352 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8353 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8354 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008355 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8356 .channel_mode = alc883_3ST_2ch_modes,
8357 .input_mux = &alc883_capture_source,
8358 },
Tobin Davis2880a862007-08-07 11:50:26 +02008359 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008360 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008361 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008362 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8363 .dac_nids = alc883_dac_nids,
8364 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008365 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8366 .channel_mode = alc883_3ST_2ch_modes,
8367 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008368 .unsol_event = alc883_acer_aspire_unsol_event,
8369 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008370 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008371 [ALC883_MEDION] = {
8372 .mixers = { alc883_fivestack_mixer,
8373 alc883_chmode_mixer },
8374 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008375 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008376 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8377 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008378 .adc_nids = alc883_adc_nids_alt,
8379 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008380 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8381 .channel_mode = alc883_sixstack_modes,
8382 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008383 },
Kailang Yang272a5272007-05-14 11:00:38 +02008384 [ALC883_MEDION_MD2] = {
8385 .mixers = { alc883_medion_md2_mixer},
8386 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8387 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8388 .dac_nids = alc883_dac_nids,
8389 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008390 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8391 .channel_mode = alc883_3ST_2ch_modes,
8392 .input_mux = &alc883_capture_source,
8393 .unsol_event = alc883_medion_md2_unsol_event,
8394 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008395 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008396 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008397 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008398 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8399 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8400 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008401 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8402 .channel_mode = alc883_3ST_2ch_modes,
8403 .input_mux = &alc883_capture_source,
8404 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008405 [ALC883_CLEVO_M720] = {
8406 .mixers = { alc883_clevo_m720_mixer },
8407 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008408 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8409 .dac_nids = alc883_dac_nids,
8410 .dig_out_nid = ALC883_DIGOUT_NID,
8411 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8412 .channel_mode = alc883_3ST_2ch_modes,
8413 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008414 .unsol_event = alc883_clevo_m720_unsol_event,
8415 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008416 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008417 [ALC883_LENOVO_101E_2ch] = {
8418 .mixers = { alc883_lenovo_101e_2ch_mixer},
8419 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8420 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8421 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008422 .adc_nids = alc883_adc_nids_alt,
8423 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008424 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8425 .channel_mode = alc883_3ST_2ch_modes,
8426 .input_mux = &alc883_lenovo_101e_capture_source,
8427 .unsol_event = alc883_lenovo_101e_unsol_event,
8428 .init_hook = alc883_lenovo_101e_all_automute,
8429 },
Kailang Yang272a5272007-05-14 11:00:38 +02008430 [ALC883_LENOVO_NB0763] = {
8431 .mixers = { alc883_lenovo_nb0763_mixer },
8432 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8433 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8434 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008435 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8436 .channel_mode = alc883_3ST_2ch_modes,
8437 .need_dac_fix = 1,
8438 .input_mux = &alc883_lenovo_nb0763_capture_source,
8439 .unsol_event = alc883_medion_md2_unsol_event,
8440 .init_hook = alc883_medion_md2_automute,
8441 },
8442 [ALC888_LENOVO_MS7195_DIG] = {
8443 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8444 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8445 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8446 .dac_nids = alc883_dac_nids,
8447 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008448 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8449 .channel_mode = alc883_3ST_6ch_modes,
8450 .need_dac_fix = 1,
8451 .input_mux = &alc883_capture_source,
8452 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8453 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008454 },
8455 [ALC883_HAIER_W66] = {
8456 .mixers = { alc883_tagra_2ch_mixer},
8457 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8458 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8459 .dac_nids = alc883_dac_nids,
8460 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008461 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8462 .channel_mode = alc883_3ST_2ch_modes,
8463 .input_mux = &alc883_capture_source,
8464 .unsol_event = alc883_haier_w66_unsol_event,
8465 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008466 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008467 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008468 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008469 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008470 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8471 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008472 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8473 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008474 .need_dac_fix = 1,
8475 .input_mux = &alc883_capture_source,
8476 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008477 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008478 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008479 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8480 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8481 .dac_nids = alc883_dac_nids,
8482 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008483 .dig_in_nid = ALC883_DIGIN_NID,
8484 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8485 .channel_mode = alc883_sixstack_modes,
8486 .input_mux = &alc883_capture_source,
8487 .unsol_event = alc888_6st_dell_unsol_event,
8488 .init_hook = alc888_6st_dell_front_automute,
8489 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008490 [ALC883_MITAC] = {
8491 .mixers = { alc883_mitac_mixer },
8492 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8493 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8494 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008495 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8496 .channel_mode = alc883_3ST_2ch_modes,
8497 .input_mux = &alc883_capture_source,
8498 .unsol_event = alc883_mitac_unsol_event,
8499 .init_hook = alc883_mitac_automute,
8500 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008501 [ALC883_FUJITSU_PI2515] = {
8502 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8503 .init_verbs = { alc883_init_verbs,
8504 alc883_2ch_fujitsu_pi2515_verbs},
8505 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8506 .dac_nids = alc883_dac_nids,
8507 .dig_out_nid = ALC883_DIGOUT_NID,
8508 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8509 .channel_mode = alc883_3ST_2ch_modes,
8510 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8511 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8512 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8513 },
Kailang Yange2757d52008-08-26 13:17:46 +02008514 [ALC888_LENOVO_SKY] = {
8515 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8516 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8517 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8518 .dac_nids = alc883_dac_nids,
8519 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008520 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8521 .channel_mode = alc883_sixstack_modes,
8522 .need_dac_fix = 1,
8523 .input_mux = &alc883_lenovo_sky_capture_source,
8524 .unsol_event = alc883_lenovo_sky_unsol_event,
8525 .init_hook = alc888_lenovo_sky_front_automute,
8526 },
8527 [ALC888_ASUS_M90V] = {
8528 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8529 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8530 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8531 .dac_nids = alc883_dac_nids,
8532 .dig_out_nid = ALC883_DIGOUT_NID,
8533 .dig_in_nid = ALC883_DIGIN_NID,
8534 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8535 .channel_mode = alc883_3ST_6ch_modes,
8536 .need_dac_fix = 1,
8537 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8538 .unsol_event = alc883_mode2_unsol_event,
8539 .init_hook = alc883_mode2_inithook,
8540 },
8541 [ALC888_ASUS_EEE1601] = {
8542 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008543 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008544 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8545 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8546 .dac_nids = alc883_dac_nids,
8547 .dig_out_nid = ALC883_DIGOUT_NID,
8548 .dig_in_nid = ALC883_DIGIN_NID,
8549 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8550 .channel_mode = alc883_3ST_2ch_modes,
8551 .need_dac_fix = 1,
8552 .input_mux = &alc883_asus_eee1601_capture_source,
8553 .unsol_event = alc883_eee1601_unsol_event,
8554 .init_hook = alc883_eee1601_inithook,
8555 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008556};
8557
8558
8559/*
8560 * BIOS auto configuration
8561 */
8562static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8563 hda_nid_t nid, int pin_type,
8564 int dac_idx)
8565{
8566 /* set as output */
8567 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008568 int idx;
8569
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008570 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008571 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8572 idx = 4;
8573 else
8574 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008575 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8576
8577}
8578
8579static void alc883_auto_init_multi_out(struct hda_codec *codec)
8580{
8581 struct alc_spec *spec = codec->spec;
8582 int i;
8583
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008584 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008585 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008586 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008587 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008588 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008589 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008590 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008591 }
8592}
8593
8594static void alc883_auto_init_hp_out(struct hda_codec *codec)
8595{
8596 struct alc_spec *spec = codec->spec;
8597 hda_nid_t pin;
8598
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008599 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008600 if (pin) /* connect to front */
8601 /* use dac 0 */
8602 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008603 pin = spec->autocfg.speaker_pins[0];
8604 if (pin)
8605 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008606}
8607
8608#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8609#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8610
8611static void alc883_auto_init_analog_input(struct hda_codec *codec)
8612{
8613 struct alc_spec *spec = codec->spec;
8614 int i;
8615
8616 for (i = 0; i < AUTO_PIN_LAST; i++) {
8617 hda_nid_t nid = spec->autocfg.input_pins[i];
8618 if (alc883_is_input_pin(nid)) {
8619 snd_hda_codec_write(codec, nid, 0,
8620 AC_VERB_SET_PIN_WIDGET_CONTROL,
8621 (i <= AUTO_PIN_FRONT_MIC ?
8622 PIN_VREF80 : PIN_IN));
8623 if (nid != ALC883_PIN_CD_NID)
8624 snd_hda_codec_write(codec, nid, 0,
8625 AC_VERB_SET_AMP_GAIN_MUTE,
8626 AMP_OUT_MUTE);
8627 }
8628 }
8629}
8630
Takashi Iwaif511b012008-08-15 16:46:42 +02008631#define alc883_auto_init_input_src alc882_auto_init_input_src
8632
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008633/* almost identical with ALC880 parser... */
8634static int alc883_parse_auto_config(struct hda_codec *codec)
8635{
8636 struct alc_spec *spec = codec->spec;
8637 int err = alc880_parse_auto_config(codec);
8638
8639 if (err < 0)
8640 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008641 else if (!err)
8642 return 0; /* no config found */
8643
8644 err = alc_auto_add_mic_boost(codec);
8645 if (err < 0)
8646 return err;
8647
8648 /* hack - override the init verbs */
8649 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02008650
8651 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008652}
8653
8654/* additional initialization for auto-configuration model */
8655static void alc883_auto_init(struct hda_codec *codec)
8656{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008657 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008658 alc883_auto_init_multi_out(codec);
8659 alc883_auto_init_hp_out(codec);
8660 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008661 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008662 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02008663 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008664}
8665
8666static int patch_alc883(struct hda_codec *codec)
8667{
8668 struct alc_spec *spec;
8669 int err, board_config;
8670
8671 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8672 if (spec == NULL)
8673 return -ENOMEM;
8674
8675 codec->spec = spec;
8676
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008677 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8678
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008679 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8680 alc883_models,
8681 alc883_cfg_tbl);
8682 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008683 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8684 "trying auto-probe from BIOS...\n");
8685 board_config = ALC883_AUTO;
8686 }
8687
8688 if (board_config == ALC883_AUTO) {
8689 /* automatic parse from the BIOS config */
8690 err = alc883_parse_auto_config(codec);
8691 if (err < 0) {
8692 alc_free(codec);
8693 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008694 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008695 printk(KERN_INFO
8696 "hda_codec: Cannot set up configuration "
8697 "from BIOS. Using base mode...\n");
8698 board_config = ALC883_3ST_2ch_DIG;
8699 }
8700 }
8701
8702 if (board_config != ALC883_AUTO)
8703 setup_preset(spec, &alc883_presets[board_config]);
8704
Kailang Yang2f893282008-05-27 12:14:47 +02008705 switch (codec->vendor_id) {
8706 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02008707 if (codec->revision_id == 0x100101) {
8708 spec->stream_name_analog = "ALC1200 Analog";
8709 spec->stream_name_digital = "ALC1200 Digital";
8710 } else {
8711 spec->stream_name_analog = "ALC888 Analog";
8712 spec->stream_name_digital = "ALC888 Digital";
8713 }
Kailang Yang2f893282008-05-27 12:14:47 +02008714 break;
8715 case 0x10ec0889:
8716 spec->stream_name_analog = "ALC889 Analog";
8717 spec->stream_name_digital = "ALC889 Digital";
8718 break;
8719 default:
8720 spec->stream_name_analog = "ALC883 Analog";
8721 spec->stream_name_digital = "ALC883 Digital";
8722 break;
8723 }
8724
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008725 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8726 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008727 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008728
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008729 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8730 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8731
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008732 if (!spec->num_adc_nids) {
8733 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8734 spec->adc_nids = alc883_adc_nids;
8735 }
8736 if (!spec->capsrc_nids)
8737 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008738 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008739 if (!spec->cap_mixer)
8740 set_capture_mixer(spec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008741
Takashi Iwai2134ea42008-01-10 16:53:55 +01008742 spec->vmaster_nid = 0x0c;
8743
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008744 codec->patch_ops = alc_patch_ops;
8745 if (board_config == ALC883_AUTO)
8746 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008747
Takashi Iwaicb53c622007-08-10 17:21:45 +02008748#ifdef CONFIG_SND_HDA_POWER_SAVE
8749 if (!spec->loopback.amplist)
8750 spec->loopback.amplist = alc883_loopbacks;
8751#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008752
8753 return 0;
8754}
8755
8756/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008757 * ALC262 support
8758 */
8759
8760#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8761#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8762
8763#define alc262_dac_nids alc260_dac_nids
8764#define alc262_adc_nids alc882_adc_nids
8765#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008766#define alc262_capsrc_nids alc882_capsrc_nids
8767#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008768
8769#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008770#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008771
Kailang Yang4e555fe2008-08-26 13:05:55 +02008772static hda_nid_t alc262_dmic_adc_nids[1] = {
8773 /* ADC0 */
8774 0x09
8775};
8776
8777static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
8778
Kailang Yangdf694da2005-12-05 19:42:22 +01008779static struct snd_kcontrol_new alc262_base_mixer[] = {
8780 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8781 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8782 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8783 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8784 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8785 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8787 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008788 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008789 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8790 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008791 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008792 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008793 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008794 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8796 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8797 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008798 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008799};
8800
Kailang Yangccc656c2006-10-17 12:32:26 +02008801static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8802 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8803 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8806 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8807 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008810 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008811 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8812 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008813 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008814 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008815 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008816 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8817 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8818 { } /* end */
8819};
8820
Takashi Iwaice875f02008-01-28 18:17:43 +01008821/* update HP, line and mono-out pins according to the master switch */
8822static void alc262_hp_master_update(struct hda_codec *codec)
8823{
8824 struct alc_spec *spec = codec->spec;
8825 int val = spec->master_sw;
8826
8827 /* HP & line-out */
8828 snd_hda_codec_write_cache(codec, 0x1b, 0,
8829 AC_VERB_SET_PIN_WIDGET_CONTROL,
8830 val ? PIN_HP : 0);
8831 snd_hda_codec_write_cache(codec, 0x15, 0,
8832 AC_VERB_SET_PIN_WIDGET_CONTROL,
8833 val ? PIN_HP : 0);
8834 /* mono (speaker) depending on the HP jack sense */
8835 val = val && !spec->jack_present;
8836 snd_hda_codec_write_cache(codec, 0x16, 0,
8837 AC_VERB_SET_PIN_WIDGET_CONTROL,
8838 val ? PIN_OUT : 0);
8839}
8840
8841static void alc262_hp_bpc_automute(struct hda_codec *codec)
8842{
8843 struct alc_spec *spec = codec->spec;
8844 unsigned int presence;
8845 presence = snd_hda_codec_read(codec, 0x1b, 0,
8846 AC_VERB_GET_PIN_SENSE, 0);
8847 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8848 alc262_hp_master_update(codec);
8849}
8850
8851static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8852{
8853 if ((res >> 26) != ALC880_HP_EVENT)
8854 return;
8855 alc262_hp_bpc_automute(codec);
8856}
8857
8858static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8859{
8860 struct alc_spec *spec = codec->spec;
8861 unsigned int presence;
8862 presence = snd_hda_codec_read(codec, 0x15, 0,
8863 AC_VERB_GET_PIN_SENSE, 0);
8864 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8865 alc262_hp_master_update(codec);
8866}
8867
8868static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8869 unsigned int res)
8870{
8871 if ((res >> 26) != ALC880_HP_EVENT)
8872 return;
8873 alc262_hp_wildwest_automute(codec);
8874}
8875
8876static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8877 struct snd_ctl_elem_value *ucontrol)
8878{
8879 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8880 struct alc_spec *spec = codec->spec;
8881 *ucontrol->value.integer.value = spec->master_sw;
8882 return 0;
8883}
8884
8885static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8886 struct snd_ctl_elem_value *ucontrol)
8887{
8888 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8889 struct alc_spec *spec = codec->spec;
8890 int val = !!*ucontrol->value.integer.value;
8891
8892 if (val == spec->master_sw)
8893 return 0;
8894 spec->master_sw = val;
8895 alc262_hp_master_update(codec);
8896 return 1;
8897}
8898
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008899static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008900 {
8901 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8902 .name = "Master Playback Switch",
8903 .info = snd_ctl_boolean_mono_info,
8904 .get = alc262_hp_master_sw_get,
8905 .put = alc262_hp_master_sw_put,
8906 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008907 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8908 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8909 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008910 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8911 HDA_OUTPUT),
8912 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8913 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008916 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008917 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8918 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008919 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008920 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8921 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8922 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8923 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8924 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8925 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8926 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8927 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8928 { } /* end */
8929};
8930
Kailang Yangcd7509a2007-01-26 18:33:17 +01008931static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008932 {
8933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8934 .name = "Master Playback Switch",
8935 .info = snd_ctl_boolean_mono_info,
8936 .get = alc262_hp_master_sw_get,
8937 .put = alc262_hp_master_sw_put,
8938 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008939 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8940 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8941 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008943 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8944 HDA_OUTPUT),
8945 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8946 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008947 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8948 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008949 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008950 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8951 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8952 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8953 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8954 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8955 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8956 { } /* end */
8957};
8958
8959static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8960 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8961 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008962 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008963 { } /* end */
8964};
8965
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008966/* mute/unmute internal speaker according to the hp jack and mute state */
8967static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8968{
8969 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008970
8971 if (force || !spec->sense_updated) {
8972 unsigned int present;
8973 present = snd_hda_codec_read(codec, 0x15, 0,
8974 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008975 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008976 spec->sense_updated = 1;
8977 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008978 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8979 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008980}
8981
8982static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8983 unsigned int res)
8984{
8985 if ((res >> 26) != ALC880_HP_EVENT)
8986 return;
8987 alc262_hp_t5735_automute(codec, 1);
8988}
8989
8990static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8991{
8992 alc262_hp_t5735_automute(codec, 1);
8993}
8994
8995static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008996 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8997 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008998 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8999 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9001 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9002 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9003 { } /* end */
9004};
9005
9006static struct hda_verb alc262_hp_t5735_verbs[] = {
9007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9008 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9009
9010 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9011 { }
9012};
9013
Kailang Yang8c427222008-01-10 13:03:59 +01009014static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009015 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9016 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009017 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9018 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009019 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9020 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9021 { } /* end */
9022};
9023
9024static struct hda_verb alc262_hp_rp5700_verbs[] = {
9025 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9026 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9027 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9028 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9029 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9030 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9032 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9034 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9035 {}
9036};
9037
9038static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9039 .num_items = 1,
9040 .items = {
9041 { "Line", 0x1 },
9042 },
9043};
9044
Takashi Iwai0724ea22007-08-23 00:31:43 +02009045/* bind hp and internal speaker mute (with plug check) */
9046static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9047 struct snd_ctl_elem_value *ucontrol)
9048{
9049 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9050 long *valp = ucontrol->value.integer.value;
9051 int change;
9052
9053 /* change hp mute */
9054 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9055 HDA_AMP_MUTE,
9056 valp[0] ? 0 : HDA_AMP_MUTE);
9057 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9058 HDA_AMP_MUTE,
9059 valp[1] ? 0 : HDA_AMP_MUTE);
9060 if (change) {
9061 /* change speaker according to HP jack state */
9062 struct alc_spec *spec = codec->spec;
9063 unsigned int mute;
9064 if (spec->jack_present)
9065 mute = HDA_AMP_MUTE;
9066 else
9067 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9068 HDA_OUTPUT, 0);
9069 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9070 HDA_AMP_MUTE, mute);
9071 }
9072 return change;
9073}
Takashi Iwai5b319542007-07-26 11:49:22 +02009074
Kailang Yang272a5272007-05-14 11:00:38 +02009075static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009076 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9077 {
9078 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9079 .name = "Master Playback Switch",
9080 .info = snd_hda_mixer_amp_switch_info,
9081 .get = snd_hda_mixer_amp_switch_get,
9082 .put = alc262_sony_master_sw_put,
9083 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9084 },
Kailang Yang272a5272007-05-14 11:00:38 +02009085 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9086 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9087 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9088 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9089 { } /* end */
9090};
9091
Kailang Yang83c34212007-07-05 11:43:05 +02009092static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9093 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9094 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9095 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9097 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9098 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9099 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9100 { } /* end */
9101};
Kailang Yang272a5272007-05-14 11:00:38 +02009102
Kailang Yangdf694da2005-12-05 19:42:22 +01009103#define alc262_capture_mixer alc882_capture_mixer
9104#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9105
9106/*
9107 * generic initialization of ADC, input mixers and output mixers
9108 */
9109static struct hda_verb alc262_init_verbs[] = {
9110 /*
9111 * Unmute ADC0-2 and set the default input to mic-in
9112 */
9113 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9115 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9116 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9117 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9118 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9119
Takashi Iwaicb53c622007-08-10 17:21:45 +02009120 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009121 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009122 * Note: PASD motherboards uses the Line In 2 as the input for
9123 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009124 */
9125 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009131
9132 /*
9133 * Set up output mixers (0x0c - 0x0e)
9134 */
9135 /* set vol=0 to output mixers */
9136 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9137 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9138 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9139 /* set up input amps for analog loopback */
9140 /* Amp Indices: DAC = 0, mixer = 1 */
9141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9142 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9143 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9144 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9145 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9146 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9147
9148 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9149 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9150 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9151 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9152 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9153 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9154
9155 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9157 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9158 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9159 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009160
Kailang Yangdf694da2005-12-05 19:42:22 +01009161 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9162 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009163
Kailang Yangdf694da2005-12-05 19:42:22 +01009164 /* FIXME: use matrix-type input source selection */
9165 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9166 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9167 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9169 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9171 /* Input mixer2 */
9172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9173 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9174 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9176 /* Input mixer3 */
9177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9179 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009180 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009181
9182 { }
9183};
9184
Kailang Yang4e555fe2008-08-26 13:05:55 +02009185static struct hda_verb alc262_eapd_verbs[] = {
9186 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9187 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9188 { }
9189};
9190
Kailang Yangccc656c2006-10-17 12:32:26 +02009191static struct hda_verb alc262_hippo_unsol_verbs[] = {
9192 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9194 {}
9195};
9196
9197static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9198 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9199 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9200 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9201
9202 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9203 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9204 {}
9205};
9206
Kailang Yang272a5272007-05-14 11:00:38 +02009207static struct hda_verb alc262_sony_unsol_verbs[] = {
9208 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9209 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9210 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9211
9212 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9213 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009214 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009215};
9216
Kailang Yang4e555fe2008-08-26 13:05:55 +02009217static struct hda_input_mux alc262_dmic_capture_source = {
9218 .num_items = 2,
9219 .items = {
9220 { "Int DMic", 0x9 },
9221 { "Mic", 0x0 },
9222 },
9223};
9224
9225static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9226 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9227 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9228 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9229 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9230 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009231 { } /* end */
9232};
9233
9234static struct hda_verb alc262_toshiba_s06_verbs[] = {
9235 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9236 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9237 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9239 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9240 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9241 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9242 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9243 {}
9244};
9245
9246static void alc262_dmic_automute(struct hda_codec *codec)
9247{
9248 unsigned int present;
9249
9250 present = snd_hda_codec_read(codec, 0x18, 0,
9251 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9252 snd_hda_codec_write(codec, 0x22, 0,
9253 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9254}
9255
9256/* toggle speaker-output according to the hp-jack state */
9257static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9258{
9259 unsigned int present;
9260 unsigned char bits;
9261
9262 present = snd_hda_codec_read(codec, 0x15, 0,
9263 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9264 bits = present ? 0 : PIN_OUT;
9265 snd_hda_codec_write(codec, 0x14, 0,
9266 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9267}
9268
9269
9270
9271/* unsolicited event for HP jack sensing */
9272static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9273 unsigned int res)
9274{
9275 if ((res >> 26) == ALC880_HP_EVENT)
9276 alc262_toshiba_s06_speaker_automute(codec);
9277 if ((res >> 26) == ALC880_MIC_EVENT)
9278 alc262_dmic_automute(codec);
9279
9280}
9281
9282static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9283{
9284 alc262_toshiba_s06_speaker_automute(codec);
9285 alc262_dmic_automute(codec);
9286}
9287
Kailang Yangccc656c2006-10-17 12:32:26 +02009288/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009289static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009290{
9291 struct alc_spec *spec = codec->spec;
9292 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009293 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009294
Takashi Iwai5b319542007-07-26 11:49:22 +02009295 /* need to execute and sync at first */
9296 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9297 present = snd_hda_codec_read(codec, 0x15, 0,
9298 AC_VERB_GET_PIN_SENSE, 0);
9299 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009300 if (spec->jack_present) {
9301 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009302 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9303 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009304 } else {
9305 /* unmute internal speaker if necessary */
9306 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009307 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9308 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009309 }
9310}
9311
9312/* unsolicited event for HP jack sensing */
9313static void alc262_hippo_unsol_event(struct hda_codec *codec,
9314 unsigned int res)
9315{
9316 if ((res >> 26) != ALC880_HP_EVENT)
9317 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009318 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009319}
9320
Takashi Iwai5b319542007-07-26 11:49:22 +02009321static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009322{
Kailang Yangccc656c2006-10-17 12:32:26 +02009323 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009324 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009325
Takashi Iwai5b319542007-07-26 11:49:22 +02009326 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9327 present = snd_hda_codec_read(codec, 0x1b, 0,
9328 AC_VERB_GET_PIN_SENSE, 0);
9329 present = (present & 0x80000000) != 0;
9330 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009331 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009332 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9333 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009334 } else {
9335 /* unmute internal speaker if necessary */
9336 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009337 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9338 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009339 }
9340}
9341
9342/* unsolicited event for HP jack sensing */
9343static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9344 unsigned int res)
9345{
9346 if ((res >> 26) != ALC880_HP_EVENT)
9347 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009348 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009349}
9350
Takashi Iwai834be882006-03-01 14:16:17 +01009351/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009352 * nec model
9353 * 0x15 = headphone
9354 * 0x16 = internal speaker
9355 * 0x18 = external mic
9356 */
9357
9358static struct snd_kcontrol_new alc262_nec_mixer[] = {
9359 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9360 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9361
9362 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9363 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9364 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9365
9366 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9367 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9368 { } /* end */
9369};
9370
9371static struct hda_verb alc262_nec_verbs[] = {
9372 /* Unmute Speaker */
9373 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9374
9375 /* Headphone */
9376 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9377 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9378
9379 /* External mic to headphone */
9380 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9381 /* External mic to speaker */
9382 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9383 {}
9384};
9385
9386/*
Takashi Iwai834be882006-03-01 14:16:17 +01009387 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009388 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9389 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009390 */
9391
9392#define ALC_HP_EVENT 0x37
9393
9394static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9395 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9396 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009397 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9398 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009399 {}
9400};
9401
Jiang zhe0e31daf2008-03-20 12:12:39 +01009402static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9403 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9404 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9405 {}
9406};
9407
Takashi Iwai834be882006-03-01 14:16:17 +01009408static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009409 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009410 .items = {
9411 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009412 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009413 { "CD", 0x4 },
9414 },
9415};
9416
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009417static struct hda_input_mux alc262_HP_capture_source = {
9418 .num_items = 5,
9419 .items = {
9420 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009421 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009422 { "Line", 0x2 },
9423 { "CD", 0x4 },
9424 { "AUX IN", 0x6 },
9425 },
9426};
9427
zhejiangaccbe492007-08-31 12:36:05 +02009428static struct hda_input_mux alc262_HP_D7000_capture_source = {
9429 .num_items = 4,
9430 .items = {
9431 { "Mic", 0x0 },
9432 { "Front Mic", 0x2 },
9433 { "Line", 0x1 },
9434 { "CD", 0x4 },
9435 },
9436};
9437
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009438/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009439static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9440{
9441 struct alc_spec *spec = codec->spec;
9442 unsigned int mute;
9443
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009444 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009445 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009446 /* need to execute and sync at first */
9447 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009448 /* check laptop HP jack */
9449 present = snd_hda_codec_read(codec, 0x14, 0,
9450 AC_VERB_GET_PIN_SENSE, 0);
9451 /* need to execute and sync at first */
9452 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9453 /* check docking HP jack */
9454 present |= snd_hda_codec_read(codec, 0x1b, 0,
9455 AC_VERB_GET_PIN_SENSE, 0);
9456 if (present & AC_PINSENSE_PRESENCE)
9457 spec->jack_present = 1;
9458 else
9459 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009460 spec->sense_updated = 1;
9461 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009462 /* unmute internal speaker only if both HPs are unplugged and
9463 * master switch is on
9464 */
9465 if (spec->jack_present)
9466 mute = HDA_AMP_MUTE;
9467 else
Takashi Iwai834be882006-03-01 14:16:17 +01009468 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009469 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9470 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009471}
9472
9473/* unsolicited event for HP jack sensing */
9474static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9475 unsigned int res)
9476{
9477 if ((res >> 26) != ALC_HP_EVENT)
9478 return;
9479 alc262_fujitsu_automute(codec, 1);
9480}
9481
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009482static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9483{
9484 alc262_fujitsu_automute(codec, 1);
9485}
9486
Takashi Iwai834be882006-03-01 14:16:17 +01009487/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009488static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9489 .ops = &snd_hda_bind_vol,
9490 .values = {
9491 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9492 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9493 0
9494 },
9495};
Takashi Iwai834be882006-03-01 14:16:17 +01009496
Jiang zhe0e31daf2008-03-20 12:12:39 +01009497/* mute/unmute internal speaker according to the hp jack and mute state */
9498static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9499{
9500 struct alc_spec *spec = codec->spec;
9501 unsigned int mute;
9502
9503 if (force || !spec->sense_updated) {
9504 unsigned int present_int_hp;
9505 /* need to execute and sync at first */
9506 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9507 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9508 AC_VERB_GET_PIN_SENSE, 0);
9509 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9510 spec->sense_updated = 1;
9511 }
9512 if (spec->jack_present) {
9513 /* mute internal speaker */
9514 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9515 HDA_AMP_MUTE, HDA_AMP_MUTE);
9516 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9517 HDA_AMP_MUTE, HDA_AMP_MUTE);
9518 } else {
9519 /* unmute internal speaker if necessary */
9520 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9521 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9522 HDA_AMP_MUTE, mute);
9523 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9524 HDA_AMP_MUTE, mute);
9525 }
9526}
9527
9528/* unsolicited event for HP jack sensing */
9529static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9530 unsigned int res)
9531{
9532 if ((res >> 26) != ALC_HP_EVENT)
9533 return;
9534 alc262_lenovo_3000_automute(codec, 1);
9535}
9536
Takashi Iwai834be882006-03-01 14:16:17 +01009537/* bind hp and internal speaker mute (with plug check) */
9538static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9539 struct snd_ctl_elem_value *ucontrol)
9540{
9541 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9542 long *valp = ucontrol->value.integer.value;
9543 int change;
9544
Tony Vroon5d9fab22008-03-14 17:09:18 +01009545 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9546 HDA_AMP_MUTE,
9547 valp ? 0 : HDA_AMP_MUTE);
9548 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9549 HDA_AMP_MUTE,
9550 valp ? 0 : HDA_AMP_MUTE);
9551
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009552 if (change)
9553 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009554 return change;
9555}
9556
9557static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009558 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009559 {
9560 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9561 .name = "Master Playback Switch",
9562 .info = snd_hda_mixer_amp_switch_info,
9563 .get = snd_hda_mixer_amp_switch_get,
9564 .put = alc262_fujitsu_master_sw_put,
9565 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9566 },
9567 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9568 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009569 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9570 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009571 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009574 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9575 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9576 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009577 { } /* end */
9578};
9579
Jiang zhe0e31daf2008-03-20 12:12:39 +01009580/* bind hp and internal speaker mute (with plug check) */
9581static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9582 struct snd_ctl_elem_value *ucontrol)
9583{
9584 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9585 long *valp = ucontrol->value.integer.value;
9586 int change;
9587
9588 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9589 HDA_AMP_MUTE,
9590 valp ? 0 : HDA_AMP_MUTE);
9591
9592 if (change)
9593 alc262_lenovo_3000_automute(codec, 0);
9594 return change;
9595}
9596
9597static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9598 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9599 {
9600 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9601 .name = "Master Playback Switch",
9602 .info = snd_hda_mixer_amp_switch_info,
9603 .get = snd_hda_mixer_amp_switch_get,
9604 .put = alc262_lenovo_3000_master_sw_put,
9605 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9606 },
9607 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9608 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9609 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9611 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9612 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9613 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9614 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9615 { } /* end */
9616};
9617
Hiroshi Miura9f99a632008-08-28 16:09:06 +02009618static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
9619 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9620 {
9621 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9622 .name = "Master Playback Switch",
9623 .info = snd_hda_mixer_amp_switch_info,
9624 .get = snd_hda_mixer_amp_switch_get,
9625 .put = alc262_sony_master_sw_put,
9626 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9627 },
9628 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9630 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9631 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9632 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9633 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9634 { } /* end */
9635};
9636
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009637/* additional init verbs for Benq laptops */
9638static struct hda_verb alc262_EAPD_verbs[] = {
9639 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9640 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9641 {}
9642};
9643
Kailang Yang83c34212007-07-05 11:43:05 +02009644static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9645 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9646 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9647
9648 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9649 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9650 {}
9651};
9652
Tobin Davisf651b502007-10-26 12:40:47 +02009653/* Samsung Q1 Ultra Vista model setup */
9654static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009655 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9656 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9659 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009660 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009661 { } /* end */
9662};
9663
9664static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009665 /* output mixer */
9666 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9667 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9668 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9669 /* speaker */
9670 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9671 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9672 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9673 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9674 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009675 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009676 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9677 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9678 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9679 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9680 /* internal mic */
9681 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9683 /* ADC, choose mic */
9684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9685 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9686 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9687 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9688 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9689 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9693 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009694 {}
9695};
9696
Tobin Davisf651b502007-10-26 12:40:47 +02009697/* mute/unmute internal speaker according to the hp jack and mute state */
9698static void alc262_ultra_automute(struct hda_codec *codec)
9699{
9700 struct alc_spec *spec = codec->spec;
9701 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009702
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009703 mute = 0;
9704 /* auto-mute only when HP is used as HP */
9705 if (!spec->cur_mux[0]) {
9706 unsigned int present;
9707 /* need to execute and sync at first */
9708 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9709 present = snd_hda_codec_read(codec, 0x15, 0,
9710 AC_VERB_GET_PIN_SENSE, 0);
9711 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9712 if (spec->jack_present)
9713 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009714 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009715 /* mute/unmute internal speaker */
9716 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9717 HDA_AMP_MUTE, mute);
9718 /* mute/unmute HP */
9719 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9720 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009721}
9722
9723/* unsolicited event for HP jack sensing */
9724static void alc262_ultra_unsol_event(struct hda_codec *codec,
9725 unsigned int res)
9726{
9727 if ((res >> 26) != ALC880_HP_EVENT)
9728 return;
9729 alc262_ultra_automute(codec);
9730}
9731
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009732static struct hda_input_mux alc262_ultra_capture_source = {
9733 .num_items = 2,
9734 .items = {
9735 { "Mic", 0x1 },
9736 { "Headphone", 0x7 },
9737 },
9738};
9739
9740static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9741 struct snd_ctl_elem_value *ucontrol)
9742{
9743 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9744 struct alc_spec *spec = codec->spec;
9745 int ret;
9746
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009747 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009748 if (!ret)
9749 return 0;
9750 /* reprogram the HP pin as mic or HP according to the input source */
9751 snd_hda_codec_write_cache(codec, 0x15, 0,
9752 AC_VERB_SET_PIN_WIDGET_CONTROL,
9753 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9754 alc262_ultra_automute(codec); /* mute/unmute HP */
9755 return ret;
9756}
9757
9758static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9759 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9760 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9761 {
9762 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9763 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009764 .info = alc_mux_enum_info,
9765 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009766 .put = alc262_ultra_mux_enum_put,
9767 },
9768 { } /* end */
9769};
9770
Kailang Yangdf694da2005-12-05 19:42:22 +01009771/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009772static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9773 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009774{
9775 hda_nid_t nid;
9776 int err;
9777
9778 spec->multiout.num_dacs = 1; /* only use one dac */
9779 spec->multiout.dac_nids = spec->private_dac_nids;
9780 spec->multiout.dac_nids[0] = 2;
9781
9782 nid = cfg->line_out_pins[0];
9783 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009784 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9785 "Front Playback Volume",
9786 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9787 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009788 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009789 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9790 "Front Playback Switch",
9791 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9792 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009793 return err;
9794 }
9795
Takashi Iwai82bc9552006-03-21 11:24:42 +01009796 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009797 if (nid) {
9798 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009799 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9800 "Speaker Playback Volume",
9801 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9802 HDA_OUTPUT));
9803 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009804 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009805 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9806 "Speaker Playback Switch",
9807 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9808 HDA_OUTPUT));
9809 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009810 return err;
9811 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009812 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9813 "Speaker Playback Switch",
9814 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9815 HDA_OUTPUT));
9816 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009817 return err;
9818 }
9819 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009820 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009821 if (nid) {
9822 /* spec->multiout.hp_nid = 2; */
9823 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009824 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9825 "Headphone Playback Volume",
9826 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9827 HDA_OUTPUT));
9828 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009829 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009830 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9831 "Headphone Playback Switch",
9832 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9833 HDA_OUTPUT));
9834 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009835 return err;
9836 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009837 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9838 "Headphone Playback Switch",
9839 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9840 HDA_OUTPUT));
9841 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009842 return err;
9843 }
9844 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009845 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009846}
9847
9848/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009849#define alc262_auto_create_analog_input_ctls \
9850 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009851
9852/*
9853 * generic initialization of ADC, input mixers and output mixers
9854 */
9855static struct hda_verb alc262_volume_init_verbs[] = {
9856 /*
9857 * Unmute ADC0-2 and set the default input to mic-in
9858 */
9859 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9860 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9861 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9862 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9863 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9864 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9865
Takashi Iwaicb53c622007-08-10 17:21:45 +02009866 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009867 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009868 * Note: PASD motherboards uses the Line In 2 as the input for
9869 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009870 */
9871 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9876 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009877
9878 /*
9879 * Set up output mixers (0x0c - 0x0f)
9880 */
9881 /* set vol=0 to output mixers */
9882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9883 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9884 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +02009885
Kailang Yangdf694da2005-12-05 19:42:22 +01009886 /* set up input amps for analog loopback */
9887 /* Amp Indices: DAC = 0, mixer = 1 */
9888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9891 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9894
9895 /* FIXME: use matrix-type input source selection */
9896 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9897 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9898 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9899 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9900 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9901 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9902 /* Input mixer2 */
9903 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9904 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9905 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9906 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9907 /* Input mixer3 */
9908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9910 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9912
9913 { }
9914};
9915
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009916static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9917 /*
9918 * Unmute ADC0-2 and set the default input to mic-in
9919 */
9920 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9921 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9922 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9923 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9924 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9925 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9926
Takashi Iwaicb53c622007-08-10 17:21:45 +02009927 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009928 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009929 * Note: PASD motherboards uses the Line In 2 as the input for
9930 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009931 */
9932 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9937 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9938 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9939 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +02009940
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009941 /*
9942 * Set up output mixers (0x0c - 0x0e)
9943 */
9944 /* set vol=0 to output mixers */
9945 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9946 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9947 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9948
9949 /* set up input amps for analog loopback */
9950 /* Amp Indices: DAC = 0, mixer = 1 */
9951 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9952 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9953 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9954 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9955 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9956 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9957
Takashi Iwaice875f02008-01-28 18:17:43 +01009958 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009959 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9960 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9961
9962 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9963 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9964
9965 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9966 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9967
9968 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9969 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9970 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9971 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9972 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9973
9974 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9975 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9976 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9977 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9978 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9979 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9980
9981
9982 /* FIXME: use matrix-type input source selection */
9983 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9984 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9987 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9988 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9989 /* Input mixer2 */
9990 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9991 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9994 /* Input mixer3 */
9995 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9996 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9997 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9999
Takashi Iwaice875f02008-01-28 18:17:43 +010010000 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10001
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010002 { }
10003};
10004
Kailang Yangcd7509a2007-01-26 18:33:17 +010010005static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10006 /*
10007 * Unmute ADC0-2 and set the default input to mic-in
10008 */
10009 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10010 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10011 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10012 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10013 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10014 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10015
Takashi Iwaicb53c622007-08-10 17:21:45 +020010016 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010017 * mixer widget
10018 * Note: PASD motherboards uses the Line In 2 as the input for front
10019 * panel mic (mic 2)
10020 */
10021 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010022 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10023 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10024 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10025 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10026 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10027 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10028 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10029 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010030 /*
10031 * Set up output mixers (0x0c - 0x0e)
10032 */
10033 /* set vol=0 to output mixers */
10034 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10035 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10036 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10037
10038 /* set up input amps for analog loopback */
10039 /* Amp Indices: DAC = 0, mixer = 1 */
10040 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10041 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10042 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10043 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10044 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10045 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10046
10047
10048 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10049 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10050 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10051 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10052 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10053 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10054 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10055
10056 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10057 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10058
10059 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10060 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10061
10062 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10063 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10064 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10065 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10066 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10067 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10068
10069 /* FIXME: use matrix-type input source selection */
10070 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10071 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10072 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10073 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10074 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10075 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10076 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10077 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10078 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10079 /* Input mixer2 */
10080 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10081 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10082 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10083 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10085 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10086 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10087 /* Input mixer3 */
10088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10093 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10094 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10095
Takashi Iwaice875f02008-01-28 18:17:43 +010010096 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10097
Kailang Yangcd7509a2007-01-26 18:33:17 +010010098 { }
10099};
10100
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010101static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10102
10103 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10104 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10105 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10106
10107 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10108 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10109 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10110 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10111
10112 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10113 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10114 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10115 {}
10116};
10117
10118
Takashi Iwaicb53c622007-08-10 17:21:45 +020010119#ifdef CONFIG_SND_HDA_POWER_SAVE
10120#define alc262_loopbacks alc880_loopbacks
10121#endif
10122
Kailang Yangdf694da2005-12-05 19:42:22 +010010123/* pcm configuration: identiacal with ALC880 */
10124#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10125#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10126#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10127#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10128
10129/*
10130 * BIOS auto configuration
10131 */
10132static int alc262_parse_auto_config(struct hda_codec *codec)
10133{
10134 struct alc_spec *spec = codec->spec;
10135 int err;
10136 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10137
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010138 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10139 alc262_ignore);
10140 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010141 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010142 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010010143 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010144 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10145 if (err < 0)
10146 return err;
10147 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10148 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010149 return err;
10150
10151 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10152
10153 if (spec->autocfg.dig_out_pin)
10154 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10155 if (spec->autocfg.dig_in_pin)
10156 spec->dig_in_nid = ALC262_DIGIN_NID;
10157
Takashi Iwai603c4012008-07-30 15:01:44 +020010158 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010159 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010160
Takashi Iwaid88897e2008-10-31 15:01:37 +010010161 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010162 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010163 spec->input_mux = &spec->private_imux;
10164
Takashi Iwai776e1842007-08-29 15:07:11 +020010165 err = alc_auto_add_mic_boost(codec);
10166 if (err < 0)
10167 return err;
10168
Takashi Iwaie044c392008-10-27 16:56:24 +010010169 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010170 return 1;
10171}
10172
10173#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10174#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10175#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010176#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010177
10178
10179/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010180static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010181{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010182 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010183 alc262_auto_init_multi_out(codec);
10184 alc262_auto_init_hp_out(codec);
10185 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010186 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010187 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010188 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010189}
10190
10191/*
10192 * configuration and preset
10193 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010194static const char *alc262_models[ALC262_MODEL_LAST] = {
10195 [ALC262_BASIC] = "basic",
10196 [ALC262_HIPPO] = "hippo",
10197 [ALC262_HIPPO_1] = "hippo_1",
10198 [ALC262_FUJITSU] = "fujitsu",
10199 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010200 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010201 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010202 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010203 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010204 [ALC262_BENQ_T31] = "benq-t31",
10205 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010206 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010207 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010208 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010209 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010210 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010211 [ALC262_AUTO] = "auto",
10212};
10213
10214static struct snd_pci_quirk alc262_cfg_tbl[] = {
10215 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010216 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010217 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010218 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010219 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10220 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010221 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010222 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010223 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010224 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010225 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010226 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010227 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010228 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010229 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010230 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010231 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010232 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010233 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10234 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10235 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010236 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10237 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010238 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010239 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010240 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010241 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10242 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10243 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010244 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010245 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010246 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010247 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010248 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010249 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010250 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010251 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010252 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010253 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010254 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010255 {}
10256};
10257
10258static struct alc_config_preset alc262_presets[] = {
10259 [ALC262_BASIC] = {
10260 .mixers = { alc262_base_mixer },
10261 .init_verbs = { alc262_init_verbs },
10262 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10263 .dac_nids = alc262_dac_nids,
10264 .hp_nid = 0x03,
10265 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10266 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010267 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010268 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010269 [ALC262_HIPPO] = {
10270 .mixers = { alc262_base_mixer },
10271 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10272 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10273 .dac_nids = alc262_dac_nids,
10274 .hp_nid = 0x03,
10275 .dig_out_nid = ALC262_DIGOUT_NID,
10276 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10277 .channel_mode = alc262_modes,
10278 .input_mux = &alc262_capture_source,
10279 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010280 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010281 },
10282 [ALC262_HIPPO_1] = {
10283 .mixers = { alc262_hippo1_mixer },
10284 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10285 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10286 .dac_nids = alc262_dac_nids,
10287 .hp_nid = 0x02,
10288 .dig_out_nid = ALC262_DIGOUT_NID,
10289 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10290 .channel_mode = alc262_modes,
10291 .input_mux = &alc262_capture_source,
10292 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010293 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010294 },
Takashi Iwai834be882006-03-01 14:16:17 +010010295 [ALC262_FUJITSU] = {
10296 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010297 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10298 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010299 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10300 .dac_nids = alc262_dac_nids,
10301 .hp_nid = 0x03,
10302 .dig_out_nid = ALC262_DIGOUT_NID,
10303 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10304 .channel_mode = alc262_modes,
10305 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010306 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010307 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010308 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010309 [ALC262_HP_BPC] = {
10310 .mixers = { alc262_HP_BPC_mixer },
10311 .init_verbs = { alc262_HP_BPC_init_verbs },
10312 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10313 .dac_nids = alc262_dac_nids,
10314 .hp_nid = 0x03,
10315 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10316 .channel_mode = alc262_modes,
10317 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010318 .unsol_event = alc262_hp_bpc_unsol_event,
10319 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010320 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010321 [ALC262_HP_BPC_D7000_WF] = {
10322 .mixers = { alc262_HP_BPC_WildWest_mixer },
10323 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10324 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10325 .dac_nids = alc262_dac_nids,
10326 .hp_nid = 0x03,
10327 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10328 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010329 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010330 .unsol_event = alc262_hp_wildwest_unsol_event,
10331 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010332 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010333 [ALC262_HP_BPC_D7000_WL] = {
10334 .mixers = { alc262_HP_BPC_WildWest_mixer,
10335 alc262_HP_BPC_WildWest_option_mixer },
10336 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10337 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10338 .dac_nids = alc262_dac_nids,
10339 .hp_nid = 0x03,
10340 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10341 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010342 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010343 .unsol_event = alc262_hp_wildwest_unsol_event,
10344 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010345 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010346 [ALC262_HP_TC_T5735] = {
10347 .mixers = { alc262_hp_t5735_mixer },
10348 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10349 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10350 .dac_nids = alc262_dac_nids,
10351 .hp_nid = 0x03,
10352 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10353 .channel_mode = alc262_modes,
10354 .input_mux = &alc262_capture_source,
10355 .unsol_event = alc262_hp_t5735_unsol_event,
10356 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010357 },
10358 [ALC262_HP_RP5700] = {
10359 .mixers = { alc262_hp_rp5700_mixer },
10360 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10361 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10362 .dac_nids = alc262_dac_nids,
10363 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10364 .channel_mode = alc262_modes,
10365 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010366 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010367 [ALC262_BENQ_ED8] = {
10368 .mixers = { alc262_base_mixer },
10369 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10370 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10371 .dac_nids = alc262_dac_nids,
10372 .hp_nid = 0x03,
10373 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10374 .channel_mode = alc262_modes,
10375 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010376 },
Kailang Yang272a5272007-05-14 11:00:38 +020010377 [ALC262_SONY_ASSAMD] = {
10378 .mixers = { alc262_sony_mixer },
10379 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10380 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10381 .dac_nids = alc262_dac_nids,
10382 .hp_nid = 0x02,
10383 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10384 .channel_mode = alc262_modes,
10385 .input_mux = &alc262_capture_source,
10386 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010387 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010388 },
10389 [ALC262_BENQ_T31] = {
10390 .mixers = { alc262_benq_t31_mixer },
10391 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10392 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10393 .dac_nids = alc262_dac_nids,
10394 .hp_nid = 0x03,
10395 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10396 .channel_mode = alc262_modes,
10397 .input_mux = &alc262_capture_source,
10398 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010399 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010400 },
Tobin Davisf651b502007-10-26 12:40:47 +020010401 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010402 .mixers = { alc262_ultra_mixer },
10403 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010404 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010405 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10406 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010407 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10408 .channel_mode = alc262_modes,
10409 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010410 .adc_nids = alc262_adc_nids, /* ADC0 */
10411 .capsrc_nids = alc262_capsrc_nids,
10412 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010413 .unsol_event = alc262_ultra_unsol_event,
10414 .init_hook = alc262_ultra_automute,
10415 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010416 [ALC262_LENOVO_3000] = {
10417 .mixers = { alc262_lenovo_3000_mixer },
10418 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10419 alc262_lenovo_3000_unsol_verbs },
10420 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10421 .dac_nids = alc262_dac_nids,
10422 .hp_nid = 0x03,
10423 .dig_out_nid = ALC262_DIGOUT_NID,
10424 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10425 .channel_mode = alc262_modes,
10426 .input_mux = &alc262_fujitsu_capture_source,
10427 .unsol_event = alc262_lenovo_3000_unsol_event,
10428 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010429 [ALC262_NEC] = {
10430 .mixers = { alc262_nec_mixer },
10431 .init_verbs = { alc262_nec_verbs },
10432 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10433 .dac_nids = alc262_dac_nids,
10434 .hp_nid = 0x03,
10435 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10436 .channel_mode = alc262_modes,
10437 .input_mux = &alc262_capture_source,
10438 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010439 [ALC262_TOSHIBA_S06] = {
10440 .mixers = { alc262_toshiba_s06_mixer },
10441 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10442 alc262_eapd_verbs },
10443 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10444 .capsrc_nids = alc262_dmic_capsrc_nids,
10445 .dac_nids = alc262_dac_nids,
10446 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10447 .dig_out_nid = ALC262_DIGOUT_NID,
10448 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10449 .channel_mode = alc262_modes,
10450 .input_mux = &alc262_dmic_capture_source,
10451 .unsol_event = alc262_toshiba_s06_unsol_event,
10452 .init_hook = alc262_toshiba_s06_init_hook,
10453 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010454 [ALC262_TOSHIBA_RX1] = {
10455 .mixers = { alc262_toshiba_rx1_mixer },
10456 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10457 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10458 .dac_nids = alc262_dac_nids,
10459 .hp_nid = 0x03,
10460 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10461 .channel_mode = alc262_modes,
10462 .input_mux = &alc262_capture_source,
10463 .unsol_event = alc262_hippo_unsol_event,
10464 .init_hook = alc262_hippo_automute,
10465 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010466};
10467
10468static int patch_alc262(struct hda_codec *codec)
10469{
10470 struct alc_spec *spec;
10471 int board_config;
10472 int err;
10473
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010474 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010475 if (spec == NULL)
10476 return -ENOMEM;
10477
10478 codec->spec = spec;
10479#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010480 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10481 * under-run
10482 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010483 {
10484 int tmp;
10485 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10486 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10487 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10488 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10489 }
10490#endif
10491
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010492 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10493
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010494 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10495 alc262_models,
10496 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010497
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010498 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010499 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10500 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010501 board_config = ALC262_AUTO;
10502 }
10503
10504 if (board_config == ALC262_AUTO) {
10505 /* automatic parse from the BIOS config */
10506 err = alc262_parse_auto_config(codec);
10507 if (err < 0) {
10508 alc_free(codec);
10509 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010510 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010511 printk(KERN_INFO
10512 "hda_codec: Cannot set up configuration "
10513 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010514 board_config = ALC262_BASIC;
10515 }
10516 }
10517
10518 if (board_config != ALC262_AUTO)
10519 setup_preset(spec, &alc262_presets[board_config]);
10520
10521 spec->stream_name_analog = "ALC262 Analog";
10522 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10523 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010524
Kailang Yangdf694da2005-12-05 19:42:22 +010010525 spec->stream_name_digital = "ALC262 Digital";
10526 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10527 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10528
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010529 spec->is_mix_capture = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010530 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010531 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010532 unsigned int wcap = get_wcaps(codec, 0x07);
10533
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010534 /* get type */
10535 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010536 if (wcap != AC_WID_AUD_IN) {
10537 spec->adc_nids = alc262_adc_nids_alt;
10538 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010539 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010010540 } else {
10541 spec->adc_nids = alc262_adc_nids;
10542 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010543 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010544 }
10545 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010546 if (!spec->cap_mixer)
10547 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010548
Takashi Iwai2134ea42008-01-10 16:53:55 +010010549 spec->vmaster_nid = 0x0c;
10550
Kailang Yangdf694da2005-12-05 19:42:22 +010010551 codec->patch_ops = alc_patch_ops;
10552 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010553 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010554#ifdef CONFIG_SND_HDA_POWER_SAVE
10555 if (!spec->loopback.amplist)
10556 spec->loopback.amplist = alc262_loopbacks;
10557#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020010558
Kailang Yangdf694da2005-12-05 19:42:22 +010010559 return 0;
10560}
10561
Kailang Yangdf694da2005-12-05 19:42:22 +010010562/*
Kailang Yanga361d842007-06-05 12:30:55 +020010563 * ALC268 channel source setting (2 channel)
10564 */
10565#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10566#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010567
Kailang Yanga361d842007-06-05 12:30:55 +020010568static hda_nid_t alc268_dac_nids[2] = {
10569 /* front, hp */
10570 0x02, 0x03
10571};
10572
10573static hda_nid_t alc268_adc_nids[2] = {
10574 /* ADC0-1 */
10575 0x08, 0x07
10576};
10577
10578static hda_nid_t alc268_adc_nids_alt[1] = {
10579 /* ADC0 */
10580 0x08
10581};
10582
Takashi Iwaie1406342008-02-11 18:32:32 +010010583static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10584
Kailang Yanga361d842007-06-05 12:30:55 +020010585static struct snd_kcontrol_new alc268_base_mixer[] = {
10586 /* output mixer control */
10587 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10588 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10589 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010591 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10592 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10593 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010594 { }
10595};
10596
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010597/* bind Beep switches of both NID 0x0f and 0x10 */
10598static struct hda_bind_ctls alc268_bind_beep_sw = {
10599 .ops = &snd_hda_bind_sw,
10600 .values = {
10601 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10602 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10603 0
10604 },
10605};
10606
10607static struct snd_kcontrol_new alc268_beep_mixer[] = {
10608 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10609 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10610 { }
10611};
10612
Kailang Yangd1a991a2007-08-15 16:21:59 +020010613static struct hda_verb alc268_eapd_verbs[] = {
10614 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10615 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10616 { }
10617};
10618
Takashi Iwaid2738092007-08-16 14:59:45 +020010619/* Toshiba specific */
10620#define alc268_toshiba_automute alc262_hippo_automute
10621
10622static struct hda_verb alc268_toshiba_verbs[] = {
10623 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10624 { } /* end */
10625};
10626
Kailang Yang8ef355d2008-08-26 13:10:22 +020010627static struct hda_input_mux alc268_acer_lc_capture_source = {
10628 .num_items = 2,
10629 .items = {
10630 { "i-Mic", 0x6 },
10631 { "E-Mic", 0x0 },
10632 },
10633};
10634
Takashi Iwaid2738092007-08-16 14:59:45 +020010635/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010636/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010637static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10638 .ops = &snd_hda_bind_vol,
10639 .values = {
10640 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10641 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10642 0
10643 },
10644};
10645
Takashi Iwai889c4392007-08-23 18:56:52 +020010646/* mute/unmute internal speaker according to the hp jack and mute state */
10647static void alc268_acer_automute(struct hda_codec *codec, int force)
10648{
10649 struct alc_spec *spec = codec->spec;
10650 unsigned int mute;
10651
10652 if (force || !spec->sense_updated) {
10653 unsigned int present;
10654 present = snd_hda_codec_read(codec, 0x14, 0,
10655 AC_VERB_GET_PIN_SENSE, 0);
10656 spec->jack_present = (present & 0x80000000) != 0;
10657 spec->sense_updated = 1;
10658 }
10659 if (spec->jack_present)
10660 mute = HDA_AMP_MUTE; /* mute internal speaker */
10661 else /* unmute internal speaker if necessary */
10662 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10663 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10664 HDA_AMP_MUTE, mute);
10665}
10666
10667
10668/* bind hp and internal speaker mute (with plug check) */
10669static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10670 struct snd_ctl_elem_value *ucontrol)
10671{
10672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10673 long *valp = ucontrol->value.integer.value;
10674 int change;
10675
10676 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10677 HDA_AMP_MUTE,
10678 valp[0] ? 0 : HDA_AMP_MUTE);
10679 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10680 HDA_AMP_MUTE,
10681 valp[1] ? 0 : HDA_AMP_MUTE);
10682 if (change)
10683 alc268_acer_automute(codec, 0);
10684 return change;
10685}
Takashi Iwaid2738092007-08-16 14:59:45 +020010686
Kailang Yang8ef355d2008-08-26 13:10:22 +020010687static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
10688 /* output mixer control */
10689 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10690 {
10691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10692 .name = "Master Playback Switch",
10693 .info = snd_hda_mixer_amp_switch_info,
10694 .get = snd_hda_mixer_amp_switch_get,
10695 .put = alc268_acer_master_sw_put,
10696 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10697 },
10698 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
10699 { }
10700};
10701
Takashi Iwaid2738092007-08-16 14:59:45 +020010702static struct snd_kcontrol_new alc268_acer_mixer[] = {
10703 /* output mixer control */
10704 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10705 {
10706 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10707 .name = "Master Playback Switch",
10708 .info = snd_hda_mixer_amp_switch_info,
10709 .get = snd_hda_mixer_amp_switch_get,
10710 .put = alc268_acer_master_sw_put,
10711 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10712 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010713 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10714 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10715 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010716 { }
10717};
10718
Takashi Iwaic238b4f2008-11-05 14:57:20 +010010719static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
10720 /* output mixer control */
10721 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10722 {
10723 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10724 .name = "Master Playback Switch",
10725 .info = snd_hda_mixer_amp_switch_info,
10726 .get = snd_hda_mixer_amp_switch_get,
10727 .put = alc268_acer_master_sw_put,
10728 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10729 },
10730 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10731 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
10732 { }
10733};
10734
Kailang Yang8ef355d2008-08-26 13:10:22 +020010735static struct hda_verb alc268_acer_aspire_one_verbs[] = {
10736 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10737 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10738 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10739 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10740 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
10741 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
10742 { }
10743};
10744
Takashi Iwaid2738092007-08-16 14:59:45 +020010745static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010746 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10747 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010748 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10749 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010750 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10751 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010752 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10753 { }
10754};
10755
10756/* unsolicited event for HP jack sensing */
10757static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10758 unsigned int res)
10759{
Takashi Iwai889c4392007-08-23 18:56:52 +020010760 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010761 return;
10762 alc268_toshiba_automute(codec);
10763}
10764
10765static void alc268_acer_unsol_event(struct hda_codec *codec,
10766 unsigned int res)
10767{
Takashi Iwai889c4392007-08-23 18:56:52 +020010768 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010769 return;
10770 alc268_acer_automute(codec, 1);
10771}
10772
Takashi Iwai889c4392007-08-23 18:56:52 +020010773static void alc268_acer_init_hook(struct hda_codec *codec)
10774{
10775 alc268_acer_automute(codec, 1);
10776}
10777
Kailang Yang8ef355d2008-08-26 13:10:22 +020010778/* toggle speaker-output according to the hp-jack state */
10779static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
10780{
10781 unsigned int present;
10782 unsigned char bits;
10783
10784 present = snd_hda_codec_read(codec, 0x15, 0,
10785 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10786 bits = present ? AMP_IN_MUTE(0) : 0;
10787 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
10788 AMP_IN_MUTE(0), bits);
10789 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
10790 AMP_IN_MUTE(0), bits);
10791}
10792
10793
10794static void alc268_acer_mic_automute(struct hda_codec *codec)
10795{
10796 unsigned int present;
10797
10798 present = snd_hda_codec_read(codec, 0x18, 0,
10799 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10800 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
10801 present ? 0x0 : 0x6);
10802}
10803
10804static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
10805 unsigned int res)
10806{
10807 if ((res >> 26) == ALC880_HP_EVENT)
10808 alc268_aspire_one_speaker_automute(codec);
10809 if ((res >> 26) == ALC880_MIC_EVENT)
10810 alc268_acer_mic_automute(codec);
10811}
10812
10813static void alc268_acer_lc_init_hook(struct hda_codec *codec)
10814{
10815 alc268_aspire_one_speaker_automute(codec);
10816 alc268_acer_mic_automute(codec);
10817}
10818
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010819static struct snd_kcontrol_new alc268_dell_mixer[] = {
10820 /* output mixer control */
10821 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10822 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10823 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10824 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10825 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10826 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10827 { }
10828};
10829
10830static struct hda_verb alc268_dell_verbs[] = {
10831 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10833 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10834 { }
10835};
10836
10837/* mute/unmute internal speaker according to the hp jack and mute state */
10838static void alc268_dell_automute(struct hda_codec *codec)
10839{
10840 unsigned int present;
10841 unsigned int mute;
10842
10843 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10844 if (present & 0x80000000)
10845 mute = HDA_AMP_MUTE;
10846 else
10847 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10848 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10849 HDA_AMP_MUTE, mute);
10850}
10851
10852static void alc268_dell_unsol_event(struct hda_codec *codec,
10853 unsigned int res)
10854{
10855 if ((res >> 26) != ALC880_HP_EVENT)
10856 return;
10857 alc268_dell_automute(codec);
10858}
10859
10860#define alc268_dell_init_hook alc268_dell_automute
10861
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010862static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10863 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10864 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10865 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10866 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10867 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10868 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10869 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10870 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10871 { }
10872};
10873
10874static struct hda_verb alc267_quanta_il1_verbs[] = {
10875 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10876 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10877 { }
10878};
10879
10880static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10881{
10882 unsigned int present;
10883
10884 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10885 & AC_PINSENSE_PRESENCE;
10886 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10887 present ? 0 : PIN_OUT);
10888}
10889
10890static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10891{
10892 unsigned int present;
10893
10894 present = snd_hda_codec_read(codec, 0x18, 0,
10895 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10896 snd_hda_codec_write(codec, 0x23, 0,
10897 AC_VERB_SET_CONNECT_SEL,
10898 present ? 0x00 : 0x01);
10899}
10900
10901static void alc267_quanta_il1_automute(struct hda_codec *codec)
10902{
10903 alc267_quanta_il1_hp_automute(codec);
10904 alc267_quanta_il1_mic_automute(codec);
10905}
10906
10907static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10908 unsigned int res)
10909{
10910 switch (res >> 26) {
10911 case ALC880_HP_EVENT:
10912 alc267_quanta_il1_hp_automute(codec);
10913 break;
10914 case ALC880_MIC_EVENT:
10915 alc267_quanta_il1_mic_automute(codec);
10916 break;
10917 }
10918}
10919
Kailang Yanga361d842007-06-05 12:30:55 +020010920/*
10921 * generic initialization of ADC, input mixers and output mixers
10922 */
10923static struct hda_verb alc268_base_init_verbs[] = {
10924 /* Unmute DAC0-1 and set vol = 0 */
10925 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10926 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10927 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10928 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10929 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10930 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10931
10932 /*
10933 * Set up output mixers (0x0c - 0x0e)
10934 */
10935 /* set vol=0 to output mixers */
10936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10937 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10938 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10939 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10940
10941 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10942 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10943
10944 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10945 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10946 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10947 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10948 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10949 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10950 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10951 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10952
10953 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10954 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10955 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10956 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10957 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10958 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10959 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010960
10961 /* set PCBEEP vol = 0, mute connections */
10962 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10963 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10964 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010965
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010966 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020010967
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010968 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10969 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10970 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10971 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020010972
Kailang Yanga361d842007-06-05 12:30:55 +020010973 { }
10974};
10975
10976/*
10977 * generic initialization of ADC, input mixers and output mixers
10978 */
10979static struct hda_verb alc268_volume_init_verbs[] = {
10980 /* set output DAC */
10981 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10982 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10983 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10984 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10985
10986 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10987 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10988 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10989 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10990 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10991
10992 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10993 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10994 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10995 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10996 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10997
10998 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10999 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11000 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11001 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11002
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011003 /* set PCBEEP vol = 0, mute connections */
11004 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11005 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11006 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011007
11008 { }
11009};
11010
Kailang Yanga361d842007-06-05 12:30:55 +020011011static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11012 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11013 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11014 {
11015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11016 /* The multiple "Capture Source" controls confuse alsamixer
11017 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011018 */
11019 /* .name = "Capture Source", */
11020 .name = "Input Source",
11021 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011022 .info = alc_mux_enum_info,
11023 .get = alc_mux_enum_get,
11024 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011025 },
11026 { } /* end */
11027};
11028
11029static struct snd_kcontrol_new alc268_capture_mixer[] = {
11030 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11031 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11032 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11033 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11034 {
11035 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11036 /* The multiple "Capture Source" controls confuse alsamixer
11037 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011038 */
11039 /* .name = "Capture Source", */
11040 .name = "Input Source",
11041 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011042 .info = alc_mux_enum_info,
11043 .get = alc_mux_enum_get,
11044 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011045 },
11046 { } /* end */
11047};
11048
11049static struct hda_input_mux alc268_capture_source = {
11050 .num_items = 4,
11051 .items = {
11052 { "Mic", 0x0 },
11053 { "Front Mic", 0x1 },
11054 { "Line", 0x2 },
11055 { "CD", 0x3 },
11056 },
11057};
11058
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011059static struct hda_input_mux alc268_acer_capture_source = {
11060 .num_items = 3,
11061 .items = {
11062 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011063 { "Internal Mic", 0x1 },
11064 { "Line", 0x2 },
11065 },
11066};
11067
11068static struct hda_input_mux alc268_acer_dmic_capture_source = {
11069 .num_items = 3,
11070 .items = {
11071 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011072 { "Internal Mic", 0x6 },
11073 { "Line", 0x2 },
11074 },
11075};
11076
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011077#ifdef CONFIG_SND_DEBUG
11078static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011079 /* Volume widgets */
11080 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11081 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11082 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11083 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11084 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11085 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11086 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11087 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11088 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11089 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11090 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11091 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11092 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011093 /* The below appears problematic on some hardwares */
11094 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011095 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11096 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11097 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11098 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11099
11100 /* Modes for retasking pin widgets */
11101 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11102 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11103 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11104 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11105
11106 /* Controls for GPIO pins, assuming they are configured as outputs */
11107 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11108 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11109 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11110 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11111
11112 /* Switches to allow the digital SPDIF output pin to be enabled.
11113 * The ALC268 does not have an SPDIF input.
11114 */
11115 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11116
11117 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11118 * this output to turn on an external amplifier.
11119 */
11120 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11121 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11122
11123 { } /* end */
11124};
11125#endif
11126
Kailang Yanga361d842007-06-05 12:30:55 +020011127/* create input playback/capture controls for the given pin */
11128static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11129 const char *ctlname, int idx)
11130{
11131 char name[32];
11132 int err;
11133
11134 sprintf(name, "%s Playback Volume", ctlname);
11135 if (nid == 0x14) {
11136 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11137 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11138 HDA_OUTPUT));
11139 if (err < 0)
11140 return err;
11141 } else if (nid == 0x15) {
11142 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11143 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11144 HDA_OUTPUT));
11145 if (err < 0)
11146 return err;
11147 } else
11148 return -1;
11149 sprintf(name, "%s Playback Switch", ctlname);
11150 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11151 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11152 if (err < 0)
11153 return err;
11154 return 0;
11155}
11156
11157/* add playback controls from the parsed DAC table */
11158static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11159 const struct auto_pin_cfg *cfg)
11160{
11161 hda_nid_t nid;
11162 int err;
11163
11164 spec->multiout.num_dacs = 2; /* only use one dac */
11165 spec->multiout.dac_nids = spec->private_dac_nids;
11166 spec->multiout.dac_nids[0] = 2;
11167 spec->multiout.dac_nids[1] = 3;
11168
11169 nid = cfg->line_out_pins[0];
11170 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011171 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011172
11173 nid = cfg->speaker_pins[0];
11174 if (nid == 0x1d) {
11175 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11176 "Speaker Playback Volume",
11177 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11178 if (err < 0)
11179 return err;
11180 }
11181 nid = cfg->hp_pins[0];
11182 if (nid)
11183 alc268_new_analog_output(spec, nid, "Headphone", 0);
11184
11185 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11186 if (nid == 0x16) {
11187 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11188 "Mono Playback Switch",
11189 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11190 if (err < 0)
11191 return err;
11192 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011193 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011194}
11195
11196/* create playback/capture controls for input pins */
11197static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11198 const struct auto_pin_cfg *cfg)
11199{
11200 struct hda_input_mux *imux = &spec->private_imux;
11201 int i, idx1;
11202
11203 for (i = 0; i < AUTO_PIN_LAST; i++) {
11204 switch(cfg->input_pins[i]) {
11205 case 0x18:
11206 idx1 = 0; /* Mic 1 */
11207 break;
11208 case 0x19:
11209 idx1 = 1; /* Mic 2 */
11210 break;
11211 case 0x1a:
11212 idx1 = 2; /* Line In */
11213 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011214 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011215 idx1 = 3; /* CD */
11216 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011217 case 0x12:
11218 case 0x13:
11219 idx1 = 6; /* digital mics */
11220 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011221 default:
11222 continue;
11223 }
11224 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11225 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011226 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011227 }
11228 return 0;
11229}
11230
11231static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11232{
11233 struct alc_spec *spec = codec->spec;
11234 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11235 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11236 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11237 unsigned int dac_vol1, dac_vol2;
11238
11239 if (speaker_nid) {
11240 snd_hda_codec_write(codec, speaker_nid, 0,
11241 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11242 snd_hda_codec_write(codec, 0x0f, 0,
11243 AC_VERB_SET_AMP_GAIN_MUTE,
11244 AMP_IN_UNMUTE(1));
11245 snd_hda_codec_write(codec, 0x10, 0,
11246 AC_VERB_SET_AMP_GAIN_MUTE,
11247 AMP_IN_UNMUTE(1));
11248 } else {
11249 snd_hda_codec_write(codec, 0x0f, 0,
11250 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11251 snd_hda_codec_write(codec, 0x10, 0,
11252 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11253 }
11254
11255 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011256 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011257 dac_vol2 = AMP_OUT_ZERO;
11258 else if (line_nid == 0x15)
11259 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011260 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011261 dac_vol2 = AMP_OUT_ZERO;
11262 else if (hp_nid == 0x15)
11263 dac_vol1 = AMP_OUT_ZERO;
11264 if (line_nid != 0x16 || hp_nid != 0x16 ||
11265 spec->autocfg.line_out_pins[1] != 0x16 ||
11266 spec->autocfg.line_out_pins[2] != 0x16)
11267 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11268
11269 snd_hda_codec_write(codec, 0x02, 0,
11270 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11271 snd_hda_codec_write(codec, 0x03, 0,
11272 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11273}
11274
11275/* pcm configuration: identiacal with ALC880 */
11276#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11277#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011278#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011279#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11280
11281/*
11282 * BIOS auto configuration
11283 */
11284static int alc268_parse_auto_config(struct hda_codec *codec)
11285{
11286 struct alc_spec *spec = codec->spec;
11287 int err;
11288 static hda_nid_t alc268_ignore[] = { 0 };
11289
11290 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11291 alc268_ignore);
11292 if (err < 0)
11293 return err;
11294 if (!spec->autocfg.line_outs)
11295 return 0; /* can't find valid BIOS pin config */
11296
11297 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11298 if (err < 0)
11299 return err;
11300 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11301 if (err < 0)
11302 return err;
11303
11304 spec->multiout.max_channels = 2;
11305
11306 /* digital only support output */
11307 if (spec->autocfg.dig_out_pin)
11308 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11309
Takashi Iwai603c4012008-07-30 15:01:44 +020011310 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011311 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011312
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011313 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011314 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011315
Takashi Iwaid88897e2008-10-31 15:01:37 +010011316 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011317 spec->num_mux_defs = 1;
11318 spec->input_mux = &spec->private_imux;
11319
Takashi Iwai776e1842007-08-29 15:07:11 +020011320 err = alc_auto_add_mic_boost(codec);
11321 if (err < 0)
11322 return err;
11323
Takashi Iwaie044c392008-10-27 16:56:24 +010011324 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011325 return 1;
11326}
11327
11328#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11329#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11330#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11331
11332/* init callback for auto-configuration model -- overriding the default init */
11333static void alc268_auto_init(struct hda_codec *codec)
11334{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011335 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011336 alc268_auto_init_multi_out(codec);
11337 alc268_auto_init_hp_out(codec);
11338 alc268_auto_init_mono_speaker_out(codec);
11339 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011340 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011341 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011342}
11343
11344/*
11345 * configuration and preset
11346 */
11347static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011348 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011349 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011350 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011351 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011352 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011353 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011354 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011355 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011356#ifdef CONFIG_SND_DEBUG
11357 [ALC268_TEST] = "test",
11358#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011359 [ALC268_AUTO] = "auto",
11360};
11361
11362static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011363 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011364 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011365 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011366 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011367 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011368 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11369 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011370 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011371 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011372 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011373 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011374 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011375 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011376 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011377 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011378 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011379 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011380 {}
11381};
11382
11383static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011384 [ALC267_QUANTA_IL1] = {
11385 .mixers = { alc267_quanta_il1_mixer },
11386 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11387 alc267_quanta_il1_verbs },
11388 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11389 .dac_nids = alc268_dac_nids,
11390 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11391 .adc_nids = alc268_adc_nids_alt,
11392 .hp_nid = 0x03,
11393 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11394 .channel_mode = alc268_modes,
11395 .input_mux = &alc268_capture_source,
11396 .unsol_event = alc267_quanta_il1_unsol_event,
11397 .init_hook = alc267_quanta_il1_automute,
11398 },
Kailang Yanga361d842007-06-05 12:30:55 +020011399 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011400 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11401 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011402 .init_verbs = { alc268_base_init_verbs },
11403 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11404 .dac_nids = alc268_dac_nids,
11405 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11406 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011407 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011408 .hp_nid = 0x03,
11409 .dig_out_nid = ALC268_DIGOUT_NID,
11410 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11411 .channel_mode = alc268_modes,
11412 .input_mux = &alc268_capture_source,
11413 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011414 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011415 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11416 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011417 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11418 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011419 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11420 .dac_nids = alc268_dac_nids,
11421 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11422 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011423 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011424 .hp_nid = 0x03,
11425 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11426 .channel_mode = alc268_modes,
11427 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011428 .unsol_event = alc268_toshiba_unsol_event,
11429 .init_hook = alc268_toshiba_automute,
11430 },
11431 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011432 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11433 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011434 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11435 alc268_acer_verbs },
11436 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11437 .dac_nids = alc268_dac_nids,
11438 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11439 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011440 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011441 .hp_nid = 0x02,
11442 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11443 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011444 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011445 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011446 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011447 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011448 [ALC268_ACER_DMIC] = {
11449 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11450 alc268_beep_mixer },
11451 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11452 alc268_acer_verbs },
11453 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11454 .dac_nids = alc268_dac_nids,
11455 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11456 .adc_nids = alc268_adc_nids_alt,
11457 .capsrc_nids = alc268_capsrc_nids,
11458 .hp_nid = 0x02,
11459 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11460 .channel_mode = alc268_modes,
11461 .input_mux = &alc268_acer_dmic_capture_source,
11462 .unsol_event = alc268_acer_unsol_event,
11463 .init_hook = alc268_acer_init_hook,
11464 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011465 [ALC268_ACER_ASPIRE_ONE] = {
11466 .mixers = { alc268_acer_aspire_one_mixer,
11467 alc268_capture_alt_mixer },
11468 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11469 alc268_acer_aspire_one_verbs },
11470 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11471 .dac_nids = alc268_dac_nids,
11472 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11473 .adc_nids = alc268_adc_nids_alt,
11474 .capsrc_nids = alc268_capsrc_nids,
11475 .hp_nid = 0x03,
11476 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11477 .channel_mode = alc268_modes,
11478 .input_mux = &alc268_acer_lc_capture_source,
11479 .unsol_event = alc268_acer_lc_unsol_event,
11480 .init_hook = alc268_acer_lc_init_hook,
11481 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011482 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011483 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011484 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11485 alc268_dell_verbs },
11486 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11487 .dac_nids = alc268_dac_nids,
11488 .hp_nid = 0x02,
11489 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11490 .channel_mode = alc268_modes,
11491 .unsol_event = alc268_dell_unsol_event,
11492 .init_hook = alc268_dell_init_hook,
11493 .input_mux = &alc268_capture_source,
11494 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011495 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011496 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11497 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011498 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11499 alc268_toshiba_verbs },
11500 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11501 .dac_nids = alc268_dac_nids,
11502 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11503 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011504 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011505 .hp_nid = 0x03,
11506 .dig_out_nid = ALC268_DIGOUT_NID,
11507 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11508 .channel_mode = alc268_modes,
11509 .input_mux = &alc268_capture_source,
11510 .unsol_event = alc268_toshiba_unsol_event,
11511 .init_hook = alc268_toshiba_automute
11512 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011513#ifdef CONFIG_SND_DEBUG
11514 [ALC268_TEST] = {
11515 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11516 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11517 alc268_volume_init_verbs },
11518 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11519 .dac_nids = alc268_dac_nids,
11520 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11521 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011522 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011523 .hp_nid = 0x03,
11524 .dig_out_nid = ALC268_DIGOUT_NID,
11525 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11526 .channel_mode = alc268_modes,
11527 .input_mux = &alc268_capture_source,
11528 },
11529#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011530};
11531
11532static int patch_alc268(struct hda_codec *codec)
11533{
11534 struct alc_spec *spec;
11535 int board_config;
11536 int err;
11537
11538 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11539 if (spec == NULL)
11540 return -ENOMEM;
11541
11542 codec->spec = spec;
11543
11544 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11545 alc268_models,
11546 alc268_cfg_tbl);
11547
11548 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11549 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11550 "trying auto-probe from BIOS...\n");
11551 board_config = ALC268_AUTO;
11552 }
11553
11554 if (board_config == ALC268_AUTO) {
11555 /* automatic parse from the BIOS config */
11556 err = alc268_parse_auto_config(codec);
11557 if (err < 0) {
11558 alc_free(codec);
11559 return err;
11560 } else if (!err) {
11561 printk(KERN_INFO
11562 "hda_codec: Cannot set up configuration "
11563 "from BIOS. Using base mode...\n");
11564 board_config = ALC268_3ST;
11565 }
11566 }
11567
11568 if (board_config != ALC268_AUTO)
11569 setup_preset(spec, &alc268_presets[board_config]);
11570
Kailang Yang2f893282008-05-27 12:14:47 +020011571 if (codec->vendor_id == 0x10ec0267) {
11572 spec->stream_name_analog = "ALC267 Analog";
11573 spec->stream_name_digital = "ALC267 Digital";
11574 } else {
11575 spec->stream_name_analog = "ALC268 Analog";
11576 spec->stream_name_digital = "ALC268 Digital";
11577 }
11578
Kailang Yanga361d842007-06-05 12:30:55 +020011579 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11580 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011581 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011582
Kailang Yanga361d842007-06-05 12:30:55 +020011583 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11584
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011585 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11586 /* override the amp caps for beep generator */
11587 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11588 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11589 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11590 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11591 (0 << AC_AMPCAP_MUTE_SHIFT));
11592
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011593 if (!spec->adc_nids && spec->input_mux) {
11594 /* check whether NID 0x07 is valid */
11595 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011596 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011597
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011598 /* get type */
11599 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011600 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011601 spec->adc_nids = alc268_adc_nids_alt;
11602 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011603 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011604 } else {
11605 spec->adc_nids = alc268_adc_nids;
11606 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011607 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020011608 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011609 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011610 /* set default input source */
11611 for (i = 0; i < spec->num_adc_nids; i++)
11612 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11613 0, AC_VERB_SET_CONNECT_SEL,
11614 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011615 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011616
11617 spec->vmaster_nid = 0x02;
11618
Kailang Yanga361d842007-06-05 12:30:55 +020011619 codec->patch_ops = alc_patch_ops;
11620 if (board_config == ALC268_AUTO)
11621 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011622
Kailang Yanga361d842007-06-05 12:30:55 +020011623 return 0;
11624}
11625
11626/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011627 * ALC269 channel source setting (2 channel)
11628 */
11629#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11630
11631#define alc269_dac_nids alc260_dac_nids
11632
11633static hda_nid_t alc269_adc_nids[1] = {
11634 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011635 0x08,
11636};
11637
Takashi Iwaie01bf502008-08-21 16:25:07 +020011638static hda_nid_t alc269_capsrc_nids[1] = {
11639 0x23,
11640};
11641
11642/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11643 * not a mux!
11644 */
11645
Kailang Yangf53281e2008-07-18 12:36:43 +020011646static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11647 .num_items = 2,
11648 .items = {
11649 { "i-Mic", 0x5 },
11650 { "e-Mic", 0x0 },
11651 },
11652};
11653
11654static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11655 .num_items = 2,
11656 .items = {
11657 { "i-Mic", 0x1 },
11658 { "e-Mic", 0x0 },
11659 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011660};
11661
11662#define alc269_modes alc260_modes
11663#define alc269_capture_source alc880_lg_lw_capture_source
11664
11665static struct snd_kcontrol_new alc269_base_mixer[] = {
11666 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11667 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11668 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11669 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11671 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020011672 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11673 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011674 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11675 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11676 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11677 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11678 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11679 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11680 { } /* end */
11681};
11682
Kailang Yang60db6b52008-08-26 13:13:00 +020011683static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
11684 /* output mixer control */
11685 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11686 {
11687 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11688 .name = "Master Playback Switch",
11689 .info = snd_hda_mixer_amp_switch_info,
11690 .get = snd_hda_mixer_amp_switch_get,
11691 .put = alc268_acer_master_sw_put,
11692 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11693 },
11694 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11695 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11696 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11697 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11698 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11699 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11700 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
11701 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
11702 { }
11703};
11704
Tony Vroon64154832008-11-06 15:08:49 +000011705static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
11706 /* output mixer control */
11707 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11708 {
11709 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11710 .name = "Master Playback Switch",
11711 .info = snd_hda_mixer_amp_switch_info,
11712 .get = snd_hda_mixer_amp_switch_get,
11713 .put = alc268_acer_master_sw_put,
11714 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11715 },
11716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11717 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11718 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11719 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11720 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11721 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11722 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
11723 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
11724 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
11725 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
11726 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
11727 { }
11728};
11729
Kailang Yangf53281e2008-07-18 12:36:43 +020011730/* bind volumes of both NID 0x0c and 0x0d */
11731static struct hda_bind_ctls alc269_epc_bind_vol = {
11732 .ops = &snd_hda_bind_vol,
11733 .values = {
11734 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11735 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11736 0
11737 },
11738};
11739
11740static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11741 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11742 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11743 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11744 { } /* end */
11745};
11746
Kailang Yangf6a92242007-12-13 16:52:54 +010011747/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020011748static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11749 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11750 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010011751 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11752 { } /* end */
11753};
11754
11755/* FSC amilo */
11756static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
11757 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11759 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020011760 { } /* end */
11761};
11762
Takashi Iwai2005af22008-08-20 18:38:26 +020011763/* beep control */
11764static struct snd_kcontrol_new alc269_beep_mixer[] = {
11765 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11766 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
11767 { } /* end */
11768};
11769
Kailang Yang60db6b52008-08-26 13:13:00 +020011770static struct hda_verb alc269_quanta_fl1_verbs[] = {
11771 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11772 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11774 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11775 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11776 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11777 { }
11778};
11779
Tony Vroon64154832008-11-06 15:08:49 +000011780static struct hda_verb alc269_lifebook_verbs[] = {
11781 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11782 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
11783 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11784 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11785 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11786 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11787 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11788 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11789 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11790 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11791 { }
11792};
11793
Kailang Yang60db6b52008-08-26 13:13:00 +020011794/* toggle speaker-output according to the hp-jack state */
11795static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
11796{
11797 unsigned int present;
11798 unsigned char bits;
11799
11800 present = snd_hda_codec_read(codec, 0x15, 0,
11801 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11802 bits = present ? AMP_IN_MUTE(0) : 0;
11803 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11804 AMP_IN_MUTE(0), bits);
11805 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11806 AMP_IN_MUTE(0), bits);
11807
11808 snd_hda_codec_write(codec, 0x20, 0,
11809 AC_VERB_SET_COEF_INDEX, 0x0c);
11810 snd_hda_codec_write(codec, 0x20, 0,
11811 AC_VERB_SET_PROC_COEF, 0x680);
11812
11813 snd_hda_codec_write(codec, 0x20, 0,
11814 AC_VERB_SET_COEF_INDEX, 0x0c);
11815 snd_hda_codec_write(codec, 0x20, 0,
11816 AC_VERB_SET_PROC_COEF, 0x480);
11817}
11818
Tony Vroon64154832008-11-06 15:08:49 +000011819/* toggle speaker-output according to the hp-jacks state */
11820static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
11821{
11822 unsigned int present;
11823 unsigned char bits;
11824
11825 /* Check laptop headphone socket */
11826 present = snd_hda_codec_read(codec, 0x15, 0,
11827 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11828
11829 /* Check port replicator headphone socket */
11830 present |= snd_hda_codec_read(codec, 0x1a, 0,
11831 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11832
11833 bits = present ? AMP_IN_MUTE(0) : 0;
11834 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11835 AMP_IN_MUTE(0), bits);
11836 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11837 AMP_IN_MUTE(0), bits);
11838
11839 snd_hda_codec_write(codec, 0x20, 0,
11840 AC_VERB_SET_COEF_INDEX, 0x0c);
11841 snd_hda_codec_write(codec, 0x20, 0,
11842 AC_VERB_SET_PROC_COEF, 0x680);
11843
11844 snd_hda_codec_write(codec, 0x20, 0,
11845 AC_VERB_SET_COEF_INDEX, 0x0c);
11846 snd_hda_codec_write(codec, 0x20, 0,
11847 AC_VERB_SET_PROC_COEF, 0x480);
11848}
11849
Kailang Yang60db6b52008-08-26 13:13:00 +020011850static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
11851{
11852 unsigned int present;
11853
11854 present = snd_hda_codec_read(codec, 0x18, 0,
11855 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11856 snd_hda_codec_write(codec, 0x23, 0,
11857 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
11858}
11859
Tony Vroon64154832008-11-06 15:08:49 +000011860static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
11861{
11862 unsigned int present_laptop;
11863 unsigned int present_dock;
11864
11865 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
11866 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11867
11868 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
11869 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11870
11871 /* Laptop mic port overrides dock mic port, design decision */
11872 if (present_dock)
11873 snd_hda_codec_write(codec, 0x23, 0,
11874 AC_VERB_SET_CONNECT_SEL, 0x3);
11875 if (present_laptop)
11876 snd_hda_codec_write(codec, 0x23, 0,
11877 AC_VERB_SET_CONNECT_SEL, 0x0);
11878 if (!present_dock && !present_laptop)
11879 snd_hda_codec_write(codec, 0x23, 0,
11880 AC_VERB_SET_CONNECT_SEL, 0x1);
11881}
11882
Kailang Yang60db6b52008-08-26 13:13:00 +020011883static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
11884 unsigned int res)
11885{
11886 if ((res >> 26) == ALC880_HP_EVENT)
11887 alc269_quanta_fl1_speaker_automute(codec);
11888 if ((res >> 26) == ALC880_MIC_EVENT)
11889 alc269_quanta_fl1_mic_automute(codec);
11890}
11891
Tony Vroon64154832008-11-06 15:08:49 +000011892static void alc269_lifebook_unsol_event(struct hda_codec *codec,
11893 unsigned int res)
11894{
11895 if ((res >> 26) == ALC880_HP_EVENT)
11896 alc269_lifebook_speaker_automute(codec);
11897 if ((res >> 26) == ALC880_MIC_EVENT)
11898 alc269_lifebook_mic_autoswitch(codec);
11899}
11900
Kailang Yang60db6b52008-08-26 13:13:00 +020011901static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
11902{
11903 alc269_quanta_fl1_speaker_automute(codec);
11904 alc269_quanta_fl1_mic_automute(codec);
11905}
11906
Tony Vroon64154832008-11-06 15:08:49 +000011907static void alc269_lifebook_init_hook(struct hda_codec *codec)
11908{
11909 alc269_lifebook_speaker_automute(codec);
11910 alc269_lifebook_mic_autoswitch(codec);
11911}
11912
Kailang Yang60db6b52008-08-26 13:13:00 +020011913static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11914 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11915 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11916 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11917 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11918 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11919 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11920 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11921 {}
11922};
11923
11924static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11925 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11926 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11927 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11928 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11929 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11930 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11931 {}
11932};
11933
11934/* toggle speaker-output according to the hp-jack state */
11935static void alc269_speaker_automute(struct hda_codec *codec)
11936{
11937 unsigned int present;
11938 unsigned char bits;
11939
11940 present = snd_hda_codec_read(codec, 0x15, 0,
11941 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11942 bits = present ? AMP_IN_MUTE(0) : 0;
11943 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11944 AMP_IN_MUTE(0), bits);
11945 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11946 AMP_IN_MUTE(0), bits);
11947}
11948
11949static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11950{
11951 unsigned int present;
11952
11953 present = snd_hda_codec_read(codec, 0x18, 0,
11954 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11955 snd_hda_codec_write(codec, 0x23, 0,
11956 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
11957}
11958
11959static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11960{
11961 unsigned int present;
11962
11963 present = snd_hda_codec_read(codec, 0x18, 0,
11964 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11965 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11966 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
11967 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11968 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
11969}
11970
11971/* unsolicited event for HP jack sensing */
11972static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11973 unsigned int res)
11974{
11975 if ((res >> 26) == ALC880_HP_EVENT)
11976 alc269_speaker_automute(codec);
11977
11978 if ((res >> 26) == ALC880_MIC_EVENT)
11979 alc269_eeepc_dmic_automute(codec);
11980}
11981
11982static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11983{
11984 alc269_speaker_automute(codec);
11985 alc269_eeepc_dmic_automute(codec);
11986}
11987
11988/* unsolicited event for HP jack sensing */
11989static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
11990 unsigned int res)
11991{
11992 if ((res >> 26) == ALC880_HP_EVENT)
11993 alc269_speaker_automute(codec);
11994
11995 if ((res >> 26) == ALC880_MIC_EVENT)
11996 alc269_eeepc_amic_automute(codec);
11997}
11998
11999static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12000{
12001 alc269_speaker_automute(codec);
12002 alc269_eeepc_amic_automute(codec);
12003}
12004
Kailang Yangf6a92242007-12-13 16:52:54 +010012005/*
12006 * generic initialization of ADC, input mixers and output mixers
12007 */
12008static struct hda_verb alc269_init_verbs[] = {
12009 /*
12010 * Unmute ADC0 and set the default input to mic-in
12011 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012012 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012013
12014 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12015 * analog-loopback mixer widget
12016 * Note: PASD motherboards uses the Line In 2 as the input for
12017 * front panel mic (mic 2)
12018 */
12019 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12022 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12023 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12024 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12025
12026 /*
12027 * Set up output mixers (0x0c - 0x0e)
12028 */
12029 /* set vol=0 to output mixers */
12030 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12031 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12032
12033 /* set up input amps for analog loopback */
12034 /* Amp Indices: DAC = 0, mixer = 1 */
12035 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12037 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12038 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12039 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12040 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12041
12042 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12043 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12044 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12045 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12046 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12047 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12048 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12049
12050 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12052 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12053 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12054 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12055 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12056 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12057
12058 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12059 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12060
12061 /* FIXME: use matrix-type input source selection */
12062 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12063 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12065 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012066 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12067 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12068
12069 /* set EAPD */
12070 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12071 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12072 { }
12073};
12074
12075/* add playback controls from the parsed DAC table */
12076static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12077 const struct auto_pin_cfg *cfg)
12078{
12079 hda_nid_t nid;
12080 int err;
12081
12082 spec->multiout.num_dacs = 1; /* only use one dac */
12083 spec->multiout.dac_nids = spec->private_dac_nids;
12084 spec->multiout.dac_nids[0] = 2;
12085
12086 nid = cfg->line_out_pins[0];
12087 if (nid) {
12088 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12089 "Front Playback Volume",
12090 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12091 if (err < 0)
12092 return err;
12093 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12094 "Front Playback Switch",
12095 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12096 if (err < 0)
12097 return err;
12098 }
12099
12100 nid = cfg->speaker_pins[0];
12101 if (nid) {
12102 if (!cfg->line_out_pins[0]) {
12103 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12104 "Speaker Playback Volume",
12105 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12106 HDA_OUTPUT));
12107 if (err < 0)
12108 return err;
12109 }
12110 if (nid == 0x16) {
12111 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12112 "Speaker Playback Switch",
12113 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12114 HDA_OUTPUT));
12115 if (err < 0)
12116 return err;
12117 } else {
12118 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12119 "Speaker Playback Switch",
12120 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12121 HDA_OUTPUT));
12122 if (err < 0)
12123 return err;
12124 }
12125 }
12126 nid = cfg->hp_pins[0];
12127 if (nid) {
12128 /* spec->multiout.hp_nid = 2; */
12129 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12130 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12131 "Headphone Playback Volume",
12132 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12133 HDA_OUTPUT));
12134 if (err < 0)
12135 return err;
12136 }
12137 if (nid == 0x16) {
12138 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12139 "Headphone Playback Switch",
12140 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12141 HDA_OUTPUT));
12142 if (err < 0)
12143 return err;
12144 } else {
12145 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12146 "Headphone Playback Switch",
12147 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12148 HDA_OUTPUT));
12149 if (err < 0)
12150 return err;
12151 }
12152 }
12153 return 0;
12154}
12155
Takashi Iwaiee956e02008-10-31 17:16:31 +010012156static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12157 const struct auto_pin_cfg *cfg)
12158{
12159 int err;
12160
12161 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12162 if (err < 0)
12163 return err;
12164 /* digital-mic input pin is excluded in alc880_auto_create..()
12165 * because it's under 0x18
12166 */
12167 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12168 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
12169 struct hda_input_mux *imux = &spec->private_imux;
12170 imux->items[imux->num_items].label = "Int Mic";
12171 imux->items[imux->num_items].index = 0x05;
12172 imux->num_items++;
12173 }
12174 return 0;
12175}
Kailang Yangf6a92242007-12-13 16:52:54 +010012176
12177#ifdef CONFIG_SND_HDA_POWER_SAVE
12178#define alc269_loopbacks alc880_loopbacks
12179#endif
12180
12181/* pcm configuration: identiacal with ALC880 */
12182#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12183#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12184#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12185#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12186
12187/*
12188 * BIOS auto configuration
12189 */
12190static int alc269_parse_auto_config(struct hda_codec *codec)
12191{
12192 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020012193 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012194 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12195
12196 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12197 alc269_ignore);
12198 if (err < 0)
12199 return err;
12200
12201 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12202 if (err < 0)
12203 return err;
12204 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12205 if (err < 0)
12206 return err;
12207
12208 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12209
12210 if (spec->autocfg.dig_out_pin)
12211 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12212
Takashi Iwai603c4012008-07-30 15:01:44 +020012213 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012214 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012215
Takashi Iwai2005af22008-08-20 18:38:26 +020012216 /* create a beep mixer control if the pin 0x1d isn't assigned */
12217 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12218 if (spec->autocfg.input_pins[i] == 0x1d)
12219 break;
12220 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
Takashi Iwaid88897e2008-10-31 15:01:37 +010012221 add_mixer(spec, alc269_beep_mixer);
Takashi Iwai2005af22008-08-20 18:38:26 +020012222
Takashi Iwaid88897e2008-10-31 15:01:37 +010012223 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012224 spec->num_mux_defs = 1;
12225 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020012226 /* set default input source */
12227 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12228 0, AC_VERB_SET_CONNECT_SEL,
12229 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012230
12231 err = alc_auto_add_mic_boost(codec);
12232 if (err < 0)
12233 return err;
12234
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012235 if (!spec->cap_mixer)
12236 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012237
Takashi Iwaie044c392008-10-27 16:56:24 +010012238 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012239 return 1;
12240}
12241
12242#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12243#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12244#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12245
12246
12247/* init callback for auto-configuration model -- overriding the default init */
12248static void alc269_auto_init(struct hda_codec *codec)
12249{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012250 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012251 alc269_auto_init_multi_out(codec);
12252 alc269_auto_init_hp_out(codec);
12253 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012254 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012255 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012256}
12257
12258/*
12259 * configuration and preset
12260 */
12261static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012262 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012263 [ALC269_QUANTA_FL1] = "quanta",
12264 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012265 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012266 [ALC269_FUJITSU] = "fujitsu",
12267 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012268};
12269
12270static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012271 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012272 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12273 ALC269_ASUS_EEEPC_P703),
12274 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12275 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012276 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12277 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012278 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012279 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012280 {}
12281};
12282
12283static struct alc_config_preset alc269_presets[] = {
12284 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012285 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012286 .init_verbs = { alc269_init_verbs },
12287 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12288 .dac_nids = alc269_dac_nids,
12289 .hp_nid = 0x03,
12290 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12291 .channel_mode = alc269_modes,
12292 .input_mux = &alc269_capture_source,
12293 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012294 [ALC269_QUANTA_FL1] = {
12295 .mixers = { alc269_quanta_fl1_mixer },
12296 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12297 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12298 .dac_nids = alc269_dac_nids,
12299 .hp_nid = 0x03,
12300 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12301 .channel_mode = alc269_modes,
12302 .input_mux = &alc269_capture_source,
12303 .unsol_event = alc269_quanta_fl1_unsol_event,
12304 .init_hook = alc269_quanta_fl1_init_hook,
12305 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012306 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012307 .mixers = { alc269_eeepc_mixer },
12308 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012309 .init_verbs = { alc269_init_verbs,
12310 alc269_eeepc_amic_init_verbs },
12311 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12312 .dac_nids = alc269_dac_nids,
12313 .hp_nid = 0x03,
12314 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12315 .channel_mode = alc269_modes,
12316 .input_mux = &alc269_eeepc_amic_capture_source,
12317 .unsol_event = alc269_eeepc_amic_unsol_event,
12318 .init_hook = alc269_eeepc_amic_inithook,
12319 },
12320 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012321 .mixers = { alc269_eeepc_mixer },
12322 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012323 .init_verbs = { alc269_init_verbs,
12324 alc269_eeepc_dmic_init_verbs },
12325 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12326 .dac_nids = alc269_dac_nids,
12327 .hp_nid = 0x03,
12328 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12329 .channel_mode = alc269_modes,
12330 .input_mux = &alc269_eeepc_dmic_capture_source,
12331 .unsol_event = alc269_eeepc_dmic_unsol_event,
12332 .init_hook = alc269_eeepc_dmic_inithook,
12333 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012334 [ALC269_FUJITSU] = {
12335 .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer },
12336 .cap_mixer = alc269_epc_capture_mixer,
12337 .init_verbs = { alc269_init_verbs,
12338 alc269_eeepc_dmic_init_verbs },
12339 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12340 .dac_nids = alc269_dac_nids,
12341 .hp_nid = 0x03,
12342 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12343 .channel_mode = alc269_modes,
12344 .input_mux = &alc269_eeepc_dmic_capture_source,
12345 .unsol_event = alc269_eeepc_dmic_unsol_event,
12346 .init_hook = alc269_eeepc_dmic_inithook,
12347 },
Tony Vroon64154832008-11-06 15:08:49 +000012348 [ALC269_LIFEBOOK] = {
12349 .mixers = { alc269_lifebook_mixer },
12350 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12351 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12352 .dac_nids = alc269_dac_nids,
12353 .hp_nid = 0x03,
12354 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12355 .channel_mode = alc269_modes,
12356 .input_mux = &alc269_capture_source,
12357 .unsol_event = alc269_lifebook_unsol_event,
12358 .init_hook = alc269_lifebook_init_hook,
12359 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012360};
12361
12362static int patch_alc269(struct hda_codec *codec)
12363{
12364 struct alc_spec *spec;
12365 int board_config;
12366 int err;
12367
12368 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12369 if (spec == NULL)
12370 return -ENOMEM;
12371
12372 codec->spec = spec;
12373
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012374 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12375
Kailang Yangf6a92242007-12-13 16:52:54 +010012376 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12377 alc269_models,
12378 alc269_cfg_tbl);
12379
12380 if (board_config < 0) {
12381 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12382 "trying auto-probe from BIOS...\n");
12383 board_config = ALC269_AUTO;
12384 }
12385
12386 if (board_config == ALC269_AUTO) {
12387 /* automatic parse from the BIOS config */
12388 err = alc269_parse_auto_config(codec);
12389 if (err < 0) {
12390 alc_free(codec);
12391 return err;
12392 } else if (!err) {
12393 printk(KERN_INFO
12394 "hda_codec: Cannot set up configuration "
12395 "from BIOS. Using base mode...\n");
12396 board_config = ALC269_BASIC;
12397 }
12398 }
12399
12400 if (board_config != ALC269_AUTO)
12401 setup_preset(spec, &alc269_presets[board_config]);
12402
12403 spec->stream_name_analog = "ALC269 Analog";
12404 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12405 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12406
12407 spec->stream_name_digital = "ALC269 Digital";
12408 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12409 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12410
12411 spec->adc_nids = alc269_adc_nids;
12412 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012413 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012414 if (!spec->cap_mixer)
12415 set_capture_mixer(spec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012416
12417 codec->patch_ops = alc_patch_ops;
12418 if (board_config == ALC269_AUTO)
12419 spec->init_hook = alc269_auto_init;
12420#ifdef CONFIG_SND_HDA_POWER_SAVE
12421 if (!spec->loopback.amplist)
12422 spec->loopback.amplist = alc269_loopbacks;
12423#endif
12424
12425 return 0;
12426}
12427
12428/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012429 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12430 */
12431
12432/*
12433 * set the path ways for 2 channel output
12434 * need to set the codec line out and mic 1 pin widgets to inputs
12435 */
12436static struct hda_verb alc861_threestack_ch2_init[] = {
12437 /* set pin widget 1Ah (line in) for input */
12438 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012439 /* set pin widget 18h (mic1/2) for input, for mic also enable
12440 * the vref
12441 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012442 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12443
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012444 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12445#if 0
12446 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12447 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12448#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012449 { } /* end */
12450};
12451/*
12452 * 6ch mode
12453 * need to set the codec line out and mic 1 pin widgets to outputs
12454 */
12455static struct hda_verb alc861_threestack_ch6_init[] = {
12456 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12457 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12458 /* set pin widget 18h (mic1) for output (CLFE)*/
12459 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12460
12461 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012462 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012463
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012464 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12465#if 0
12466 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12467 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12468#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012469 { } /* end */
12470};
12471
12472static struct hda_channel_mode alc861_threestack_modes[2] = {
12473 { 2, alc861_threestack_ch2_init },
12474 { 6, alc861_threestack_ch6_init },
12475};
Takashi Iwai22309c32006-08-09 16:57:28 +020012476/* Set mic1 as input and unmute the mixer */
12477static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12478 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12479 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12480 { } /* end */
12481};
12482/* Set mic1 as output and mute mixer */
12483static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12484 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12485 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12486 { } /* end */
12487};
12488
12489static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12490 { 2, alc861_uniwill_m31_ch2_init },
12491 { 4, alc861_uniwill_m31_ch4_init },
12492};
Kailang Yangdf694da2005-12-05 19:42:22 +010012493
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012494/* Set mic1 and line-in as input and unmute the mixer */
12495static struct hda_verb alc861_asus_ch2_init[] = {
12496 /* set pin widget 1Ah (line in) for input */
12497 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012498 /* set pin widget 18h (mic1/2) for input, for mic also enable
12499 * the vref
12500 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012501 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12502
12503 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12504#if 0
12505 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12506 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12507#endif
12508 { } /* end */
12509};
12510/* Set mic1 nad line-in as output and mute mixer */
12511static struct hda_verb alc861_asus_ch6_init[] = {
12512 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12513 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12514 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12515 /* set pin widget 18h (mic1) for output (CLFE)*/
12516 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12517 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12518 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12519 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12520
12521 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12522#if 0
12523 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12524 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12525#endif
12526 { } /* end */
12527};
12528
12529static struct hda_channel_mode alc861_asus_modes[2] = {
12530 { 2, alc861_asus_ch2_init },
12531 { 6, alc861_asus_ch6_init },
12532};
12533
Kailang Yangdf694da2005-12-05 19:42:22 +010012534/* patch-ALC861 */
12535
12536static struct snd_kcontrol_new alc861_base_mixer[] = {
12537 /* output mixer control */
12538 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12539 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12540 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12541 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12542 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12543
12544 /*Input mixer control */
12545 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12546 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12547 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12548 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12549 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12550 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12552 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12553 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12554 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012555
Kailang Yangdf694da2005-12-05 19:42:22 +010012556 { } /* end */
12557};
12558
12559static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12560 /* output mixer control */
12561 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12562 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12563 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12564 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12565 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12566
12567 /* Input mixer control */
12568 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12569 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12570 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12571 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12572 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12573 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12575 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12576 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12577 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012578
Kailang Yangdf694da2005-12-05 19:42:22 +010012579 {
12580 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12581 .name = "Channel Mode",
12582 .info = alc_ch_mode_info,
12583 .get = alc_ch_mode_get,
12584 .put = alc_ch_mode_put,
12585 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12586 },
12587 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012588};
12589
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012590static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012591 /* output mixer control */
12592 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12594 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012595
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012596 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012597};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012598
Takashi Iwai22309c32006-08-09 16:57:28 +020012599static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12600 /* output mixer control */
12601 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12602 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12603 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12604 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12605 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12606
12607 /* Input mixer control */
12608 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12609 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12610 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12611 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12612 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12613 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12615 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12616 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12617 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012618
Takashi Iwai22309c32006-08-09 16:57:28 +020012619 {
12620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12621 .name = "Channel Mode",
12622 .info = alc_ch_mode_info,
12623 .get = alc_ch_mode_get,
12624 .put = alc_ch_mode_put,
12625 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12626 },
12627 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012628};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012629
12630static struct snd_kcontrol_new alc861_asus_mixer[] = {
12631 /* output mixer control */
12632 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12633 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12634 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12635 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12636 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12637
12638 /* Input mixer control */
12639 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12640 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12641 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12642 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12643 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12644 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12646 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12647 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012648 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12649
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012650 {
12651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12652 .name = "Channel Mode",
12653 .info = alc_ch_mode_info,
12654 .get = alc_ch_mode_get,
12655 .put = alc_ch_mode_put,
12656 .private_value = ARRAY_SIZE(alc861_asus_modes),
12657 },
12658 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012659};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012660
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012661/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012662static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012663 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12664 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12665 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12666 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12667 { }
12668};
12669
Kailang Yangdf694da2005-12-05 19:42:22 +010012670/*
12671 * generic initialization of ADC, input mixers and output mixers
12672 */
12673static struct hda_verb alc861_base_init_verbs[] = {
12674 /*
12675 * Unmute ADC0 and set the default input to mic-in
12676 */
12677 /* port-A for surround (rear panel) */
12678 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12679 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
12680 /* port-B for mic-in (rear panel) with vref */
12681 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12682 /* port-C for line-in (rear panel) */
12683 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12684 /* port-D for Front */
12685 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12686 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12687 /* port-E for HP out (front panel) */
12688 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12689 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012690 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012691 /* port-F for mic-in (front panel) with vref */
12692 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12693 /* port-G for CLFE (rear panel) */
12694 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12695 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
12696 /* port-H for side (rear panel) */
12697 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12698 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
12699 /* CD-in */
12700 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12701 /* route front mic to ADC1*/
12702 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12703 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012704
Kailang Yangdf694da2005-12-05 19:42:22 +010012705 /* Unmute DAC0~3 & spdif out*/
12706 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12707 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12708 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12709 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012711
Kailang Yangdf694da2005-12-05 19:42:22 +010012712 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12713 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12714 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12715 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12716 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012717
Kailang Yangdf694da2005-12-05 19:42:22 +010012718 /* Unmute Stereo Mixer 15 */
12719 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12720 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12721 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012722 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012723
12724 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12725 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12726 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12727 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12729 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12730 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12731 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012732 /* hp used DAC 3 (Front) */
12733 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012734 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12735
12736 { }
12737};
12738
12739static struct hda_verb alc861_threestack_init_verbs[] = {
12740 /*
12741 * Unmute ADC0 and set the default input to mic-in
12742 */
12743 /* port-A for surround (rear panel) */
12744 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12745 /* port-B for mic-in (rear panel) with vref */
12746 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12747 /* port-C for line-in (rear panel) */
12748 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12749 /* port-D for Front */
12750 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12751 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12752 /* port-E for HP out (front panel) */
12753 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12754 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012755 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012756 /* port-F for mic-in (front panel) with vref */
12757 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12758 /* port-G for CLFE (rear panel) */
12759 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12760 /* port-H for side (rear panel) */
12761 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12762 /* CD-in */
12763 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12764 /* route front mic to ADC1*/
12765 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12766 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12767 /* Unmute DAC0~3 & spdif out*/
12768 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12769 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12770 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12771 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12772 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012773
Kailang Yangdf694da2005-12-05 19:42:22 +010012774 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12775 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12776 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12777 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12778 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012779
Kailang Yangdf694da2005-12-05 19:42:22 +010012780 /* Unmute Stereo Mixer 15 */
12781 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12782 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12783 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012784 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012785
12786 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12787 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12788 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12789 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12790 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12791 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12792 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12793 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012794 /* hp used DAC 3 (Front) */
12795 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012796 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12797 { }
12798};
Takashi Iwai22309c32006-08-09 16:57:28 +020012799
12800static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
12801 /*
12802 * Unmute ADC0 and set the default input to mic-in
12803 */
12804 /* port-A for surround (rear panel) */
12805 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12806 /* port-B for mic-in (rear panel) with vref */
12807 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12808 /* port-C for line-in (rear panel) */
12809 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12810 /* port-D for Front */
12811 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12812 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12813 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012814 /* this has to be set to VREF80 */
12815 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012816 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012817 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012818 /* port-F for mic-in (front panel) with vref */
12819 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12820 /* port-G for CLFE (rear panel) */
12821 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12822 /* port-H for side (rear panel) */
12823 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12824 /* CD-in */
12825 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12826 /* route front mic to ADC1*/
12827 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12828 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12829 /* Unmute DAC0~3 & spdif out*/
12830 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12831 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12832 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12833 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12834 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012835
Takashi Iwai22309c32006-08-09 16:57:28 +020012836 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12837 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12838 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12839 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12840 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012841
Takashi Iwai22309c32006-08-09 16:57:28 +020012842 /* Unmute Stereo Mixer 15 */
12843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012846 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012847
12848 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12849 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12850 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12851 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12853 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12854 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12855 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012856 /* hp used DAC 3 (Front) */
12857 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012858 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12859 { }
12860};
12861
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012862static struct hda_verb alc861_asus_init_verbs[] = {
12863 /*
12864 * Unmute ADC0 and set the default input to mic-in
12865 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012866 /* port-A for surround (rear panel)
12867 * according to codec#0 this is the HP jack
12868 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012869 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12870 /* route front PCM to HP */
12871 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12872 /* port-B for mic-in (rear panel) with vref */
12873 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12874 /* port-C for line-in (rear panel) */
12875 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12876 /* port-D for Front */
12877 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12878 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12879 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012880 /* this has to be set to VREF80 */
12881 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012882 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012883 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012884 /* port-F for mic-in (front panel) with vref */
12885 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12886 /* port-G for CLFE (rear panel) */
12887 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12888 /* port-H for side (rear panel) */
12889 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12890 /* CD-in */
12891 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12892 /* route front mic to ADC1*/
12893 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12894 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12895 /* Unmute DAC0~3 & spdif out*/
12896 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12897 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12898 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12899 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12900 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12901 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12902 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12903 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12904 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12905 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012906
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012907 /* Unmute Stereo Mixer 15 */
12908 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12909 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12910 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012912
12913 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12914 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12915 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12916 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12917 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12918 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12919 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12920 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012921 /* hp used DAC 3 (Front) */
12922 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012923 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12924 { }
12925};
12926
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012927/* additional init verbs for ASUS laptops */
12928static struct hda_verb alc861_asus_laptop_init_verbs[] = {
12929 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
12930 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
12931 { }
12932};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012933
Kailang Yangdf694da2005-12-05 19:42:22 +010012934/*
12935 * generic initialization of ADC, input mixers and output mixers
12936 */
12937static struct hda_verb alc861_auto_init_verbs[] = {
12938 /*
12939 * Unmute ADC0 and set the default input to mic-in
12940 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012941 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010012942 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012943
Kailang Yangdf694da2005-12-05 19:42:22 +010012944 /* Unmute DAC0~3 & spdif out*/
12945 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12946 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12947 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12948 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12949 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012950
Kailang Yangdf694da2005-12-05 19:42:22 +010012951 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12952 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12953 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12954 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12955 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012956
Kailang Yangdf694da2005-12-05 19:42:22 +010012957 /* Unmute Stereo Mixer 15 */
12958 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12960 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
12962
12963 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12964 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12965 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12966 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12967 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12968 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12969 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12970 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12971
12972 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12973 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012974 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12975 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012976 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12977 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012978 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12979 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012980
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012981 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012982
12983 { }
12984};
12985
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012986static struct hda_verb alc861_toshiba_init_verbs[] = {
12987 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012988
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012989 { }
12990};
12991
12992/* toggle speaker-output according to the hp-jack state */
12993static void alc861_toshiba_automute(struct hda_codec *codec)
12994{
12995 unsigned int present;
12996
12997 present = snd_hda_codec_read(codec, 0x0f, 0,
12998 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012999 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13000 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13001 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13002 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013003}
13004
13005static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13006 unsigned int res)
13007{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013008 if ((res >> 26) == ALC880_HP_EVENT)
13009 alc861_toshiba_automute(codec);
13010}
13011
Kailang Yangdf694da2005-12-05 19:42:22 +010013012/* pcm configuration: identiacal with ALC880 */
13013#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13014#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13015#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13016#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13017
13018
13019#define ALC861_DIGOUT_NID 0x07
13020
13021static struct hda_channel_mode alc861_8ch_modes[1] = {
13022 { 8, NULL }
13023};
13024
13025static hda_nid_t alc861_dac_nids[4] = {
13026 /* front, surround, clfe, side */
13027 0x03, 0x06, 0x05, 0x04
13028};
13029
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013030static hda_nid_t alc660_dac_nids[3] = {
13031 /* front, clfe, surround */
13032 0x03, 0x05, 0x06
13033};
13034
Kailang Yangdf694da2005-12-05 19:42:22 +010013035static hda_nid_t alc861_adc_nids[1] = {
13036 /* ADC0-2 */
13037 0x08,
13038};
13039
13040static struct hda_input_mux alc861_capture_source = {
13041 .num_items = 5,
13042 .items = {
13043 { "Mic", 0x0 },
13044 { "Front Mic", 0x3 },
13045 { "Line", 0x1 },
13046 { "CD", 0x4 },
13047 { "Mixer", 0x5 },
13048 },
13049};
13050
13051/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013052static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13053 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013054{
13055 int i;
13056 hda_nid_t nid;
13057
13058 spec->multiout.dac_nids = spec->private_dac_nids;
13059 for (i = 0; i < cfg->line_outs; i++) {
13060 nid = cfg->line_out_pins[i];
13061 if (nid) {
13062 if (i >= ARRAY_SIZE(alc861_dac_nids))
13063 continue;
13064 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13065 }
13066 }
13067 spec->multiout.num_dacs = cfg->line_outs;
13068 return 0;
13069}
13070
13071/* add playback controls from the parsed DAC table */
13072static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13073 const struct auto_pin_cfg *cfg)
13074{
13075 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013076 static const char *chname[4] = {
13077 "Front", "Surround", NULL /*CLFE*/, "Side"
13078 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013079 hda_nid_t nid;
13080 int i, idx, err;
13081
13082 for (i = 0; i < cfg->line_outs; i++) {
13083 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013084 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013085 continue;
13086 if (nid == 0x05) {
13087 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013088 err = add_control(spec, ALC_CTL_BIND_MUTE,
13089 "Center Playback Switch",
13090 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13091 HDA_OUTPUT));
13092 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013093 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013094 err = add_control(spec, ALC_CTL_BIND_MUTE,
13095 "LFE Playback Switch",
13096 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13097 HDA_OUTPUT));
13098 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013099 return err;
13100 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013101 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13102 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013103 if (nid == alc861_dac_nids[idx])
13104 break;
13105 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013106 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13107 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13108 HDA_OUTPUT));
13109 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013110 return err;
13111 }
13112 }
13113 return 0;
13114}
13115
13116static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13117{
13118 int err;
13119 hda_nid_t nid;
13120
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013121 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013122 return 0;
13123
13124 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13125 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013126 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13127 "Headphone Playback Switch",
13128 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13129 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013130 return err;
13131 spec->multiout.hp_nid = nid;
13132 }
13133 return 0;
13134}
13135
13136/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013137static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13138 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013139{
Kailang Yangdf694da2005-12-05 19:42:22 +010013140 struct hda_input_mux *imux = &spec->private_imux;
13141 int i, err, idx, idx1;
13142
13143 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013144 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013145 case 0x0c:
13146 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013147 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013148 break;
13149 case 0x0f:
13150 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013151 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013152 break;
13153 case 0x0d:
13154 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013155 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013156 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013157 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013158 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013159 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013160 break;
13161 case 0x11:
13162 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013163 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013164 break;
13165 default:
13166 continue;
13167 }
13168
Takashi Iwai4a471b72005-12-07 13:56:29 +010013169 err = new_analog_input(spec, cfg->input_pins[i],
13170 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013171 if (err < 0)
13172 return err;
13173
Takashi Iwai4a471b72005-12-07 13:56:29 +010013174 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013175 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013176 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013177 }
13178 return 0;
13179}
13180
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013181static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13182 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013183 int pin_type, int dac_idx)
13184{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013185 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13186 pin_type);
13187 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13188 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013189}
13190
13191static void alc861_auto_init_multi_out(struct hda_codec *codec)
13192{
13193 struct alc_spec *spec = codec->spec;
13194 int i;
13195
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013196 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013197 for (i = 0; i < spec->autocfg.line_outs; i++) {
13198 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013199 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013200 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013201 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013202 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013203 }
13204}
13205
13206static void alc861_auto_init_hp_out(struct hda_codec *codec)
13207{
13208 struct alc_spec *spec = codec->spec;
13209 hda_nid_t pin;
13210
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013211 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013212 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013213 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13214 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013215 pin = spec->autocfg.speaker_pins[0];
13216 if (pin)
13217 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013218}
13219
13220static void alc861_auto_init_analog_input(struct hda_codec *codec)
13221{
13222 struct alc_spec *spec = codec->spec;
13223 int i;
13224
13225 for (i = 0; i < AUTO_PIN_LAST; i++) {
13226 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013227 if (nid >= 0x0c && nid <= 0x11) {
13228 snd_hda_codec_write(codec, nid, 0,
13229 AC_VERB_SET_PIN_WIDGET_CONTROL,
13230 i <= AUTO_PIN_FRONT_MIC ?
13231 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013232 }
13233 }
13234}
13235
13236/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013237/* return 1 if successful, 0 if the proper config is not found,
13238 * or a negative error code
13239 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013240static int alc861_parse_auto_config(struct hda_codec *codec)
13241{
13242 struct alc_spec *spec = codec->spec;
13243 int err;
13244 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13245
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013246 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13247 alc861_ignore);
13248 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013249 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013250 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013251 return 0; /* can't find valid BIOS pin config */
13252
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013253 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13254 if (err < 0)
13255 return err;
13256 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13257 if (err < 0)
13258 return err;
13259 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13260 if (err < 0)
13261 return err;
13262 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13263 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013264 return err;
13265
13266 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13267
13268 if (spec->autocfg.dig_out_pin)
13269 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13270
Takashi Iwai603c4012008-07-30 15:01:44 +020013271 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013272 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013273
Takashi Iwaid88897e2008-10-31 15:01:37 +010013274 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013275
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013276 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010013277 spec->input_mux = &spec->private_imux;
13278
13279 spec->adc_nids = alc861_adc_nids;
13280 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013281 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013282
Takashi Iwaie044c392008-10-27 16:56:24 +010013283 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013284 return 1;
13285}
13286
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013287/* additional initialization for auto-configuration model */
13288static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013289{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013290 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013291 alc861_auto_init_multi_out(codec);
13292 alc861_auto_init_hp_out(codec);
13293 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013294 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013295 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013296}
13297
Takashi Iwaicb53c622007-08-10 17:21:45 +020013298#ifdef CONFIG_SND_HDA_POWER_SAVE
13299static struct hda_amp_list alc861_loopbacks[] = {
13300 { 0x15, HDA_INPUT, 0 },
13301 { 0x15, HDA_INPUT, 1 },
13302 { 0x15, HDA_INPUT, 2 },
13303 { 0x15, HDA_INPUT, 3 },
13304 { } /* end */
13305};
13306#endif
13307
Kailang Yangdf694da2005-12-05 19:42:22 +010013308
13309/*
13310 * configuration and preset
13311 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013312static const char *alc861_models[ALC861_MODEL_LAST] = {
13313 [ALC861_3ST] = "3stack",
13314 [ALC660_3ST] = "3stack-660",
13315 [ALC861_3ST_DIG] = "3stack-dig",
13316 [ALC861_6ST_DIG] = "6stack-dig",
13317 [ALC861_UNIWILL_M31] = "uniwill-m31",
13318 [ALC861_TOSHIBA] = "toshiba",
13319 [ALC861_ASUS] = "asus",
13320 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13321 [ALC861_AUTO] = "auto",
13322};
13323
13324static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013325 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013326 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13327 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13328 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013329 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013330 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013331 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013332 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13333 * Any other models that need this preset?
13334 */
13335 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013336 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13337 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013338 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13339 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13340 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13341 /* FIXME: the below seems conflict */
13342 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13343 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13344 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013345 {}
13346};
13347
13348static struct alc_config_preset alc861_presets[] = {
13349 [ALC861_3ST] = {
13350 .mixers = { alc861_3ST_mixer },
13351 .init_verbs = { alc861_threestack_init_verbs },
13352 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13353 .dac_nids = alc861_dac_nids,
13354 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13355 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013356 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013357 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13358 .adc_nids = alc861_adc_nids,
13359 .input_mux = &alc861_capture_source,
13360 },
13361 [ALC861_3ST_DIG] = {
13362 .mixers = { alc861_base_mixer },
13363 .init_verbs = { alc861_threestack_init_verbs },
13364 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13365 .dac_nids = alc861_dac_nids,
13366 .dig_out_nid = ALC861_DIGOUT_NID,
13367 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13368 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013369 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013370 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13371 .adc_nids = alc861_adc_nids,
13372 .input_mux = &alc861_capture_source,
13373 },
13374 [ALC861_6ST_DIG] = {
13375 .mixers = { alc861_base_mixer },
13376 .init_verbs = { alc861_base_init_verbs },
13377 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13378 .dac_nids = alc861_dac_nids,
13379 .dig_out_nid = ALC861_DIGOUT_NID,
13380 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13381 .channel_mode = alc861_8ch_modes,
13382 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13383 .adc_nids = alc861_adc_nids,
13384 .input_mux = &alc861_capture_source,
13385 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013386 [ALC660_3ST] = {
13387 .mixers = { alc861_3ST_mixer },
13388 .init_verbs = { alc861_threestack_init_verbs },
13389 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13390 .dac_nids = alc660_dac_nids,
13391 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13392 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013393 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013394 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13395 .adc_nids = alc861_adc_nids,
13396 .input_mux = &alc861_capture_source,
13397 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013398 [ALC861_UNIWILL_M31] = {
13399 .mixers = { alc861_uniwill_m31_mixer },
13400 .init_verbs = { alc861_uniwill_m31_init_verbs },
13401 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13402 .dac_nids = alc861_dac_nids,
13403 .dig_out_nid = ALC861_DIGOUT_NID,
13404 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13405 .channel_mode = alc861_uniwill_m31_modes,
13406 .need_dac_fix = 1,
13407 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13408 .adc_nids = alc861_adc_nids,
13409 .input_mux = &alc861_capture_source,
13410 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013411 [ALC861_TOSHIBA] = {
13412 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013413 .init_verbs = { alc861_base_init_verbs,
13414 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013415 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13416 .dac_nids = alc861_dac_nids,
13417 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13418 .channel_mode = alc883_3ST_2ch_modes,
13419 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13420 .adc_nids = alc861_adc_nids,
13421 .input_mux = &alc861_capture_source,
13422 .unsol_event = alc861_toshiba_unsol_event,
13423 .init_hook = alc861_toshiba_automute,
13424 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013425 [ALC861_ASUS] = {
13426 .mixers = { alc861_asus_mixer },
13427 .init_verbs = { alc861_asus_init_verbs },
13428 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13429 .dac_nids = alc861_dac_nids,
13430 .dig_out_nid = ALC861_DIGOUT_NID,
13431 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13432 .channel_mode = alc861_asus_modes,
13433 .need_dac_fix = 1,
13434 .hp_nid = 0x06,
13435 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13436 .adc_nids = alc861_adc_nids,
13437 .input_mux = &alc861_capture_source,
13438 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013439 [ALC861_ASUS_LAPTOP] = {
13440 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13441 .init_verbs = { alc861_asus_init_verbs,
13442 alc861_asus_laptop_init_verbs },
13443 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13444 .dac_nids = alc861_dac_nids,
13445 .dig_out_nid = ALC861_DIGOUT_NID,
13446 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13447 .channel_mode = alc883_3ST_2ch_modes,
13448 .need_dac_fix = 1,
13449 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13450 .adc_nids = alc861_adc_nids,
13451 .input_mux = &alc861_capture_source,
13452 },
13453};
Kailang Yangdf694da2005-12-05 19:42:22 +010013454
13455
13456static int patch_alc861(struct hda_codec *codec)
13457{
13458 struct alc_spec *spec;
13459 int board_config;
13460 int err;
13461
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013462 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013463 if (spec == NULL)
13464 return -ENOMEM;
13465
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013466 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013467
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013468 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13469 alc861_models,
13470 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013471
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013472 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013473 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13474 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013475 board_config = ALC861_AUTO;
13476 }
13477
13478 if (board_config == ALC861_AUTO) {
13479 /* automatic parse from the BIOS config */
13480 err = alc861_parse_auto_config(codec);
13481 if (err < 0) {
13482 alc_free(codec);
13483 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013484 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013485 printk(KERN_INFO
13486 "hda_codec: Cannot set up configuration "
13487 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013488 board_config = ALC861_3ST_DIG;
13489 }
13490 }
13491
13492 if (board_config != ALC861_AUTO)
13493 setup_preset(spec, &alc861_presets[board_config]);
13494
13495 spec->stream_name_analog = "ALC861 Analog";
13496 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13497 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13498
13499 spec->stream_name_digital = "ALC861 Digital";
13500 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13501 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13502
Takashi Iwai2134ea42008-01-10 16:53:55 +010013503 spec->vmaster_nid = 0x03;
13504
Kailang Yangdf694da2005-12-05 19:42:22 +010013505 codec->patch_ops = alc_patch_ops;
13506 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013507 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013508#ifdef CONFIG_SND_HDA_POWER_SAVE
13509 if (!spec->loopback.amplist)
13510 spec->loopback.amplist = alc861_loopbacks;
13511#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013512
Kailang Yangdf694da2005-12-05 19:42:22 +010013513 return 0;
13514}
13515
13516/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013517 * ALC861-VD support
13518 *
13519 * Based on ALC882
13520 *
13521 * In addition, an independent DAC
13522 */
13523#define ALC861VD_DIGOUT_NID 0x06
13524
13525static hda_nid_t alc861vd_dac_nids[4] = {
13526 /* front, surr, clfe, side surr */
13527 0x02, 0x03, 0x04, 0x05
13528};
13529
13530/* dac_nids for ALC660vd are in a different order - according to
13531 * Realtek's driver.
13532 * This should probably tesult in a different mixer for 6stack models
13533 * of ALC660vd codecs, but for now there is only 3stack mixer
13534 * - and it is the same as in 861vd.
13535 * adc_nids in ALC660vd are (is) the same as in 861vd
13536 */
13537static hda_nid_t alc660vd_dac_nids[3] = {
13538 /* front, rear, clfe, rear_surr */
13539 0x02, 0x04, 0x03
13540};
13541
13542static hda_nid_t alc861vd_adc_nids[1] = {
13543 /* ADC0 */
13544 0x09,
13545};
13546
Takashi Iwaie1406342008-02-11 18:32:32 +010013547static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13548
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013549/* input MUX */
13550/* FIXME: should be a matrix-type input source selection */
13551static struct hda_input_mux alc861vd_capture_source = {
13552 .num_items = 4,
13553 .items = {
13554 { "Mic", 0x0 },
13555 { "Front Mic", 0x1 },
13556 { "Line", 0x2 },
13557 { "CD", 0x4 },
13558 },
13559};
13560
Kailang Yang272a5272007-05-14 11:00:38 +020013561static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013562 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013563 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013564 { "Ext Mic", 0x0 },
13565 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013566 },
13567};
13568
Kailang Yangd1a991a2007-08-15 16:21:59 +020013569static struct hda_input_mux alc861vd_hp_capture_source = {
13570 .num_items = 2,
13571 .items = {
13572 { "Front Mic", 0x0 },
13573 { "ATAPI Mic", 0x1 },
13574 },
13575};
13576
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013577/*
13578 * 2ch mode
13579 */
13580static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13581 { 2, NULL }
13582};
13583
13584/*
13585 * 6ch mode
13586 */
13587static struct hda_verb alc861vd_6stack_ch6_init[] = {
13588 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13589 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13590 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13591 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13592 { } /* end */
13593};
13594
13595/*
13596 * 8ch mode
13597 */
13598static struct hda_verb alc861vd_6stack_ch8_init[] = {
13599 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13600 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13601 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13602 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13603 { } /* end */
13604};
13605
13606static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13607 { 6, alc861vd_6stack_ch6_init },
13608 { 8, alc861vd_6stack_ch8_init },
13609};
13610
13611static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13612 {
13613 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13614 .name = "Channel Mode",
13615 .info = alc_ch_mode_info,
13616 .get = alc_ch_mode_get,
13617 .put = alc_ch_mode_put,
13618 },
13619 { } /* end */
13620};
13621
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013622/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13623 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13624 */
13625static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13626 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13627 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13628
13629 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13630 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13631
13632 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13633 HDA_OUTPUT),
13634 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13635 HDA_OUTPUT),
13636 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13637 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13638
13639 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13640 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13641
13642 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13643
13644 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13647
13648 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13649 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13650 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13651
13652 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13653 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13654
13655 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13656 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13657
13658 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13659 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13660
13661 { } /* end */
13662};
13663
13664static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13665 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13666 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13667
13668 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13669
13670 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13672 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13673
13674 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13675 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13676 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13677
13678 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13679 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13680
13681 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13682 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13683
13684 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13685 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13686
13687 { } /* end */
13688};
13689
Kailang Yangbdd148a2007-05-08 15:19:08 +020013690static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
13691 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13692 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
13693 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13694
13695 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13696
13697 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13698 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13699 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13700
13701 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13702 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13703 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13704
13705 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13706 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13707
13708 { } /* end */
13709};
13710
Tobin Davisb419f342008-03-07 11:57:51 +010013711/* Pin assignment: Speaker=0x14, HP = 0x15,
13712 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020013713 */
13714static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010013715 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13716 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013717 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13718 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010013719 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13720 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13721 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13722 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13723 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13724 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13725 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
13726 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013727 { } /* end */
13728};
13729
Kailang Yangd1a991a2007-08-15 16:21:59 +020013730/* Pin assignment: Speaker=0x14, Line-out = 0x15,
13731 * Front Mic=0x18, ATAPI Mic = 0x19,
13732 */
13733static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
13734 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13735 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13736 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13737 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
13738 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13739 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13740 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13741 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013742
Kailang Yangd1a991a2007-08-15 16:21:59 +020013743 { } /* end */
13744};
13745
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013746/*
13747 * generic initialization of ADC, input mixers and output mixers
13748 */
13749static struct hda_verb alc861vd_volume_init_verbs[] = {
13750 /*
13751 * Unmute ADC0 and set the default input to mic-in
13752 */
13753 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13754 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13755
13756 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
13757 * the analog-loopback mixer widget
13758 */
13759 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13762 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013765
13766 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020013767 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013771
13772 /*
13773 * Set up output mixers (0x02 - 0x05)
13774 */
13775 /* set vol=0 to output mixers */
13776 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13777 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13778 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13779 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13780
13781 /* set up input amps for analog loopback */
13782 /* Amp Indices: DAC = 0, mixer = 1 */
13783 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13784 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13785 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13786 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13787 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13788 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13789 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13790 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13791
13792 { }
13793};
13794
13795/*
13796 * 3-stack pin configuration:
13797 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13798 */
13799static struct hda_verb alc861vd_3stack_init_verbs[] = {
13800 /*
13801 * Set pin mode and muting
13802 */
13803 /* set front pin widgets 0x14 for output */
13804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13806 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13807
13808 /* Mic (rear) pin: input vref at 80% */
13809 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13810 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13811 /* Front Mic pin: input vref at 80% */
13812 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13814 /* Line In pin: input */
13815 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13816 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13817 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13818 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13819 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13820 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13821 /* CD pin widget for input */
13822 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13823
13824 { }
13825};
13826
13827/*
13828 * 6-stack pin configuration:
13829 */
13830static struct hda_verb alc861vd_6stack_init_verbs[] = {
13831 /*
13832 * Set pin mode and muting
13833 */
13834 /* set front pin widgets 0x14 for output */
13835 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13836 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13837 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13838
13839 /* Rear Pin: output 1 (0x0d) */
13840 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13841 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13842 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13843 /* CLFE Pin: output 2 (0x0e) */
13844 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13845 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13846 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13847 /* Side Pin: output 3 (0x0f) */
13848 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13849 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13850 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13851
13852 /* Mic (rear) pin: input vref at 80% */
13853 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13854 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13855 /* Front Mic pin: input vref at 80% */
13856 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13857 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13858 /* Line In pin: input */
13859 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13860 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13861 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13862 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13863 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13864 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13865 /* CD pin widget for input */
13866 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13867
13868 { }
13869};
13870
Kailang Yangbdd148a2007-05-08 15:19:08 +020013871static struct hda_verb alc861vd_eapd_verbs[] = {
13872 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13873 { }
13874};
13875
Kailang Yangf9423e72008-05-27 12:32:25 +020013876static struct hda_verb alc660vd_eapd_verbs[] = {
13877 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13878 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13879 { }
13880};
13881
Kailang Yangbdd148a2007-05-08 15:19:08 +020013882static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
13883 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13884 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
13886 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020013887 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020013888 {}
13889};
13890
13891/* toggle speaker-output according to the hp-jack state */
13892static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
13893{
13894 unsigned int present;
13895 unsigned char bits;
13896
13897 present = snd_hda_codec_read(codec, 0x1b, 0,
13898 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013899 bits = present ? HDA_AMP_MUTE : 0;
13900 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13901 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013902}
13903
13904static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
13905{
13906 unsigned int present;
13907 unsigned char bits;
13908
13909 present = snd_hda_codec_read(codec, 0x18, 0,
13910 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013911 bits = present ? HDA_AMP_MUTE : 0;
13912 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
13913 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013914}
13915
13916static void alc861vd_lenovo_automute(struct hda_codec *codec)
13917{
13918 alc861vd_lenovo_hp_automute(codec);
13919 alc861vd_lenovo_mic_automute(codec);
13920}
13921
13922static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
13923 unsigned int res)
13924{
13925 switch (res >> 26) {
13926 case ALC880_HP_EVENT:
13927 alc861vd_lenovo_hp_automute(codec);
13928 break;
13929 case ALC880_MIC_EVENT:
13930 alc861vd_lenovo_mic_automute(codec);
13931 break;
13932 }
13933}
13934
Kailang Yang272a5272007-05-14 11:00:38 +020013935static struct hda_verb alc861vd_dallas_verbs[] = {
13936 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13937 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13938 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13939 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13940
13941 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13942 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13944 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13946 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13947 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13948 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013949
Kailang Yang272a5272007-05-14 11:00:38 +020013950 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13951 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13952 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13953 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13954 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13955 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13956 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13957 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13958
13959 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13960 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13961 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13962 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13963 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13964 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13965 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13966 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13967
13968 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13972
13973 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013974 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020013975 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13976
13977 { } /* end */
13978};
13979
13980/* toggle speaker-output according to the hp-jack state */
13981static void alc861vd_dallas_automute(struct hda_codec *codec)
13982{
13983 unsigned int present;
13984
13985 present = snd_hda_codec_read(codec, 0x15, 0,
13986 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013987 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13988 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020013989}
13990
13991static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
13992{
13993 if ((res >> 26) == ALC880_HP_EVENT)
13994 alc861vd_dallas_automute(codec);
13995}
13996
Takashi Iwaicb53c622007-08-10 17:21:45 +020013997#ifdef CONFIG_SND_HDA_POWER_SAVE
13998#define alc861vd_loopbacks alc880_loopbacks
13999#endif
14000
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014001/* pcm configuration: identiacal with ALC880 */
14002#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14003#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14004#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14005#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14006
14007/*
14008 * configuration and preset
14009 */
14010static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14011 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014012 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014013 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014014 [ALC861VD_3ST] = "3stack",
14015 [ALC861VD_3ST_DIG] = "3stack-digout",
14016 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014017 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014018 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014019 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014020 [ALC861VD_AUTO] = "auto",
14021};
14022
14023static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014024 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14025 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014026 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014027 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014028 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014029 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014030 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014031 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014032 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014033 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014034 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014035 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014036 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014037 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
14038 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020014039 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014040 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014041 {}
14042};
14043
14044static struct alc_config_preset alc861vd_presets[] = {
14045 [ALC660VD_3ST] = {
14046 .mixers = { alc861vd_3st_mixer },
14047 .init_verbs = { alc861vd_volume_init_verbs,
14048 alc861vd_3stack_init_verbs },
14049 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14050 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014051 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14052 .channel_mode = alc861vd_3stack_2ch_modes,
14053 .input_mux = &alc861vd_capture_source,
14054 },
Mike Crash6963f842007-06-25 12:12:51 +020014055 [ALC660VD_3ST_DIG] = {
14056 .mixers = { alc861vd_3st_mixer },
14057 .init_verbs = { alc861vd_volume_init_verbs,
14058 alc861vd_3stack_init_verbs },
14059 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14060 .dac_nids = alc660vd_dac_nids,
14061 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014062 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14063 .channel_mode = alc861vd_3stack_2ch_modes,
14064 .input_mux = &alc861vd_capture_source,
14065 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014066 [ALC861VD_3ST] = {
14067 .mixers = { alc861vd_3st_mixer },
14068 .init_verbs = { alc861vd_volume_init_verbs,
14069 alc861vd_3stack_init_verbs },
14070 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14071 .dac_nids = alc861vd_dac_nids,
14072 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14073 .channel_mode = alc861vd_3stack_2ch_modes,
14074 .input_mux = &alc861vd_capture_source,
14075 },
14076 [ALC861VD_3ST_DIG] = {
14077 .mixers = { alc861vd_3st_mixer },
14078 .init_verbs = { alc861vd_volume_init_verbs,
14079 alc861vd_3stack_init_verbs },
14080 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14081 .dac_nids = alc861vd_dac_nids,
14082 .dig_out_nid = ALC861VD_DIGOUT_NID,
14083 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14084 .channel_mode = alc861vd_3stack_2ch_modes,
14085 .input_mux = &alc861vd_capture_source,
14086 },
14087 [ALC861VD_6ST_DIG] = {
14088 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14089 .init_verbs = { alc861vd_volume_init_verbs,
14090 alc861vd_6stack_init_verbs },
14091 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14092 .dac_nids = alc861vd_dac_nids,
14093 .dig_out_nid = ALC861VD_DIGOUT_NID,
14094 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14095 .channel_mode = alc861vd_6stack_modes,
14096 .input_mux = &alc861vd_capture_source,
14097 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014098 [ALC861VD_LENOVO] = {
14099 .mixers = { alc861vd_lenovo_mixer },
14100 .init_verbs = { alc861vd_volume_init_verbs,
14101 alc861vd_3stack_init_verbs,
14102 alc861vd_eapd_verbs,
14103 alc861vd_lenovo_unsol_verbs },
14104 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14105 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014106 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14107 .channel_mode = alc861vd_3stack_2ch_modes,
14108 .input_mux = &alc861vd_capture_source,
14109 .unsol_event = alc861vd_lenovo_unsol_event,
14110 .init_hook = alc861vd_lenovo_automute,
14111 },
Kailang Yang272a5272007-05-14 11:00:38 +020014112 [ALC861VD_DALLAS] = {
14113 .mixers = { alc861vd_dallas_mixer },
14114 .init_verbs = { alc861vd_dallas_verbs },
14115 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14116 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014117 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14118 .channel_mode = alc861vd_3stack_2ch_modes,
14119 .input_mux = &alc861vd_dallas_capture_source,
14120 .unsol_event = alc861vd_dallas_unsol_event,
14121 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014122 },
14123 [ALC861VD_HP] = {
14124 .mixers = { alc861vd_hp_mixer },
14125 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14126 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14127 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014128 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014129 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14130 .channel_mode = alc861vd_3stack_2ch_modes,
14131 .input_mux = &alc861vd_hp_capture_source,
14132 .unsol_event = alc861vd_dallas_unsol_event,
14133 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014134 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014135 [ALC660VD_ASUS_V1S] = {
14136 .mixers = { alc861vd_lenovo_mixer },
14137 .init_verbs = { alc861vd_volume_init_verbs,
14138 alc861vd_3stack_init_verbs,
14139 alc861vd_eapd_verbs,
14140 alc861vd_lenovo_unsol_verbs },
14141 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14142 .dac_nids = alc660vd_dac_nids,
14143 .dig_out_nid = ALC861VD_DIGOUT_NID,
14144 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14145 .channel_mode = alc861vd_3stack_2ch_modes,
14146 .input_mux = &alc861vd_capture_source,
14147 .unsol_event = alc861vd_lenovo_unsol_event,
14148 .init_hook = alc861vd_lenovo_automute,
14149 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014150};
14151
14152/*
14153 * BIOS auto configuration
14154 */
14155static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14156 hda_nid_t nid, int pin_type, int dac_idx)
14157{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014158 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014159}
14160
14161static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14162{
14163 struct alc_spec *spec = codec->spec;
14164 int i;
14165
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014166 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014167 for (i = 0; i <= HDA_SIDE; i++) {
14168 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014169 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014170 if (nid)
14171 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014172 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014173 }
14174}
14175
14176
14177static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14178{
14179 struct alc_spec *spec = codec->spec;
14180 hda_nid_t pin;
14181
14182 pin = spec->autocfg.hp_pins[0];
14183 if (pin) /* connect to front and use dac 0 */
14184 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014185 pin = spec->autocfg.speaker_pins[0];
14186 if (pin)
14187 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014188}
14189
14190#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14191#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14192
14193static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14194{
14195 struct alc_spec *spec = codec->spec;
14196 int i;
14197
14198 for (i = 0; i < AUTO_PIN_LAST; i++) {
14199 hda_nid_t nid = spec->autocfg.input_pins[i];
14200 if (alc861vd_is_input_pin(nid)) {
14201 snd_hda_codec_write(codec, nid, 0,
14202 AC_VERB_SET_PIN_WIDGET_CONTROL,
14203 i <= AUTO_PIN_FRONT_MIC ?
14204 PIN_VREF80 : PIN_IN);
14205 if (nid != ALC861VD_PIN_CD_NID)
14206 snd_hda_codec_write(codec, nid, 0,
14207 AC_VERB_SET_AMP_GAIN_MUTE,
14208 AMP_OUT_MUTE);
14209 }
14210 }
14211}
14212
Takashi Iwaif511b012008-08-15 16:46:42 +020014213#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14214
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014215#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14216#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14217
14218/* add playback controls from the parsed DAC table */
14219/* Based on ALC880 version. But ALC861VD has separate,
14220 * different NIDs for mute/unmute switch and volume control */
14221static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14222 const struct auto_pin_cfg *cfg)
14223{
14224 char name[32];
14225 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14226 hda_nid_t nid_v, nid_s;
14227 int i, err;
14228
14229 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014230 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014231 continue;
14232 nid_v = alc861vd_idx_to_mixer_vol(
14233 alc880_dac_to_idx(
14234 spec->multiout.dac_nids[i]));
14235 nid_s = alc861vd_idx_to_mixer_switch(
14236 alc880_dac_to_idx(
14237 spec->multiout.dac_nids[i]));
14238
14239 if (i == 2) {
14240 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014241 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14242 "Center Playback Volume",
14243 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14244 HDA_OUTPUT));
14245 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014246 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014247 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14248 "LFE Playback Volume",
14249 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14250 HDA_OUTPUT));
14251 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014252 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014253 err = add_control(spec, ALC_CTL_BIND_MUTE,
14254 "Center Playback Switch",
14255 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14256 HDA_INPUT));
14257 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014258 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014259 err = add_control(spec, ALC_CTL_BIND_MUTE,
14260 "LFE Playback Switch",
14261 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14262 HDA_INPUT));
14263 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014264 return err;
14265 } else {
14266 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014267 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14268 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14269 HDA_OUTPUT));
14270 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014271 return err;
14272 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014273 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014274 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014275 HDA_INPUT));
14276 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014277 return err;
14278 }
14279 }
14280 return 0;
14281}
14282
14283/* add playback controls for speaker and HP outputs */
14284/* Based on ALC880 version. But ALC861VD has separate,
14285 * different NIDs for mute/unmute switch and volume control */
14286static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14287 hda_nid_t pin, const char *pfx)
14288{
14289 hda_nid_t nid_v, nid_s;
14290 int err;
14291 char name[32];
14292
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014293 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014294 return 0;
14295
14296 if (alc880_is_fixed_pin(pin)) {
14297 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14298 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014299 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014300 spec->multiout.hp_nid = nid_v;
14301 else
14302 spec->multiout.extra_out_nid[0] = nid_v;
14303 /* control HP volume/switch on the output mixer amp */
14304 nid_v = alc861vd_idx_to_mixer_vol(
14305 alc880_fixed_pin_idx(pin));
14306 nid_s = alc861vd_idx_to_mixer_switch(
14307 alc880_fixed_pin_idx(pin));
14308
14309 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014310 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14311 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14312 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014313 return err;
14314 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014315 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14316 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14317 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014318 return err;
14319 } else if (alc880_is_multi_pin(pin)) {
14320 /* set manual connection */
14321 /* we have only a switch on HP-out PIN */
14322 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014323 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14324 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14325 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014326 return err;
14327 }
14328 return 0;
14329}
14330
14331/* parse the BIOS configuration and set up the alc_spec
14332 * return 1 if successful, 0 if the proper config is not found,
14333 * or a negative error code
14334 * Based on ALC880 version - had to change it to override
14335 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14336static int alc861vd_parse_auto_config(struct hda_codec *codec)
14337{
14338 struct alc_spec *spec = codec->spec;
14339 int err;
14340 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14341
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014342 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14343 alc861vd_ignore);
14344 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014345 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014346 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014347 return 0; /* can't find valid BIOS pin config */
14348
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014349 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14350 if (err < 0)
14351 return err;
14352 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14353 if (err < 0)
14354 return err;
14355 err = alc861vd_auto_create_extra_out(spec,
14356 spec->autocfg.speaker_pins[0],
14357 "Speaker");
14358 if (err < 0)
14359 return err;
14360 err = alc861vd_auto_create_extra_out(spec,
14361 spec->autocfg.hp_pins[0],
14362 "Headphone");
14363 if (err < 0)
14364 return err;
14365 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14366 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014367 return err;
14368
14369 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14370
14371 if (spec->autocfg.dig_out_pin)
14372 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14373
Takashi Iwai603c4012008-07-30 15:01:44 +020014374 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014375 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014376
Takashi Iwaid88897e2008-10-31 15:01:37 +010014377 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014378
14379 spec->num_mux_defs = 1;
14380 spec->input_mux = &spec->private_imux;
14381
Takashi Iwai776e1842007-08-29 15:07:11 +020014382 err = alc_auto_add_mic_boost(codec);
14383 if (err < 0)
14384 return err;
14385
Takashi Iwaie044c392008-10-27 16:56:24 +010014386 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014387 return 1;
14388}
14389
14390/* additional initialization for auto-configuration model */
14391static void alc861vd_auto_init(struct hda_codec *codec)
14392{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014393 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014394 alc861vd_auto_init_multi_out(codec);
14395 alc861vd_auto_init_hp_out(codec);
14396 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014397 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014398 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014399 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014400}
14401
14402static int patch_alc861vd(struct hda_codec *codec)
14403{
14404 struct alc_spec *spec;
14405 int err, board_config;
14406
14407 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14408 if (spec == NULL)
14409 return -ENOMEM;
14410
14411 codec->spec = spec;
14412
14413 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14414 alc861vd_models,
14415 alc861vd_cfg_tbl);
14416
14417 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14418 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14419 "ALC861VD, trying auto-probe from BIOS...\n");
14420 board_config = ALC861VD_AUTO;
14421 }
14422
14423 if (board_config == ALC861VD_AUTO) {
14424 /* automatic parse from the BIOS config */
14425 err = alc861vd_parse_auto_config(codec);
14426 if (err < 0) {
14427 alc_free(codec);
14428 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014429 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014430 printk(KERN_INFO
14431 "hda_codec: Cannot set up configuration "
14432 "from BIOS. Using base mode...\n");
14433 board_config = ALC861VD_3ST;
14434 }
14435 }
14436
14437 if (board_config != ALC861VD_AUTO)
14438 setup_preset(spec, &alc861vd_presets[board_config]);
14439
Kailang Yang2f893282008-05-27 12:14:47 +020014440 if (codec->vendor_id == 0x10ec0660) {
14441 spec->stream_name_analog = "ALC660-VD Analog";
14442 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014443 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014444 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014445 } else {
14446 spec->stream_name_analog = "ALC861VD Analog";
14447 spec->stream_name_digital = "ALC861VD Digital";
14448 }
14449
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014450 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14451 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14452
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014453 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14454 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14455
14456 spec->adc_nids = alc861vd_adc_nids;
14457 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014458 spec->capsrc_nids = alc861vd_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010014459 spec->is_mix_capture = 1;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014460
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014461 set_capture_mixer(spec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014462
Takashi Iwai2134ea42008-01-10 16:53:55 +010014463 spec->vmaster_nid = 0x02;
14464
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014465 codec->patch_ops = alc_patch_ops;
14466
14467 if (board_config == ALC861VD_AUTO)
14468 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014469#ifdef CONFIG_SND_HDA_POWER_SAVE
14470 if (!spec->loopback.amplist)
14471 spec->loopback.amplist = alc861vd_loopbacks;
14472#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014473
14474 return 0;
14475}
14476
14477/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014478 * ALC662 support
14479 *
14480 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14481 * configuration. Each pin widget can choose any input DACs and a mixer.
14482 * Each ADC is connected from a mixer of all inputs. This makes possible
14483 * 6-channel independent captures.
14484 *
14485 * In addition, an independent DAC for the multi-playback (not used in this
14486 * driver yet).
14487 */
14488#define ALC662_DIGOUT_NID 0x06
14489#define ALC662_DIGIN_NID 0x0a
14490
14491static hda_nid_t alc662_dac_nids[4] = {
14492 /* front, rear, clfe, rear_surr */
14493 0x02, 0x03, 0x04
14494};
14495
14496static hda_nid_t alc662_adc_nids[1] = {
14497 /* ADC1-2 */
14498 0x09,
14499};
Takashi Iwaie1406342008-02-11 18:32:32 +010014500
Kailang Yang77a261b2008-02-19 11:38:05 +010014501static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014502
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014503/* input MUX */
14504/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014505static struct hda_input_mux alc662_capture_source = {
14506 .num_items = 4,
14507 .items = {
14508 { "Mic", 0x0 },
14509 { "Front Mic", 0x1 },
14510 { "Line", 0x2 },
14511 { "CD", 0x4 },
14512 },
14513};
14514
14515static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14516 .num_items = 2,
14517 .items = {
14518 { "Mic", 0x1 },
14519 { "Line", 0x2 },
14520 },
14521};
Kailang Yang291702f2007-10-16 14:28:03 +020014522
14523static struct hda_input_mux alc662_eeepc_capture_source = {
14524 .num_items = 2,
14525 .items = {
14526 { "i-Mic", 0x1 },
14527 { "e-Mic", 0x0 },
14528 },
14529};
14530
Kailang Yang6dda9f42008-05-27 12:05:31 +020014531static struct hda_input_mux alc663_capture_source = {
14532 .num_items = 3,
14533 .items = {
14534 { "Mic", 0x0 },
14535 { "Front Mic", 0x1 },
14536 { "Line", 0x2 },
14537 },
14538};
14539
14540static struct hda_input_mux alc663_m51va_capture_source = {
14541 .num_items = 2,
14542 .items = {
14543 { "Ext-Mic", 0x0 },
14544 { "D-Mic", 0x9 },
14545 },
14546};
14547
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014548/*
14549 * 2ch mode
14550 */
14551static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14552 { 2, NULL }
14553};
14554
14555/*
14556 * 2ch mode
14557 */
14558static struct hda_verb alc662_3ST_ch2_init[] = {
14559 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14560 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14561 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14562 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14563 { } /* end */
14564};
14565
14566/*
14567 * 6ch mode
14568 */
14569static struct hda_verb alc662_3ST_ch6_init[] = {
14570 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14571 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14572 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14573 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14574 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14575 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14576 { } /* end */
14577};
14578
14579static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14580 { 2, alc662_3ST_ch2_init },
14581 { 6, alc662_3ST_ch6_init },
14582};
14583
14584/*
14585 * 2ch mode
14586 */
14587static struct hda_verb alc662_sixstack_ch6_init[] = {
14588 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14589 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14590 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14591 { } /* end */
14592};
14593
14594/*
14595 * 6ch mode
14596 */
14597static struct hda_verb alc662_sixstack_ch8_init[] = {
14598 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14599 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14600 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14601 { } /* end */
14602};
14603
14604static struct hda_channel_mode alc662_5stack_modes[2] = {
14605 { 2, alc662_sixstack_ch6_init },
14606 { 6, alc662_sixstack_ch8_init },
14607};
14608
14609/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14610 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14611 */
14612
14613static struct snd_kcontrol_new alc662_base_mixer[] = {
14614 /* output mixer control */
14615 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014616 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014617 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014618 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014619 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14620 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014621 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14622 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014623 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14624
14625 /*Input mixer control */
14626 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14627 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14628 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14629 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14630 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14631 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14632 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14633 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014634 { } /* end */
14635};
14636
14637static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14638 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014639 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014640 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14641 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14642 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14643 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14644 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14647 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14648 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14649 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14650 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014651 { } /* end */
14652};
14653
14654static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14655 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014656 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014657 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014658 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014659 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14660 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014661 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14662 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014663 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14664 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14665 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14666 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14667 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14668 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14669 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14670 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14671 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14672 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14673 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014674 { } /* end */
14675};
14676
14677static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
14678 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14679 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014680 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14681 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14683 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14684 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14685 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14686 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014687 { } /* end */
14688};
14689
Kailang Yang291702f2007-10-16 14:28:03 +020014690static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010014691 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014692
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010014693 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14694 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014695
14696 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
14697 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14698 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14699
14700 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
14701 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14702 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14703 { } /* end */
14704};
14705
Kailang Yang8c427222008-01-10 13:03:59 +010014706static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010014707 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14708 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014709 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14710 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
14711 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14712 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
14713 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
14714 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014715 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014716 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
14717 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14718 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14721 { } /* end */
14722};
14723
Kailang Yangf1d4e282008-08-26 14:03:29 +020014724static struct hda_bind_ctls alc663_asus_bind_master_vol = {
14725 .ops = &snd_hda_bind_vol,
14726 .values = {
14727 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14728 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
14729 0
14730 },
14731};
14732
14733static struct hda_bind_ctls alc663_asus_one_bind_switch = {
14734 .ops = &snd_hda_bind_sw,
14735 .values = {
14736 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14737 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14738 0
14739 },
14740};
14741
Kailang Yang6dda9f42008-05-27 12:05:31 +020014742static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020014743 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14744 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
14745 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14747 { } /* end */
14748};
14749
14750static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
14751 .ops = &snd_hda_bind_sw,
14752 .values = {
14753 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14754 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14755 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14756 0
14757 },
14758};
14759
14760static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
14761 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14762 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
14763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14765 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14766 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14767
14768 { } /* end */
14769};
14770
14771static struct hda_bind_ctls alc663_asus_four_bind_switch = {
14772 .ops = &snd_hda_bind_sw,
14773 .values = {
14774 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14775 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14776 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
14777 0
14778 },
14779};
14780
14781static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
14782 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14783 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
14784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14785 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14786 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14787 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14788 { } /* end */
14789};
14790
14791static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014792 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14793 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014794 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14795 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14796 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14797 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14798 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14799 { } /* end */
14800};
14801
14802static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
14803 .ops = &snd_hda_bind_vol,
14804 .values = {
14805 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14806 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
14807 0
14808 },
14809};
14810
14811static struct hda_bind_ctls alc663_asus_two_bind_switch = {
14812 .ops = &snd_hda_bind_sw,
14813 .values = {
14814 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14815 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
14816 0
14817 },
14818};
14819
14820static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
14821 HDA_BIND_VOL("Master Playback Volume",
14822 &alc663_asus_two_bind_master_vol),
14823 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14824 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014825 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014828 { } /* end */
14829};
14830
14831static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
14832 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14833 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14834 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14835 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014838 { } /* end */
14839};
14840
14841static struct snd_kcontrol_new alc663_g71v_mixer[] = {
14842 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14843 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14844 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14845 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14846 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14847
14848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14849 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14850 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14851 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14852 { } /* end */
14853};
14854
14855static struct snd_kcontrol_new alc663_g50v_mixer[] = {
14856 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14857 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14858 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14859
14860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14862 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14863 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14864 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14865 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14866 { } /* end */
14867};
14868
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014869static struct snd_kcontrol_new alc662_chmode_mixer[] = {
14870 {
14871 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14872 .name = "Channel Mode",
14873 .info = alc_ch_mode_info,
14874 .get = alc_ch_mode_get,
14875 .put = alc_ch_mode_put,
14876 },
14877 { } /* end */
14878};
14879
14880static struct hda_verb alc662_init_verbs[] = {
14881 /* ADC: mute amp left and right */
14882 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14883 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14884 /* Front mixer: unmute input/output amp left and right (volume = 0) */
14885
Takashi Iwaicb53c622007-08-10 17:21:45 +020014886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14887 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14888 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14889 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14890 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014891
Kailang Yangb60dd392007-09-20 12:50:29 +020014892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014898
14899 /* Front Pin: output 0 (0x0c) */
14900 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14902
14903 /* Rear Pin: output 1 (0x0d) */
14904 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14906
14907 /* CLFE Pin: output 2 (0x0e) */
14908 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14909 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14910
14911 /* Mic (rear) pin: input vref at 80% */
14912 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14913 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14914 /* Front Mic pin: input vref at 80% */
14915 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14916 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14917 /* Line In pin: input */
14918 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14919 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14920 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14921 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14922 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14923 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14924 /* CD pin widget for input */
14925 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14926
14927 /* FIXME: use matrix-type input source selection */
14928 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14929 /* Input mixer */
14930 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14932 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14933 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020014934
14935 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14936 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14937 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14938 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014939
14940 /* always trun on EAPD */
14941 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14942 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14943
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014944 { }
14945};
14946
14947static struct hda_verb alc662_sue_init_verbs[] = {
14948 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14949 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020014950 {}
14951};
14952
14953static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
14954 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14955 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14956 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014957};
14958
Kailang Yang8c427222008-01-10 13:03:59 +010014959/* Set Unsolicited Event*/
14960static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
14961 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14962 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14963 {}
14964};
14965
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014966/*
14967 * generic initialization of ADC, input mixers and output mixers
14968 */
14969static struct hda_verb alc662_auto_init_verbs[] = {
14970 /*
14971 * Unmute ADC and set the default input to mic-in
14972 */
14973 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14974 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14975
14976 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
14977 * mixer widget
14978 * Note: PASD motherboards uses the Line In 2 as the input for front
14979 * panel mic (mic 2)
14980 */
14981 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014982 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14983 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14986 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014987
14988 /*
14989 * Set up output mixers (0x0c - 0x0f)
14990 */
14991 /* set vol=0 to output mixers */
14992 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14993 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14994 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14995
14996 /* set up input amps for analog loopback */
14997 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020014998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14999 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15000 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15001 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15002 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15003 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015004
15005
15006 /* FIXME: use matrix-type input source selection */
15007 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15008 /* Input mixer */
15009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015010 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015011 { }
15012};
15013
Takashi Iwai24fb9172008-09-02 14:48:20 +020015014/* additional verbs for ALC663 */
15015static struct hda_verb alc663_auto_init_verbs[] = {
15016 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15017 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15018 { }
15019};
15020
Kailang Yang6dda9f42008-05-27 12:05:31 +020015021static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015022 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15023 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015024 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15025 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015026 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15027 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15028 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015029 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15030 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15031 {}
15032};
15033
Kailang Yangf1d4e282008-08-26 14:03:29 +020015034static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15035 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15036 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15037 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15040 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15041 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15042 {}
15043};
15044
15045static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15046 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15047 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15048 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15049 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15050 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15052 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15053 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15054 {}
15055};
15056
15057static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15058 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15059 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15060 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15061 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15063 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15064 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15065 {}
15066};
15067
15068static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15069 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15070 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15071 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15072 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15073 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15075 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15076 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15077 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15078 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15079 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15080 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15081 {}
15082};
15083
15084static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15085 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15086 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15087 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15088 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15089 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15090 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15091 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15093 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15094 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15095 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15096 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15097 {}
15098};
15099
Kailang Yang6dda9f42008-05-27 12:05:31 +020015100static struct hda_verb alc663_g71v_init_verbs[] = {
15101 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15102 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15103 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15104
15105 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15106 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15107 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15108
15109 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15110 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15111 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15112 {}
15113};
15114
15115static struct hda_verb alc663_g50v_init_verbs[] = {
15116 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15117 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15118 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15119
15120 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15121 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15122 {}
15123};
15124
Kailang Yangf1d4e282008-08-26 14:03:29 +020015125static struct hda_verb alc662_ecs_init_verbs[] = {
15126 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15127 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15128 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15129 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15130 {}
15131};
15132
Kailang Yangf1d4e282008-08-26 14:03:29 +020015133static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15134 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15135 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15136 { } /* end */
15137};
15138
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015139static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15140{
15141 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015142 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015143
15144 present = snd_hda_codec_read(codec, 0x14, 0,
15145 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015146 bits = present ? HDA_AMP_MUTE : 0;
15147 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15148 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015149}
15150
15151static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15152{
15153 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015154 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015155
15156 present = snd_hda_codec_read(codec, 0x1b, 0,
15157 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015158 bits = present ? HDA_AMP_MUTE : 0;
15159 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15160 HDA_AMP_MUTE, bits);
15161 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15162 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015163}
15164
15165static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15166 unsigned int res)
15167{
15168 if ((res >> 26) == ALC880_HP_EVENT)
15169 alc662_lenovo_101e_all_automute(codec);
15170 if ((res >> 26) == ALC880_FRONT_EVENT)
15171 alc662_lenovo_101e_ispeaker_automute(codec);
15172}
15173
Kailang Yang291702f2007-10-16 14:28:03 +020015174static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15175{
15176 unsigned int present;
15177
15178 present = snd_hda_codec_read(codec, 0x18, 0,
15179 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15180 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15181 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15182 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15183 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15184 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15185 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15186 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15187 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15188}
15189
15190/* unsolicited event for HP jack sensing */
15191static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15192 unsigned int res)
15193{
15194 if ((res >> 26) == ALC880_HP_EVENT)
15195 alc262_hippo1_automute( codec );
15196
15197 if ((res >> 26) == ALC880_MIC_EVENT)
15198 alc662_eeepc_mic_automute(codec);
15199}
15200
15201static void alc662_eeepc_inithook(struct hda_codec *codec)
15202{
15203 alc262_hippo1_automute( codec );
15204 alc662_eeepc_mic_automute(codec);
15205}
15206
Kailang Yang8c427222008-01-10 13:03:59 +010015207static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15208{
15209 unsigned int mute;
15210 unsigned int present;
15211
15212 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15213 present = snd_hda_codec_read(codec, 0x14, 0,
15214 AC_VERB_GET_PIN_SENSE, 0);
15215 present = (present & 0x80000000) != 0;
15216 if (present) {
15217 /* mute internal speaker */
15218 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015219 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015220 } else {
15221 /* unmute internal speaker if necessary */
15222 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15223 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015224 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015225 }
15226}
15227
15228/* unsolicited event for HP jack sensing */
15229static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15230 unsigned int res)
15231{
15232 if ((res >> 26) == ALC880_HP_EVENT)
15233 alc662_eeepc_ep20_automute(codec);
15234}
15235
15236static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15237{
15238 alc662_eeepc_ep20_automute(codec);
15239}
15240
Kailang Yang6dda9f42008-05-27 12:05:31 +020015241static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15242{
15243 unsigned int present;
15244 unsigned char bits;
15245
15246 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015247 AC_VERB_GET_PIN_SENSE, 0)
15248 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015249 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015250 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15251 AMP_IN_MUTE(0), bits);
15252 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15253 AMP_IN_MUTE(0), bits);
15254}
15255
15256static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15257{
15258 unsigned int present;
15259 unsigned char bits;
15260
15261 present = snd_hda_codec_read(codec, 0x21, 0,
15262 AC_VERB_GET_PIN_SENSE, 0)
15263 & AC_PINSENSE_PRESENCE;
15264 bits = present ? HDA_AMP_MUTE : 0;
15265 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15266 AMP_IN_MUTE(0), bits);
15267 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15268 AMP_IN_MUTE(0), bits);
15269 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15270 AMP_IN_MUTE(0), bits);
15271 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15272 AMP_IN_MUTE(0), bits);
15273}
15274
15275static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15276{
15277 unsigned int present;
15278 unsigned char bits;
15279
15280 present = snd_hda_codec_read(codec, 0x15, 0,
15281 AC_VERB_GET_PIN_SENSE, 0)
15282 & AC_PINSENSE_PRESENCE;
15283 bits = present ? HDA_AMP_MUTE : 0;
15284 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15285 AMP_IN_MUTE(0), bits);
15286 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15287 AMP_IN_MUTE(0), bits);
15288 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15289 AMP_IN_MUTE(0), bits);
15290 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15291 AMP_IN_MUTE(0), bits);
15292}
15293
15294static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15295{
15296 unsigned int present;
15297 unsigned char bits;
15298
15299 present = snd_hda_codec_read(codec, 0x1b, 0,
15300 AC_VERB_GET_PIN_SENSE, 0)
15301 & AC_PINSENSE_PRESENCE;
15302 bits = present ? 0 : PIN_OUT;
15303 snd_hda_codec_write(codec, 0x14, 0,
15304 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15305}
15306
15307static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15308{
15309 unsigned int present1, present2;
15310
15311 present1 = snd_hda_codec_read(codec, 0x21, 0,
15312 AC_VERB_GET_PIN_SENSE, 0)
15313 & AC_PINSENSE_PRESENCE;
15314 present2 = snd_hda_codec_read(codec, 0x15, 0,
15315 AC_VERB_GET_PIN_SENSE, 0)
15316 & AC_PINSENSE_PRESENCE;
15317
15318 if (present1 || present2) {
15319 snd_hda_codec_write_cache(codec, 0x14, 0,
15320 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15321 } else {
15322 snd_hda_codec_write_cache(codec, 0x14, 0,
15323 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15324 }
15325}
15326
15327static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15328{
15329 unsigned int present1, present2;
15330
15331 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15332 AC_VERB_GET_PIN_SENSE, 0)
15333 & AC_PINSENSE_PRESENCE;
15334 present2 = snd_hda_codec_read(codec, 0x15, 0,
15335 AC_VERB_GET_PIN_SENSE, 0)
15336 & AC_PINSENSE_PRESENCE;
15337
15338 if (present1 || present2) {
15339 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15340 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15341 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15342 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15343 } else {
15344 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15345 AMP_IN_MUTE(0), 0);
15346 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15347 AMP_IN_MUTE(0), 0);
15348 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015349}
15350
15351static void alc663_m51va_mic_automute(struct hda_codec *codec)
15352{
15353 unsigned int present;
15354
15355 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015356 AC_VERB_GET_PIN_SENSE, 0)
15357 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015358 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015359 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015360 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015361 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015362 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015363 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015364 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015365 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015366}
15367
15368static void alc663_m51va_unsol_event(struct hda_codec *codec,
15369 unsigned int res)
15370{
15371 switch (res >> 26) {
15372 case ALC880_HP_EVENT:
15373 alc663_m51va_speaker_automute(codec);
15374 break;
15375 case ALC880_MIC_EVENT:
15376 alc663_m51va_mic_automute(codec);
15377 break;
15378 }
15379}
15380
15381static void alc663_m51va_inithook(struct hda_codec *codec)
15382{
15383 alc663_m51va_speaker_automute(codec);
15384 alc663_m51va_mic_automute(codec);
15385}
15386
Kailang Yangf1d4e282008-08-26 14:03:29 +020015387/* ***************** Mode1 ******************************/
15388static void alc663_mode1_unsol_event(struct hda_codec *codec,
15389 unsigned int res)
15390{
15391 switch (res >> 26) {
15392 case ALC880_HP_EVENT:
15393 alc663_m51va_speaker_automute(codec);
15394 break;
15395 case ALC880_MIC_EVENT:
15396 alc662_eeepc_mic_automute(codec);
15397 break;
15398 }
15399}
15400
15401static void alc663_mode1_inithook(struct hda_codec *codec)
15402{
15403 alc663_m51va_speaker_automute(codec);
15404 alc662_eeepc_mic_automute(codec);
15405}
15406/* ***************** Mode2 ******************************/
15407static void alc662_mode2_unsol_event(struct hda_codec *codec,
15408 unsigned int res)
15409{
15410 switch (res >> 26) {
15411 case ALC880_HP_EVENT:
15412 alc662_f5z_speaker_automute(codec);
15413 break;
15414 case ALC880_MIC_EVENT:
15415 alc662_eeepc_mic_automute(codec);
15416 break;
15417 }
15418}
15419
15420static void alc662_mode2_inithook(struct hda_codec *codec)
15421{
15422 alc662_f5z_speaker_automute(codec);
15423 alc662_eeepc_mic_automute(codec);
15424}
15425/* ***************** Mode3 ******************************/
15426static void alc663_mode3_unsol_event(struct hda_codec *codec,
15427 unsigned int res)
15428{
15429 switch (res >> 26) {
15430 case ALC880_HP_EVENT:
15431 alc663_two_hp_m1_speaker_automute(codec);
15432 break;
15433 case ALC880_MIC_EVENT:
15434 alc662_eeepc_mic_automute(codec);
15435 break;
15436 }
15437}
15438
15439static void alc663_mode3_inithook(struct hda_codec *codec)
15440{
15441 alc663_two_hp_m1_speaker_automute(codec);
15442 alc662_eeepc_mic_automute(codec);
15443}
15444/* ***************** Mode4 ******************************/
15445static void alc663_mode4_unsol_event(struct hda_codec *codec,
15446 unsigned int res)
15447{
15448 switch (res >> 26) {
15449 case ALC880_HP_EVENT:
15450 alc663_21jd_two_speaker_automute(codec);
15451 break;
15452 case ALC880_MIC_EVENT:
15453 alc662_eeepc_mic_automute(codec);
15454 break;
15455 }
15456}
15457
15458static void alc663_mode4_inithook(struct hda_codec *codec)
15459{
15460 alc663_21jd_two_speaker_automute(codec);
15461 alc662_eeepc_mic_automute(codec);
15462}
15463/* ***************** Mode5 ******************************/
15464static void alc663_mode5_unsol_event(struct hda_codec *codec,
15465 unsigned int res)
15466{
15467 switch (res >> 26) {
15468 case ALC880_HP_EVENT:
15469 alc663_15jd_two_speaker_automute(codec);
15470 break;
15471 case ALC880_MIC_EVENT:
15472 alc662_eeepc_mic_automute(codec);
15473 break;
15474 }
15475}
15476
15477static void alc663_mode5_inithook(struct hda_codec *codec)
15478{
15479 alc663_15jd_two_speaker_automute(codec);
15480 alc662_eeepc_mic_automute(codec);
15481}
15482/* ***************** Mode6 ******************************/
15483static void alc663_mode6_unsol_event(struct hda_codec *codec,
15484 unsigned int res)
15485{
15486 switch (res >> 26) {
15487 case ALC880_HP_EVENT:
15488 alc663_two_hp_m2_speaker_automute(codec);
15489 break;
15490 case ALC880_MIC_EVENT:
15491 alc662_eeepc_mic_automute(codec);
15492 break;
15493 }
15494}
15495
15496static void alc663_mode6_inithook(struct hda_codec *codec)
15497{
15498 alc663_two_hp_m2_speaker_automute(codec);
15499 alc662_eeepc_mic_automute(codec);
15500}
15501
Kailang Yang6dda9f42008-05-27 12:05:31 +020015502static void alc663_g71v_hp_automute(struct hda_codec *codec)
15503{
15504 unsigned int present;
15505 unsigned char bits;
15506
15507 present = snd_hda_codec_read(codec, 0x21, 0,
15508 AC_VERB_GET_PIN_SENSE, 0)
15509 & AC_PINSENSE_PRESENCE;
15510 bits = present ? HDA_AMP_MUTE : 0;
15511 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15512 HDA_AMP_MUTE, bits);
15513 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15514 HDA_AMP_MUTE, bits);
15515}
15516
15517static void alc663_g71v_front_automute(struct hda_codec *codec)
15518{
15519 unsigned int present;
15520 unsigned char bits;
15521
15522 present = snd_hda_codec_read(codec, 0x15, 0,
15523 AC_VERB_GET_PIN_SENSE, 0)
15524 & AC_PINSENSE_PRESENCE;
15525 bits = present ? HDA_AMP_MUTE : 0;
15526 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15527 HDA_AMP_MUTE, bits);
15528}
15529
15530static void alc663_g71v_unsol_event(struct hda_codec *codec,
15531 unsigned int res)
15532{
15533 switch (res >> 26) {
15534 case ALC880_HP_EVENT:
15535 alc663_g71v_hp_automute(codec);
15536 break;
15537 case ALC880_FRONT_EVENT:
15538 alc663_g71v_front_automute(codec);
15539 break;
15540 case ALC880_MIC_EVENT:
15541 alc662_eeepc_mic_automute(codec);
15542 break;
15543 }
15544}
15545
15546static void alc663_g71v_inithook(struct hda_codec *codec)
15547{
15548 alc663_g71v_front_automute(codec);
15549 alc663_g71v_hp_automute(codec);
15550 alc662_eeepc_mic_automute(codec);
15551}
15552
15553static void alc663_g50v_unsol_event(struct hda_codec *codec,
15554 unsigned int res)
15555{
15556 switch (res >> 26) {
15557 case ALC880_HP_EVENT:
15558 alc663_m51va_speaker_automute(codec);
15559 break;
15560 case ALC880_MIC_EVENT:
15561 alc662_eeepc_mic_automute(codec);
15562 break;
15563 }
15564}
15565
15566static void alc663_g50v_inithook(struct hda_codec *codec)
15567{
15568 alc663_m51va_speaker_automute(codec);
15569 alc662_eeepc_mic_automute(codec);
15570}
15571
Kailang Yangf1d4e282008-08-26 14:03:29 +020015572/* bind hp and internal speaker mute (with plug check) */
15573static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
15574 struct snd_ctl_elem_value *ucontrol)
15575{
15576 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
15577 long *valp = ucontrol->value.integer.value;
15578 int change;
15579
15580 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
15581 HDA_AMP_MUTE,
15582 valp[0] ? 0 : HDA_AMP_MUTE);
15583 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
15584 HDA_AMP_MUTE,
15585 valp[1] ? 0 : HDA_AMP_MUTE);
15586 if (change)
15587 alc262_hippo1_automute(codec);
15588 return change;
15589}
15590
15591static struct snd_kcontrol_new alc662_ecs_mixer[] = {
15592 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15593 {
15594 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15595 .name = "Master Playback Switch",
15596 .info = snd_hda_mixer_amp_switch_info,
15597 .get = snd_hda_mixer_amp_switch_get,
15598 .put = alc662_ecs_master_sw_put,
15599 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15600 },
15601
15602 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
15603 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
15604 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
15605
15606 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15607 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15608 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15609 { } /* end */
15610};
15611
Takashi Iwaicb53c622007-08-10 17:21:45 +020015612#ifdef CONFIG_SND_HDA_POWER_SAVE
15613#define alc662_loopbacks alc880_loopbacks
15614#endif
15615
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015616
15617/* pcm configuration: identiacal with ALC880 */
15618#define alc662_pcm_analog_playback alc880_pcm_analog_playback
15619#define alc662_pcm_analog_capture alc880_pcm_analog_capture
15620#define alc662_pcm_digital_playback alc880_pcm_digital_playback
15621#define alc662_pcm_digital_capture alc880_pcm_digital_capture
15622
15623/*
15624 * configuration and preset
15625 */
15626static const char *alc662_models[ALC662_MODEL_LAST] = {
15627 [ALC662_3ST_2ch_DIG] = "3stack-dig",
15628 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
15629 [ALC662_3ST_6ch] = "3stack-6ch",
15630 [ALC662_5ST_DIG] = "6stack-dig",
15631 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020015632 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010015633 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015634 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020015635 [ALC663_ASUS_M51VA] = "m51va",
15636 [ALC663_ASUS_G71V] = "g71v",
15637 [ALC663_ASUS_H13] = "h13",
15638 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015639 [ALC663_ASUS_MODE1] = "asus-mode1",
15640 [ALC662_ASUS_MODE2] = "asus-mode2",
15641 [ALC663_ASUS_MODE3] = "asus-mode3",
15642 [ALC663_ASUS_MODE4] = "asus-mode4",
15643 [ALC663_ASUS_MODE5] = "asus-mode5",
15644 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015645 [ALC662_AUTO] = "auto",
15646};
15647
15648static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015649 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Kailang Yang80ffe862008-10-15 11:23:27 +020015650 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010015651 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020015652 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010015653 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015654 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
15655 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
15656 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
15657 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
15658 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
15659 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
15660 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
15661 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
15662 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020015663 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015664 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
15665 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
15666 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
15667 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
15668 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
15669 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
15670 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
15671 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
15672 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
15673 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
15674 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
15675 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
15676 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
15677 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
15678 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
15679 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
15680 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
15681 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
15682 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
15683 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
15684 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
15685 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030015686 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
15687 ALC662_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015688 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015689 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
15690 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030015691 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
15692 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020015693 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai238713d2008-10-05 10:57:39 +020015694 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020015695 ALC662_3ST_6ch_DIG),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015696 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
15697 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
15698 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015699 {}
15700};
15701
15702static struct alc_config_preset alc662_presets[] = {
15703 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015704 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015705 .init_verbs = { alc662_init_verbs },
15706 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15707 .dac_nids = alc662_dac_nids,
15708 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015709 .dig_in_nid = ALC662_DIGIN_NID,
15710 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15711 .channel_mode = alc662_3ST_2ch_modes,
15712 .input_mux = &alc662_capture_source,
15713 },
15714 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015715 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015716 .init_verbs = { alc662_init_verbs },
15717 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15718 .dac_nids = alc662_dac_nids,
15719 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015720 .dig_in_nid = ALC662_DIGIN_NID,
15721 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15722 .channel_mode = alc662_3ST_6ch_modes,
15723 .need_dac_fix = 1,
15724 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015725 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015726 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015727 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015728 .init_verbs = { alc662_init_verbs },
15729 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15730 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015731 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15732 .channel_mode = alc662_3ST_6ch_modes,
15733 .need_dac_fix = 1,
15734 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015735 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015736 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015737 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015738 .init_verbs = { alc662_init_verbs },
15739 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15740 .dac_nids = alc662_dac_nids,
15741 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015742 .dig_in_nid = ALC662_DIGIN_NID,
15743 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
15744 .channel_mode = alc662_5stack_modes,
15745 .input_mux = &alc662_capture_source,
15746 },
15747 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015748 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015749 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
15750 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15751 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015752 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15753 .channel_mode = alc662_3ST_2ch_modes,
15754 .input_mux = &alc662_lenovo_101e_capture_source,
15755 .unsol_event = alc662_lenovo_101e_unsol_event,
15756 .init_hook = alc662_lenovo_101e_all_automute,
15757 },
Kailang Yang291702f2007-10-16 14:28:03 +020015758 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015759 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020015760 .init_verbs = { alc662_init_verbs,
15761 alc662_eeepc_sue_init_verbs },
15762 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15763 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020015764 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15765 .channel_mode = alc662_3ST_2ch_modes,
15766 .input_mux = &alc662_eeepc_capture_source,
15767 .unsol_event = alc662_eeepc_unsol_event,
15768 .init_hook = alc662_eeepc_inithook,
15769 },
Kailang Yang8c427222008-01-10 13:03:59 +010015770 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015771 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010015772 alc662_chmode_mixer },
15773 .init_verbs = { alc662_init_verbs,
15774 alc662_eeepc_ep20_sue_init_verbs },
15775 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15776 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010015777 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15778 .channel_mode = alc662_3ST_6ch_modes,
15779 .input_mux = &alc662_lenovo_101e_capture_source,
15780 .unsol_event = alc662_eeepc_ep20_unsol_event,
15781 .init_hook = alc662_eeepc_ep20_inithook,
15782 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015783 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015784 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015785 .init_verbs = { alc662_init_verbs,
15786 alc662_ecs_init_verbs },
15787 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15788 .dac_nids = alc662_dac_nids,
15789 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15790 .channel_mode = alc662_3ST_2ch_modes,
15791 .input_mux = &alc662_eeepc_capture_source,
15792 .unsol_event = alc662_eeepc_unsol_event,
15793 .init_hook = alc662_eeepc_inithook,
15794 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015795 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015796 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015797 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15798 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15799 .dac_nids = alc662_dac_nids,
15800 .dig_out_nid = ALC662_DIGOUT_NID,
15801 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15802 .channel_mode = alc662_3ST_2ch_modes,
15803 .input_mux = &alc663_m51va_capture_source,
15804 .unsol_event = alc663_m51va_unsol_event,
15805 .init_hook = alc663_m51va_inithook,
15806 },
15807 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015808 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015809 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
15810 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15811 .dac_nids = alc662_dac_nids,
15812 .dig_out_nid = ALC662_DIGOUT_NID,
15813 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15814 .channel_mode = alc662_3ST_2ch_modes,
15815 .input_mux = &alc662_eeepc_capture_source,
15816 .unsol_event = alc663_g71v_unsol_event,
15817 .init_hook = alc663_g71v_inithook,
15818 },
15819 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015820 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015821 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15822 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15823 .dac_nids = alc662_dac_nids,
15824 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15825 .channel_mode = alc662_3ST_2ch_modes,
15826 .input_mux = &alc663_m51va_capture_source,
15827 .unsol_event = alc663_m51va_unsol_event,
15828 .init_hook = alc663_m51va_inithook,
15829 },
15830 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015831 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015832 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
15833 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15834 .dac_nids = alc662_dac_nids,
15835 .dig_out_nid = ALC662_DIGOUT_NID,
15836 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15837 .channel_mode = alc662_3ST_6ch_modes,
15838 .input_mux = &alc663_capture_source,
15839 .unsol_event = alc663_g50v_unsol_event,
15840 .init_hook = alc663_g50v_inithook,
15841 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015842 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015843 .mixers = { alc663_m51va_mixer },
15844 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015845 .init_verbs = { alc662_init_verbs,
15846 alc663_21jd_amic_init_verbs },
15847 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15848 .hp_nid = 0x03,
15849 .dac_nids = alc662_dac_nids,
15850 .dig_out_nid = ALC662_DIGOUT_NID,
15851 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15852 .channel_mode = alc662_3ST_2ch_modes,
15853 .input_mux = &alc662_eeepc_capture_source,
15854 .unsol_event = alc663_mode1_unsol_event,
15855 .init_hook = alc663_mode1_inithook,
15856 },
15857 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015858 .mixers = { alc662_1bjd_mixer },
15859 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015860 .init_verbs = { alc662_init_verbs,
15861 alc662_1bjd_amic_init_verbs },
15862 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15863 .dac_nids = alc662_dac_nids,
15864 .dig_out_nid = ALC662_DIGOUT_NID,
15865 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15866 .channel_mode = alc662_3ST_2ch_modes,
15867 .input_mux = &alc662_eeepc_capture_source,
15868 .unsol_event = alc662_mode2_unsol_event,
15869 .init_hook = alc662_mode2_inithook,
15870 },
15871 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015872 .mixers = { alc663_two_hp_m1_mixer },
15873 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015874 .init_verbs = { alc662_init_verbs,
15875 alc663_two_hp_amic_m1_init_verbs },
15876 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15877 .hp_nid = 0x03,
15878 .dac_nids = alc662_dac_nids,
15879 .dig_out_nid = ALC662_DIGOUT_NID,
15880 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15881 .channel_mode = alc662_3ST_2ch_modes,
15882 .input_mux = &alc662_eeepc_capture_source,
15883 .unsol_event = alc663_mode3_unsol_event,
15884 .init_hook = alc663_mode3_inithook,
15885 },
15886 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015887 .mixers = { alc663_asus_21jd_clfe_mixer },
15888 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015889 .init_verbs = { alc662_init_verbs,
15890 alc663_21jd_amic_init_verbs},
15891 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15892 .hp_nid = 0x03,
15893 .dac_nids = alc662_dac_nids,
15894 .dig_out_nid = ALC662_DIGOUT_NID,
15895 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15896 .channel_mode = alc662_3ST_2ch_modes,
15897 .input_mux = &alc662_eeepc_capture_source,
15898 .unsol_event = alc663_mode4_unsol_event,
15899 .init_hook = alc663_mode4_inithook,
15900 },
15901 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015902 .mixers = { alc663_asus_15jd_clfe_mixer },
15903 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015904 .init_verbs = { alc662_init_verbs,
15905 alc663_15jd_amic_init_verbs },
15906 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15907 .hp_nid = 0x03,
15908 .dac_nids = alc662_dac_nids,
15909 .dig_out_nid = ALC662_DIGOUT_NID,
15910 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15911 .channel_mode = alc662_3ST_2ch_modes,
15912 .input_mux = &alc662_eeepc_capture_source,
15913 .unsol_event = alc663_mode5_unsol_event,
15914 .init_hook = alc663_mode5_inithook,
15915 },
15916 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015917 .mixers = { alc663_two_hp_m2_mixer },
15918 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015919 .init_verbs = { alc662_init_verbs,
15920 alc663_two_hp_amic_m2_init_verbs },
15921 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15922 .hp_nid = 0x03,
15923 .dac_nids = alc662_dac_nids,
15924 .dig_out_nid = ALC662_DIGOUT_NID,
15925 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15926 .channel_mode = alc662_3ST_2ch_modes,
15927 .input_mux = &alc662_eeepc_capture_source,
15928 .unsol_event = alc663_mode6_unsol_event,
15929 .init_hook = alc663_mode6_inithook,
15930 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015931};
15932
15933
15934/*
15935 * BIOS auto configuration
15936 */
15937
15938/* add playback controls from the parsed DAC table */
15939static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
15940 const struct auto_pin_cfg *cfg)
15941{
15942 char name[32];
15943 static const char *chname[4] = {
15944 "Front", "Surround", NULL /*CLFE*/, "Side"
15945 };
15946 hda_nid_t nid;
15947 int i, err;
15948
15949 for (i = 0; i < cfg->line_outs; i++) {
15950 if (!spec->multiout.dac_nids[i])
15951 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020015952 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015953 if (i == 2) {
15954 /* Center/LFE */
15955 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15956 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015957 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
15958 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015959 if (err < 0)
15960 return err;
15961 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15962 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015963 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
15964 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015965 if (err < 0)
15966 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015967 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015968 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015969 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015970 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015971 if (err < 0)
15972 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015973 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015974 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015975 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015976 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015977 if (err < 0)
15978 return err;
15979 } else {
15980 sprintf(name, "%s Playback Volume", chname[i]);
15981 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015982 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
15983 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015984 if (err < 0)
15985 return err;
15986 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015987 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15988 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
15989 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015990 if (err < 0)
15991 return err;
15992 }
15993 }
15994 return 0;
15995}
15996
15997/* add playback controls for speaker and HP outputs */
15998static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
15999 const char *pfx)
16000{
16001 hda_nid_t nid;
16002 int err;
16003 char name[32];
16004
16005 if (!pin)
16006 return 0;
16007
Takashi Iwai24fb9172008-09-02 14:48:20 +020016008 if (pin == 0x17) {
16009 /* ALC663 has a mono output pin on 0x17 */
16010 sprintf(name, "%s Playback Switch", pfx);
16011 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16012 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16013 return err;
16014 }
16015
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016016 if (alc880_is_fixed_pin(pin)) {
16017 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16018 /* printk("DAC nid=%x\n",nid); */
16019 /* specify the DAC as the extra output */
16020 if (!spec->multiout.hp_nid)
16021 spec->multiout.hp_nid = nid;
16022 else
16023 spec->multiout.extra_out_nid[0] = nid;
16024 /* control HP volume/switch on the output mixer amp */
16025 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16026 sprintf(name, "%s Playback Volume", pfx);
16027 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16028 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16029 if (err < 0)
16030 return err;
16031 sprintf(name, "%s Playback Switch", pfx);
16032 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16033 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16034 if (err < 0)
16035 return err;
16036 } else if (alc880_is_multi_pin(pin)) {
16037 /* set manual connection */
16038 /* we have only a switch on HP-out PIN */
16039 sprintf(name, "%s Playback Switch", pfx);
16040 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16041 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16042 if (err < 0)
16043 return err;
16044 }
16045 return 0;
16046}
16047
16048/* create playback/capture controls for input pins */
16049static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16050 const struct auto_pin_cfg *cfg)
16051{
16052 struct hda_input_mux *imux = &spec->private_imux;
16053 int i, err, idx;
16054
16055 for (i = 0; i < AUTO_PIN_LAST; i++) {
16056 if (alc880_is_input_pin(cfg->input_pins[i])) {
16057 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16058 err = new_analog_input(spec, cfg->input_pins[i],
16059 auto_pin_cfg_labels[i],
16060 idx, 0x0b);
16061 if (err < 0)
16062 return err;
16063 imux->items[imux->num_items].label =
16064 auto_pin_cfg_labels[i];
16065 imux->items[imux->num_items].index =
16066 alc880_input_pin_idx(cfg->input_pins[i]);
16067 imux->num_items++;
16068 }
16069 }
16070 return 0;
16071}
16072
16073static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16074 hda_nid_t nid, int pin_type,
16075 int dac_idx)
16076{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016077 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016078 /* need the manual connection? */
16079 if (alc880_is_multi_pin(nid)) {
16080 struct alc_spec *spec = codec->spec;
16081 int idx = alc880_multi_pin_idx(nid);
16082 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16083 AC_VERB_SET_CONNECT_SEL,
16084 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16085 }
16086}
16087
16088static void alc662_auto_init_multi_out(struct hda_codec *codec)
16089{
16090 struct alc_spec *spec = codec->spec;
16091 int i;
16092
Kailang Yang8c427222008-01-10 13:03:59 +010016093 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016094 for (i = 0; i <= HDA_SIDE; i++) {
16095 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016096 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016097 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016098 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016099 i);
16100 }
16101}
16102
16103static void alc662_auto_init_hp_out(struct hda_codec *codec)
16104{
16105 struct alc_spec *spec = codec->spec;
16106 hda_nid_t pin;
16107
16108 pin = spec->autocfg.hp_pins[0];
16109 if (pin) /* connect to front */
16110 /* use dac 0 */
16111 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016112 pin = spec->autocfg.speaker_pins[0];
16113 if (pin)
16114 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016115}
16116
16117#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16118#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16119
16120static void alc662_auto_init_analog_input(struct hda_codec *codec)
16121{
16122 struct alc_spec *spec = codec->spec;
16123 int i;
16124
16125 for (i = 0; i < AUTO_PIN_LAST; i++) {
16126 hda_nid_t nid = spec->autocfg.input_pins[i];
16127 if (alc662_is_input_pin(nid)) {
16128 snd_hda_codec_write(codec, nid, 0,
16129 AC_VERB_SET_PIN_WIDGET_CONTROL,
16130 (i <= AUTO_PIN_FRONT_MIC ?
16131 PIN_VREF80 : PIN_IN));
16132 if (nid != ALC662_PIN_CD_NID)
16133 snd_hda_codec_write(codec, nid, 0,
16134 AC_VERB_SET_AMP_GAIN_MUTE,
16135 AMP_OUT_MUTE);
16136 }
16137 }
16138}
16139
Takashi Iwaif511b012008-08-15 16:46:42 +020016140#define alc662_auto_init_input_src alc882_auto_init_input_src
16141
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016142static int alc662_parse_auto_config(struct hda_codec *codec)
16143{
16144 struct alc_spec *spec = codec->spec;
16145 int err;
16146 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16147
16148 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16149 alc662_ignore);
16150 if (err < 0)
16151 return err;
16152 if (!spec->autocfg.line_outs)
16153 return 0; /* can't find valid BIOS pin config */
16154
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016155 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16156 if (err < 0)
16157 return err;
16158 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16159 if (err < 0)
16160 return err;
16161 err = alc662_auto_create_extra_out(spec,
16162 spec->autocfg.speaker_pins[0],
16163 "Speaker");
16164 if (err < 0)
16165 return err;
16166 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16167 "Headphone");
16168 if (err < 0)
16169 return err;
16170 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16171 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016172 return err;
16173
16174 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16175
16176 if (spec->autocfg.dig_out_pin)
16177 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16178
Takashi Iwai603c4012008-07-30 15:01:44 +020016179 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016180 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016181
16182 spec->num_mux_defs = 1;
16183 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020016184
Takashi Iwaid88897e2008-10-31 15:01:37 +010016185 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016186 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016187 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016188
16189 err = alc_auto_add_mic_boost(codec);
16190 if (err < 0)
16191 return err;
16192
Takashi Iwaie044c392008-10-27 16:56:24 +010016193 store_pin_configs(codec);
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016194 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016195}
16196
16197/* additional initialization for auto-configuration model */
16198static void alc662_auto_init(struct hda_codec *codec)
16199{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016200 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016201 alc662_auto_init_multi_out(codec);
16202 alc662_auto_init_hp_out(codec);
16203 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016204 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016205 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016206 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016207}
16208
16209static int patch_alc662(struct hda_codec *codec)
16210{
16211 struct alc_spec *spec;
16212 int err, board_config;
16213
16214 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16215 if (!spec)
16216 return -ENOMEM;
16217
16218 codec->spec = spec;
16219
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016220 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16221
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016222 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16223 alc662_models,
16224 alc662_cfg_tbl);
16225 if (board_config < 0) {
16226 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16227 "trying auto-probe from BIOS...\n");
16228 board_config = ALC662_AUTO;
16229 }
16230
16231 if (board_config == ALC662_AUTO) {
16232 /* automatic parse from the BIOS config */
16233 err = alc662_parse_auto_config(codec);
16234 if (err < 0) {
16235 alc_free(codec);
16236 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016237 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016238 printk(KERN_INFO
16239 "hda_codec: Cannot set up configuration "
16240 "from BIOS. Using base mode...\n");
16241 board_config = ALC662_3ST_2ch_DIG;
16242 }
16243 }
16244
16245 if (board_config != ALC662_AUTO)
16246 setup_preset(spec, &alc662_presets[board_config]);
16247
Kailang Yang6dda9f42008-05-27 12:05:31 +020016248 if (codec->vendor_id == 0x10ec0663) {
16249 spec->stream_name_analog = "ALC663 Analog";
16250 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016251 } else if (codec->vendor_id == 0x10ec0272) {
16252 spec->stream_name_analog = "ALC272 Analog";
16253 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016254 } else {
16255 spec->stream_name_analog = "ALC662 Analog";
16256 spec->stream_name_digital = "ALC662 Digital";
16257 }
16258
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016259 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16260 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16261
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016262 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16263 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16264
Takashi Iwaie1406342008-02-11 18:32:32 +010016265 spec->adc_nids = alc662_adc_nids;
16266 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16267 spec->capsrc_nids = alc662_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010016268 spec->is_mix_capture = 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016269
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016270 if (!spec->cap_mixer)
16271 set_capture_mixer(spec);
16272
Takashi Iwai2134ea42008-01-10 16:53:55 +010016273 spec->vmaster_nid = 0x02;
16274
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016275 codec->patch_ops = alc_patch_ops;
16276 if (board_config == ALC662_AUTO)
16277 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016278#ifdef CONFIG_SND_HDA_POWER_SAVE
16279 if (!spec->loopback.amplist)
16280 spec->loopback.amplist = alc662_loopbacks;
16281#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016282
16283 return 0;
16284}
16285
16286/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016287 * patch entries
16288 */
16289struct hda_codec_preset snd_hda_preset_realtek[] = {
16290 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016291 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016292 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016293 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016294 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016295 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016296 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016297 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016298 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16299 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16300 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016301 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16302 .patch = patch_alc883 },
16303 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16304 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016305 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016306 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016307 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016308 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016309 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16310 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016311 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016312 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016313 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016314 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016315 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016316 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16317 .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016318 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016319 {} /* terminator */
16320};