blob: 15779d8c75643bb7dbfd1c7bf2fa308436410a84 [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 Woithe7cf51e42006-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 Woithe7cf51e42006-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,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200117 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100118 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100119 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100120#ifdef CONFIG_SND_DEBUG
121 ALC268_TEST,
122#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200123 ALC268_AUTO,
124 ALC268_MODEL_LAST /* last tag */
125};
126
Kailang Yangf6a92242007-12-13 16:52:54 +0100127/* ALC269 models */
128enum {
129 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200130 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200131 ALC269_ASUS_EEEPC_P703,
132 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100133 ALC269_FUJITSU,
Kailang Yangf6a92242007-12-13 16:52:54 +0100134 ALC269_AUTO,
135 ALC269_MODEL_LAST /* last tag */
136};
137
Kailang Yangdf694da2005-12-05 19:42:22 +0100138/* ALC861 models */
139enum {
140 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200141 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100142 ALC861_3ST_DIG,
143 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200144 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200145 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200146 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100147 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100148 ALC861_AUTO,
149 ALC861_MODEL_LAST,
150};
151
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100152/* ALC861-VD models */
153enum {
154 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200155 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100156 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100157 ALC861VD_3ST,
158 ALC861VD_3ST_DIG,
159 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200160 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200161 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200162 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100163 ALC861VD_AUTO,
164 ALC861VD_MODEL_LAST,
165};
166
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200167/* ALC662 models */
168enum {
169 ALC662_3ST_2ch_DIG,
170 ALC662_3ST_6ch_DIG,
171 ALC662_3ST_6ch,
172 ALC662_5ST_DIG,
173 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200174 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100175 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200176 ALC663_ASUS_M51VA,
177 ALC663_ASUS_G71V,
178 ALC663_ASUS_H13,
179 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200180 ALC662_ECS,
181 ALC663_ASUS_MODE1,
182 ALC662_ASUS_MODE2,
183 ALC663_ASUS_MODE3,
184 ALC663_ASUS_MODE4,
185 ALC663_ASUS_MODE5,
186 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200187 ALC662_AUTO,
188 ALC662_MODEL_LAST,
189};
190
Kailang Yangdf694da2005-12-05 19:42:22 +0100191/* ALC882 models */
192enum {
193 ALC882_3ST_DIG,
194 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200195 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200196 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200197 ALC882_TARGA,
198 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200199 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100200 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200201 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200202 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200203 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100204 ALC882_MODEL_LAST,
205};
206
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200207/* ALC883 models */
208enum {
209 ALC883_3ST_2ch_DIG,
210 ALC883_3ST_6ch_DIG,
211 ALC883_3ST_6ch,
212 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200213 ALC883_TARGA_DIG,
214 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200215 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200216 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200217 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200218 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100219 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200220 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200221 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200222 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200223 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200224 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200225 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100226 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100227 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100228 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100229 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200230 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200231 ALC888_ASUS_M90V,
232 ALC888_ASUS_EEE1601,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200233 ALC883_AUTO,
234 ALC883_MODEL_LAST,
235};
236
Kailang Yangdf694da2005-12-05 19:42:22 +0100237/* for GPIO Poll */
238#define GPIO_MASK 0x03
239
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240struct alc_spec {
241 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100242 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100244 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245
Kailang Yangdf694da2005-12-05 19:42:22 +0100246 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200247 * don't forget NULL
248 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200249 */
250 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
Takashi Iwai16ded522005-06-10 19:58:24 +0200252 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 struct hda_pcm_stream *stream_analog_playback;
254 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100255 struct hda_pcm_stream *stream_analog_alt_playback;
256 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200258 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 struct hda_pcm_stream *stream_digital_playback;
260 struct hda_pcm_stream *stream_digital_capture;
261
262 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200263 struct hda_multi_out multiout; /* playback set-up
264 * max_channels, dacs must be set
265 * dig_out_nid and hp_nid are optional
266 */
Takashi Iwai63300792008-01-24 15:31:36 +0100267 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
269 /* capture */
270 unsigned int num_adc_nids;
271 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100272 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200273 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100274 unsigned char is_mix_capture; /* matrix-style capture (non-mux) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
276 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200277 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 const struct hda_input_mux *input_mux;
279 unsigned int cur_mux[3];
280
281 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100282 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200284 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100287 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200288
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200289 /* dynamic controls, init_verbs and input_mux */
290 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200291 struct snd_array kctls;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200292 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200293 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100294
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100295 /* hooks */
296 void (*init_hook)(struct hda_codec *codec);
297 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
298
Takashi Iwai834be882006-03-01 14:16:17 +0100299 /* for pin sensing */
300 unsigned int sense_updated: 1;
301 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100302 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200303
Takashi Iwai2134ea42008-01-10 16:53:55 +0100304 /* for virtual master */
305 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200306#ifdef CONFIG_SND_HDA_POWER_SAVE
307 struct hda_loopback_check loopback;
308#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200309
310 /* for PLL fix */
311 hda_nid_t pll_nid;
312 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaie044c392008-10-27 16:56:24 +0100313
314#ifdef SND_HDA_NEEDS_RESUME
315#define ALC_MAX_PINS 16
316 unsigned int num_pins;
317 hda_nid_t pin_nids[ALC_MAX_PINS];
318 unsigned int pin_cfgs[ALC_MAX_PINS];
319#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100320};
321
322/*
323 * configuration template - to be copied to the spec instance
324 */
325struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200326 struct snd_kcontrol_new *mixers[5]; /* should be identical size
327 * with spec
328 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100329 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100330 const struct hda_verb *init_verbs[5];
331 unsigned int num_dacs;
332 hda_nid_t *dac_nids;
333 hda_nid_t dig_out_nid; /* optional */
334 hda_nid_t hp_nid; /* optional */
335 unsigned int num_adc_nids;
336 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100337 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100338 hda_nid_t dig_in_nid;
339 unsigned int num_channel_mode;
340 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200341 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200342 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100343 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100344 void (*unsol_event)(struct hda_codec *, unsigned int);
345 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200346#ifdef CONFIG_SND_HDA_POWER_SAVE
347 struct hda_amp_list *loopbacks;
348#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349};
350
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351
352/*
353 * input MUX handling
354 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200355static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
356 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357{
358 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
359 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200360 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
361 if (mux_idx >= spec->num_mux_defs)
362 mux_idx = 0;
363 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364}
365
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200366static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
367 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368{
369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
370 struct alc_spec *spec = codec->spec;
371 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
372
373 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
374 return 0;
375}
376
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200377static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
378 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379{
380 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
381 struct alc_spec *spec = codec->spec;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100382 const struct hda_input_mux *imux = spec->input_mux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaie1406342008-02-11 18:32:32 +0100384 hda_nid_t nid = spec->capsrc_nids ?
385 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100387 if (spec->is_mix_capture) {
388 /* Matrix-mixer style (e.g. ALC882) */
389 unsigned int *cur_val = &spec->cur_mux[adc_idx];
390 unsigned int i, idx;
391
392 idx = ucontrol->value.enumerated.item[0];
393 if (idx >= imux->num_items)
394 idx = imux->num_items - 1;
395 if (*cur_val == idx)
396 return 0;
397 for (i = 0; i < imux->num_items; i++) {
398 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
399 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
400 imux->items[i].index,
401 HDA_AMP_MUTE, v);
402 }
403 *cur_val = idx;
404 return 1;
405 } else {
406 /* MUX style (e.g. ALC880) */
407 unsigned int mux_idx;
408 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
409 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx],
410 ucontrol, nid,
411 &spec->cur_mux[adc_idx]);
412 }
413}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200414
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415/*
416 * channel mode setting
417 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200418static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
419 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420{
421 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
422 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100423 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
424 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425}
426
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200427static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
428 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429{
430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
431 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100432 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200433 spec->num_channel_mode,
434 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435}
436
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200437static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
438 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439{
440 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
441 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200442 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
443 spec->num_channel_mode,
444 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200445 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200446 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
447 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448}
449
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100451 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200452 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100453 * being part of a format specifier. Maximum allowed length of a value is
454 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100455 *
456 * Note: some retasking pin complexes seem to ignore requests for input
457 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
458 * are requested. Therefore order this list so that this behaviour will not
459 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200460 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
461 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200462 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100463static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100464 "Mic 50pc bias", "Mic 80pc bias",
465 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100466};
467static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100468 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100469};
470/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200471 * in the pin being assumed to be exclusively an input or an output pin. In
472 * addition, "input" pins may or may not process the mic bias option
473 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
474 * accept requests for bias as of chip versions up to March 2006) and/or
475 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100476 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200477#define ALC_PIN_DIR_IN 0x00
478#define ALC_PIN_DIR_OUT 0x01
479#define ALC_PIN_DIR_INOUT 0x02
480#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
481#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100482
Kailang Yangea1fb292008-08-26 12:58:38 +0200483/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100484 * For each direction the minimum and maximum values are given.
485 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200486static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100487 { 0, 2 }, /* ALC_PIN_DIR_IN */
488 { 3, 4 }, /* ALC_PIN_DIR_OUT */
489 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200490 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
491 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100492};
493#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
494#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
495#define alc_pin_mode_n_items(_dir) \
496 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
497
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200498static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
499 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200500{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100501 unsigned int item_num = uinfo->value.enumerated.item;
502 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
503
504 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200505 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
507
508 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
509 item_num = alc_pin_mode_min(dir);
510 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200511 return 0;
512}
513
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200514static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200516{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100517 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100520 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200521 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200522 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
523 AC_VERB_GET_PIN_WIDGET_CONTROL,
524 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200525
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100526 /* Find enumerated value for current pinctl setting */
527 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200528 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100529 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531 return 0;
532}
533
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200534static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
535 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536{
537 signed int change;
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 hda_nid_t nid = kcontrol->private_value & 0xffff;
540 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
541 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200542 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
543 AC_VERB_GET_PIN_WIDGET_CONTROL,
544 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200546 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100547 val = alc_pin_mode_min(dir);
548
549 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100550 if (change) {
551 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200552 snd_hda_codec_write_cache(codec, nid, 0,
553 AC_VERB_SET_PIN_WIDGET_CONTROL,
554 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100555
Kailang Yangea1fb292008-08-26 12:58:38 +0200556 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100557 * for the requested pin mode. Enum values of 2 or less are
558 * input modes.
559 *
560 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200561 * reduces noise slightly (particularly on input) so we'll
562 * do it. However, having both input and output buffers
563 * enabled simultaneously doesn't seem to be problematic if
564 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100565 */
566 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200567 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
568 HDA_AMP_MUTE, HDA_AMP_MUTE);
569 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
570 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100571 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200572 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
573 HDA_AMP_MUTE, HDA_AMP_MUTE);
574 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
575 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100576 }
577 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200578 return change;
579}
580
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200582 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100583 .info = alc_pin_mode_info, \
584 .get = alc_pin_mode_get, \
585 .put = alc_pin_mode_put, \
586 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100587
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100588/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
589 * together using a mask with more than one bit set. This control is
590 * currently used only by the ALC260 test model. At this stage they are not
591 * needed for any "production" models.
592 */
593#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200594#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200595
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200596static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
597 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100598{
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 hda_nid_t nid = kcontrol->private_value & 0xffff;
601 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
602 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200603 unsigned int val = snd_hda_codec_read(codec, nid, 0,
604 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100605
606 *valp = (val & mask) != 0;
607 return 0;
608}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200609static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
610 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100611{
612 signed int change;
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 hda_nid_t nid = kcontrol->private_value & 0xffff;
615 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
616 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200617 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
618 AC_VERB_GET_GPIO_DATA,
619 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100620
621 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200622 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
623 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100624 gpio_data &= ~mask;
625 else
626 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200627 snd_hda_codec_write_cache(codec, nid, 0,
628 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100629
630 return change;
631}
632#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
633 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
634 .info = alc_gpio_data_info, \
635 .get = alc_gpio_data_get, \
636 .put = alc_gpio_data_put, \
637 .private_value = nid | (mask<<16) }
638#endif /* CONFIG_SND_DEBUG */
639
Jonathan Woithe92621f12006-02-28 11:47:47 +0100640/* A switch control to allow the enabling of the digital IO pins on the
641 * ALC260. This is incredibly simplistic; the intention of this control is
642 * to provide something in the test model allowing digital outputs to be
643 * identified if present. If models are found which can utilise these
644 * outputs a more complete mixer control can be devised for those models if
645 * necessary.
646 */
647#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200648#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200649
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200650static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
651 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100652{
653 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
654 hda_nid_t nid = kcontrol->private_value & 0xffff;
655 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
656 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200657 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100658 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100659
660 *valp = (val & mask) != 0;
661 return 0;
662}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200663static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
664 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100665{
666 signed int change;
667 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
668 hda_nid_t nid = kcontrol->private_value & 0xffff;
669 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
670 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200671 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100672 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200673 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100674
675 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200676 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100677 if (val==0)
678 ctrl_data &= ~mask;
679 else
680 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200681 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
682 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100683
684 return change;
685}
686#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
687 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
688 .info = alc_spdif_ctrl_info, \
689 .get = alc_spdif_ctrl_get, \
690 .put = alc_spdif_ctrl_put, \
691 .private_value = nid | (mask<<16) }
692#endif /* CONFIG_SND_DEBUG */
693
Jonathan Woithef8225f62008-01-08 12:16:54 +0100694/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
695 * Again, this is only used in the ALC26x test models to help identify when
696 * the EAPD line must be asserted for features to work.
697 */
698#ifdef CONFIG_SND_DEBUG
699#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
700
701static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
702 struct snd_ctl_elem_value *ucontrol)
703{
704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
705 hda_nid_t nid = kcontrol->private_value & 0xffff;
706 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
707 long *valp = ucontrol->value.integer.value;
708 unsigned int val = snd_hda_codec_read(codec, nid, 0,
709 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
710
711 *valp = (val & mask) != 0;
712 return 0;
713}
714
715static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
716 struct snd_ctl_elem_value *ucontrol)
717{
718 int change;
719 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
720 hda_nid_t nid = kcontrol->private_value & 0xffff;
721 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
722 long val = *ucontrol->value.integer.value;
723 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
724 AC_VERB_GET_EAPD_BTLENABLE,
725 0x00);
726
727 /* Set/unset the masked control bit(s) as needed */
728 change = (!val ? 0 : mask) != (ctrl_data & mask);
729 if (!val)
730 ctrl_data &= ~mask;
731 else
732 ctrl_data |= mask;
733 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
734 ctrl_data);
735
736 return change;
737}
738
739#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
740 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
741 .info = alc_eapd_ctrl_info, \
742 .get = alc_eapd_ctrl_get, \
743 .put = alc_eapd_ctrl_put, \
744 .private_value = nid | (mask<<16) }
745#endif /* CONFIG_SND_DEBUG */
746
Kailang Yangdf694da2005-12-05 19:42:22 +0100747/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100748 */
749static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
750{
751 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
752 return;
753 spec->mixers[spec->num_mixers++] = mix;
754}
755
756static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
757{
758 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
759 return;
760 spec->init_verbs[spec->num_init_verbs++] = verb;
761}
762
763/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100764 * set up from the preset table
765 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200766static void setup_preset(struct alc_spec *spec,
767 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100768{
769 int i;
770
771 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100772 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100773 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200774 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
775 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100776 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200777
Kailang Yangdf694da2005-12-05 19:42:22 +0100778 spec->channel_mode = preset->channel_mode;
779 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200780 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100781
782 spec->multiout.max_channels = spec->channel_mode[0].channels;
783
784 spec->multiout.num_dacs = preset->num_dacs;
785 spec->multiout.dac_nids = preset->dac_nids;
786 spec->multiout.dig_out_nid = preset->dig_out_nid;
787 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200788
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200789 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200790 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200791 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100792 spec->input_mux = preset->input_mux;
793
794 spec->num_adc_nids = preset->num_adc_nids;
795 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100796 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100797 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100798
799 spec->unsol_event = preset->unsol_event;
800 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200801#ifdef CONFIG_SND_HDA_POWER_SAVE
802 spec->loopback.amplist = preset->loopbacks;
803#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100804}
805
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200806/* Enable GPIO mask and set output */
807static struct hda_verb alc_gpio1_init_verbs[] = {
808 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
809 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
810 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
811 { }
812};
813
814static struct hda_verb alc_gpio2_init_verbs[] = {
815 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
816 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
817 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
818 { }
819};
820
Kailang Yangbdd148a2007-05-08 15:19:08 +0200821static struct hda_verb alc_gpio3_init_verbs[] = {
822 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
823 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
824 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
825 { }
826};
827
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200828/*
829 * Fix hardware PLL issue
830 * On some codecs, the analog PLL gating control must be off while
831 * the default value is 1.
832 */
833static void alc_fix_pll(struct hda_codec *codec)
834{
835 struct alc_spec *spec = codec->spec;
836 unsigned int val;
837
838 if (!spec->pll_nid)
839 return;
840 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
841 spec->pll_coef_idx);
842 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
843 AC_VERB_GET_PROC_COEF, 0);
844 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
845 spec->pll_coef_idx);
846 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
847 val & ~(1 << spec->pll_coef_bit));
848}
849
850static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
851 unsigned int coef_idx, unsigned int coef_bit)
852{
853 struct alc_spec *spec = codec->spec;
854 spec->pll_nid = nid;
855 spec->pll_coef_idx = coef_idx;
856 spec->pll_coef_bit = coef_bit;
857 alc_fix_pll(codec);
858}
859
Kailang Yangc9b58002007-10-16 14:30:01 +0200860static void alc_sku_automute(struct hda_codec *codec)
861{
862 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200863 unsigned int present;
864 unsigned int hp_nid = spec->autocfg.hp_pins[0];
865 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
866
867 /* need to execute and sync at first */
868 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
869 present = snd_hda_codec_read(codec, hp_nid, 0,
870 AC_VERB_GET_PIN_SENSE, 0);
871 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100872 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
873 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200874}
875
Takashi Iwai4605b712008-10-31 14:18:24 +0100876#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200877static void alc_mic_automute(struct hda_codec *codec)
878{
879 struct alc_spec *spec = codec->spec;
880 unsigned int present;
881 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
882 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
883 unsigned int mix_nid = spec->capsrc_nids[0];
884 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
885
886 capsrc_idx_mic = mic_nid - 0x18;
887 capsrc_idx_fmic = fmic_nid - 0x18;
888 present = snd_hda_codec_read(codec, mic_nid, 0,
889 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
890 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
891 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
892 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
893 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
894 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
895 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
896}
Takashi Iwai4605b712008-10-31 14:18:24 +0100897#else
898#define alc_mic_automute(codec) /* NOP */
899#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200900
Kailang Yangc9b58002007-10-16 14:30:01 +0200901/* unsolicited event for HP jack sensing */
902static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
903{
904 if (codec->vendor_id == 0x10ec0880)
905 res >>= 28;
906 else
907 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200908 if (res == ALC880_HP_EVENT)
909 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200910
Kailang Yang7fb0d782008-10-15 11:12:35 +0200911 if (res == ALC880_MIC_EVENT)
912 alc_mic_automute(codec);
913}
914
915static void alc_inithook(struct hda_codec *codec)
916{
Kailang Yangc9b58002007-10-16 14:30:01 +0200917 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200918 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200919}
920
Kailang Yangf9423e72008-05-27 12:32:25 +0200921/* additional initialization for ALC888 variants */
922static void alc888_coef_init(struct hda_codec *codec)
923{
924 unsigned int tmp;
925
926 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
927 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
928 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
929 if ((tmp & 0xf0) == 2)
930 /* alc888S-VC */
931 snd_hda_codec_read(codec, 0x20, 0,
932 AC_VERB_SET_PROC_COEF, 0x830);
933 else
934 /* alc888-VB */
935 snd_hda_codec_read(codec, 0x20, 0,
936 AC_VERB_SET_PROC_COEF, 0x3030);
937}
938
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200939/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
940 * 31 ~ 16 : Manufacture ID
941 * 15 ~ 8 : SKU ID
942 * 7 ~ 0 : Assembly ID
943 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
944 */
945static void alc_subsystem_id(struct hda_codec *codec,
946 unsigned int porta, unsigned int porte,
947 unsigned int portd)
948{
Kailang Yangc9b58002007-10-16 14:30:01 +0200949 unsigned int ass, tmp, i;
950 unsigned nid;
951 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200952
Kailang Yangc9b58002007-10-16 14:30:01 +0200953 ass = codec->subsystem_id & 0xffff;
954 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
955 goto do_sku;
956
Kailang Yangea1fb292008-08-26 12:58:38 +0200957 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200958 * 31~30 : port conetcivity
959 * 29~21 : reserve
960 * 20 : PCBEEP input
961 * 19~16 : Check sum (15:1)
962 * 15~1 : Custom
963 * 0 : override
964 */
965 nid = 0x1d;
966 if (codec->vendor_id == 0x10ec0260)
967 nid = 0x17;
968 ass = snd_hda_codec_read(codec, nid, 0,
969 AC_VERB_GET_CONFIG_DEFAULT, 0);
970 if (!(ass & 1) && !(ass & 0x100000))
971 return;
972 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200973 return;
974
Kailang Yangc9b58002007-10-16 14:30:01 +0200975 /* check sum */
976 tmp = 0;
977 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100978 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200979 tmp++;
980 }
981 if (((ass >> 16) & 0xf) != tmp)
982 return;
983do_sku:
984 /*
985 * 0 : override
986 * 1 : Swap Jack
987 * 2 : 0 --> Desktop, 1 --> Laptop
988 * 3~5 : External Amplifier control
989 * 7~6 : Reserved
990 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200991 tmp = (ass & 0x38) >> 3; /* external Amp control */
992 switch (tmp) {
993 case 1:
994 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
995 break;
996 case 3:
997 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
998 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200999 case 7:
1000 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1001 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001002 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001003 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001004 case 0x10ec0260:
1005 snd_hda_codec_write(codec, 0x0f, 0,
1006 AC_VERB_SET_EAPD_BTLENABLE, 2);
1007 snd_hda_codec_write(codec, 0x10, 0,
1008 AC_VERB_SET_EAPD_BTLENABLE, 2);
1009 break;
1010 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001011 case 0x10ec0267:
1012 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001013 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +02001014 case 0x10ec0660:
1015 case 0x10ec0662:
1016 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001017 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001018 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001019 snd_hda_codec_write(codec, 0x14, 0,
1020 AC_VERB_SET_EAPD_BTLENABLE, 2);
1021 snd_hda_codec_write(codec, 0x15, 0,
1022 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001023 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001024 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001025 switch (codec->vendor_id) {
1026 case 0x10ec0260:
1027 snd_hda_codec_write(codec, 0x1a, 0,
1028 AC_VERB_SET_COEF_INDEX, 7);
1029 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1030 AC_VERB_GET_PROC_COEF, 0);
1031 snd_hda_codec_write(codec, 0x1a, 0,
1032 AC_VERB_SET_COEF_INDEX, 7);
1033 snd_hda_codec_write(codec, 0x1a, 0,
1034 AC_VERB_SET_PROC_COEF,
1035 tmp | 0x2010);
1036 break;
1037 case 0x10ec0262:
1038 case 0x10ec0880:
1039 case 0x10ec0882:
1040 case 0x10ec0883:
1041 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001042 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001043 snd_hda_codec_write(codec, 0x20, 0,
1044 AC_VERB_SET_COEF_INDEX, 7);
1045 tmp = snd_hda_codec_read(codec, 0x20, 0,
1046 AC_VERB_GET_PROC_COEF, 0);
1047 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001048 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001049 snd_hda_codec_write(codec, 0x20, 0,
1050 AC_VERB_SET_PROC_COEF,
1051 tmp | 0x2010);
1052 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001053 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001054 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001055 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001056 case 0x10ec0267:
1057 case 0x10ec0268:
1058 snd_hda_codec_write(codec, 0x20, 0,
1059 AC_VERB_SET_COEF_INDEX, 7);
1060 tmp = snd_hda_codec_read(codec, 0x20, 0,
1061 AC_VERB_GET_PROC_COEF, 0);
1062 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001063 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001064 snd_hda_codec_write(codec, 0x20, 0,
1065 AC_VERB_SET_PROC_COEF,
1066 tmp | 0x3000);
1067 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001068 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001069 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001070 break;
1071 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001072
Kailang Yang8c427222008-01-10 13:03:59 +01001073 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001074 * when the external headphone out jack is plugged"
1075 */
Kailang Yang8c427222008-01-10 13:03:59 +01001076 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001077 return;
1078 /*
1079 * 10~8 : Jack location
1080 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1081 * 14~13: Resvered
1082 * 15 : 1 --> enable the function "Mute internal speaker
1083 * when the external headphone out jack is plugged"
1084 */
1085 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001086 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001087 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001088 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001089 else
1090 return;
1091 }
1092
1093 if (!spec->autocfg.hp_pins[0]) {
1094 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1095 if (tmp == 0)
1096 spec->autocfg.hp_pins[0] = porta;
1097 else if (tmp == 1)
1098 spec->autocfg.hp_pins[0] = porte;
1099 else if (tmp == 2)
1100 spec->autocfg.hp_pins[0] = portd;
1101 else
1102 return;
1103 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001104 if (spec->autocfg.hp_pins[0])
1105 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1106 AC_VERB_SET_UNSOLICITED_ENABLE,
1107 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001108
Takashi Iwai4605b712008-10-31 14:18:24 +01001109#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001110 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1111 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1112 snd_hda_codec_write(codec,
1113 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1114 AC_VERB_SET_UNSOLICITED_ENABLE,
1115 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001116#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001117
Kailang Yangc9b58002007-10-16 14:30:01 +02001118 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001119}
1120
Takashi Iwai41e41f12005-06-08 14:48:49 +02001121/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001122 * Fix-up pin default configurations
1123 */
1124
1125struct alc_pincfg {
1126 hda_nid_t nid;
1127 u32 val;
1128};
1129
1130static void alc_fix_pincfg(struct hda_codec *codec,
1131 const struct snd_pci_quirk *quirk,
1132 const struct alc_pincfg **pinfix)
1133{
1134 const struct alc_pincfg *cfg;
1135
1136 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1137 if (!quirk)
1138 return;
1139
1140 cfg = pinfix[quirk->value];
1141 for (; cfg->nid; cfg++) {
1142 int i;
1143 u32 val = cfg->val;
1144 for (i = 0; i < 4; i++) {
1145 snd_hda_codec_write(codec, cfg->nid, 0,
1146 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1147 val & 0xff);
1148 val >>= 8;
1149 }
1150 }
1151}
1152
1153/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001154 * ALC880 3-stack model
1155 *
1156 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001157 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1158 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 */
1160
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001161static hda_nid_t alc880_dac_nids[4] = {
1162 /* front, rear, clfe, rear_surr */
1163 0x02, 0x05, 0x04, 0x03
1164};
1165
1166static hda_nid_t alc880_adc_nids[3] = {
1167 /* ADC0-2 */
1168 0x07, 0x08, 0x09,
1169};
1170
1171/* The datasheet says the node 0x07 is connected from inputs,
1172 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001173 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001175static hda_nid_t alc880_adc_nids_alt[2] = {
1176 /* ADC1-2 */
1177 0x08, 0x09,
1178};
1179
1180#define ALC880_DIGOUT_NID 0x06
1181#define ALC880_DIGIN_NID 0x0a
1182
1183static struct hda_input_mux alc880_capture_source = {
1184 .num_items = 4,
1185 .items = {
1186 { "Mic", 0x0 },
1187 { "Front Mic", 0x3 },
1188 { "Line", 0x2 },
1189 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001191};
1192
1193/* channel source setting (2/6 channel selection for 3-stack) */
1194/* 2ch mode */
1195static struct hda_verb alc880_threestack_ch2_init[] = {
1196 /* set line-in to input, mute it */
1197 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1198 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1199 /* set mic-in to input vref 80%, mute it */
1200 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1201 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 { } /* end */
1203};
1204
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001205/* 6ch mode */
1206static struct hda_verb alc880_threestack_ch6_init[] = {
1207 /* set line-in to output, unmute it */
1208 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1209 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1210 /* set mic-in to output, unmute it */
1211 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1212 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1213 { } /* end */
1214};
1215
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001216static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001217 { 2, alc880_threestack_ch2_init },
1218 { 6, alc880_threestack_ch6_init },
1219};
1220
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001221static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001222 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001223 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001224 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001225 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001226 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1227 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001228 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1229 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1231 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1232 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1233 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1234 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1235 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1236 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1237 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1238 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1239 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001240 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001241 {
1242 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1243 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001244 .info = alc_ch_mode_info,
1245 .get = alc_ch_mode_get,
1246 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001247 },
1248 { } /* end */
1249};
1250
1251/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001252static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1253 struct snd_ctl_elem_info *uinfo)
1254{
1255 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1256 struct alc_spec *spec = codec->spec;
1257 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001258
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001259 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1260 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1261 HDA_INPUT);
1262 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1263 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1264 return err;
1265}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001266
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001267static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1268 unsigned int size, unsigned int __user *tlv)
1269{
1270 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1271 struct alc_spec *spec = codec->spec;
1272 int err;
1273
1274 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1275 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1276 HDA_INPUT);
1277 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1278 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1279 return err;
1280}
1281
1282typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1283 struct snd_ctl_elem_value *ucontrol);
1284
1285static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1286 struct snd_ctl_elem_value *ucontrol,
1287 getput_call_t func)
1288{
1289 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1290 struct alc_spec *spec = codec->spec;
1291 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1292 int err;
1293
1294 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1295 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1296 3, 0, HDA_INPUT);
1297 err = func(kcontrol, ucontrol);
1298 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1299 return err;
1300}
1301
1302static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1303 struct snd_ctl_elem_value *ucontrol)
1304{
1305 return alc_cap_getput_caller(kcontrol, ucontrol,
1306 snd_hda_mixer_amp_volume_get);
1307}
1308
1309static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1310 struct snd_ctl_elem_value *ucontrol)
1311{
1312 return alc_cap_getput_caller(kcontrol, ucontrol,
1313 snd_hda_mixer_amp_volume_put);
1314}
1315
1316/* capture mixer elements */
1317#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1318
1319static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1320 struct snd_ctl_elem_value *ucontrol)
1321{
1322 return alc_cap_getput_caller(kcontrol, ucontrol,
1323 snd_hda_mixer_amp_switch_get);
1324}
1325
1326static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1327 struct snd_ctl_elem_value *ucontrol)
1328{
1329 return alc_cap_getput_caller(kcontrol, ucontrol,
1330 snd_hda_mixer_amp_switch_put);
1331}
1332
1333#define DEFINE_CAPMIX(num) \
1334static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1335 { \
1336 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1337 .name = "Capture Switch", \
1338 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1339 .count = num, \
1340 .info = alc_cap_sw_info, \
1341 .get = alc_cap_sw_get, \
1342 .put = alc_cap_sw_put, \
1343 }, \
1344 { \
1345 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1346 .name = "Capture Volume", \
1347 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1348 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1349 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1350 .count = num, \
1351 .info = alc_cap_vol_info, \
1352 .get = alc_cap_vol_get, \
1353 .put = alc_cap_vol_put, \
1354 .tlv = { .c = alc_cap_vol_tlv }, \
1355 }, \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001356 { \
1357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1358 /* .name = "Capture Source", */ \
1359 .name = "Input Source", \
1360 .count = num, \
1361 .info = alc_mux_enum_info, \
1362 .get = alc_mux_enum_get, \
1363 .put = alc_mux_enum_put, \
1364 }, \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001365 { } /* end */ \
1366}
1367
1368/* up to three ADCs */
1369DEFINE_CAPMIX(1);
1370DEFINE_CAPMIX(2);
1371DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001372
1373
1374/*
1375 * ALC880 5-stack model
1376 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001377 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1378 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001379 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1380 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1381 */
1382
1383/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001384static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001385 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001386 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387 { } /* end */
1388};
1389
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001390/* channel source setting (6/8 channel selection for 5-stack) */
1391/* 6ch mode */
1392static struct hda_verb alc880_fivestack_ch6_init[] = {
1393 /* set line-in to input, mute it */
1394 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1395 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001396 { } /* end */
1397};
1398
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001399/* 8ch mode */
1400static struct hda_verb alc880_fivestack_ch8_init[] = {
1401 /* set line-in to output, unmute it */
1402 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1403 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1404 { } /* end */
1405};
1406
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001407static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001408 { 6, alc880_fivestack_ch6_init },
1409 { 8, alc880_fivestack_ch8_init },
1410};
1411
1412
1413/*
1414 * ALC880 6-stack model
1415 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001416 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1417 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001418 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1419 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1420 */
1421
1422static hda_nid_t alc880_6st_dac_nids[4] = {
1423 /* front, rear, clfe, rear_surr */
1424 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001425};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001426
1427static struct hda_input_mux alc880_6stack_capture_source = {
1428 .num_items = 4,
1429 .items = {
1430 { "Mic", 0x0 },
1431 { "Front Mic", 0x1 },
1432 { "Line", 0x2 },
1433 { "CD", 0x4 },
1434 },
1435};
1436
1437/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001438static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001439 { 8, NULL },
1440};
1441
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001442static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001443 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001444 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001445 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001446 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001447 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1448 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001449 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1450 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001451 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001452 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001453 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1454 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1455 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1456 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1457 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1458 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1459 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1460 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1461 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1462 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001463 {
1464 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1465 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001466 .info = alc_ch_mode_info,
1467 .get = alc_ch_mode_get,
1468 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001469 },
1470 { } /* end */
1471};
1472
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001473
1474/*
1475 * ALC880 W810 model
1476 *
1477 * W810 has rear IO for:
1478 * Front (DAC 02)
1479 * Surround (DAC 03)
1480 * Center/LFE (DAC 04)
1481 * Digital out (06)
1482 *
1483 * The system also has a pair of internal speakers, and a headphone jack.
1484 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001485 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001486 * There is a variable resistor to control the speaker or headphone
1487 * volume. This is a hardware-only device without a software API.
1488 *
1489 * Plugging headphones in will disable the internal speakers. This is
1490 * implemented in hardware, not via the driver using jack sense. In
1491 * a similar fashion, plugging into the rear socket marked "front" will
1492 * disable both the speakers and headphones.
1493 *
1494 * For input, there's a microphone jack, and an "audio in" jack.
1495 * These may not do anything useful with this driver yet, because I
1496 * haven't setup any initialization verbs for these yet...
1497 */
1498
1499static hda_nid_t alc880_w810_dac_nids[3] = {
1500 /* front, rear/surround, clfe */
1501 0x02, 0x03, 0x04
1502};
1503
1504/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001505static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001506 { 6, NULL }
1507};
1508
1509/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001510static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001511 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001512 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001513 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001514 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001515 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1516 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001517 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1518 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001519 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1520 { } /* end */
1521};
1522
1523
1524/*
1525 * Z710V model
1526 *
1527 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001528 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1529 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001530 */
1531
1532static hda_nid_t alc880_z71v_dac_nids[1] = {
1533 0x02
1534};
1535#define ALC880_Z71V_HP_DAC 0x03
1536
1537/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001538static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001539 { 2, NULL }
1540};
1541
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001542static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001543 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001544 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001545 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001546 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001547 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1548 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1551 { } /* end */
1552};
1553
1554
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001555/*
1556 * ALC880 F1734 model
1557 *
1558 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1559 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1560 */
1561
1562static hda_nid_t alc880_f1734_dac_nids[1] = {
1563 0x03
1564};
1565#define ALC880_F1734_HP_DAC 0x02
1566
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001567static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001568 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001569 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001570 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1571 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001572 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1573 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1575 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001576 { } /* end */
1577};
1578
Takashi Iwai937b4162008-02-11 14:52:36 +01001579static struct hda_input_mux alc880_f1734_capture_source = {
1580 .num_items = 2,
1581 .items = {
1582 { "Mic", 0x1 },
1583 { "CD", 0x4 },
1584 },
1585};
1586
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001587
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001588/*
1589 * ALC880 ASUS model
1590 *
1591 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1592 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1593 * Mic = 0x18, Line = 0x1a
1594 */
1595
1596#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1597#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1598
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001599static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001600 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001601 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001602 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001603 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001604 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1605 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001606 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1607 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001608 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1609 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1610 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1611 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1612 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1613 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001614 {
1615 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1616 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001617 .info = alc_ch_mode_info,
1618 .get = alc_ch_mode_get,
1619 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001620 },
1621 { } /* end */
1622};
1623
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001624/*
1625 * ALC880 ASUS W1V model
1626 *
1627 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1628 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1629 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1630 */
1631
1632/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001633static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001634 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1635 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001636 { } /* end */
1637};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001638
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001639/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001640static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001641 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1642 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1643 { } /* end */
1644};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001645
Kailang Yangdf694da2005-12-05 19:42:22 +01001646/* TCL S700 */
1647static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1648 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1649 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1650 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1651 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1652 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1653 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1654 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1655 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1656 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001657 { } /* end */
1658};
1659
Kailang Yangccc656c2006-10-17 12:32:26 +02001660/* Uniwill */
1661static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001662 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1663 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1664 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1665 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001666 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1667 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1668 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1669 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1670 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1671 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1672 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1673 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1674 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1675 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1676 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1677 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1678 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1679 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1680 {
1681 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1682 .name = "Channel Mode",
1683 .info = alc_ch_mode_info,
1684 .get = alc_ch_mode_get,
1685 .put = alc_ch_mode_put,
1686 },
1687 { } /* end */
1688};
1689
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001690static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1691 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1692 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1693 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1694 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1695 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1696 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1697 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1698 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1699 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1700 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1701 { } /* end */
1702};
1703
Kailang Yangccc656c2006-10-17 12:32:26 +02001704static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001705 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1706 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1707 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1708 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1710 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1711 { } /* end */
1712};
1713
Linus Torvalds1da177e2005-04-16 15:20:36 -07001714/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001715 * virtual master controls
1716 */
1717
1718/*
1719 * slave controls for virtual master
1720 */
1721static const char *alc_slave_vols[] = {
1722 "Front Playback Volume",
1723 "Surround Playback Volume",
1724 "Center Playback Volume",
1725 "LFE Playback Volume",
1726 "Side Playback Volume",
1727 "Headphone Playback Volume",
1728 "Speaker Playback Volume",
1729 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001730 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001731 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001732 NULL,
1733};
1734
1735static const char *alc_slave_sws[] = {
1736 "Front Playback Switch",
1737 "Surround Playback Switch",
1738 "Center Playback Switch",
1739 "LFE Playback Switch",
1740 "Side Playback Switch",
1741 "Headphone Playback Switch",
1742 "Speaker Playback Switch",
1743 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001744 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001745 NULL,
1746};
1747
1748/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001749 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 */
Takashi Iwai603c4012008-07-30 15:01:44 +02001751
1752static void alc_free_kctls(struct hda_codec *codec);
1753
Linus Torvalds1da177e2005-04-16 15:20:36 -07001754static int alc_build_controls(struct hda_codec *codec)
1755{
1756 struct alc_spec *spec = codec->spec;
1757 int err;
1758 int i;
1759
1760 for (i = 0; i < spec->num_mixers; i++) {
1761 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1762 if (err < 0)
1763 return err;
1764 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001765 if (spec->cap_mixer) {
1766 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
1767 if (err < 0)
1768 return err;
1769 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001770 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001771 err = snd_hda_create_spdif_out_ctls(codec,
1772 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001773 if (err < 0)
1774 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001775 err = snd_hda_create_spdif_share_sw(codec,
1776 &spec->multiout);
1777 if (err < 0)
1778 return err;
1779 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001780 }
1781 if (spec->dig_in_nid) {
1782 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1783 if (err < 0)
1784 return err;
1785 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001786
1787 /* if we have no master control, let's create it */
1788 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001789 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001790 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001791 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001792 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001793 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001794 if (err < 0)
1795 return err;
1796 }
1797 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1798 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1799 NULL, alc_slave_sws);
1800 if (err < 0)
1801 return err;
1802 }
1803
Takashi Iwai603c4012008-07-30 15:01:44 +02001804 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001805 return 0;
1806}
1807
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001808
Linus Torvalds1da177e2005-04-16 15:20:36 -07001809/*
1810 * initialize the codec volumes, etc
1811 */
1812
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001813/*
1814 * generic initialization of ADC, input mixers and output mixers
1815 */
1816static struct hda_verb alc880_volume_init_verbs[] = {
1817 /*
1818 * Unmute ADC0-2 and set the default input to mic-in
1819 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001820 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001822 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001823 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001824 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001825 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001826
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001827 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1828 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001829 * Note: PASD motherboards uses the Line In 2 as the input for front
1830 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001831 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001840
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001841 /*
1842 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001843 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001844 /* set vol=0 to output mixers */
1845 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1846 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1847 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1848 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1849 /* set up input amps for analog loopback */
1850 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001853 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1854 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001855 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1856 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001857 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1858 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859
1860 { }
1861};
1862
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001863/*
1864 * 3-stack pin configuration:
1865 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1866 */
1867static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1868 /*
1869 * preset connection lists of input pins
1870 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1871 */
1872 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1873 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1874 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1875
1876 /*
1877 * Set pin mode and muting
1878 */
1879 /* set front pin widgets 0x14 for output */
1880 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1881 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1882 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1883 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1884 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1885 /* Mic2 (as headphone out) for HP output */
1886 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1887 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1888 /* Line In pin widget for input */
1889 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1890 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1891 /* Line2 (as front mic) pin widget for input and vref at 80% */
1892 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1893 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1894 /* CD pin widget for input */
1895 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1896
1897 { }
1898};
1899
1900/*
1901 * 5-stack pin configuration:
1902 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1903 * line-in/side = 0x1a, f-mic = 0x1b
1904 */
1905static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1906 /*
1907 * preset connection lists of input pins
1908 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1909 */
1910 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1911 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1912
1913 /*
1914 * Set pin mode and muting
1915 */
1916 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001917 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1918 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1919 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1920 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001921 /* unmute pins for output (no gain on this amp) */
1922 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1923 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1924 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1926
Linus Torvalds1da177e2005-04-16 15:20:36 -07001927 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1930 /* Mic2 (as headphone out) for HP output */
1931 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001932 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001933 /* Line In pin widget for input */
1934 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1935 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1936 /* Line2 (as front mic) pin widget for input and vref at 80% */
1937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1938 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1939 /* CD pin widget for input */
1940 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001941
1942 { }
1943};
1944
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001945/*
1946 * W810 pin configuration:
1947 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1948 */
1949static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950 /* hphone/speaker input selector: front DAC */
1951 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1952
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001953 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1955 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1956 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1957 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1958 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1959
1960 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001961 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001962
Linus Torvalds1da177e2005-04-16 15:20:36 -07001963 { }
1964};
1965
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001966/*
1967 * Z71V pin configuration:
1968 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1969 */
1970static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001971 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001972 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001973 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001974 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001975
Takashi Iwai16ded522005-06-10 19:58:24 +02001976 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001977 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001978 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001979 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001980
1981 { }
1982};
1983
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001984/*
1985 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001986 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1987 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001988 */
1989static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1990 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1991
Takashi Iwai16ded522005-06-10 19:58:24 +02001992 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001993 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001994 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001995 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001996 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001997 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001998 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001999 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2000
Takashi Iwai16ded522005-06-10 19:58:24 +02002001 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002002 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002003 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002004 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002005 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002006 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002007 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002008 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002009 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002010
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002011 { }
2012};
Takashi Iwai16ded522005-06-10 19:58:24 +02002013
Kailang Yangccc656c2006-10-17 12:32:26 +02002014/*
2015 * Uniwill pin configuration:
2016 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2017 * line = 0x1a
2018 */
2019static struct hda_verb alc880_uniwill_init_verbs[] = {
2020 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2021
2022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2023 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2024 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2025 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2026 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2027 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2028 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2029 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2030 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2031 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2032 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2033 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2034 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2035 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2036
2037 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2038 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2039 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2040 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2041 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2042 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2043 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2044 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2045 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2046
2047 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2048 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2049
2050 { }
2051};
2052
2053/*
2054* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002055* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002056 */
2057static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2058 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2059
2060 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2061 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2064 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2065 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2066 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2068 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2069 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2070 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2072
2073 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2075 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2077 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2078 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2079
2080 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2081 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2082
2083 { }
2084};
2085
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002086static struct hda_verb alc880_beep_init_verbs[] = {
2087 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2088 { }
2089};
2090
Kailang Yangccc656c2006-10-17 12:32:26 +02002091/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002092static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002093{
2094 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002095 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002096
2097 present = snd_hda_codec_read(codec, 0x14, 0,
2098 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002099 bits = present ? HDA_AMP_MUTE : 0;
2100 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2101 HDA_AMP_MUTE, bits);
2102 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2103 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002104}
2105
2106/* auto-toggle front mic */
2107static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2108{
2109 unsigned int present;
2110 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002111
2112 present = snd_hda_codec_read(codec, 0x18, 0,
2113 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002114 bits = present ? HDA_AMP_MUTE : 0;
2115 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002116}
2117
2118static void alc880_uniwill_automute(struct hda_codec *codec)
2119{
2120 alc880_uniwill_hp_automute(codec);
2121 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002122}
2123
2124static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2125 unsigned int res)
2126{
2127 /* Looks like the unsol event is incompatible with the standard
2128 * definition. 4bit tag is placed at 28 bit!
2129 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002130 switch (res >> 28) {
2131 case ALC880_HP_EVENT:
2132 alc880_uniwill_hp_automute(codec);
2133 break;
2134 case ALC880_MIC_EVENT:
2135 alc880_uniwill_mic_automute(codec);
2136 break;
2137 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002138}
2139
2140static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2141{
2142 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002143 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002144
2145 present = snd_hda_codec_read(codec, 0x14, 0,
2146 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002147 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002148 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002149}
2150
2151static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2152{
2153 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002154
Kailang Yangccc656c2006-10-17 12:32:26 +02002155 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002156 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2157 present &= HDA_AMP_VOLMASK;
2158 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2159 HDA_AMP_VOLMASK, present);
2160 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2161 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002162}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002163
Kailang Yangccc656c2006-10-17 12:32:26 +02002164static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2165 unsigned int res)
2166{
2167 /* Looks like the unsol event is incompatible with the standard
2168 * definition. 4bit tag is placed at 28 bit!
2169 */
2170 if ((res >> 28) == ALC880_HP_EVENT)
2171 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002172 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002173 alc880_uniwill_p53_dcvol_automute(codec);
2174}
2175
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002176/*
2177 * F1734 pin configuration:
2178 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2179 */
2180static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002181 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002182 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2183 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2184 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2185 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2186
2187 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2188 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2189 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2190 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2191
2192 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2193 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002194 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002195 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2196 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2197 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2198 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2199 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2200 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002201
Takashi Iwai937b4162008-02-11 14:52:36 +01002202 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2203 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2204
Takashi Iwai16ded522005-06-10 19:58:24 +02002205 { }
2206};
2207
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002208/*
2209 * ASUS pin configuration:
2210 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2211 */
2212static struct hda_verb alc880_pin_asus_init_verbs[] = {
2213 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2214 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2215 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2216 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2217
2218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2219 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2220 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2222 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2223 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2224 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2225 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2226
2227 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2228 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2229 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2230 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2231 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2233 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2234 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2235 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002236
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002237 { }
2238};
2239
2240/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002241#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2242#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002243
Kailang Yangdf694da2005-12-05 19:42:22 +01002244/* Clevo m520g init */
2245static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2246 /* headphone output */
2247 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2248 /* line-out */
2249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2250 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2251 /* Line-in */
2252 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2253 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2254 /* CD */
2255 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2256 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2257 /* Mic1 (rear panel) */
2258 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2259 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2260 /* Mic2 (front panel) */
2261 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2262 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2263 /* headphone */
2264 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2265 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2266 /* change to EAPD mode */
2267 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2268 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2269
2270 { }
2271};
2272
2273static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002274 /* change to EAPD mode */
2275 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2276 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2277
Kailang Yangdf694da2005-12-05 19:42:22 +01002278 /* Headphone output */
2279 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2280 /* Front output*/
2281 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2282 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2283
2284 /* Line In pin widget for input */
2285 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2286 /* CD pin widget for input */
2287 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2288 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2289 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2290
2291 /* change to EAPD mode */
2292 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2293 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2294
2295 { }
2296};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002297
2298/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002299 * LG m1 express dual
2300 *
2301 * Pin assignment:
2302 * Rear Line-In/Out (blue): 0x14
2303 * Build-in Mic-In: 0x15
2304 * Speaker-out: 0x17
2305 * HP-Out (green): 0x1b
2306 * Mic-In/Out (red): 0x19
2307 * SPDIF-Out: 0x1e
2308 */
2309
2310/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2311static hda_nid_t alc880_lg_dac_nids[3] = {
2312 0x05, 0x02, 0x03
2313};
2314
2315/* seems analog CD is not working */
2316static struct hda_input_mux alc880_lg_capture_source = {
2317 .num_items = 3,
2318 .items = {
2319 { "Mic", 0x1 },
2320 { "Line", 0x5 },
2321 { "Internal Mic", 0x6 },
2322 },
2323};
2324
2325/* 2,4,6 channel modes */
2326static struct hda_verb alc880_lg_ch2_init[] = {
2327 /* set line-in and mic-in to input */
2328 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2329 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2330 { }
2331};
2332
2333static struct hda_verb alc880_lg_ch4_init[] = {
2334 /* set line-in to out and mic-in to input */
2335 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2336 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2337 { }
2338};
2339
2340static struct hda_verb alc880_lg_ch6_init[] = {
2341 /* set line-in and mic-in to output */
2342 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2343 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2344 { }
2345};
2346
2347static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2348 { 2, alc880_lg_ch2_init },
2349 { 4, alc880_lg_ch4_init },
2350 { 6, alc880_lg_ch6_init },
2351};
2352
2353static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002354 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2355 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002356 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2357 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2358 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2359 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2360 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2361 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2362 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2363 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2364 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2365 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2366 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2367 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2368 {
2369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2370 .name = "Channel Mode",
2371 .info = alc_ch_mode_info,
2372 .get = alc_ch_mode_get,
2373 .put = alc_ch_mode_put,
2374 },
2375 { } /* end */
2376};
2377
2378static struct hda_verb alc880_lg_init_verbs[] = {
2379 /* set capture source to mic-in */
2380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2381 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2382 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2383 /* mute all amp mixer inputs */
2384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002387 /* line-in to input */
2388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2389 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2390 /* built-in mic */
2391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2392 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2393 /* speaker-out */
2394 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2395 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2396 /* mic-in to input */
2397 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2398 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2399 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2400 /* HP-out */
2401 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2402 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2403 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2404 /* jack sense */
2405 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2406 { }
2407};
2408
2409/* toggle speaker-output according to the hp-jack state */
2410static void alc880_lg_automute(struct hda_codec *codec)
2411{
2412 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002413 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002414
2415 present = snd_hda_codec_read(codec, 0x1b, 0,
2416 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002417 bits = present ? HDA_AMP_MUTE : 0;
2418 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2419 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002420}
2421
2422static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2423{
2424 /* Looks like the unsol event is incompatible with the standard
2425 * definition. 4bit tag is placed at 28 bit!
2426 */
2427 if ((res >> 28) == 0x01)
2428 alc880_lg_automute(codec);
2429}
2430
2431/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002432 * LG LW20
2433 *
2434 * Pin assignment:
2435 * Speaker-out: 0x14
2436 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002437 * Built-in Mic-In: 0x19
2438 * Line-In: 0x1b
2439 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002440 * SPDIF-Out: 0x1e
2441 */
2442
Takashi Iwaid6815182006-03-23 16:06:23 +01002443static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002444 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002445 .items = {
2446 { "Mic", 0x0 },
2447 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002448 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002449 },
2450};
2451
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002452#define alc880_lg_lw_modes alc880_threestack_modes
2453
Takashi Iwaid6815182006-03-23 16:06:23 +01002454static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002455 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2456 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2457 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2458 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2459 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2460 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2461 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2462 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2463 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2464 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002465 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2467 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2468 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002469 {
2470 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2471 .name = "Channel Mode",
2472 .info = alc_ch_mode_info,
2473 .get = alc_ch_mode_get,
2474 .put = alc_ch_mode_put,
2475 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002476 { } /* end */
2477};
2478
2479static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002480 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2481 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2482 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2483
Takashi Iwaid6815182006-03-23 16:06:23 +01002484 /* set capture source to mic-in */
2485 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2486 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002488 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002489 /* speaker-out */
2490 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2491 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2492 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002493 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2494 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2495 /* mic-in to input */
2496 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2497 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2498 /* built-in mic */
2499 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2500 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2501 /* jack sense */
2502 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2503 { }
2504};
2505
2506/* toggle speaker-output according to the hp-jack state */
2507static void alc880_lg_lw_automute(struct hda_codec *codec)
2508{
2509 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002510 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002511
2512 present = snd_hda_codec_read(codec, 0x1b, 0,
2513 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002514 bits = present ? HDA_AMP_MUTE : 0;
2515 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2516 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002517}
2518
2519static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2520{
2521 /* Looks like the unsol event is incompatible with the standard
2522 * definition. 4bit tag is placed at 28 bit!
2523 */
2524 if ((res >> 28) == 0x01)
2525 alc880_lg_lw_automute(codec);
2526}
2527
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002528static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2529 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2530 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2532 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2533 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2534 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2535 { } /* end */
2536};
2537
2538static struct hda_input_mux alc880_medion_rim_capture_source = {
2539 .num_items = 2,
2540 .items = {
2541 { "Mic", 0x0 },
2542 { "Internal Mic", 0x1 },
2543 },
2544};
2545
2546static struct hda_verb alc880_medion_rim_init_verbs[] = {
2547 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2548
2549 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2550 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2551
2552 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2553 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2554 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2555 /* Mic2 (as headphone out) for HP output */
2556 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2557 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2558 /* Internal Speaker */
2559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2560 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2561
2562 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2563 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2564
2565 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2566 { }
2567};
2568
2569/* toggle speaker-output according to the hp-jack state */
2570static void alc880_medion_rim_automute(struct hda_codec *codec)
2571{
2572 unsigned int present;
2573 unsigned char bits;
2574
2575 present = snd_hda_codec_read(codec, 0x14, 0,
2576 AC_VERB_GET_PIN_SENSE, 0)
2577 & AC_PINSENSE_PRESENCE;
2578 bits = present ? HDA_AMP_MUTE : 0;
2579 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2580 HDA_AMP_MUTE, bits);
2581 if (present)
2582 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2583 else
2584 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2585}
2586
2587static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2588 unsigned int res)
2589{
2590 /* Looks like the unsol event is incompatible with the standard
2591 * definition. 4bit tag is placed at 28 bit!
2592 */
2593 if ((res >> 28) == ALC880_HP_EVENT)
2594 alc880_medion_rim_automute(codec);
2595}
2596
Takashi Iwaicb53c622007-08-10 17:21:45 +02002597#ifdef CONFIG_SND_HDA_POWER_SAVE
2598static struct hda_amp_list alc880_loopbacks[] = {
2599 { 0x0b, HDA_INPUT, 0 },
2600 { 0x0b, HDA_INPUT, 1 },
2601 { 0x0b, HDA_INPUT, 2 },
2602 { 0x0b, HDA_INPUT, 3 },
2603 { 0x0b, HDA_INPUT, 4 },
2604 { } /* end */
2605};
2606
2607static struct hda_amp_list alc880_lg_loopbacks[] = {
2608 { 0x0b, HDA_INPUT, 1 },
2609 { 0x0b, HDA_INPUT, 6 },
2610 { 0x0b, HDA_INPUT, 7 },
2611 { } /* end */
2612};
2613#endif
2614
Takashi Iwaid6815182006-03-23 16:06:23 +01002615/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002616 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002617 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002618
Linus Torvalds1da177e2005-04-16 15:20:36 -07002619static int alc_init(struct hda_codec *codec)
2620{
2621 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002622 unsigned int i;
2623
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002624 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002625 if (codec->vendor_id == 0x10ec0888)
2626 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002627
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002628 for (i = 0; i < spec->num_init_verbs; i++)
2629 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002630
2631 if (spec->init_hook)
2632 spec->init_hook(codec);
2633
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634 return 0;
2635}
2636
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002637static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2638{
2639 struct alc_spec *spec = codec->spec;
2640
2641 if (spec->unsol_event)
2642 spec->unsol_event(codec, res);
2643}
2644
Takashi Iwaicb53c622007-08-10 17:21:45 +02002645#ifdef CONFIG_SND_HDA_POWER_SAVE
2646static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2647{
2648 struct alc_spec *spec = codec->spec;
2649 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2650}
2651#endif
2652
Linus Torvalds1da177e2005-04-16 15:20:36 -07002653/*
2654 * Analog playback callbacks
2655 */
2656static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2657 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002658 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002659{
2660 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002661 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2662 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002663}
2664
2665static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2666 struct hda_codec *codec,
2667 unsigned int stream_tag,
2668 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002669 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670{
2671 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002672 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2673 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002674}
2675
2676static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2677 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002678 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679{
2680 struct alc_spec *spec = codec->spec;
2681 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2682}
2683
2684/*
2685 * Digital out
2686 */
2687static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2688 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002689 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690{
2691 struct alc_spec *spec = codec->spec;
2692 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2693}
2694
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002695static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2696 struct hda_codec *codec,
2697 unsigned int stream_tag,
2698 unsigned int format,
2699 struct snd_pcm_substream *substream)
2700{
2701 struct alc_spec *spec = codec->spec;
2702 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2703 stream_tag, format, substream);
2704}
2705
Linus Torvalds1da177e2005-04-16 15:20:36 -07002706static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2707 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002708 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002709{
2710 struct alc_spec *spec = codec->spec;
2711 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2712}
2713
2714/*
2715 * Analog capture
2716 */
Takashi Iwai63300792008-01-24 15:31:36 +01002717static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002718 struct hda_codec *codec,
2719 unsigned int stream_tag,
2720 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002721 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002722{
2723 struct alc_spec *spec = codec->spec;
2724
Takashi Iwai63300792008-01-24 15:31:36 +01002725 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002726 stream_tag, 0, format);
2727 return 0;
2728}
2729
Takashi Iwai63300792008-01-24 15:31:36 +01002730static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002731 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002732 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002733{
2734 struct alc_spec *spec = codec->spec;
2735
Takashi Iwai888afa12008-03-18 09:57:50 +01002736 snd_hda_codec_cleanup_stream(codec,
2737 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002738 return 0;
2739}
2740
2741
2742/*
2743 */
2744static struct hda_pcm_stream alc880_pcm_analog_playback = {
2745 .substreams = 1,
2746 .channels_min = 2,
2747 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002748 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002749 .ops = {
2750 .open = alc880_playback_pcm_open,
2751 .prepare = alc880_playback_pcm_prepare,
2752 .cleanup = alc880_playback_pcm_cleanup
2753 },
2754};
2755
2756static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002757 .substreams = 1,
2758 .channels_min = 2,
2759 .channels_max = 2,
2760 /* NID is set in alc_build_pcms */
2761};
2762
2763static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2764 .substreams = 1,
2765 .channels_min = 2,
2766 .channels_max = 2,
2767 /* NID is set in alc_build_pcms */
2768};
2769
2770static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2771 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002772 .channels_min = 2,
2773 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002774 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002775 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002776 .prepare = alc880_alt_capture_pcm_prepare,
2777 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002778 },
2779};
2780
2781static struct hda_pcm_stream alc880_pcm_digital_playback = {
2782 .substreams = 1,
2783 .channels_min = 2,
2784 .channels_max = 2,
2785 /* NID is set in alc_build_pcms */
2786 .ops = {
2787 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002788 .close = alc880_dig_playback_pcm_close,
2789 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002790 },
2791};
2792
2793static struct hda_pcm_stream alc880_pcm_digital_capture = {
2794 .substreams = 1,
2795 .channels_min = 2,
2796 .channels_max = 2,
2797 /* NID is set in alc_build_pcms */
2798};
2799
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002800/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002801static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002802 .substreams = 0,
2803 .channels_min = 0,
2804 .channels_max = 0,
2805};
2806
Linus Torvalds1da177e2005-04-16 15:20:36 -07002807static int alc_build_pcms(struct hda_codec *codec)
2808{
2809 struct alc_spec *spec = codec->spec;
2810 struct hda_pcm *info = spec->pcm_rec;
2811 int i;
2812
2813 codec->num_pcms = 1;
2814 codec->pcm_info = info;
2815
2816 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002817 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002818 if (snd_BUG_ON(!spec->multiout.dac_nids))
2819 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002820 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2821 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2822 }
2823 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002824 if (snd_BUG_ON(!spec->adc_nids))
2825 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002826 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2827 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2828 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002829
Takashi Iwai4a471b72005-12-07 13:56:29 +01002830 if (spec->channel_mode) {
2831 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2832 for (i = 0; i < spec->num_channel_mode; i++) {
2833 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2834 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2835 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002836 }
2837 }
2838
Takashi Iwaie08a0072006-09-07 17:52:14 +02002839 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002840 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002841 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002842 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002843 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002844 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002845 if (spec->multiout.dig_out_nid &&
2846 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002847 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2848 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2849 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002850 if (spec->dig_in_nid &&
2851 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002852 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2853 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2854 }
Takashi Iwai963f8032008-08-11 10:04:40 +02002855 /* FIXME: do we need this for all Realtek codec models? */
2856 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002857 }
2858
Takashi Iwaie08a0072006-09-07 17:52:14 +02002859 /* If the use of more than one ADC is requested for the current
2860 * model, configure a second analog capture-only PCM.
2861 */
2862 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002863 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2864 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002865 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002866 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002867 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002868 if (spec->alt_dac_nid) {
2869 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2870 *spec->stream_analog_alt_playback;
2871 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2872 spec->alt_dac_nid;
2873 } else {
2874 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2875 alc_pcm_null_stream;
2876 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2877 }
2878 if (spec->num_adc_nids > 1) {
2879 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2880 *spec->stream_analog_alt_capture;
2881 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2882 spec->adc_nids[1];
2883 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2884 spec->num_adc_nids - 1;
2885 } else {
2886 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2887 alc_pcm_null_stream;
2888 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002889 }
2890 }
2891
Linus Torvalds1da177e2005-04-16 15:20:36 -07002892 return 0;
2893}
2894
Takashi Iwai603c4012008-07-30 15:01:44 +02002895static void alc_free_kctls(struct hda_codec *codec)
2896{
2897 struct alc_spec *spec = codec->spec;
2898
2899 if (spec->kctls.list) {
2900 struct snd_kcontrol_new *kctl = spec->kctls.list;
2901 int i;
2902 for (i = 0; i < spec->kctls.used; i++)
2903 kfree(kctl[i].name);
2904 }
2905 snd_array_free(&spec->kctls);
2906}
2907
Linus Torvalds1da177e2005-04-16 15:20:36 -07002908static void alc_free(struct hda_codec *codec)
2909{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002910 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002911
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002912 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002913 return;
2914
Takashi Iwai603c4012008-07-30 15:01:44 +02002915 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002916 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002917 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002918}
2919
Takashi Iwaie044c392008-10-27 16:56:24 +01002920#ifdef SND_HDA_NEEDS_RESUME
2921static void store_pin_configs(struct hda_codec *codec)
2922{
2923 struct alc_spec *spec = codec->spec;
2924 hda_nid_t nid, end_nid;
2925
2926 end_nid = codec->start_nid + codec->num_nodes;
2927 for (nid = codec->start_nid; nid < end_nid; nid++) {
2928 unsigned int wid_caps = get_wcaps(codec, nid);
2929 unsigned int wid_type =
2930 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2931 if (wid_type != AC_WID_PIN)
2932 continue;
2933 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
2934 break;
2935 spec->pin_nids[spec->num_pins] = nid;
2936 spec->pin_cfgs[spec->num_pins] =
2937 snd_hda_codec_read(codec, nid, 0,
2938 AC_VERB_GET_CONFIG_DEFAULT, 0);
2939 spec->num_pins++;
2940 }
2941}
2942
2943static void resume_pin_configs(struct hda_codec *codec)
2944{
2945 struct alc_spec *spec = codec->spec;
2946 int i;
2947
2948 for (i = 0; i < spec->num_pins; i++) {
2949 hda_nid_t pin_nid = spec->pin_nids[i];
2950 unsigned int pin_config = spec->pin_cfgs[i];
2951 snd_hda_codec_write(codec, pin_nid, 0,
2952 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2953 pin_config & 0x000000ff);
2954 snd_hda_codec_write(codec, pin_nid, 0,
2955 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2956 (pin_config & 0x0000ff00) >> 8);
2957 snd_hda_codec_write(codec, pin_nid, 0,
2958 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2959 (pin_config & 0x00ff0000) >> 16);
2960 snd_hda_codec_write(codec, pin_nid, 0,
2961 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2962 pin_config >> 24);
2963 }
2964}
2965
2966static int alc_resume(struct hda_codec *codec)
2967{
2968 resume_pin_configs(codec);
2969 codec->patch_ops.init(codec);
2970 snd_hda_codec_resume_amp(codec);
2971 snd_hda_codec_resume_cache(codec);
2972 return 0;
2973}
2974#else
2975#define store_pin_configs(codec)
2976#endif
2977
Linus Torvalds1da177e2005-04-16 15:20:36 -07002978/*
2979 */
2980static struct hda_codec_ops alc_patch_ops = {
2981 .build_controls = alc_build_controls,
2982 .build_pcms = alc_build_pcms,
2983 .init = alc_init,
2984 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002985 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01002986#ifdef SND_HDA_NEEDS_RESUME
2987 .resume = alc_resume,
2988#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02002989#ifdef CONFIG_SND_HDA_POWER_SAVE
2990 .check_power_status = alc_check_power_status,
2991#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002992};
2993
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002994
2995/*
2996 * Test configuration for debugging
2997 *
2998 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2999 * enum controls.
3000 */
3001#ifdef CONFIG_SND_DEBUG
3002static hda_nid_t alc880_test_dac_nids[4] = {
3003 0x02, 0x03, 0x04, 0x05
3004};
3005
3006static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003007 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003008 .items = {
3009 { "In-1", 0x0 },
3010 { "In-2", 0x1 },
3011 { "In-3", 0x2 },
3012 { "In-4", 0x3 },
3013 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003014 { "Front", 0x5 },
3015 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003016 },
3017};
3018
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003019static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003020 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003021 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003022 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003023 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003024};
3025
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003026static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3027 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003028{
3029 static char *texts[] = {
3030 "N/A", "Line Out", "HP Out",
3031 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3032 };
3033 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3034 uinfo->count = 1;
3035 uinfo->value.enumerated.items = 8;
3036 if (uinfo->value.enumerated.item >= 8)
3037 uinfo->value.enumerated.item = 7;
3038 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3039 return 0;
3040}
3041
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003042static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3043 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003044{
3045 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3046 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3047 unsigned int pin_ctl, item = 0;
3048
3049 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3050 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3051 if (pin_ctl & AC_PINCTL_OUT_EN) {
3052 if (pin_ctl & AC_PINCTL_HP_EN)
3053 item = 2;
3054 else
3055 item = 1;
3056 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3057 switch (pin_ctl & AC_PINCTL_VREFEN) {
3058 case AC_PINCTL_VREF_HIZ: item = 3; break;
3059 case AC_PINCTL_VREF_50: item = 4; break;
3060 case AC_PINCTL_VREF_GRD: item = 5; break;
3061 case AC_PINCTL_VREF_80: item = 6; break;
3062 case AC_PINCTL_VREF_100: item = 7; break;
3063 }
3064 }
3065 ucontrol->value.enumerated.item[0] = item;
3066 return 0;
3067}
3068
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003069static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3070 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003071{
3072 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3073 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3074 static unsigned int ctls[] = {
3075 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3076 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3077 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3078 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3079 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3080 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3081 };
3082 unsigned int old_ctl, new_ctl;
3083
3084 old_ctl = snd_hda_codec_read(codec, nid, 0,
3085 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3086 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3087 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003088 int val;
3089 snd_hda_codec_write_cache(codec, nid, 0,
3090 AC_VERB_SET_PIN_WIDGET_CONTROL,
3091 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003092 val = ucontrol->value.enumerated.item[0] >= 3 ?
3093 HDA_AMP_MUTE : 0;
3094 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3095 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003096 return 1;
3097 }
3098 return 0;
3099}
3100
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003101static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3102 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003103{
3104 static char *texts[] = {
3105 "Front", "Surround", "CLFE", "Side"
3106 };
3107 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3108 uinfo->count = 1;
3109 uinfo->value.enumerated.items = 4;
3110 if (uinfo->value.enumerated.item >= 4)
3111 uinfo->value.enumerated.item = 3;
3112 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3113 return 0;
3114}
3115
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003116static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3117 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003118{
3119 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3120 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3121 unsigned int sel;
3122
3123 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3124 ucontrol->value.enumerated.item[0] = sel & 3;
3125 return 0;
3126}
3127
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003128static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3129 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003130{
3131 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3132 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3133 unsigned int sel;
3134
3135 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3136 if (ucontrol->value.enumerated.item[0] != sel) {
3137 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003138 snd_hda_codec_write_cache(codec, nid, 0,
3139 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003140 return 1;
3141 }
3142 return 0;
3143}
3144
3145#define PIN_CTL_TEST(xname,nid) { \
3146 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3147 .name = xname, \
3148 .info = alc_test_pin_ctl_info, \
3149 .get = alc_test_pin_ctl_get, \
3150 .put = alc_test_pin_ctl_put, \
3151 .private_value = nid \
3152 }
3153
3154#define PIN_SRC_TEST(xname,nid) { \
3155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3156 .name = xname, \
3157 .info = alc_test_pin_src_info, \
3158 .get = alc_test_pin_src_get, \
3159 .put = alc_test_pin_src_put, \
3160 .private_value = nid \
3161 }
3162
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003163static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003164 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3165 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3166 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3167 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003168 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3169 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3170 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3171 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003172 PIN_CTL_TEST("Front Pin Mode", 0x14),
3173 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3174 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3175 PIN_CTL_TEST("Side Pin Mode", 0x17),
3176 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3177 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3178 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3179 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3180 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3181 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3182 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3183 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3184 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3185 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3186 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3187 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3188 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3189 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3190 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3191 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3192 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3193 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003194 {
3195 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3196 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003197 .info = alc_ch_mode_info,
3198 .get = alc_ch_mode_get,
3199 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003200 },
3201 { } /* end */
3202};
3203
3204static struct hda_verb alc880_test_init_verbs[] = {
3205 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3209 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3210 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3211 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3212 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3213 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003214 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3216 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3217 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3218 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003219 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3221 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3222 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3223 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003224 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003225 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3226 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3227 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3228 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003229 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003230 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3231 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003232 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3233 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3234 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003235 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003236 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3237 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3238 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3239 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003240 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003242 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003243 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003244 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003245 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003246 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003247 /* Analog input/passthru */
3248 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3249 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003253 { }
3254};
3255#endif
3256
Linus Torvalds1da177e2005-04-16 15:20:36 -07003257/*
3258 */
3259
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003260static const char *alc880_models[ALC880_MODEL_LAST] = {
3261 [ALC880_3ST] = "3stack",
3262 [ALC880_TCL_S700] = "tcl",
3263 [ALC880_3ST_DIG] = "3stack-digout",
3264 [ALC880_CLEVO] = "clevo",
3265 [ALC880_5ST] = "5stack",
3266 [ALC880_5ST_DIG] = "5stack-digout",
3267 [ALC880_W810] = "w810",
3268 [ALC880_Z71V] = "z71v",
3269 [ALC880_6ST] = "6stack",
3270 [ALC880_6ST_DIG] = "6stack-digout",
3271 [ALC880_ASUS] = "asus",
3272 [ALC880_ASUS_W1V] = "asus-w1v",
3273 [ALC880_ASUS_DIG] = "asus-dig",
3274 [ALC880_ASUS_DIG2] = "asus-dig2",
3275 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003276 [ALC880_UNIWILL_P53] = "uniwill-p53",
3277 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003278 [ALC880_F1734] = "F1734",
3279 [ALC880_LG] = "lg",
3280 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003281 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003282#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003283 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003284#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003285 [ALC880_AUTO] = "auto",
3286};
3287
3288static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003289 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003290 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3291 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3292 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3293 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3294 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3295 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3296 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3297 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003298 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3299 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003300 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3301 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3302 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3303 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3304 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3305 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3306 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3307 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3308 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3309 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003310 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003311 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3312 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3313 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003314 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003315 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003316 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3317 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003318 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3319 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003320 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3321 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3322 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3323 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003324 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3325 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003326 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003327 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003328 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003329 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003330 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3331 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003332 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003333 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003334 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003335 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003336 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003337 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003338 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003339 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003340 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003341 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3342 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003343 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003344 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3345 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3346 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3347 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003348 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3349 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003350 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003351 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003352 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3353 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003354 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3355 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3356 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003357 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3358 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3359 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003360 {}
3361};
3362
Takashi Iwai16ded522005-06-10 19:58:24 +02003363/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003364 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003365 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003366static struct alc_config_preset alc880_presets[] = {
3367 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003368 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003369 .init_verbs = { alc880_volume_init_verbs,
3370 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003371 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003372 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003373 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3374 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003375 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003376 .input_mux = &alc880_capture_source,
3377 },
3378 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003379 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003380 .init_verbs = { alc880_volume_init_verbs,
3381 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003382 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003383 .dac_nids = alc880_dac_nids,
3384 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003385 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3386 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003387 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003388 .input_mux = &alc880_capture_source,
3389 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003390 [ALC880_TCL_S700] = {
3391 .mixers = { alc880_tcl_s700_mixer },
3392 .init_verbs = { alc880_volume_init_verbs,
3393 alc880_pin_tcl_S700_init_verbs,
3394 alc880_gpio2_init_verbs },
3395 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3396 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003397 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3398 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003399 .hp_nid = 0x03,
3400 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3401 .channel_mode = alc880_2_jack_modes,
3402 .input_mux = &alc880_capture_source,
3403 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003404 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003405 .mixers = { alc880_three_stack_mixer,
3406 alc880_five_stack_mixer},
3407 .init_verbs = { alc880_volume_init_verbs,
3408 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003409 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3410 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003411 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3412 .channel_mode = alc880_fivestack_modes,
3413 .input_mux = &alc880_capture_source,
3414 },
3415 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003416 .mixers = { alc880_three_stack_mixer,
3417 alc880_five_stack_mixer },
3418 .init_verbs = { alc880_volume_init_verbs,
3419 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003420 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3421 .dac_nids = alc880_dac_nids,
3422 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003423 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3424 .channel_mode = alc880_fivestack_modes,
3425 .input_mux = &alc880_capture_source,
3426 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003427 [ALC880_6ST] = {
3428 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003429 .init_verbs = { alc880_volume_init_verbs,
3430 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003431 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3432 .dac_nids = alc880_6st_dac_nids,
3433 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3434 .channel_mode = alc880_sixstack_modes,
3435 .input_mux = &alc880_6stack_capture_source,
3436 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003437 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003438 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003439 .init_verbs = { alc880_volume_init_verbs,
3440 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003441 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3442 .dac_nids = alc880_6st_dac_nids,
3443 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003444 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3445 .channel_mode = alc880_sixstack_modes,
3446 .input_mux = &alc880_6stack_capture_source,
3447 },
3448 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003449 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003450 .init_verbs = { alc880_volume_init_verbs,
3451 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003452 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003453 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3454 .dac_nids = alc880_w810_dac_nids,
3455 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003456 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3457 .channel_mode = alc880_w810_modes,
3458 .input_mux = &alc880_capture_source,
3459 },
3460 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003461 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003462 .init_verbs = { alc880_volume_init_verbs,
3463 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003464 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3465 .dac_nids = alc880_z71v_dac_nids,
3466 .dig_out_nid = ALC880_DIGOUT_NID,
3467 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003468 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3469 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003470 .input_mux = &alc880_capture_source,
3471 },
3472 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003473 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003474 .init_verbs = { alc880_volume_init_verbs,
3475 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003476 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3477 .dac_nids = alc880_f1734_dac_nids,
3478 .hp_nid = 0x02,
3479 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3480 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003481 .input_mux = &alc880_f1734_capture_source,
3482 .unsol_event = alc880_uniwill_p53_unsol_event,
3483 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003484 },
3485 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003486 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003487 .init_verbs = { alc880_volume_init_verbs,
3488 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003489 alc880_gpio1_init_verbs },
3490 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3491 .dac_nids = alc880_asus_dac_nids,
3492 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3493 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003494 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003495 .input_mux = &alc880_capture_source,
3496 },
3497 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003498 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003499 .init_verbs = { alc880_volume_init_verbs,
3500 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003501 alc880_gpio1_init_verbs },
3502 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3503 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003504 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003505 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3506 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003507 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003508 .input_mux = &alc880_capture_source,
3509 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003510 [ALC880_ASUS_DIG2] = {
3511 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003512 .init_verbs = { alc880_volume_init_verbs,
3513 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003514 alc880_gpio2_init_verbs }, /* use GPIO2 */
3515 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3516 .dac_nids = alc880_asus_dac_nids,
3517 .dig_out_nid = ALC880_DIGOUT_NID,
3518 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3519 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003520 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003521 .input_mux = &alc880_capture_source,
3522 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003523 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003524 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003525 .init_verbs = { alc880_volume_init_verbs,
3526 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003527 alc880_gpio1_init_verbs },
3528 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3529 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003530 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003531 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3532 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003533 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003534 .input_mux = &alc880_capture_source,
3535 },
3536 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003537 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003538 .init_verbs = { alc880_volume_init_verbs,
3539 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003540 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3541 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003542 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003543 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3544 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003545 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003546 .input_mux = &alc880_capture_source,
3547 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003548 [ALC880_UNIWILL] = {
3549 .mixers = { alc880_uniwill_mixer },
3550 .init_verbs = { alc880_volume_init_verbs,
3551 alc880_uniwill_init_verbs },
3552 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3553 .dac_nids = alc880_asus_dac_nids,
3554 .dig_out_nid = ALC880_DIGOUT_NID,
3555 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3556 .channel_mode = alc880_threestack_modes,
3557 .need_dac_fix = 1,
3558 .input_mux = &alc880_capture_source,
3559 .unsol_event = alc880_uniwill_unsol_event,
3560 .init_hook = alc880_uniwill_automute,
3561 },
3562 [ALC880_UNIWILL_P53] = {
3563 .mixers = { alc880_uniwill_p53_mixer },
3564 .init_verbs = { alc880_volume_init_verbs,
3565 alc880_uniwill_p53_init_verbs },
3566 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3567 .dac_nids = alc880_asus_dac_nids,
3568 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003569 .channel_mode = alc880_threestack_modes,
3570 .input_mux = &alc880_capture_source,
3571 .unsol_event = alc880_uniwill_p53_unsol_event,
3572 .init_hook = alc880_uniwill_p53_hp_automute,
3573 },
3574 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003575 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003576 alc880_pcbeep_mixer, },
3577 .init_verbs = { alc880_volume_init_verbs,
3578 alc880_uniwill_p53_init_verbs,
3579 alc880_beep_init_verbs },
3580 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3581 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003582 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003583 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3584 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003585 .input_mux = &alc880_capture_source,
3586 .unsol_event = alc880_uniwill_p53_unsol_event,
3587 .init_hook = alc880_uniwill_p53_hp_automute,
3588 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003589 [ALC880_CLEVO] = {
3590 .mixers = { alc880_three_stack_mixer },
3591 .init_verbs = { alc880_volume_init_verbs,
3592 alc880_pin_clevo_init_verbs },
3593 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3594 .dac_nids = alc880_dac_nids,
3595 .hp_nid = 0x03,
3596 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3597 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003598 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003599 .input_mux = &alc880_capture_source,
3600 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003601 [ALC880_LG] = {
3602 .mixers = { alc880_lg_mixer },
3603 .init_verbs = { alc880_volume_init_verbs,
3604 alc880_lg_init_verbs },
3605 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3606 .dac_nids = alc880_lg_dac_nids,
3607 .dig_out_nid = ALC880_DIGOUT_NID,
3608 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3609 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003610 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003611 .input_mux = &alc880_lg_capture_source,
3612 .unsol_event = alc880_lg_unsol_event,
3613 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003614#ifdef CONFIG_SND_HDA_POWER_SAVE
3615 .loopbacks = alc880_lg_loopbacks,
3616#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003617 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003618 [ALC880_LG_LW] = {
3619 .mixers = { alc880_lg_lw_mixer },
3620 .init_verbs = { alc880_volume_init_verbs,
3621 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003622 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003623 .dac_nids = alc880_dac_nids,
3624 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003625 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3626 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003627 .input_mux = &alc880_lg_lw_capture_source,
3628 .unsol_event = alc880_lg_lw_unsol_event,
3629 .init_hook = alc880_lg_lw_automute,
3630 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003631 [ALC880_MEDION_RIM] = {
3632 .mixers = { alc880_medion_rim_mixer },
3633 .init_verbs = { alc880_volume_init_verbs,
3634 alc880_medion_rim_init_verbs,
3635 alc_gpio2_init_verbs },
3636 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3637 .dac_nids = alc880_dac_nids,
3638 .dig_out_nid = ALC880_DIGOUT_NID,
3639 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3640 .channel_mode = alc880_2_jack_modes,
3641 .input_mux = &alc880_medion_rim_capture_source,
3642 .unsol_event = alc880_medion_rim_unsol_event,
3643 .init_hook = alc880_medion_rim_automute,
3644 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003645#ifdef CONFIG_SND_DEBUG
3646 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003647 .mixers = { alc880_test_mixer },
3648 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003649 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3650 .dac_nids = alc880_test_dac_nids,
3651 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003652 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3653 .channel_mode = alc880_test_modes,
3654 .input_mux = &alc880_test_capture_source,
3655 },
3656#endif
3657};
3658
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003659/*
3660 * Automatic parse of I/O pins from the BIOS configuration
3661 */
3662
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003663enum {
3664 ALC_CTL_WIDGET_VOL,
3665 ALC_CTL_WIDGET_MUTE,
3666 ALC_CTL_BIND_MUTE,
3667};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003668static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003669 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3670 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003671 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003672};
3673
3674/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003675static int add_control(struct alc_spec *spec, int type, const char *name,
3676 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003677{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003678 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003679
Takashi Iwai603c4012008-07-30 15:01:44 +02003680 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3681 knew = snd_array_new(&spec->kctls);
3682 if (!knew)
3683 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003684 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003685 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003686 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003687 return -ENOMEM;
3688 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003689 return 0;
3690}
3691
3692#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3693#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3694#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3695#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3696#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3697#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3698#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3699#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3700#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3701#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3702#define ALC880_PIN_CD_NID 0x1c
3703
3704/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003705static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3706 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003707{
3708 hda_nid_t nid;
3709 int assigned[4];
3710 int i, j;
3711
3712 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003713 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003714
3715 /* check the pins hardwired to audio widget */
3716 for (i = 0; i < cfg->line_outs; i++) {
3717 nid = cfg->line_out_pins[i];
3718 if (alc880_is_fixed_pin(nid)) {
3719 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003720 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003721 assigned[idx] = 1;
3722 }
3723 }
3724 /* left pins can be connect to any audio widget */
3725 for (i = 0; i < cfg->line_outs; i++) {
3726 nid = cfg->line_out_pins[i];
3727 if (alc880_is_fixed_pin(nid))
3728 continue;
3729 /* search for an empty channel */
3730 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003731 if (!assigned[j]) {
3732 spec->multiout.dac_nids[i] =
3733 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003734 assigned[j] = 1;
3735 break;
3736 }
3737 }
3738 }
3739 spec->multiout.num_dacs = cfg->line_outs;
3740 return 0;
3741}
3742
3743/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003744static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3745 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003746{
3747 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003748 static const char *chname[4] = {
3749 "Front", "Surround", NULL /*CLFE*/, "Side"
3750 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003751 hda_nid_t nid;
3752 int i, err;
3753
3754 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003755 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003756 continue;
3757 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3758 if (i == 2) {
3759 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003760 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3761 "Center Playback Volume",
3762 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3763 HDA_OUTPUT));
3764 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003765 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003766 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3767 "LFE Playback Volume",
3768 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3769 HDA_OUTPUT));
3770 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003771 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003772 err = add_control(spec, ALC_CTL_BIND_MUTE,
3773 "Center Playback Switch",
3774 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3775 HDA_INPUT));
3776 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003777 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003778 err = add_control(spec, ALC_CTL_BIND_MUTE,
3779 "LFE Playback Switch",
3780 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3781 HDA_INPUT));
3782 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003783 return err;
3784 } else {
3785 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003786 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3787 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3788 HDA_OUTPUT));
3789 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003790 return err;
3791 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003792 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3793 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3794 HDA_INPUT));
3795 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003796 return err;
3797 }
3798 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003799 return 0;
3800}
3801
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003802/* add playback controls for speaker and HP outputs */
3803static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3804 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003805{
3806 hda_nid_t nid;
3807 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003808 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003809
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003810 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003811 return 0;
3812
3813 if (alc880_is_fixed_pin(pin)) {
3814 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003815 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003816 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003817 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003818 else
3819 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003820 /* control HP volume/switch on the output mixer amp */
3821 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003822 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003823 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3824 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3825 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003826 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003827 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003828 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3829 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3830 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003831 return err;
3832 } else if (alc880_is_multi_pin(pin)) {
3833 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003834 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003835 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003836 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3837 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3838 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003839 return err;
3840 }
3841 return 0;
3842}
3843
3844/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003845static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3846 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003847 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003848{
3849 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003850 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003851
3852 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003853 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3854 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3855 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003856 return err;
3857 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003858 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3859 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3860 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003861 return err;
3862 return 0;
3863}
3864
3865/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003866static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3867 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003868{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003869 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003870 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003871
3872 for (i = 0; i < AUTO_PIN_LAST; i++) {
3873 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003874 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003875 err = new_analog_input(spec, cfg->input_pins[i],
3876 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003877 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003878 if (err < 0)
3879 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003880 imux->items[imux->num_items].label =
3881 auto_pin_cfg_labels[i];
3882 imux->items[imux->num_items].index =
3883 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003884 imux->num_items++;
3885 }
3886 }
3887 return 0;
3888}
3889
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003890static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3891 unsigned int pin_type)
3892{
3893 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3894 pin_type);
3895 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003896 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3897 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003898}
3899
Kailang Yangdf694da2005-12-05 19:42:22 +01003900static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3901 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003902 int dac_idx)
3903{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003904 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003905 /* need the manual connection? */
3906 if (alc880_is_multi_pin(nid)) {
3907 struct alc_spec *spec = codec->spec;
3908 int idx = alc880_multi_pin_idx(nid);
3909 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3910 AC_VERB_SET_CONNECT_SEL,
3911 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3912 }
3913}
3914
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003915static int get_pin_type(int line_out_type)
3916{
3917 if (line_out_type == AUTO_PIN_HP_OUT)
3918 return PIN_HP;
3919 else
3920 return PIN_OUT;
3921}
3922
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003923static void alc880_auto_init_multi_out(struct hda_codec *codec)
3924{
3925 struct alc_spec *spec = codec->spec;
3926 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02003927
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003928 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003929 for (i = 0; i < spec->autocfg.line_outs; i++) {
3930 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003931 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3932 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003933 }
3934}
3935
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003936static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003937{
3938 struct alc_spec *spec = codec->spec;
3939 hda_nid_t pin;
3940
Takashi Iwai82bc9552006-03-21 11:24:42 +01003941 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003942 if (pin) /* connect to front */
3943 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003944 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003945 if (pin) /* connect to front */
3946 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3947}
3948
3949static void alc880_auto_init_analog_input(struct hda_codec *codec)
3950{
3951 struct alc_spec *spec = codec->spec;
3952 int i;
3953
3954 for (i = 0; i < AUTO_PIN_LAST; i++) {
3955 hda_nid_t nid = spec->autocfg.input_pins[i];
3956 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003957 snd_hda_codec_write(codec, nid, 0,
3958 AC_VERB_SET_PIN_WIDGET_CONTROL,
3959 i <= AUTO_PIN_FRONT_MIC ?
3960 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003961 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003962 snd_hda_codec_write(codec, nid, 0,
3963 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003964 AMP_OUT_MUTE);
3965 }
3966 }
3967}
3968
3969/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003970/* return 1 if successful, 0 if the proper config is not found,
3971 * or a negative error code
3972 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003973static int alc880_parse_auto_config(struct hda_codec *codec)
3974{
3975 struct alc_spec *spec = codec->spec;
3976 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003977 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003978
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003979 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3980 alc880_ignore);
3981 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003982 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003983 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003984 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003985
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003986 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3987 if (err < 0)
3988 return err;
3989 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3990 if (err < 0)
3991 return err;
3992 err = alc880_auto_create_extra_out(spec,
3993 spec->autocfg.speaker_pins[0],
3994 "Speaker");
3995 if (err < 0)
3996 return err;
3997 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3998 "Headphone");
3999 if (err < 0)
4000 return err;
4001 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4002 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004003 return err;
4004
4005 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4006
4007 if (spec->autocfg.dig_out_pin)
4008 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
4009 if (spec->autocfg.dig_in_pin)
4010 spec->dig_in_nid = ALC880_DIGIN_NID;
4011
Takashi Iwai603c4012008-07-30 15:01:44 +02004012 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004013 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004014
Takashi Iwaid88897e2008-10-31 15:01:37 +01004015 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004016
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004017 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004018 spec->input_mux = &spec->private_imux;
4019
Takashi Iwaie044c392008-10-27 16:56:24 +01004020 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004021 return 1;
4022}
4023
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004024/* additional initialization for auto-configuration model */
4025static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004026{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004027 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004028 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004029 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004030 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004031 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004032 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004033}
4034
4035/*
4036 * OK, here we have finally the patch for ALC880
4037 */
4038
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004039static void set_capture_mixer(struct alc_spec *spec)
4040{
4041 static struct snd_kcontrol_new *caps[3] = {
4042 alc_capture_mixer1,
4043 alc_capture_mixer2,
4044 alc_capture_mixer3,
4045 };
4046 if (spec->num_adc_nids > 0 && spec->num_adc_nids < 3)
4047 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4048}
4049
Linus Torvalds1da177e2005-04-16 15:20:36 -07004050static int patch_alc880(struct hda_codec *codec)
4051{
4052 struct alc_spec *spec;
4053 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004054 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004055
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004056 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004057 if (spec == NULL)
4058 return -ENOMEM;
4059
4060 codec->spec = spec;
4061
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004062 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4063 alc880_models,
4064 alc880_cfg_tbl);
4065 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004066 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4067 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004068 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004069 }
4070
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004071 if (board_config == ALC880_AUTO) {
4072 /* automatic parse from the BIOS config */
4073 err = alc880_parse_auto_config(codec);
4074 if (err < 0) {
4075 alc_free(codec);
4076 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004077 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004078 printk(KERN_INFO
4079 "hda_codec: Cannot set up configuration "
4080 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004081 board_config = ALC880_3ST;
4082 }
4083 }
4084
Kailang Yangdf694da2005-12-05 19:42:22 +01004085 if (board_config != ALC880_AUTO)
4086 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004087
4088 spec->stream_name_analog = "ALC880 Analog";
4089 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4090 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004091 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004092
4093 spec->stream_name_digital = "ALC880 Digital";
4094 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4095 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4096
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004097 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004098 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004099 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004100 /* get type */
4101 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004102 if (wcap != AC_WID_AUD_IN) {
4103 spec->adc_nids = alc880_adc_nids_alt;
4104 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004105 } else {
4106 spec->adc_nids = alc880_adc_nids;
4107 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004108 }
4109 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004110 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004111
Takashi Iwai2134ea42008-01-10 16:53:55 +01004112 spec->vmaster_nid = 0x0c;
4113
Linus Torvalds1da177e2005-04-16 15:20:36 -07004114 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004115 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004116 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004117#ifdef CONFIG_SND_HDA_POWER_SAVE
4118 if (!spec->loopback.amplist)
4119 spec->loopback.amplist = alc880_loopbacks;
4120#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07004121
4122 return 0;
4123}
4124
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004125
Linus Torvalds1da177e2005-04-16 15:20:36 -07004126/*
4127 * ALC260 support
4128 */
4129
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004130static hda_nid_t alc260_dac_nids[1] = {
4131 /* front */
4132 0x02,
4133};
4134
4135static hda_nid_t alc260_adc_nids[1] = {
4136 /* ADC0 */
4137 0x04,
4138};
4139
Kailang Yangdf694da2005-12-05 19:42:22 +01004140static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004141 /* ADC1 */
4142 0x05,
4143};
4144
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004145/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4146 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4147 */
4148static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004149 /* ADC0, ADC1 */
4150 0x04, 0x05
4151};
4152
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004153#define ALC260_DIGOUT_NID 0x03
4154#define ALC260_DIGIN_NID 0x06
4155
4156static struct hda_input_mux alc260_capture_source = {
4157 .num_items = 4,
4158 .items = {
4159 { "Mic", 0x0 },
4160 { "Front Mic", 0x1 },
4161 { "Line", 0x2 },
4162 { "CD", 0x4 },
4163 },
4164};
4165
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004166/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004167 * headphone jack and the internal CD lines since these are the only pins at
4168 * which audio can appear. For flexibility, also allow the option of
4169 * recording the mixer output on the second ADC (ADC0 doesn't have a
4170 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004171 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004172static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4173 {
4174 .num_items = 3,
4175 .items = {
4176 { "Mic/Line", 0x0 },
4177 { "CD", 0x4 },
4178 { "Headphone", 0x2 },
4179 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004180 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004181 {
4182 .num_items = 4,
4183 .items = {
4184 { "Mic/Line", 0x0 },
4185 { "CD", 0x4 },
4186 { "Headphone", 0x2 },
4187 { "Mixer", 0x5 },
4188 },
4189 },
4190
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004191};
4192
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004193/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4194 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004195 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004196static struct hda_input_mux alc260_acer_capture_sources[2] = {
4197 {
4198 .num_items = 4,
4199 .items = {
4200 { "Mic", 0x0 },
4201 { "Line", 0x2 },
4202 { "CD", 0x4 },
4203 { "Headphone", 0x5 },
4204 },
4205 },
4206 {
4207 .num_items = 5,
4208 .items = {
4209 { "Mic", 0x0 },
4210 { "Line", 0x2 },
4211 { "CD", 0x4 },
4212 { "Headphone", 0x6 },
4213 { "Mixer", 0x5 },
4214 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004215 },
4216};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004217/*
4218 * This is just place-holder, so there's something for alc_build_pcms to look
4219 * at when it calculates the maximum number of channels. ALC260 has no mixer
4220 * element which allows changing the channel mode, so the verb list is
4221 * never used.
4222 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004223static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004224 { 2, NULL },
4225};
4226
Kailang Yangdf694da2005-12-05 19:42:22 +01004227
4228/* Mixer combinations
4229 *
4230 * basic: base_output + input + pc_beep + capture
4231 * HP: base_output + input + capture_alt
4232 * HP_3013: hp_3013 + input + capture
4233 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004234 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004235 */
4236
4237static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004238 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004239 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004240 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4241 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4242 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4243 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4244 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004245};
Kailang Yangdf694da2005-12-05 19:42:22 +01004246
4247static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004248 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4249 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4250 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4251 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4253 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4254 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4255 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004256 { } /* end */
4257};
4258
Kailang Yangdf694da2005-12-05 19:42:22 +01004259static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4260 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4261 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4262 { } /* end */
4263};
4264
Takashi Iwaibec15c32008-01-28 18:16:30 +01004265/* update HP, line and mono out pins according to the master switch */
4266static void alc260_hp_master_update(struct hda_codec *codec,
4267 hda_nid_t hp, hda_nid_t line,
4268 hda_nid_t mono)
4269{
4270 struct alc_spec *spec = codec->spec;
4271 unsigned int val = spec->master_sw ? PIN_HP : 0;
4272 /* change HP and line-out pins */
4273 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4274 val);
4275 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4276 val);
4277 /* mono (speaker) depending on the HP jack sense */
4278 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4279 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4280 val);
4281}
4282
4283static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4284 struct snd_ctl_elem_value *ucontrol)
4285{
4286 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4287 struct alc_spec *spec = codec->spec;
4288 *ucontrol->value.integer.value = spec->master_sw;
4289 return 0;
4290}
4291
4292static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4293 struct snd_ctl_elem_value *ucontrol)
4294{
4295 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4296 struct alc_spec *spec = codec->spec;
4297 int val = !!*ucontrol->value.integer.value;
4298 hda_nid_t hp, line, mono;
4299
4300 if (val == spec->master_sw)
4301 return 0;
4302 spec->master_sw = val;
4303 hp = (kcontrol->private_value >> 16) & 0xff;
4304 line = (kcontrol->private_value >> 8) & 0xff;
4305 mono = kcontrol->private_value & 0xff;
4306 alc260_hp_master_update(codec, hp, line, mono);
4307 return 1;
4308}
4309
4310static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4311 {
4312 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4313 .name = "Master Playback Switch",
4314 .info = snd_ctl_boolean_mono_info,
4315 .get = alc260_hp_master_sw_get,
4316 .put = alc260_hp_master_sw_put,
4317 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4318 },
4319 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4320 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4321 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4322 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4323 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4324 HDA_OUTPUT),
4325 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4326 { } /* end */
4327};
4328
4329static struct hda_verb alc260_hp_unsol_verbs[] = {
4330 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4331 {},
4332};
4333
4334static void alc260_hp_automute(struct hda_codec *codec)
4335{
4336 struct alc_spec *spec = codec->spec;
4337 unsigned int present;
4338
4339 present = snd_hda_codec_read(codec, 0x10, 0,
4340 AC_VERB_GET_PIN_SENSE, 0);
4341 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4342 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4343}
4344
4345static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4346{
4347 if ((res >> 26) == ALC880_HP_EVENT)
4348 alc260_hp_automute(codec);
4349}
4350
Kailang Yangdf694da2005-12-05 19:42:22 +01004351static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004352 {
4353 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4354 .name = "Master Playback Switch",
4355 .info = snd_ctl_boolean_mono_info,
4356 .get = alc260_hp_master_sw_get,
4357 .put = alc260_hp_master_sw_put,
4358 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4359 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004360 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4361 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4362 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4363 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4364 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4365 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004366 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4367 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004368 { } /* end */
4369};
4370
Kailang Yang3f878302008-08-26 13:02:23 +02004371static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4372 .ops = &snd_hda_bind_vol,
4373 .values = {
4374 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4375 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4376 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4377 0
4378 },
4379};
4380
4381static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4382 .ops = &snd_hda_bind_sw,
4383 .values = {
4384 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4385 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4386 0
4387 },
4388};
4389
4390static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4391 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4392 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4393 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4394 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4395 { } /* end */
4396};
4397
Takashi Iwaibec15c32008-01-28 18:16:30 +01004398static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4399 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4400 {},
4401};
4402
4403static void alc260_hp_3013_automute(struct hda_codec *codec)
4404{
4405 struct alc_spec *spec = codec->spec;
4406 unsigned int present;
4407
4408 present = snd_hda_codec_read(codec, 0x15, 0,
4409 AC_VERB_GET_PIN_SENSE, 0);
4410 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4411 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4412}
4413
4414static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4415 unsigned int res)
4416{
4417 if ((res >> 26) == ALC880_HP_EVENT)
4418 alc260_hp_3013_automute(codec);
4419}
4420
Kailang Yang3f878302008-08-26 13:02:23 +02004421static void alc260_hp_3012_automute(struct hda_codec *codec)
4422{
4423 unsigned int present, bits;
4424
4425 present = snd_hda_codec_read(codec, 0x10, 0,
4426 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4427
4428 bits = present ? 0 : PIN_OUT;
4429 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4430 bits);
4431 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4432 bits);
4433 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4434 bits);
4435}
4436
4437static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4438 unsigned int res)
4439{
4440 if ((res >> 26) == ALC880_HP_EVENT)
4441 alc260_hp_3012_automute(codec);
4442}
4443
4444/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004445 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4446 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004447static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004448 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004449 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004450 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004451 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4452 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4453 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4454 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004455 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004456 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4457 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004458 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4459 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004460 { } /* end */
4461};
4462
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004463/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4464 * versions of the ALC260 don't act on requests to enable mic bias from NID
4465 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4466 * datasheet doesn't mention this restriction. At this stage it's not clear
4467 * whether this behaviour is intentional or is a hardware bug in chip
4468 * revisions available in early 2006. Therefore for now allow the
4469 * "Headphone Jack Mode" control to span all choices, but if it turns out
4470 * that the lack of mic bias for this NID is intentional we could change the
4471 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4472 *
4473 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4474 * don't appear to make the mic bias available from the "line" jack, even
4475 * though the NID used for this jack (0x14) can supply it. The theory is
4476 * that perhaps Acer have included blocking capacitors between the ALC260
4477 * and the output jack. If this turns out to be the case for all such
4478 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4479 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004480 *
4481 * The C20x Tablet series have a mono internal speaker which is controlled
4482 * via the chip's Mono sum widget and pin complex, so include the necessary
4483 * controls for such models. On models without a "mono speaker" the control
4484 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004485 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004486static struct snd_kcontrol_new alc260_acer_mixer[] = {
4487 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4488 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004489 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004490 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004491 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004492 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004493 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004494 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4495 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4496 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4497 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4498 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4499 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4500 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4501 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4502 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4503 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4504 { } /* end */
4505};
4506
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004507/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4508 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4509 */
4510static struct snd_kcontrol_new alc260_will_mixer[] = {
4511 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4512 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4513 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4514 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4515 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4516 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4517 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4518 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4519 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4520 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4521 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4522 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4523 { } /* end */
4524};
4525
4526/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4527 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4528 */
4529static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4530 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4531 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4532 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4533 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4534 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4535 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4536 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4537 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4538 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4539 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4540 { } /* end */
4541};
4542
Kailang Yangdf694da2005-12-05 19:42:22 +01004543/*
4544 * initialization verbs
4545 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004546static struct hda_verb alc260_init_verbs[] = {
4547 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004549 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004550 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004551 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004552 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004553 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004554 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004555 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004556 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004557 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004558 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004559 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004560 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004561 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004562 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004563 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004564 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4565 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004566 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004567 /* set connection select to line in (default select for this ADC) */
4568 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004569 /* mute capture amp left and right */
4570 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4571 /* set connection select to line in (default select for this ADC) */
4572 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004573 /* set vol=0 Line-Out mixer amp left and right */
4574 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4575 /* unmute pin widget amp left and right (no gain on this amp) */
4576 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4577 /* set vol=0 HP mixer amp left and right */
4578 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4579 /* unmute pin widget amp left and right (no gain on this amp) */
4580 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4581 /* set vol=0 Mono mixer amp left and right */
4582 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4583 /* unmute pin widget amp left and right (no gain on this amp) */
4584 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4585 /* unmute LINE-2 out pin */
4586 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004587 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4588 * Line In 2 = 0x03
4589 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004590 /* mute analog inputs */
4591 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4592 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4593 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004596 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004597 /* mute Front out path */
4598 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4599 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4600 /* mute Headphone out path */
4601 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4602 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4603 /* mute Mono out path */
4604 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4605 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004606 { }
4607};
4608
Takashi Iwai474167d2006-05-17 17:17:43 +02004609#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004610static struct hda_verb alc260_hp_init_verbs[] = {
4611 /* Headphone and output */
4612 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4613 /* mono output */
4614 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4615 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4616 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4617 /* Mic2 (front panel) pin widget for input and vref at 80% */
4618 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4619 /* Line In pin widget for input */
4620 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4621 /* Line-2 pin widget for output */
4622 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4623 /* CD pin widget for input */
4624 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4625 /* unmute amp left and right */
4626 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4627 /* set connection select to line in (default select for this ADC) */
4628 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4629 /* unmute Line-Out mixer amp left and right (volume = 0) */
4630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4631 /* mute pin widget amp left and right (no gain on this amp) */
4632 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4633 /* unmute HP mixer amp left and right (volume = 0) */
4634 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4635 /* mute pin widget amp left and right (no gain on this amp) */
4636 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004637 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4638 * Line In 2 = 0x03
4639 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004640 /* mute analog inputs */
4641 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4645 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004646 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4647 /* Unmute Front out path */
4648 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4649 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4650 /* Unmute Headphone out path */
4651 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4652 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4653 /* Unmute Mono out path */
4654 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4655 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4656 { }
4657};
Takashi Iwai474167d2006-05-17 17:17:43 +02004658#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004659
4660static struct hda_verb alc260_hp_3013_init_verbs[] = {
4661 /* Line out and output */
4662 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4663 /* mono output */
4664 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4665 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4666 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4667 /* Mic2 (front panel) pin widget for input and vref at 80% */
4668 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4669 /* Line In pin widget for input */
4670 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4671 /* Headphone pin widget for output */
4672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4673 /* CD pin widget for input */
4674 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4675 /* unmute amp left and right */
4676 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4677 /* set connection select to line in (default select for this ADC) */
4678 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4679 /* unmute Line-Out mixer amp left and right (volume = 0) */
4680 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4681 /* mute pin widget amp left and right (no gain on this amp) */
4682 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4683 /* unmute HP mixer amp left and right (volume = 0) */
4684 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4685 /* mute pin widget amp left and right (no gain on this amp) */
4686 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004687 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4688 * Line In 2 = 0x03
4689 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004690 /* mute analog inputs */
4691 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4692 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004696 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4697 /* Unmute Front out path */
4698 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4699 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4700 /* Unmute Headphone out path */
4701 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4702 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4703 /* Unmute Mono out path */
4704 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4705 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4706 { }
4707};
4708
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004709/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004710 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4711 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004712 */
4713static struct hda_verb alc260_fujitsu_init_verbs[] = {
4714 /* Disable all GPIOs */
4715 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4716 /* Internal speaker is connected to headphone pin */
4717 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4718 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4719 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004720 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4721 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4722 /* Ensure all other unused pins are disabled and muted. */
4723 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4724 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004725 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004726 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004727 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004728 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4729 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004731
Jonathan Woithef7ace402006-02-28 11:46:14 +01004732 /* Disable digital (SPDIF) pins */
4733 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4734 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004735
Kailang Yangea1fb292008-08-26 12:58:38 +02004736 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004737 * when acting as an output.
4738 */
4739 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4740
4741 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004742 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4743 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4744 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4745 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4746 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4747 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4748 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4749 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4750 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004751
Jonathan Woithef7ace402006-02-28 11:46:14 +01004752 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4753 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4754 /* Unmute Line1 pin widget output buffer since it starts as an output.
4755 * If the pin mode is changed by the user the pin mode control will
4756 * take care of enabling the pin's input/output buffers as needed.
4757 * Therefore there's no need to enable the input buffer at this
4758 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004759 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02004761 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004762 * mixer ctrl)
4763 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004764 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004765
Jonathan Woithef7ace402006-02-28 11:46:14 +01004766 /* Mute capture amp left and right */
4767 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02004768 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01004769 * in (on mic1 pin)
4770 */
4771 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004772
Jonathan Woithef7ace402006-02-28 11:46:14 +01004773 /* Do the same for the second ADC: mute capture input amp and
4774 * set ADC connection to line in (on mic1 pin)
4775 */
4776 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4777 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004778
Jonathan Woithef7ace402006-02-28 11:46:14 +01004779 /* Mute all inputs to mixer widget (even unconnected ones) */
4780 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4781 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4785 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4786 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004788
4789 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004790};
4791
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004792/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4793 * similar laptops (adapted from Fujitsu init verbs).
4794 */
4795static struct hda_verb alc260_acer_init_verbs[] = {
4796 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4797 * the headphone jack. Turn this on and rely on the standard mute
4798 * methods whenever the user wants to turn these outputs off.
4799 */
4800 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4801 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4802 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4803 /* Internal speaker/Headphone jack is connected to Line-out pin */
4804 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4805 /* Internal microphone/Mic jack is connected to Mic1 pin */
4806 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4807 /* Line In jack is connected to Line1 pin */
4808 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004809 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4810 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004811 /* Ensure all other unused pins are disabled and muted. */
4812 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4813 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004814 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4815 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4816 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4818 /* Disable digital (SPDIF) pins */
4819 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4820 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4821
Kailang Yangea1fb292008-08-26 12:58:38 +02004822 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004823 * bus when acting as outputs.
4824 */
4825 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4826 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4827
4828 /* Start with output sum widgets muted and their output gains at min */
4829 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4830 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4831 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4832 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4833 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4834 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4835 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4836 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4837 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4838
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004839 /* Unmute Line-out pin widget amp left and right
4840 * (no equiv mixer ctrl)
4841 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004842 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004843 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4844 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004845 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4846 * inputs. If the pin mode is changed by the user the pin mode control
4847 * will take care of enabling the pin's input/output buffers as needed.
4848 * Therefore there's no need to enable the input buffer at this
4849 * stage.
4850 */
4851 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4852 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4853
4854 /* Mute capture amp left and right */
4855 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4856 /* Set ADC connection select to match default mixer setting - mic
4857 * (on mic1 pin)
4858 */
4859 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4860
4861 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004862 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004863 */
4864 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004865 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004866
4867 /* Mute all inputs to mixer widget (even unconnected ones) */
4868 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4869 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4870 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4871 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4872 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4873 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4876
4877 { }
4878};
4879
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004880static struct hda_verb alc260_will_verbs[] = {
4881 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4882 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4883 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4884 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4885 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4886 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4887 {}
4888};
4889
4890static struct hda_verb alc260_replacer_672v_verbs[] = {
4891 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4892 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4893 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4894
4895 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4896 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4897 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4898
4899 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4900 {}
4901};
4902
4903/* toggle speaker-output according to the hp-jack state */
4904static void alc260_replacer_672v_automute(struct hda_codec *codec)
4905{
4906 unsigned int present;
4907
4908 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4909 present = snd_hda_codec_read(codec, 0x0f, 0,
4910 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4911 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004912 snd_hda_codec_write_cache(codec, 0x01, 0,
4913 AC_VERB_SET_GPIO_DATA, 1);
4914 snd_hda_codec_write_cache(codec, 0x0f, 0,
4915 AC_VERB_SET_PIN_WIDGET_CONTROL,
4916 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004917 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004918 snd_hda_codec_write_cache(codec, 0x01, 0,
4919 AC_VERB_SET_GPIO_DATA, 0);
4920 snd_hda_codec_write_cache(codec, 0x0f, 0,
4921 AC_VERB_SET_PIN_WIDGET_CONTROL,
4922 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004923 }
4924}
4925
4926static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4927 unsigned int res)
4928{
4929 if ((res >> 26) == ALC880_HP_EVENT)
4930 alc260_replacer_672v_automute(codec);
4931}
4932
Kailang Yang3f878302008-08-26 13:02:23 +02004933static struct hda_verb alc260_hp_dc7600_verbs[] = {
4934 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
4935 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4936 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4937 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4938 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4940 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4941 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4942 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4943 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4944 {}
4945};
4946
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004947/* Test configuration for debugging, modelled after the ALC880 test
4948 * configuration.
4949 */
4950#ifdef CONFIG_SND_DEBUG
4951static hda_nid_t alc260_test_dac_nids[1] = {
4952 0x02,
4953};
4954static hda_nid_t alc260_test_adc_nids[2] = {
4955 0x04, 0x05,
4956};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004957/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02004958 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004959 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004960 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004961static struct hda_input_mux alc260_test_capture_sources[2] = {
4962 {
4963 .num_items = 7,
4964 .items = {
4965 { "MIC1 pin", 0x0 },
4966 { "MIC2 pin", 0x1 },
4967 { "LINE1 pin", 0x2 },
4968 { "LINE2 pin", 0x3 },
4969 { "CD pin", 0x4 },
4970 { "LINE-OUT pin", 0x5 },
4971 { "HP-OUT pin", 0x6 },
4972 },
4973 },
4974 {
4975 .num_items = 8,
4976 .items = {
4977 { "MIC1 pin", 0x0 },
4978 { "MIC2 pin", 0x1 },
4979 { "LINE1 pin", 0x2 },
4980 { "LINE2 pin", 0x3 },
4981 { "CD pin", 0x4 },
4982 { "Mixer", 0x5 },
4983 { "LINE-OUT pin", 0x6 },
4984 { "HP-OUT pin", 0x7 },
4985 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004986 },
4987};
4988static struct snd_kcontrol_new alc260_test_mixer[] = {
4989 /* Output driver widgets */
4990 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4991 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4992 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4993 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4994 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4995 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4996
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004997 /* Modes for retasking pin widgets
4998 * Note: the ALC260 doesn't seem to act on requests to enable mic
4999 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5000 * mention this restriction. At this stage it's not clear whether
5001 * this behaviour is intentional or is a hardware bug in chip
5002 * revisions available at least up until early 2006. Therefore for
5003 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5004 * choices, but if it turns out that the lack of mic bias for these
5005 * NIDs is intentional we could change their modes from
5006 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5007 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005008 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5009 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5010 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5011 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5012 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5013 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5014
5015 /* Loopback mixer controls */
5016 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5017 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5018 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5019 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5020 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5021 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5022 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5023 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5024 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5025 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5026 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
5027 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
5028 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5029 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5030 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5031 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005032
5033 /* Controls for GPIO pins, assuming they are configured as outputs */
5034 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5035 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5036 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5037 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5038
Jonathan Woithe92621f12006-02-28 11:47:47 +01005039 /* Switches to allow the digital IO pins to be enabled. The datasheet
5040 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005041 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005042 */
5043 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5044 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5045
Jonathan Woithef8225f62008-01-08 12:16:54 +01005046 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5047 * this output to turn on an external amplifier.
5048 */
5049 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5050 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5051
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005052 { } /* end */
5053};
5054static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005055 /* Enable all GPIOs as outputs with an initial value of 0 */
5056 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5057 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5058 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5059
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005060 /* Enable retasking pins as output, initially without power amp */
5061 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5062 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5063 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5064 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5065 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5066 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5067
Jonathan Woithe92621f12006-02-28 11:47:47 +01005068 /* Disable digital (SPDIF) pins initially, but users can enable
5069 * them via a mixer switch. In the case of SPDIF-out, this initverb
5070 * payload also sets the generation to 0, output to be in "consumer"
5071 * PCM format, copyright asserted, no pre-emphasis and no validity
5072 * control.
5073 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005074 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5075 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5076
Kailang Yangea1fb292008-08-26 12:58:38 +02005077 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005078 * OUT1 sum bus when acting as an output.
5079 */
5080 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5081 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5082 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5083 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5084
5085 /* Start with output sum widgets muted and their output gains at min */
5086 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5087 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5088 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5089 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5090 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5092 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5093 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5094 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5095
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005096 /* Unmute retasking pin widget output buffers since the default
5097 * state appears to be output. As the pin mode is changed by the
5098 * user the pin mode control will take care of enabling the pin's
5099 * input/output buffers as needed.
5100 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005101 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5102 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5103 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5104 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5105 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5106 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5107 /* Also unmute the mono-out pin widget */
5108 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5109
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005110 /* Mute capture amp left and right */
5111 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005112 /* Set ADC connection select to match default mixer setting (mic1
5113 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005114 */
5115 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5116
5117 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005118 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005119 */
5120 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5121 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5122
5123 /* Mute all inputs to mixer widget (even unconnected ones) */
5124 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5125 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5126 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5127 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5132
5133 { }
5134};
5135#endif
5136
Takashi Iwai63300792008-01-24 15:31:36 +01005137#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5138#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005139
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005140#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5141#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5142
Kailang Yangdf694da2005-12-05 19:42:22 +01005143/*
5144 * for BIOS auto-configuration
5145 */
5146
5147static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005148 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005149{
5150 hda_nid_t nid_vol;
5151 unsigned long vol_val, sw_val;
5152 char name[32];
5153 int err;
5154
5155 if (nid >= 0x0f && nid < 0x11) {
5156 nid_vol = nid - 0x7;
5157 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5158 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5159 } else if (nid == 0x11) {
5160 nid_vol = nid - 0x7;
5161 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5162 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5163 } else if (nid >= 0x12 && nid <= 0x15) {
5164 nid_vol = 0x08;
5165 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5166 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5167 } else
5168 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005169
Takashi Iwai863b4512008-10-21 17:01:47 +02005170 if (!(*vol_bits & (1 << nid_vol))) {
5171 /* first control for the volume widget */
5172 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5173 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5174 if (err < 0)
5175 return err;
5176 *vol_bits |= (1 << nid_vol);
5177 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005178 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005179 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5180 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005181 return err;
5182 return 1;
5183}
5184
5185/* add playback controls from the parsed DAC table */
5186static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5187 const struct auto_pin_cfg *cfg)
5188{
5189 hda_nid_t nid;
5190 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005191 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005192
5193 spec->multiout.num_dacs = 1;
5194 spec->multiout.dac_nids = spec->private_dac_nids;
5195 spec->multiout.dac_nids[0] = 0x02;
5196
5197 nid = cfg->line_out_pins[0];
5198 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005199 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005200 if (err < 0)
5201 return err;
5202 }
5203
Takashi Iwai82bc9552006-03-21 11:24:42 +01005204 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005205 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005206 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005207 if (err < 0)
5208 return err;
5209 }
5210
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005211 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005212 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005213 err = alc260_add_playback_controls(spec, nid, "Headphone",
5214 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005215 if (err < 0)
5216 return err;
5217 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005218 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005219}
5220
5221/* create playback/capture controls for input pins */
5222static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5223 const struct auto_pin_cfg *cfg)
5224{
Kailang Yangdf694da2005-12-05 19:42:22 +01005225 struct hda_input_mux *imux = &spec->private_imux;
5226 int i, err, idx;
5227
5228 for (i = 0; i < AUTO_PIN_LAST; i++) {
5229 if (cfg->input_pins[i] >= 0x12) {
5230 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005231 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005232 auto_pin_cfg_labels[i], idx,
5233 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005234 if (err < 0)
5235 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005236 imux->items[imux->num_items].label =
5237 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005238 imux->items[imux->num_items].index = idx;
5239 imux->num_items++;
5240 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005241 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005242 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005243 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005244 auto_pin_cfg_labels[i], idx,
5245 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005246 if (err < 0)
5247 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005248 imux->items[imux->num_items].label =
5249 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005250 imux->items[imux->num_items].index = idx;
5251 imux->num_items++;
5252 }
5253 }
5254 return 0;
5255}
5256
5257static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5258 hda_nid_t nid, int pin_type,
5259 int sel_idx)
5260{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005261 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005262 /* need the manual connection? */
5263 if (nid >= 0x12) {
5264 int idx = nid - 0x12;
5265 snd_hda_codec_write(codec, idx + 0x0b, 0,
5266 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005267 }
5268}
5269
5270static void alc260_auto_init_multi_out(struct hda_codec *codec)
5271{
5272 struct alc_spec *spec = codec->spec;
5273 hda_nid_t nid;
5274
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005275 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005276 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005277 if (nid) {
5278 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5279 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5280 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005281
Takashi Iwai82bc9552006-03-21 11:24:42 +01005282 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005283 if (nid)
5284 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5285
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005286 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005287 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005288 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005289}
Kailang Yangdf694da2005-12-05 19:42:22 +01005290
5291#define ALC260_PIN_CD_NID 0x16
5292static void alc260_auto_init_analog_input(struct hda_codec *codec)
5293{
5294 struct alc_spec *spec = codec->spec;
5295 int i;
5296
5297 for (i = 0; i < AUTO_PIN_LAST; i++) {
5298 hda_nid_t nid = spec->autocfg.input_pins[i];
5299 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005300 snd_hda_codec_write(codec, nid, 0,
5301 AC_VERB_SET_PIN_WIDGET_CONTROL,
5302 i <= AUTO_PIN_FRONT_MIC ?
5303 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005304 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005305 snd_hda_codec_write(codec, nid, 0,
5306 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005307 AMP_OUT_MUTE);
5308 }
5309 }
5310}
5311
5312/*
5313 * generic initialization of ADC, input mixers and output mixers
5314 */
5315static struct hda_verb alc260_volume_init_verbs[] = {
5316 /*
5317 * Unmute ADC0-1 and set the default input to mic-in
5318 */
5319 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5320 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5321 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5322 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005323
Kailang Yangdf694da2005-12-05 19:42:22 +01005324 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5325 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005326 * Note: PASD motherboards uses the Line In 2 as the input for
5327 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005328 */
5329 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005330 /* mute analog inputs */
5331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005336
5337 /*
5338 * Set up output mixers (0x08 - 0x0a)
5339 */
5340 /* set vol=0 to output mixers */
5341 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5343 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5344 /* set up input amps for analog loopback */
5345 /* Amp Indices: DAC = 0, mixer = 1 */
5346 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5347 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5348 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5349 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5350 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5351 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005352
Kailang Yangdf694da2005-12-05 19:42:22 +01005353 { }
5354};
5355
5356static int alc260_parse_auto_config(struct hda_codec *codec)
5357{
5358 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005359 int err;
5360 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5361
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005362 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5363 alc260_ignore);
5364 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005365 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005366 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5367 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005368 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005369 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005370 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005371 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5372 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005373 return err;
5374
5375 spec->multiout.max_channels = 2;
5376
5377 if (spec->autocfg.dig_out_pin)
5378 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005379 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005380 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005381
Takashi Iwaid88897e2008-10-31 15:01:37 +01005382 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005383
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005384 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005385 spec->input_mux = &spec->private_imux;
5386
Takashi Iwaie044c392008-10-27 16:56:24 +01005387 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005388 return 1;
5389}
5390
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005391/* additional initialization for auto-configuration model */
5392static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005393{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005394 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005395 alc260_auto_init_multi_out(codec);
5396 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005397 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005398 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005399}
5400
Takashi Iwaicb53c622007-08-10 17:21:45 +02005401#ifdef CONFIG_SND_HDA_POWER_SAVE
5402static struct hda_amp_list alc260_loopbacks[] = {
5403 { 0x07, HDA_INPUT, 0 },
5404 { 0x07, HDA_INPUT, 1 },
5405 { 0x07, HDA_INPUT, 2 },
5406 { 0x07, HDA_INPUT, 3 },
5407 { 0x07, HDA_INPUT, 4 },
5408 { } /* end */
5409};
5410#endif
5411
Kailang Yangdf694da2005-12-05 19:42:22 +01005412/*
5413 * ALC260 configurations
5414 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005415static const char *alc260_models[ALC260_MODEL_LAST] = {
5416 [ALC260_BASIC] = "basic",
5417 [ALC260_HP] = "hp",
5418 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005419 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005420 [ALC260_FUJITSU_S702X] = "fujitsu",
5421 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005422 [ALC260_WILL] = "will",
5423 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005424#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005425 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005426#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005427 [ALC260_AUTO] = "auto",
5428};
5429
5430static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005431 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005432 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005433 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005434 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005435 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005436 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005437 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005438 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5439 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5440 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5441 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5442 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5443 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5444 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5445 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5446 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005447 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005448 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005449 {}
5450};
5451
Kailang Yangdf694da2005-12-05 19:42:22 +01005452static struct alc_config_preset alc260_presets[] = {
5453 [ALC260_BASIC] = {
5454 .mixers = { alc260_base_output_mixer,
5455 alc260_input_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005456 alc260_pc_beep_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005457 .init_verbs = { alc260_init_verbs },
5458 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5459 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005460 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005461 .adc_nids = alc260_adc_nids,
5462 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5463 .channel_mode = alc260_modes,
5464 .input_mux = &alc260_capture_source,
5465 },
5466 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005467 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005468 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005469 .init_verbs = { alc260_init_verbs,
5470 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005471 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5472 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005473 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5474 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005475 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5476 .channel_mode = alc260_modes,
5477 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005478 .unsol_event = alc260_hp_unsol_event,
5479 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005480 },
Kailang Yang3f878302008-08-26 13:02:23 +02005481 [ALC260_HP_DC7600] = {
5482 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005483 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005484 .init_verbs = { alc260_init_verbs,
5485 alc260_hp_dc7600_verbs },
5486 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5487 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005488 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5489 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005490 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5491 .channel_mode = alc260_modes,
5492 .input_mux = &alc260_capture_source,
5493 .unsol_event = alc260_hp_3012_unsol_event,
5494 .init_hook = alc260_hp_3012_automute,
5495 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005496 [ALC260_HP_3013] = {
5497 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005498 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005499 .init_verbs = { alc260_hp_3013_init_verbs,
5500 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005501 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5502 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005503 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5504 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005505 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5506 .channel_mode = alc260_modes,
5507 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005508 .unsol_event = alc260_hp_3013_unsol_event,
5509 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005510 },
5511 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005512 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005513 .init_verbs = { alc260_fujitsu_init_verbs },
5514 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5515 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005516 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5517 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005518 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5519 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005520 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5521 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005522 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005523 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005524 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005525 .init_verbs = { alc260_acer_init_verbs },
5526 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5527 .dac_nids = alc260_dac_nids,
5528 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5529 .adc_nids = alc260_dual_adc_nids,
5530 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5531 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005532 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5533 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005534 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005535 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005536 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005537 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5538 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5539 .dac_nids = alc260_dac_nids,
5540 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5541 .adc_nids = alc260_adc_nids,
5542 .dig_out_nid = ALC260_DIGOUT_NID,
5543 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5544 .channel_mode = alc260_modes,
5545 .input_mux = &alc260_capture_source,
5546 },
5547 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005548 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005549 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5550 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5551 .dac_nids = alc260_dac_nids,
5552 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5553 .adc_nids = alc260_adc_nids,
5554 .dig_out_nid = ALC260_DIGOUT_NID,
5555 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5556 .channel_mode = alc260_modes,
5557 .input_mux = &alc260_capture_source,
5558 .unsol_event = alc260_replacer_672v_unsol_event,
5559 .init_hook = alc260_replacer_672v_automute,
5560 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005561#ifdef CONFIG_SND_DEBUG
5562 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005563 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005564 .init_verbs = { alc260_test_init_verbs },
5565 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5566 .dac_nids = alc260_test_dac_nids,
5567 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5568 .adc_nids = alc260_test_adc_nids,
5569 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5570 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005571 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5572 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005573 },
5574#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005575};
5576
Linus Torvalds1da177e2005-04-16 15:20:36 -07005577static int patch_alc260(struct hda_codec *codec)
5578{
5579 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005580 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005581
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005582 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005583 if (spec == NULL)
5584 return -ENOMEM;
5585
5586 codec->spec = spec;
5587
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005588 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5589 alc260_models,
5590 alc260_cfg_tbl);
5591 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005592 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5593 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005594 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005595 }
5596
Kailang Yangdf694da2005-12-05 19:42:22 +01005597 if (board_config == ALC260_AUTO) {
5598 /* automatic parse from the BIOS config */
5599 err = alc260_parse_auto_config(codec);
5600 if (err < 0) {
5601 alc_free(codec);
5602 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005603 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005604 printk(KERN_INFO
5605 "hda_codec: Cannot set up configuration "
5606 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005607 board_config = ALC260_BASIC;
5608 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005609 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005610
Kailang Yangdf694da2005-12-05 19:42:22 +01005611 if (board_config != ALC260_AUTO)
5612 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005613
5614 spec->stream_name_analog = "ALC260 Analog";
5615 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5616 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5617
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005618 spec->stream_name_digital = "ALC260 Digital";
5619 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5620 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5621
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01005622 if (!spec->adc_nids && spec->input_mux) {
5623 /* check whether NID 0x04 is valid */
5624 unsigned int wcap = get_wcaps(codec, 0x04);
5625 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5626 /* get type */
5627 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5628 spec->adc_nids = alc260_adc_nids_alt;
5629 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5630 } else {
5631 spec->adc_nids = alc260_adc_nids;
5632 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5633 }
5634 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005635 set_capture_mixer(spec);
5636
Takashi Iwai2134ea42008-01-10 16:53:55 +01005637 spec->vmaster_nid = 0x08;
5638
Linus Torvalds1da177e2005-04-16 15:20:36 -07005639 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005640 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005641 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005642#ifdef CONFIG_SND_HDA_POWER_SAVE
5643 if (!spec->loopback.amplist)
5644 spec->loopback.amplist = alc260_loopbacks;
5645#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005646
5647 return 0;
5648}
5649
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005650
Linus Torvalds1da177e2005-04-16 15:20:36 -07005651/*
5652 * ALC882 support
5653 *
5654 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5655 * configuration. Each pin widget can choose any input DACs and a mixer.
5656 * Each ADC is connected from a mixer of all inputs. This makes possible
5657 * 6-channel independent captures.
5658 *
5659 * In addition, an independent DAC for the multi-playback (not used in this
5660 * driver yet).
5661 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005662#define ALC882_DIGOUT_NID 0x06
5663#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005664
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005665static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005666 { 8, NULL }
5667};
5668
5669static hda_nid_t alc882_dac_nids[4] = {
5670 /* front, rear, clfe, rear_surr */
5671 0x02, 0x03, 0x04, 0x05
5672};
5673
Kailang Yangdf694da2005-12-05 19:42:22 +01005674/* identical with ALC880 */
5675#define alc882_adc_nids alc880_adc_nids
5676#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005677
Takashi Iwaie1406342008-02-11 18:32:32 +01005678static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5679static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5680
Linus Torvalds1da177e2005-04-16 15:20:36 -07005681/* input MUX */
5682/* FIXME: should be a matrix-type input source selection */
5683
5684static struct hda_input_mux alc882_capture_source = {
5685 .num_items = 4,
5686 .items = {
5687 { "Mic", 0x0 },
5688 { "Front Mic", 0x1 },
5689 { "Line", 0x2 },
5690 { "CD", 0x4 },
5691 },
5692};
Kailang Yangdf694da2005-12-05 19:42:22 +01005693/*
Kailang Yang272a5272007-05-14 11:00:38 +02005694 * 2ch mode
5695 */
5696static struct hda_verb alc882_3ST_ch2_init[] = {
5697 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5698 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5699 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5700 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5701 { } /* end */
5702};
5703
5704/*
5705 * 6ch mode
5706 */
5707static struct hda_verb alc882_3ST_ch6_init[] = {
5708 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5709 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5710 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5711 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5712 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5713 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5714 { } /* end */
5715};
5716
5717static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5718 { 2, alc882_3ST_ch2_init },
5719 { 6, alc882_3ST_ch6_init },
5720};
5721
5722/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005723 * 6ch mode
5724 */
5725static struct hda_verb alc882_sixstack_ch6_init[] = {
5726 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5727 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5728 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5729 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5730 { } /* end */
5731};
5732
5733/*
5734 * 8ch mode
5735 */
5736static struct hda_verb alc882_sixstack_ch8_init[] = {
5737 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5738 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5739 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5740 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5741 { } /* end */
5742};
5743
5744static struct hda_channel_mode alc882_sixstack_modes[2] = {
5745 { 6, alc882_sixstack_ch6_init },
5746 { 8, alc882_sixstack_ch8_init },
5747};
5748
Takashi Iwai87350ad2007-08-16 18:19:38 +02005749/*
5750 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5751 */
5752
5753/*
5754 * 2ch mode
5755 */
5756static struct hda_verb alc885_mbp_ch2_init[] = {
5757 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5758 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5759 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5760 { } /* end */
5761};
5762
5763/*
5764 * 6ch mode
5765 */
5766static struct hda_verb alc885_mbp_ch6_init[] = {
5767 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5768 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5769 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5770 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5771 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5772 { } /* end */
5773};
5774
5775static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5776 { 2, alc885_mbp_ch2_init },
5777 { 6, alc885_mbp_ch6_init },
5778};
5779
5780
Linus Torvalds1da177e2005-04-16 15:20:36 -07005781/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5782 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5783 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005784static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005785 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005786 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005787 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005788 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005789 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5790 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005791 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5792 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005793 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005794 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5796 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5797 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5798 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5799 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5800 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005801 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005802 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5803 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005804 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005805 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5806 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5807 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005808 { } /* end */
5809};
5810
Takashi Iwai87350ad2007-08-16 18:19:38 +02005811static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005812 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5813 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5814 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5815 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5816 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5817 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5819 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005820 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005821 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5822 { } /* end */
5823};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005824static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5825 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5826 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5827 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5828 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5829 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5830 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5832 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5834 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5835 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5836 { } /* end */
5837};
5838
Kailang Yang272a5272007-05-14 11:00:38 +02005839static struct snd_kcontrol_new alc882_targa_mixer[] = {
5840 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5841 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5845 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005849 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005850 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5851 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005852 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005853 { } /* end */
5854};
5855
5856/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5857 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5858 */
5859static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5860 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5861 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5862 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5863 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5864 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5865 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5866 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5867 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5868 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5869 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5870 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5871 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005872 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005873 { } /* end */
5874};
5875
Takashi Iwai914759b2007-09-06 14:52:04 +02005876static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5877 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5878 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5879 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5880 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5881 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5882 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5883 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5884 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5885 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5886 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5887 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5888 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5889 { } /* end */
5890};
5891
Kailang Yangdf694da2005-12-05 19:42:22 +01005892static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5893 {
5894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5895 .name = "Channel Mode",
5896 .info = alc_ch_mode_info,
5897 .get = alc_ch_mode_get,
5898 .put = alc_ch_mode_put,
5899 },
5900 { } /* end */
5901};
5902
Linus Torvalds1da177e2005-04-16 15:20:36 -07005903static struct hda_verb alc882_init_verbs[] = {
5904 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005905 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5906 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5907 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005908 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005909 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5910 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5911 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005912 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005913 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5914 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5915 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005916 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005917 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5918 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5919 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005920
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005921 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005922 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005923 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005924 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005925 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005926 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005927 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005928 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005929 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005930 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005931 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005932 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005933 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005934 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005935 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005936 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005937 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005938 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005939 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5940 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005941 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005942 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5943 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005944 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005945 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5946 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5947 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5948 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5949 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005950 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005951 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005952
5953 /* FIXME: use matrix-type input source selection */
5954 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5955 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005956 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5957 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5958 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5959 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005960 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005961 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5962 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5963 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5964 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005965 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005966 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5967 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5968 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5970 /* ADC1: mute amp left and right */
5971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005972 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005973 /* ADC2: mute amp left and right */
5974 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005975 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005976 /* ADC3: mute amp left and right */
5977 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005978 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005979
5980 { }
5981};
5982
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005983static struct hda_verb alc882_eapd_verbs[] = {
5984 /* change to EAPD mode */
5985 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005986 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005987 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005988};
5989
Tobin Davis9102cd12006-12-15 10:02:12 +01005990/* Mac Pro test */
5991static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5993 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5995 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5996 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5997 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5998 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5999 { } /* end */
6000};
6001
6002static struct hda_verb alc882_macpro_init_verbs[] = {
6003 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6004 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6005 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6006 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6007 /* Front Pin: output 0 (0x0c) */
6008 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6009 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6010 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6011 /* Front Mic pin: input vref at 80% */
6012 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6013 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6014 /* Speaker: output */
6015 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6016 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6017 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6018 /* Headphone output (output 0 - 0x0c) */
6019 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6020 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6021 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6022
6023 /* FIXME: use matrix-type input source selection */
6024 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6025 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6027 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6029 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6030 /* Input mixer2 */
6031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6032 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6034 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6035 /* Input mixer3 */
6036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6037 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6040 /* ADC1: mute amp left and right */
6041 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6042 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6043 /* ADC2: mute amp left and right */
6044 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6045 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6046 /* ADC3: mute amp left and right */
6047 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6048 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6049
6050 { }
6051};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006052
Takashi Iwai87350ad2007-08-16 18:19:38 +02006053/* Macbook Pro rev3 */
6054static struct hda_verb alc885_mbp3_init_verbs[] = {
6055 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6056 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6057 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6058 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6059 /* Rear mixer */
6060 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6061 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6062 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6063 /* Front Pin: output 0 (0x0c) */
6064 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6065 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6066 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6067 /* HP Pin: output 0 (0x0d) */
6068 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6070 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6071 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6072 /* Mic (rear) pin: input vref at 80% */
6073 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6075 /* Front Mic pin: input vref at 80% */
6076 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6077 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6078 /* Line In pin: use output 1 when in LineOut mode */
6079 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6080 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6081 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6082
6083 /* FIXME: use matrix-type input source selection */
6084 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6085 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6086 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6087 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6088 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6089 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6090 /* Input mixer2 */
6091 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6092 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6094 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6095 /* Input mixer3 */
6096 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6100 /* ADC1: mute amp left and right */
6101 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6102 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6103 /* ADC2: mute amp left and right */
6104 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6105 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6106 /* ADC3: mute amp left and right */
6107 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6108 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6109
6110 { }
6111};
6112
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006113/* iMac 24 mixer. */
6114static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6115 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6116 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6117 { } /* end */
6118};
6119
6120/* iMac 24 init verbs. */
6121static struct hda_verb alc885_imac24_init_verbs[] = {
6122 /* Internal speakers: output 0 (0x0c) */
6123 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6124 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6125 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6126 /* Internal speakers: output 0 (0x0c) */
6127 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6128 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6129 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6130 /* Headphone: output 0 (0x0c) */
6131 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6132 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6133 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6134 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6135 /* Front Mic: input vref at 80% */
6136 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6137 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6138 { }
6139};
6140
6141/* Toggle speaker-output according to the hp-jack state */
6142static void alc885_imac24_automute(struct hda_codec *codec)
6143{
6144 unsigned int present;
6145
6146 present = snd_hda_codec_read(codec, 0x14, 0,
6147 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006148 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6149 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6150 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6151 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006152}
6153
6154/* Processes unsolicited events. */
6155static void alc885_imac24_unsol_event(struct hda_codec *codec,
6156 unsigned int res)
6157{
6158 /* Headphone insertion or removal. */
6159 if ((res >> 26) == ALC880_HP_EVENT)
6160 alc885_imac24_automute(codec);
6161}
6162
Takashi Iwai87350ad2007-08-16 18:19:38 +02006163static void alc885_mbp3_automute(struct hda_codec *codec)
6164{
6165 unsigned int present;
6166
6167 present = snd_hda_codec_read(codec, 0x15, 0,
6168 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6169 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6170 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6171 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6172 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6173
6174}
6175static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6176 unsigned int res)
6177{
6178 /* Headphone insertion or removal. */
6179 if ((res >> 26) == ALC880_HP_EVENT)
6180 alc885_mbp3_automute(codec);
6181}
6182
6183
Kailang Yang272a5272007-05-14 11:00:38 +02006184static struct hda_verb alc882_targa_verbs[] = {
6185 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6186 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6187
6188 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6189 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006190
Kailang Yang272a5272007-05-14 11:00:38 +02006191 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6192 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6193 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6194
6195 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6196 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6197 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6198 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6199 { } /* end */
6200};
6201
6202/* toggle speaker-output according to the hp-jack state */
6203static void alc882_targa_automute(struct hda_codec *codec)
6204{
6205 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006206
Kailang Yang272a5272007-05-14 11:00:38 +02006207 present = snd_hda_codec_read(codec, 0x14, 0,
6208 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006209 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6210 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006211 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6212 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006213}
6214
6215static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6216{
6217 /* Looks like the unsol event is incompatible with the standard
6218 * definition. 4bit tag is placed at 26 bit!
6219 */
6220 if (((res >> 26) == ALC880_HP_EVENT)) {
6221 alc882_targa_automute(codec);
6222 }
6223}
6224
6225static struct hda_verb alc882_asus_a7j_verbs[] = {
6226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6228
6229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6230 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6231 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006232
Kailang Yang272a5272007-05-14 11:00:38 +02006233 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6234 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6235 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6236
6237 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6238 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6239 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6240 { } /* end */
6241};
6242
Takashi Iwai914759b2007-09-06 14:52:04 +02006243static struct hda_verb alc882_asus_a7m_verbs[] = {
6244 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6245 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6246
6247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6248 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6249 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006250
Takashi Iwai914759b2007-09-06 14:52:04 +02006251 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6252 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6253 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6254
6255 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6256 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6257 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6258 { } /* end */
6259};
6260
Tobin Davis9102cd12006-12-15 10:02:12 +01006261static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6262{
6263 unsigned int gpiostate, gpiomask, gpiodir;
6264
6265 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6266 AC_VERB_GET_GPIO_DATA, 0);
6267
6268 if (!muted)
6269 gpiostate |= (1 << pin);
6270 else
6271 gpiostate &= ~(1 << pin);
6272
6273 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6274 AC_VERB_GET_GPIO_MASK, 0);
6275 gpiomask |= (1 << pin);
6276
6277 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6278 AC_VERB_GET_GPIO_DIRECTION, 0);
6279 gpiodir |= (1 << pin);
6280
6281
6282 snd_hda_codec_write(codec, codec->afg, 0,
6283 AC_VERB_SET_GPIO_MASK, gpiomask);
6284 snd_hda_codec_write(codec, codec->afg, 0,
6285 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6286
6287 msleep(1);
6288
6289 snd_hda_codec_write(codec, codec->afg, 0,
6290 AC_VERB_SET_GPIO_DATA, gpiostate);
6291}
6292
Takashi Iwai7debbe52007-08-16 15:01:03 +02006293/* set up GPIO at initialization */
6294static void alc885_macpro_init_hook(struct hda_codec *codec)
6295{
6296 alc882_gpio_mute(codec, 0, 0);
6297 alc882_gpio_mute(codec, 1, 0);
6298}
6299
6300/* set up GPIO and update auto-muting at initialization */
6301static void alc885_imac24_init_hook(struct hda_codec *codec)
6302{
6303 alc885_macpro_init_hook(codec);
6304 alc885_imac24_automute(codec);
6305}
6306
Kailang Yangdf694da2005-12-05 19:42:22 +01006307/*
6308 * generic initialization of ADC, input mixers and output mixers
6309 */
6310static struct hda_verb alc882_auto_init_verbs[] = {
6311 /*
6312 * Unmute ADC0-2 and set the default input to mic-in
6313 */
6314 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6315 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6316 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6317 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6318 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6319 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6320
Takashi Iwaicb53c622007-08-10 17:21:45 +02006321 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006322 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006323 * Note: PASD motherboards uses the Line In 2 as the input for
6324 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006325 */
6326 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006332
6333 /*
6334 * Set up output mixers (0x0c - 0x0f)
6335 */
6336 /* set vol=0 to output mixers */
6337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6338 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6339 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6340 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6341 /* set up input amps for analog loopback */
6342 /* Amp Indices: DAC = 0, mixer = 1 */
6343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6345 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6349 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6351 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6352 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6353
6354 /* FIXME: use matrix-type input source selection */
6355 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6356 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6357 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6361 /* Input mixer2 */
6362 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6363 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6365 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6366 /* Input mixer3 */
6367 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6368 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6369 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6371
6372 { }
6373};
6374
Takashi Iwaicb53c622007-08-10 17:21:45 +02006375#ifdef CONFIG_SND_HDA_POWER_SAVE
6376#define alc882_loopbacks alc880_loopbacks
6377#endif
6378
Kailang Yangdf694da2005-12-05 19:42:22 +01006379/* pcm configuration: identiacal with ALC880 */
6380#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6381#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6382#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6383#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6384
6385/*
6386 * configuration and preset
6387 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006388static const char *alc882_models[ALC882_MODEL_LAST] = {
6389 [ALC882_3ST_DIG] = "3stack-dig",
6390 [ALC882_6ST_DIG] = "6stack-dig",
6391 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006392 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006393 [ALC882_TARGA] = "targa",
6394 [ALC882_ASUS_A7J] = "asus-a7j",
6395 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006396 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006397 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006398 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006399 [ALC882_AUTO] = "auto",
6400};
6401
6402static struct snd_pci_quirk alc882_cfg_tbl[] = {
6403 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006404 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006405 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006406 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006407 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006408 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006409 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006410 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006411 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006412 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6413 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6414 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006415 {}
6416};
6417
6418static struct alc_config_preset alc882_presets[] = {
6419 [ALC882_3ST_DIG] = {
6420 .mixers = { alc882_base_mixer },
6421 .init_verbs = { alc882_init_verbs },
6422 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6423 .dac_nids = alc882_dac_nids,
6424 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006425 .dig_in_nid = ALC882_DIGIN_NID,
6426 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6427 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006428 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006429 .input_mux = &alc882_capture_source,
6430 },
6431 [ALC882_6ST_DIG] = {
6432 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6433 .init_verbs = { alc882_init_verbs },
6434 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6435 .dac_nids = alc882_dac_nids,
6436 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006437 .dig_in_nid = ALC882_DIGIN_NID,
6438 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6439 .channel_mode = alc882_sixstack_modes,
6440 .input_mux = &alc882_capture_source,
6441 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006442 [ALC882_ARIMA] = {
6443 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6444 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6445 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6446 .dac_nids = alc882_dac_nids,
6447 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6448 .channel_mode = alc882_sixstack_modes,
6449 .input_mux = &alc882_capture_source,
6450 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006451 [ALC882_W2JC] = {
6452 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6453 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6454 alc880_gpio1_init_verbs },
6455 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6456 .dac_nids = alc882_dac_nids,
6457 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6458 .channel_mode = alc880_threestack_modes,
6459 .need_dac_fix = 1,
6460 .input_mux = &alc882_capture_source,
6461 .dig_out_nid = ALC882_DIGOUT_NID,
6462 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006463 [ALC885_MBP3] = {
6464 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6465 .init_verbs = { alc885_mbp3_init_verbs,
6466 alc880_gpio1_init_verbs },
6467 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6468 .dac_nids = alc882_dac_nids,
6469 .channel_mode = alc885_mbp_6ch_modes,
6470 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6471 .input_mux = &alc882_capture_source,
6472 .dig_out_nid = ALC882_DIGOUT_NID,
6473 .dig_in_nid = ALC882_DIGIN_NID,
6474 .unsol_event = alc885_mbp3_unsol_event,
6475 .init_hook = alc885_mbp3_automute,
6476 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006477 [ALC885_MACPRO] = {
6478 .mixers = { alc882_macpro_mixer },
6479 .init_verbs = { alc882_macpro_init_verbs },
6480 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6481 .dac_nids = alc882_dac_nids,
6482 .dig_out_nid = ALC882_DIGOUT_NID,
6483 .dig_in_nid = ALC882_DIGIN_NID,
6484 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6485 .channel_mode = alc882_ch_modes,
6486 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006487 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006488 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006489 [ALC885_IMAC24] = {
6490 .mixers = { alc885_imac24_mixer },
6491 .init_verbs = { alc885_imac24_init_verbs },
6492 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6493 .dac_nids = alc882_dac_nids,
6494 .dig_out_nid = ALC882_DIGOUT_NID,
6495 .dig_in_nid = ALC882_DIGIN_NID,
6496 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6497 .channel_mode = alc882_ch_modes,
6498 .input_mux = &alc882_capture_source,
6499 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006500 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006501 },
Kailang Yang272a5272007-05-14 11:00:38 +02006502 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006503 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006504 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6505 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6506 .dac_nids = alc882_dac_nids,
6507 .dig_out_nid = ALC882_DIGOUT_NID,
6508 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6509 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006510 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006511 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6512 .channel_mode = alc882_3ST_6ch_modes,
6513 .need_dac_fix = 1,
6514 .input_mux = &alc882_capture_source,
6515 .unsol_event = alc882_targa_unsol_event,
6516 .init_hook = alc882_targa_automute,
6517 },
6518 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006519 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006520 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6521 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6522 .dac_nids = alc882_dac_nids,
6523 .dig_out_nid = ALC882_DIGOUT_NID,
6524 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6525 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006526 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006527 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6528 .channel_mode = alc882_3ST_6ch_modes,
6529 .need_dac_fix = 1,
6530 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006531 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006532 [ALC882_ASUS_A7M] = {
6533 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6534 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6535 alc880_gpio1_init_verbs,
6536 alc882_asus_a7m_verbs },
6537 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6538 .dac_nids = alc882_dac_nids,
6539 .dig_out_nid = ALC882_DIGOUT_NID,
6540 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6541 .channel_mode = alc880_threestack_modes,
6542 .need_dac_fix = 1,
6543 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006544 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006545};
6546
6547
6548/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006549 * Pin config fixes
6550 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006551enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006552 PINFIX_ABIT_AW9D_MAX
6553};
6554
6555static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6556 { 0x15, 0x01080104 }, /* side */
6557 { 0x16, 0x01011012 }, /* rear */
6558 { 0x17, 0x01016011 }, /* clfe */
6559 { }
6560};
6561
6562static const struct alc_pincfg *alc882_pin_fixes[] = {
6563 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6564};
6565
6566static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6567 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6568 {}
6569};
6570
6571/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006572 * BIOS auto configuration
6573 */
6574static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6575 hda_nid_t nid, int pin_type,
6576 int dac_idx)
6577{
6578 /* set as output */
6579 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006580 int idx;
6581
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006582 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006583 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6584 idx = 4;
6585 else
6586 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006587 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6588
6589}
6590
6591static void alc882_auto_init_multi_out(struct hda_codec *codec)
6592{
6593 struct alc_spec *spec = codec->spec;
6594 int i;
6595
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006596 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006597 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006598 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006599 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006600 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006601 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006602 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006603 }
6604}
6605
6606static void alc882_auto_init_hp_out(struct hda_codec *codec)
6607{
6608 struct alc_spec *spec = codec->spec;
6609 hda_nid_t pin;
6610
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006611 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006612 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006613 /* use dac 0 */
6614 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006615 pin = spec->autocfg.speaker_pins[0];
6616 if (pin)
6617 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006618}
6619
6620#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6621#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6622
6623static void alc882_auto_init_analog_input(struct hda_codec *codec)
6624{
6625 struct alc_spec *spec = codec->spec;
6626 int i;
6627
6628 for (i = 0; i < AUTO_PIN_LAST; i++) {
6629 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006630 unsigned int vref;
6631 if (!nid)
6632 continue;
6633 vref = PIN_IN;
6634 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006635 unsigned int pincap;
6636 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6637 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006638 AC_PINCAP_VREF_80)
6639 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006640 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006641 snd_hda_codec_write(codec, nid, 0,
6642 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6643 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6644 snd_hda_codec_write(codec, nid, 0,
6645 AC_VERB_SET_AMP_GAIN_MUTE,
6646 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006647 }
6648}
6649
Takashi Iwaif511b012008-08-15 16:46:42 +02006650static void alc882_auto_init_input_src(struct hda_codec *codec)
6651{
6652 struct alc_spec *spec = codec->spec;
6653 const struct hda_input_mux *imux = spec->input_mux;
6654 int c;
6655
6656 for (c = 0; c < spec->num_adc_nids; c++) {
6657 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6658 hda_nid_t nid = spec->capsrc_nids[c];
6659 int conns, mute, idx, item;
6660
6661 conns = snd_hda_get_connections(codec, nid, conn_list,
6662 ARRAY_SIZE(conn_list));
6663 if (conns < 0)
6664 continue;
6665 for (idx = 0; idx < conns; idx++) {
6666 /* if the current connection is the selected one,
6667 * unmute it as default - otherwise mute it
6668 */
6669 mute = AMP_IN_MUTE(idx);
6670 for (item = 0; item < imux->num_items; item++) {
6671 if (imux->items[item].index == idx) {
6672 if (spec->cur_mux[c] == item)
6673 mute = AMP_IN_UNMUTE(idx);
6674 break;
6675 }
6676 }
6677 snd_hda_codec_write(codec, nid, 0,
6678 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6679 }
6680 }
6681}
6682
Takashi Iwai776e1842007-08-29 15:07:11 +02006683/* add mic boosts if needed */
6684static int alc_auto_add_mic_boost(struct hda_codec *codec)
6685{
6686 struct alc_spec *spec = codec->spec;
6687 int err;
6688 hda_nid_t nid;
6689
6690 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006691 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006692 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6693 "Mic Boost",
6694 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6695 if (err < 0)
6696 return err;
6697 }
6698 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006699 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006700 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6701 "Front Mic Boost",
6702 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6703 if (err < 0)
6704 return err;
6705 }
6706 return 0;
6707}
6708
Kailang Yangdf694da2005-12-05 19:42:22 +01006709/* almost identical with ALC880 parser... */
6710static int alc882_parse_auto_config(struct hda_codec *codec)
6711{
6712 struct alc_spec *spec = codec->spec;
6713 int err = alc880_parse_auto_config(codec);
6714
6715 if (err < 0)
6716 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006717 else if (!err)
6718 return 0; /* no config found */
6719
6720 err = alc_auto_add_mic_boost(codec);
6721 if (err < 0)
6722 return err;
6723
6724 /* hack - override the init verbs */
6725 spec->init_verbs[0] = alc882_auto_init_verbs;
6726
6727 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006728}
6729
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006730/* additional initialization for auto-configuration model */
6731static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006732{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006733 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006734 alc882_auto_init_multi_out(codec);
6735 alc882_auto_init_hp_out(codec);
6736 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006737 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006738 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006739 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006740}
6741
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006742static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6743
Linus Torvalds1da177e2005-04-16 15:20:36 -07006744static int patch_alc882(struct hda_codec *codec)
6745{
6746 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006747 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006748
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006749 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006750 if (spec == NULL)
6751 return -ENOMEM;
6752
Linus Torvalds1da177e2005-04-16 15:20:36 -07006753 codec->spec = spec;
6754
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006755 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6756 alc882_models,
6757 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006758
Kailang Yangdf694da2005-12-05 19:42:22 +01006759 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006760 /* Pick up systems that don't supply PCI SSID */
6761 switch (codec->subsystem_id) {
6762 case 0x106b0c00: /* Mac Pro */
6763 board_config = ALC885_MACPRO;
6764 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006765 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02006766 case 0x106b2800: /* AppleTV */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006767 board_config = ALC885_IMAC24;
6768 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006769 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07006770 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006771 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006772 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006773 board_config = ALC885_MBP3;
6774 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006775 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006776 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02006777 if (codec->revision_id == 0x100101 ||
6778 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006779 alc_free(codec);
6780 return patch_alc883(codec);
6781 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006782 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6783 "trying auto-probe from BIOS...\n");
6784 board_config = ALC882_AUTO;
6785 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006786 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006787
Takashi Iwaif95474e2007-07-10 00:47:43 +02006788 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6789
Kailang Yangdf694da2005-12-05 19:42:22 +01006790 if (board_config == ALC882_AUTO) {
6791 /* automatic parse from the BIOS config */
6792 err = alc882_parse_auto_config(codec);
6793 if (err < 0) {
6794 alc_free(codec);
6795 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006796 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006797 printk(KERN_INFO
6798 "hda_codec: Cannot set up configuration "
6799 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006800 board_config = ALC882_3ST_DIG;
6801 }
6802 }
6803
6804 if (board_config != ALC882_AUTO)
6805 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006806
Kailang Yang2f893282008-05-27 12:14:47 +02006807 if (codec->vendor_id == 0x10ec0885) {
6808 spec->stream_name_analog = "ALC885 Analog";
6809 spec->stream_name_digital = "ALC885 Digital";
6810 } else {
6811 spec->stream_name_analog = "ALC882 Analog";
6812 spec->stream_name_digital = "ALC882 Digital";
6813 }
6814
Kailang Yangdf694da2005-12-05 19:42:22 +01006815 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6816 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006817 /* FIXME: setup DAC5 */
6818 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6819 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006820
Kailang Yangdf694da2005-12-05 19:42:22 +01006821 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6822 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006823
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01006824 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006825 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006826 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006827 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006828 /* get type */
6829 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006830 if (wcap != AC_WID_AUD_IN) {
6831 spec->adc_nids = alc882_adc_nids_alt;
6832 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006833 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01006834 } else {
6835 spec->adc_nids = alc882_adc_nids;
6836 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006837 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006838 }
6839 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006840 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006841
Takashi Iwai2134ea42008-01-10 16:53:55 +01006842 spec->vmaster_nid = 0x0c;
6843
Linus Torvalds1da177e2005-04-16 15:20:36 -07006844 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006845 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006846 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006847#ifdef CONFIG_SND_HDA_POWER_SAVE
6848 if (!spec->loopback.amplist)
6849 spec->loopback.amplist = alc882_loopbacks;
6850#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006851
6852 return 0;
6853}
6854
6855/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006856 * ALC883 support
6857 *
6858 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6859 * configuration. Each pin widget can choose any input DACs and a mixer.
6860 * Each ADC is connected from a mixer of all inputs. This makes possible
6861 * 6-channel independent captures.
6862 *
6863 * In addition, an independent DAC for the multi-playback (not used in this
6864 * driver yet).
6865 */
6866#define ALC883_DIGOUT_NID 0x06
6867#define ALC883_DIGIN_NID 0x0a
6868
6869static hda_nid_t alc883_dac_nids[4] = {
6870 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006871 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006872};
6873
6874static hda_nid_t alc883_adc_nids[2] = {
6875 /* ADC1-2 */
6876 0x08, 0x09,
6877};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006878
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006879static hda_nid_t alc883_adc_nids_alt[1] = {
6880 /* ADC1 */
6881 0x08,
6882};
6883
Takashi Iwaie1406342008-02-11 18:32:32 +01006884static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6885
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006886/* input MUX */
6887/* FIXME: should be a matrix-type input source selection */
6888
6889static struct hda_input_mux alc883_capture_source = {
6890 .num_items = 4,
6891 .items = {
6892 { "Mic", 0x0 },
6893 { "Front Mic", 0x1 },
6894 { "Line", 0x2 },
6895 { "CD", 0x4 },
6896 },
6897};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006898
Jiang zhe17bba1b2008-06-04 12:11:07 +02006899static struct hda_input_mux alc883_3stack_6ch_intel = {
6900 .num_items = 4,
6901 .items = {
6902 { "Mic", 0x1 },
6903 { "Front Mic", 0x0 },
6904 { "Line", 0x2 },
6905 { "CD", 0x4 },
6906 },
6907};
6908
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006909static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6910 .num_items = 2,
6911 .items = {
6912 { "Mic", 0x1 },
6913 { "Line", 0x2 },
6914 },
6915};
6916
Kailang Yang272a5272007-05-14 11:00:38 +02006917static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6918 .num_items = 4,
6919 .items = {
6920 { "Mic", 0x0 },
6921 { "iMic", 0x1 },
6922 { "Line", 0x2 },
6923 { "CD", 0x4 },
6924 },
6925};
6926
Jiang zhefb97dc62008-03-06 11:07:11 +01006927static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6928 .num_items = 2,
6929 .items = {
6930 { "Mic", 0x0 },
6931 { "Int Mic", 0x1 },
6932 },
6933};
6934
Kailang Yange2757d52008-08-26 13:17:46 +02006935static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6936 .num_items = 3,
6937 .items = {
6938 { "Mic", 0x0 },
6939 { "Front Mic", 0x1 },
6940 { "Line", 0x4 },
6941 },
6942};
6943
6944static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6945 .num_items = 2,
6946 .items = {
6947 { "Mic", 0x0 },
6948 { "Line", 0x2 },
6949 },
6950};
6951
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006952/*
6953 * 2ch mode
6954 */
6955static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6956 { 2, NULL }
6957};
6958
6959/*
6960 * 2ch mode
6961 */
6962static struct hda_verb alc883_3ST_ch2_init[] = {
6963 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6964 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6965 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6966 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6967 { } /* end */
6968};
6969
6970/*
Tobin Davisb2011312007-09-17 12:45:11 +02006971 * 4ch mode
6972 */
6973static struct hda_verb alc883_3ST_ch4_init[] = {
6974 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6975 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6976 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6977 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6978 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6979 { } /* end */
6980};
6981
6982/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006983 * 6ch mode
6984 */
6985static struct hda_verb alc883_3ST_ch6_init[] = {
6986 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6987 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6988 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6989 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6990 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6991 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6992 { } /* end */
6993};
6994
Tobin Davisb2011312007-09-17 12:45:11 +02006995static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006996 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006997 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006998 { 6, alc883_3ST_ch6_init },
6999};
7000
7001/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007002 * 2ch mode
7003 */
7004static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7005 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7006 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7007 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7008 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7009 { } /* end */
7010};
7011
7012/*
7013 * 4ch mode
7014 */
7015static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7016 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7017 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7018 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7019 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7020 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7021 { } /* end */
7022};
7023
7024/*
7025 * 6ch mode
7026 */
7027static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7028 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7029 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7030 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7031 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7032 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7033 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7034 { } /* end */
7035};
7036
7037static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7038 { 2, alc883_3ST_ch2_intel_init },
7039 { 4, alc883_3ST_ch4_intel_init },
7040 { 6, alc883_3ST_ch6_intel_init },
7041};
7042
7043/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007044 * 6ch mode
7045 */
7046static struct hda_verb alc883_sixstack_ch6_init[] = {
7047 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7048 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7049 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7050 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7051 { } /* end */
7052};
7053
7054/*
7055 * 8ch mode
7056 */
7057static struct hda_verb alc883_sixstack_ch8_init[] = {
7058 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7059 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7060 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7061 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7062 { } /* end */
7063};
7064
7065static struct hda_channel_mode alc883_sixstack_modes[2] = {
7066 { 6, alc883_sixstack_ch6_init },
7067 { 8, alc883_sixstack_ch8_init },
7068};
7069
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007070static struct hda_verb alc883_medion_eapd_verbs[] = {
7071 /* eanable EAPD on medion laptop */
7072 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7073 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7074 { }
7075};
7076
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007077/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7078 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7079 */
7080
7081static struct snd_kcontrol_new alc883_base_mixer[] = {
7082 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7083 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7084 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7085 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7086 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7087 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7088 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7089 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7090 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7091 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7092 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7093 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7094 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7095 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7096 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7097 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007098 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7100 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007101 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007102 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7103 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7104 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007105 { } /* end */
7106};
7107
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007108static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7109 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7110 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7111 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7112 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7113 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7114 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7117 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7119 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7120 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7121 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007122 { } /* end */
7123};
7124
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007125static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007126 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7127 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7128 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7129 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7132 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7133 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7134 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7135 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007136 { } /* end */
7137};
7138
Jiang zhefb97dc62008-03-06 11:07:11 +01007139static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7140 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7141 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7142 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7143 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7145 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7146 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7147 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7148 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7149 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007150 { } /* end */
7151};
7152
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007153static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7154 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7155 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7156 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7157 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7158 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7159 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7160 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7161 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007162 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7164 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007165 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007166 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7167 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7168 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007169 { } /* end */
7170};
7171
7172static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7173 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7174 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7175 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7176 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7177 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7178 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7179 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7180 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7181 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7182 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7183 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7184 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7185 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7186 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007187 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007188 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7189 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007190 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007191 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7192 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7193 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007194 { } /* end */
7195};
7196
Jiang zhe17bba1b2008-06-04 12:11:07 +02007197static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7198 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7199 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7200 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7201 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7202 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7203 HDA_OUTPUT),
7204 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7205 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7206 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7207 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7208 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7209 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7210 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7211 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7213 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7214 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7215 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7216 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7217 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7218 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7219 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007220 { } /* end */
7221};
7222
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007223static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007224 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007225 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007226 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007227 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007228 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7229 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007230 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7231 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007232 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7233 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7234 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7235 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7236 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007238 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007239 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7240 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007241 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007242 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7243 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7244 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007245 { } /* end */
7246};
7247
Kailang Yangccc656c2006-10-17 12:32:26 +02007248static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7249 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7250 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7251 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7252 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7253 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7254 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7255 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7256 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7257 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7258 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7259 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7260 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7261 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007263 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007264 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007265 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007266};
Kailang Yangccc656c2006-10-17 12:32:26 +02007267
7268static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7269 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7270 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7271 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7272 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7273 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007275 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007276 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007277 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7278 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7279 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007280 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007281};
Kailang Yangccc656c2006-10-17 12:32:26 +02007282
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007283static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7284 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7285 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007286 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7287 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007288 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7289 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7290 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7291 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007292 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007293};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007294
Kailang Yang272a5272007-05-14 11:00:38 +02007295static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7296 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7297 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7298 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7299 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7300 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7301 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7302 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7303 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7304 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007305 { } /* end */
7306};
7307
7308static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7309 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7310 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7311 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7313 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7315 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7316 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7317 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007318 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007319};
Kailang Yang272a5272007-05-14 11:00:38 +02007320
Tobin Davis2880a862007-08-07 11:50:26 +02007321static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007322 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7323 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007324 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007325 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7326 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007327 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7328 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7329 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007330 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007331};
Tobin Davis2880a862007-08-07 11:50:26 +02007332
Kailang Yange2757d52008-08-26 13:17:46 +02007333static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7334 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7335 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7336 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7337 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7338 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7339 0x0d, 1, 0x0, HDA_OUTPUT),
7340 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7341 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7342 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7343 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7344 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7345 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7346 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7347 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7348 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7349 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7350 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7352 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7354 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7355 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7356 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007357 { } /* end */
7358};
7359
7360static struct hda_bind_ctls alc883_bind_cap_vol = {
7361 .ops = &snd_hda_bind_vol,
7362 .values = {
7363 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7364 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7365 0
7366 },
7367};
7368
7369static struct hda_bind_ctls alc883_bind_cap_switch = {
7370 .ops = &snd_hda_bind_sw,
7371 .values = {
7372 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7373 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7374 0
7375 },
7376};
7377
7378static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7379 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7380 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7381 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7382 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7383 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7384 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7385 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7386 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007387 { } /* end */
7388};
7389
7390static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007391 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7392 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7393 {
7394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7395 /* .name = "Capture Source", */
7396 .name = "Input Source",
7397 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007398 .info = alc_mux_enum_info,
7399 .get = alc_mux_enum_get,
7400 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007401 },
7402 { } /* end */
7403};
7404
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007405static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7406 {
7407 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7408 .name = "Channel Mode",
7409 .info = alc_ch_mode_info,
7410 .get = alc_ch_mode_get,
7411 .put = alc_ch_mode_put,
7412 },
7413 { } /* end */
7414};
7415
7416static struct hda_verb alc883_init_verbs[] = {
7417 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007418 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007419 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7420 /* ADC2: mute amp left and right */
7421 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7422 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7423 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7424 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7427 /* Rear mixer */
7428 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7429 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7430 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7431 /* CLFE mixer */
7432 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7433 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7435 /* Side mixer */
7436 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7437 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7438 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7439
Takashi Iwaicb53c622007-08-10 17:21:45 +02007440 /* mute analog input loopbacks */
7441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007446
7447 /* Front Pin: output 0 (0x0c) */
7448 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7450 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7451 /* Rear Pin: output 1 (0x0d) */
7452 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7453 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7454 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7455 /* CLFE Pin: output 2 (0x0e) */
7456 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7457 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7458 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7459 /* Side Pin: output 3 (0x0f) */
7460 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7461 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7462 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7463 /* Mic (rear) pin: input vref at 80% */
7464 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7465 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7466 /* Front Mic pin: input vref at 80% */
7467 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7468 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7469 /* Line In pin: input */
7470 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7471 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7472 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7473 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7474 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7475 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7476 /* CD pin widget for input */
7477 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7478
7479 /* FIXME: use matrix-type input source selection */
7480 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7481 /* Input mixer2 */
7482 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007483 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007486 /* Input mixer3 */
7487 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007488 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7489 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7490 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007491 { }
7492};
7493
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007494/* toggle speaker-output according to the hp-jack state */
7495static void alc883_mitac_hp_automute(struct hda_codec *codec)
7496{
7497 unsigned int present;
7498
7499 present = snd_hda_codec_read(codec, 0x15, 0,
7500 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7501 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7502 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7503 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7504 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7505}
7506
7507/* auto-toggle front mic */
7508/*
7509static void alc883_mitac_mic_automute(struct hda_codec *codec)
7510{
7511 unsigned int present;
7512 unsigned char bits;
7513
7514 present = snd_hda_codec_read(codec, 0x18, 0,
7515 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7516 bits = present ? HDA_AMP_MUTE : 0;
7517 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7518}
7519*/
7520
7521static void alc883_mitac_automute(struct hda_codec *codec)
7522{
7523 alc883_mitac_hp_automute(codec);
7524 /* alc883_mitac_mic_automute(codec); */
7525}
7526
7527static void alc883_mitac_unsol_event(struct hda_codec *codec,
7528 unsigned int res)
7529{
7530 switch (res >> 26) {
7531 case ALC880_HP_EVENT:
7532 alc883_mitac_hp_automute(codec);
7533 break;
7534 case ALC880_MIC_EVENT:
7535 /* alc883_mitac_mic_automute(codec); */
7536 break;
7537 }
7538}
7539
7540static struct hda_verb alc883_mitac_verbs[] = {
7541 /* HP */
7542 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7543 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7544 /* Subwoofer */
7545 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7546 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7547
7548 /* enable unsolicited event */
7549 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7550 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7551
7552 { } /* end */
7553};
7554
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007555static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007556 /* HP */
7557 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7558 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7559 /* Int speaker */
7560 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7561 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7562
7563 /* enable unsolicited event */
7564 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007565 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007566
7567 { } /* end */
7568};
7569
Jiang zhefb97dc62008-03-06 11:07:11 +01007570static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7571 /* HP */
7572 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7573 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7574 /* Subwoofer */
7575 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7577
7578 /* enable unsolicited event */
7579 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7580
7581 { } /* end */
7582};
7583
Kailang Yangccc656c2006-10-17 12:32:26 +02007584static struct hda_verb alc883_tagra_verbs[] = {
7585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7586 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7587
7588 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7589 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007590
Kailang Yangccc656c2006-10-17 12:32:26 +02007591 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7592 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7593 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7594
7595 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007596 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7597 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7598 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007599
7600 { } /* end */
7601};
7602
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007603static struct hda_verb alc883_lenovo_101e_verbs[] = {
7604 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7605 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7606 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7607 { } /* end */
7608};
7609
Kailang Yang272a5272007-05-14 11:00:38 +02007610static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7611 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7612 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7613 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7614 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7615 { } /* end */
7616};
7617
7618static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7619 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7620 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7621 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7622 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7623 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7624 { } /* end */
7625};
7626
Kailang Yang189609a2007-08-20 11:31:23 +02007627static struct hda_verb alc883_haier_w66_verbs[] = {
7628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7629 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7630
7631 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7632
7633 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7634 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7635 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7636 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7637 { } /* end */
7638};
7639
Kailang Yange2757d52008-08-26 13:17:46 +02007640static struct hda_verb alc888_lenovo_sky_verbs[] = {
7641 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7642 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7643 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7644 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7645 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7646 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7647 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7648 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7649 { } /* end */
7650};
7651
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007652static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007653 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007654 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7655 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007656 { }
7657};
7658
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007659static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007660 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7661 { }
7662};
7663
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007664static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007665 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7666 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7667 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7668 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7669 { }
7670};
7671
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007672static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007673 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7674 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7675 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7676 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7677 { }
7678};
7679
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007680static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7681 { 2, alc888_3st_hp_2ch_init },
7682 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007683};
7684
Kailang Yang272a5272007-05-14 11:00:38 +02007685/* toggle front-jack and RCA according to the hp-jack state */
7686static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7687{
7688 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007689
Kailang Yang272a5272007-05-14 11:00:38 +02007690 present = snd_hda_codec_read(codec, 0x1b, 0,
7691 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007692 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7693 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7694 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7695 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007696}
7697
7698/* toggle RCA according to the front-jack state */
7699static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7700{
7701 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007702
Kailang Yang272a5272007-05-14 11:00:38 +02007703 present = snd_hda_codec_read(codec, 0x14, 0,
7704 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007705 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7706 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007707}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007708
Kailang Yang272a5272007-05-14 11:00:38 +02007709static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7710 unsigned int res)
7711{
7712 if ((res >> 26) == ALC880_HP_EVENT)
7713 alc888_lenovo_ms7195_front_automute(codec);
7714 if ((res >> 26) == ALC880_FRONT_EVENT)
7715 alc888_lenovo_ms7195_rca_automute(codec);
7716}
7717
7718static struct hda_verb alc883_medion_md2_verbs[] = {
7719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7721
7722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7723
7724 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7725 { } /* end */
7726};
7727
7728/* toggle speaker-output according to the hp-jack state */
7729static void alc883_medion_md2_automute(struct hda_codec *codec)
7730{
7731 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007732
Kailang Yang272a5272007-05-14 11:00:38 +02007733 present = snd_hda_codec_read(codec, 0x14, 0,
7734 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007735 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7736 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007737}
7738
7739static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7740 unsigned int res)
7741{
7742 if ((res >> 26) == ALC880_HP_EVENT)
7743 alc883_medion_md2_automute(codec);
7744}
7745
Kailang Yangccc656c2006-10-17 12:32:26 +02007746/* toggle speaker-output according to the hp-jack state */
7747static void alc883_tagra_automute(struct hda_codec *codec)
7748{
7749 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007750 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007751
7752 present = snd_hda_codec_read(codec, 0x14, 0,
7753 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007754 bits = present ? HDA_AMP_MUTE : 0;
7755 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7756 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007757 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7758 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007759}
7760
7761static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7762{
7763 if ((res >> 26) == ALC880_HP_EVENT)
7764 alc883_tagra_automute(codec);
7765}
7766
Jiang zhe368c7a92008-03-04 11:20:33 +01007767/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007768static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007769{
7770 unsigned int present;
7771 unsigned char bits;
7772
7773 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7774 & AC_PINSENSE_PRESENCE;
7775 bits = present ? HDA_AMP_MUTE : 0;
7776 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7777 HDA_AMP_MUTE, bits);
7778}
7779
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007780static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7781{
7782 unsigned int present;
7783
7784 present = snd_hda_codec_read(codec, 0x18, 0,
7785 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7786 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7787 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7788}
7789
7790static void alc883_clevo_m720_automute(struct hda_codec *codec)
7791{
7792 alc883_clevo_m720_hp_automute(codec);
7793 alc883_clevo_m720_mic_automute(codec);
7794}
7795
7796static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007797 unsigned int res)
7798{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007799 switch (res >> 26) {
7800 case ALC880_HP_EVENT:
7801 alc883_clevo_m720_hp_automute(codec);
7802 break;
7803 case ALC880_MIC_EVENT:
7804 alc883_clevo_m720_mic_automute(codec);
7805 break;
7806 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007807}
7808
Jiang zhefb97dc62008-03-06 11:07:11 +01007809/* toggle speaker-output according to the hp-jack state */
7810static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7811{
7812 unsigned int present;
7813 unsigned char bits;
7814
7815 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7816 & AC_PINSENSE_PRESENCE;
7817 bits = present ? HDA_AMP_MUTE : 0;
7818 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7819 HDA_AMP_MUTE, bits);
7820}
7821
7822static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7823 unsigned int res)
7824{
7825 if ((res >> 26) == ALC880_HP_EVENT)
7826 alc883_2ch_fujitsu_pi2515_automute(codec);
7827}
7828
Kailang Yang189609a2007-08-20 11:31:23 +02007829static void alc883_haier_w66_automute(struct hda_codec *codec)
7830{
7831 unsigned int present;
7832 unsigned char bits;
7833
7834 present = snd_hda_codec_read(codec, 0x1b, 0,
7835 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7836 bits = present ? 0x80 : 0;
7837 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7838 0x80, bits);
7839}
7840
7841static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7842 unsigned int res)
7843{
7844 if ((res >> 26) == ALC880_HP_EVENT)
7845 alc883_haier_w66_automute(codec);
7846}
7847
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007848static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7849{
7850 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007851 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007852
7853 present = snd_hda_codec_read(codec, 0x14, 0,
7854 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007855 bits = present ? HDA_AMP_MUTE : 0;
7856 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7857 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007858}
7859
7860static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7861{
7862 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007863 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007864
7865 present = snd_hda_codec_read(codec, 0x1b, 0,
7866 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007867 bits = present ? HDA_AMP_MUTE : 0;
7868 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7869 HDA_AMP_MUTE, bits);
7870 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7871 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007872}
7873
7874static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7875 unsigned int res)
7876{
7877 if ((res >> 26) == ALC880_HP_EVENT)
7878 alc883_lenovo_101e_all_automute(codec);
7879 if ((res >> 26) == ALC880_FRONT_EVENT)
7880 alc883_lenovo_101e_ispeaker_automute(codec);
7881}
7882
Takashi Iwai676a9b52007-08-16 15:23:35 +02007883/* toggle speaker-output according to the hp-jack state */
7884static void alc883_acer_aspire_automute(struct hda_codec *codec)
7885{
7886 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007887
Takashi Iwai676a9b52007-08-16 15:23:35 +02007888 present = snd_hda_codec_read(codec, 0x14, 0,
7889 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7890 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7891 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7892 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7893 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7894}
7895
7896static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7897 unsigned int res)
7898{
7899 if ((res >> 26) == ALC880_HP_EVENT)
7900 alc883_acer_aspire_automute(codec);
7901}
7902
Kailang Yangd1a991a2007-08-15 16:21:59 +02007903static struct hda_verb alc883_acer_eapd_verbs[] = {
7904 /* HP Pin: output 0 (0x0c) */
7905 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7907 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7908 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007909 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7910 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007911 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007912 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7913 /* eanable EAPD on medion laptop */
7914 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7915 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007916 /* enable unsolicited event */
7917 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007918 { }
7919};
7920
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007921static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7922{
7923 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007924
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007925 present = snd_hda_codec_read(codec, 0x1b, 0,
7926 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7927 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7928 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7929 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7930 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7931 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7932 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7933 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7934 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7935}
7936
7937static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7938 unsigned int res)
7939{
7940 switch (res >> 26) {
7941 case ALC880_HP_EVENT:
7942 printk("hp_event\n");
7943 alc888_6st_dell_front_automute(codec);
7944 break;
7945 }
7946}
7947
Kailang Yange2757d52008-08-26 13:17:46 +02007948static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
7949{
7950 unsigned int mute;
7951 unsigned int present;
7952
7953 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7954 present = snd_hda_codec_read(codec, 0x1b, 0,
7955 AC_VERB_GET_PIN_SENSE, 0);
7956 present = (present & 0x80000000) != 0;
7957 if (present) {
7958 /* mute internal speaker */
7959 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7960 HDA_AMP_MUTE, HDA_AMP_MUTE);
7961 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7962 HDA_AMP_MUTE, HDA_AMP_MUTE);
7963 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7964 HDA_AMP_MUTE, HDA_AMP_MUTE);
7965 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7966 HDA_AMP_MUTE, HDA_AMP_MUTE);
7967 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7968 HDA_AMP_MUTE, HDA_AMP_MUTE);
7969 } else {
7970 /* unmute internal speaker if necessary */
7971 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7972 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7973 HDA_AMP_MUTE, mute);
7974 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7975 HDA_AMP_MUTE, mute);
7976 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7977 HDA_AMP_MUTE, mute);
7978 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7979 HDA_AMP_MUTE, mute);
7980 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7981 HDA_AMP_MUTE, mute);
7982 }
7983}
7984
7985static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
7986 unsigned int res)
7987{
7988 if ((res >> 26) == ALC880_HP_EVENT)
7989 alc888_lenovo_sky_front_automute(codec);
7990}
7991
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007992/*
7993 * generic initialization of ADC, input mixers and output mixers
7994 */
7995static struct hda_verb alc883_auto_init_verbs[] = {
7996 /*
7997 * Unmute ADC0-2 and set the default input to mic-in
7998 */
7999 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8000 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8001 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8002 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8003
Takashi Iwaicb53c622007-08-10 17:21:45 +02008004 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008005 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008006 * Note: PASD motherboards uses the Line In 2 as the input for
8007 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008008 */
8009 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008015
8016 /*
8017 * Set up output mixers (0x0c - 0x0f)
8018 */
8019 /* set vol=0 to output mixers */
8020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8021 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8022 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8023 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8024 /* set up input amps for analog loopback */
8025 /* Amp Indices: DAC = 0, mixer = 1 */
8026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8028 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8029 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8030 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8031 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8032 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8033 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8034 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8035 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8036
8037 /* FIXME: use matrix-type input source selection */
8038 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8039 /* Input mixer1 */
8040 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8041 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8042 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008043 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8045 /* Input mixer2 */
8046 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8047 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8048 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008049 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008050 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008051
8052 { }
8053};
8054
Kailang Yange2757d52008-08-26 13:17:46 +02008055static struct hda_verb alc888_asus_m90v_verbs[] = {
8056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8057 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8058 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8059 /* enable unsolicited event */
8060 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8061 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8062 { } /* end */
8063};
8064
8065static void alc883_nb_mic_automute(struct hda_codec *codec)
8066{
8067 unsigned int present;
8068
8069 present = snd_hda_codec_read(codec, 0x18, 0,
8070 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8071 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8072 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8073 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8074 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8075}
8076
8077static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8078{
8079 unsigned int present;
8080 unsigned char bits;
8081
8082 present = snd_hda_codec_read(codec, 0x1b, 0,
8083 AC_VERB_GET_PIN_SENSE, 0)
8084 & AC_PINSENSE_PRESENCE;
8085 bits = present ? 0 : PIN_OUT;
8086 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8087 bits);
8088 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8089 bits);
8090 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8091 bits);
8092}
8093
8094static void alc883_mode2_unsol_event(struct hda_codec *codec,
8095 unsigned int res)
8096{
8097 switch (res >> 26) {
8098 case ALC880_HP_EVENT:
8099 alc883_M90V_speaker_automute(codec);
8100 break;
8101 case ALC880_MIC_EVENT:
8102 alc883_nb_mic_automute(codec);
8103 break;
8104 }
8105}
8106
8107static void alc883_mode2_inithook(struct hda_codec *codec)
8108{
8109 alc883_M90V_speaker_automute(codec);
8110 alc883_nb_mic_automute(codec);
8111}
8112
8113static struct hda_verb alc888_asus_eee1601_verbs[] = {
8114 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8115 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8117 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8118 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8119 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8120 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8121 /* enable unsolicited event */
8122 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8123 { } /* end */
8124};
8125
8126static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8127{
8128 unsigned int present;
8129 unsigned char bits;
8130
8131 present = snd_hda_codec_read(codec, 0x14, 0,
8132 AC_VERB_GET_PIN_SENSE, 0)
8133 & AC_PINSENSE_PRESENCE;
8134 bits = present ? 0 : PIN_OUT;
8135 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8136 bits);
8137}
8138
8139static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8140 unsigned int res)
8141{
8142 switch (res >> 26) {
8143 case ALC880_HP_EVENT:
8144 alc883_eee1601_speaker_automute(codec);
8145 break;
8146 }
8147}
8148
8149static void alc883_eee1601_inithook(struct hda_codec *codec)
8150{
8151 alc883_eee1601_speaker_automute(codec);
8152}
8153
Takashi Iwaicb53c622007-08-10 17:21:45 +02008154#ifdef CONFIG_SND_HDA_POWER_SAVE
8155#define alc883_loopbacks alc880_loopbacks
8156#endif
8157
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008158/* pcm configuration: identiacal with ALC880 */
8159#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8160#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008161#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008162#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8163#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8164
8165/*
8166 * configuration and preset
8167 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008168static const char *alc883_models[ALC883_MODEL_LAST] = {
8169 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8170 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8171 [ALC883_3ST_6ch] = "3stack-6ch",
8172 [ALC883_6ST_DIG] = "6stack-dig",
8173 [ALC883_TARGA_DIG] = "targa-dig",
8174 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008175 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008176 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008177 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008178 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008179 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008180 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008181 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8182 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008183 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008184 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008185 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008186 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008187 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008188 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008189 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008190 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008191 [ALC883_AUTO] = "auto",
8192};
8193
8194static struct snd_pci_quirk alc883_cfg_tbl[] = {
8195 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008196 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8197 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8198 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008199 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008200 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008201 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008202 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008203 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8204 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008205 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008206 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008207 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Kailang Yange2757d52008-08-26 13:17:46 +02008208 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008209 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008210 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008211 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8212 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008213 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008214 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008215 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008216 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8217 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8218 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008219 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008220 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008221 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008222 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8223 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8224 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8225 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8226 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8227 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8228 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8229 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8230 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008231 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8232 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008233 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008234 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008235 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008236 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008237 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008238 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008239 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8240 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008241 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008242 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008243 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008244 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02008245 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008246 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008247 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8248 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008249 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008250 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008251 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008252 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008253 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8254 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008255 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008256 {}
8257};
8258
8259static struct alc_config_preset alc883_presets[] = {
8260 [ALC883_3ST_2ch_DIG] = {
8261 .mixers = { alc883_3ST_2ch_mixer },
8262 .init_verbs = { alc883_init_verbs },
8263 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8264 .dac_nids = alc883_dac_nids,
8265 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008266 .dig_in_nid = ALC883_DIGIN_NID,
8267 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8268 .channel_mode = alc883_3ST_2ch_modes,
8269 .input_mux = &alc883_capture_source,
8270 },
8271 [ALC883_3ST_6ch_DIG] = {
8272 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8273 .init_verbs = { alc883_init_verbs },
8274 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8275 .dac_nids = alc883_dac_nids,
8276 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008277 .dig_in_nid = ALC883_DIGIN_NID,
8278 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8279 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008280 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008281 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008282 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008283 [ALC883_3ST_6ch] = {
8284 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8285 .init_verbs = { alc883_init_verbs },
8286 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8287 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008288 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8289 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008290 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008291 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008292 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008293 [ALC883_3ST_6ch_INTEL] = {
8294 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8295 .init_verbs = { alc883_init_verbs },
8296 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8297 .dac_nids = alc883_dac_nids,
8298 .dig_out_nid = ALC883_DIGOUT_NID,
8299 .dig_in_nid = ALC883_DIGIN_NID,
8300 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8301 .channel_mode = alc883_3ST_6ch_intel_modes,
8302 .need_dac_fix = 1,
8303 .input_mux = &alc883_3stack_6ch_intel,
8304 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008305 [ALC883_6ST_DIG] = {
8306 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8307 .init_verbs = { alc883_init_verbs },
8308 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8309 .dac_nids = alc883_dac_nids,
8310 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008311 .dig_in_nid = ALC883_DIGIN_NID,
8312 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8313 .channel_mode = alc883_sixstack_modes,
8314 .input_mux = &alc883_capture_source,
8315 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008316 [ALC883_TARGA_DIG] = {
8317 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8318 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8319 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8320 .dac_nids = alc883_dac_nids,
8321 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008322 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8323 .channel_mode = alc883_3ST_6ch_modes,
8324 .need_dac_fix = 1,
8325 .input_mux = &alc883_capture_source,
8326 .unsol_event = alc883_tagra_unsol_event,
8327 .init_hook = alc883_tagra_automute,
8328 },
8329 [ALC883_TARGA_2ch_DIG] = {
8330 .mixers = { alc883_tagra_2ch_mixer},
8331 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8332 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8333 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008334 .adc_nids = alc883_adc_nids_alt,
8335 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008336 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008337 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8338 .channel_mode = alc883_3ST_2ch_modes,
8339 .input_mux = &alc883_capture_source,
8340 .unsol_event = alc883_tagra_unsol_event,
8341 .init_hook = alc883_tagra_automute,
8342 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008343 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008344 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008345 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8346 * and the headphone jack. Turn this on and rely on the
8347 * standard mute methods whenever the user wants to turn
8348 * these outputs off.
8349 */
8350 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8351 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8352 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008353 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8354 .channel_mode = alc883_3ST_2ch_modes,
8355 .input_mux = &alc883_capture_source,
8356 },
Tobin Davis2880a862007-08-07 11:50:26 +02008357 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008358 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008359 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008360 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8361 .dac_nids = alc883_dac_nids,
8362 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008363 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8364 .channel_mode = alc883_3ST_2ch_modes,
8365 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008366 .unsol_event = alc883_acer_aspire_unsol_event,
8367 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008368 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008369 [ALC883_MEDION] = {
8370 .mixers = { alc883_fivestack_mixer,
8371 alc883_chmode_mixer },
8372 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008373 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008374 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8375 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008376 .adc_nids = alc883_adc_nids_alt,
8377 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008378 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8379 .channel_mode = alc883_sixstack_modes,
8380 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008381 },
Kailang Yang272a5272007-05-14 11:00:38 +02008382 [ALC883_MEDION_MD2] = {
8383 .mixers = { alc883_medion_md2_mixer},
8384 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8385 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8386 .dac_nids = alc883_dac_nids,
8387 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008388 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8389 .channel_mode = alc883_3ST_2ch_modes,
8390 .input_mux = &alc883_capture_source,
8391 .unsol_event = alc883_medion_md2_unsol_event,
8392 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008393 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008394 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008395 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008396 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8397 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8398 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008399 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8400 .channel_mode = alc883_3ST_2ch_modes,
8401 .input_mux = &alc883_capture_source,
8402 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008403 [ALC883_CLEVO_M720] = {
8404 .mixers = { alc883_clevo_m720_mixer },
8405 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008406 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8407 .dac_nids = alc883_dac_nids,
8408 .dig_out_nid = ALC883_DIGOUT_NID,
8409 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8410 .channel_mode = alc883_3ST_2ch_modes,
8411 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008412 .unsol_event = alc883_clevo_m720_unsol_event,
8413 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008414 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008415 [ALC883_LENOVO_101E_2ch] = {
8416 .mixers = { alc883_lenovo_101e_2ch_mixer},
8417 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8418 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8419 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008420 .adc_nids = alc883_adc_nids_alt,
8421 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008422 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8423 .channel_mode = alc883_3ST_2ch_modes,
8424 .input_mux = &alc883_lenovo_101e_capture_source,
8425 .unsol_event = alc883_lenovo_101e_unsol_event,
8426 .init_hook = alc883_lenovo_101e_all_automute,
8427 },
Kailang Yang272a5272007-05-14 11:00:38 +02008428 [ALC883_LENOVO_NB0763] = {
8429 .mixers = { alc883_lenovo_nb0763_mixer },
8430 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8431 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8432 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008433 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8434 .channel_mode = alc883_3ST_2ch_modes,
8435 .need_dac_fix = 1,
8436 .input_mux = &alc883_lenovo_nb0763_capture_source,
8437 .unsol_event = alc883_medion_md2_unsol_event,
8438 .init_hook = alc883_medion_md2_automute,
8439 },
8440 [ALC888_LENOVO_MS7195_DIG] = {
8441 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8442 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8443 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8444 .dac_nids = alc883_dac_nids,
8445 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008446 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8447 .channel_mode = alc883_3ST_6ch_modes,
8448 .need_dac_fix = 1,
8449 .input_mux = &alc883_capture_source,
8450 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8451 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008452 },
8453 [ALC883_HAIER_W66] = {
8454 .mixers = { alc883_tagra_2ch_mixer},
8455 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8456 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8457 .dac_nids = alc883_dac_nids,
8458 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008459 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8460 .channel_mode = alc883_3ST_2ch_modes,
8461 .input_mux = &alc883_capture_source,
8462 .unsol_event = alc883_haier_w66_unsol_event,
8463 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008464 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008465 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008466 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008467 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008468 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8469 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008470 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8471 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008472 .need_dac_fix = 1,
8473 .input_mux = &alc883_capture_source,
8474 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008475 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008476 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008477 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8478 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8479 .dac_nids = alc883_dac_nids,
8480 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008481 .dig_in_nid = ALC883_DIGIN_NID,
8482 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8483 .channel_mode = alc883_sixstack_modes,
8484 .input_mux = &alc883_capture_source,
8485 .unsol_event = alc888_6st_dell_unsol_event,
8486 .init_hook = alc888_6st_dell_front_automute,
8487 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008488 [ALC883_MITAC] = {
8489 .mixers = { alc883_mitac_mixer },
8490 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8491 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8492 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008493 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8494 .channel_mode = alc883_3ST_2ch_modes,
8495 .input_mux = &alc883_capture_source,
8496 .unsol_event = alc883_mitac_unsol_event,
8497 .init_hook = alc883_mitac_automute,
8498 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008499 [ALC883_FUJITSU_PI2515] = {
8500 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8501 .init_verbs = { alc883_init_verbs,
8502 alc883_2ch_fujitsu_pi2515_verbs},
8503 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8504 .dac_nids = alc883_dac_nids,
8505 .dig_out_nid = ALC883_DIGOUT_NID,
8506 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8507 .channel_mode = alc883_3ST_2ch_modes,
8508 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8509 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8510 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8511 },
Kailang Yange2757d52008-08-26 13:17:46 +02008512 [ALC888_LENOVO_SKY] = {
8513 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8514 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8515 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8516 .dac_nids = alc883_dac_nids,
8517 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008518 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8519 .channel_mode = alc883_sixstack_modes,
8520 .need_dac_fix = 1,
8521 .input_mux = &alc883_lenovo_sky_capture_source,
8522 .unsol_event = alc883_lenovo_sky_unsol_event,
8523 .init_hook = alc888_lenovo_sky_front_automute,
8524 },
8525 [ALC888_ASUS_M90V] = {
8526 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8527 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8528 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8529 .dac_nids = alc883_dac_nids,
8530 .dig_out_nid = ALC883_DIGOUT_NID,
8531 .dig_in_nid = ALC883_DIGIN_NID,
8532 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8533 .channel_mode = alc883_3ST_6ch_modes,
8534 .need_dac_fix = 1,
8535 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8536 .unsol_event = alc883_mode2_unsol_event,
8537 .init_hook = alc883_mode2_inithook,
8538 },
8539 [ALC888_ASUS_EEE1601] = {
8540 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008541 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008542 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8543 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8544 .dac_nids = alc883_dac_nids,
8545 .dig_out_nid = ALC883_DIGOUT_NID,
8546 .dig_in_nid = ALC883_DIGIN_NID,
8547 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8548 .channel_mode = alc883_3ST_2ch_modes,
8549 .need_dac_fix = 1,
8550 .input_mux = &alc883_asus_eee1601_capture_source,
8551 .unsol_event = alc883_eee1601_unsol_event,
8552 .init_hook = alc883_eee1601_inithook,
8553 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008554};
8555
8556
8557/*
8558 * BIOS auto configuration
8559 */
8560static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8561 hda_nid_t nid, int pin_type,
8562 int dac_idx)
8563{
8564 /* set as output */
8565 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008566 int idx;
8567
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008568 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008569 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8570 idx = 4;
8571 else
8572 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008573 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8574
8575}
8576
8577static void alc883_auto_init_multi_out(struct hda_codec *codec)
8578{
8579 struct alc_spec *spec = codec->spec;
8580 int i;
8581
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008582 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008583 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008584 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008585 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008586 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008587 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008588 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008589 }
8590}
8591
8592static void alc883_auto_init_hp_out(struct hda_codec *codec)
8593{
8594 struct alc_spec *spec = codec->spec;
8595 hda_nid_t pin;
8596
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008597 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008598 if (pin) /* connect to front */
8599 /* use dac 0 */
8600 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008601 pin = spec->autocfg.speaker_pins[0];
8602 if (pin)
8603 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008604}
8605
8606#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8607#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8608
8609static void alc883_auto_init_analog_input(struct hda_codec *codec)
8610{
8611 struct alc_spec *spec = codec->spec;
8612 int i;
8613
8614 for (i = 0; i < AUTO_PIN_LAST; i++) {
8615 hda_nid_t nid = spec->autocfg.input_pins[i];
8616 if (alc883_is_input_pin(nid)) {
8617 snd_hda_codec_write(codec, nid, 0,
8618 AC_VERB_SET_PIN_WIDGET_CONTROL,
8619 (i <= AUTO_PIN_FRONT_MIC ?
8620 PIN_VREF80 : PIN_IN));
8621 if (nid != ALC883_PIN_CD_NID)
8622 snd_hda_codec_write(codec, nid, 0,
8623 AC_VERB_SET_AMP_GAIN_MUTE,
8624 AMP_OUT_MUTE);
8625 }
8626 }
8627}
8628
Takashi Iwaif511b012008-08-15 16:46:42 +02008629#define alc883_auto_init_input_src alc882_auto_init_input_src
8630
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008631/* almost identical with ALC880 parser... */
8632static int alc883_parse_auto_config(struct hda_codec *codec)
8633{
8634 struct alc_spec *spec = codec->spec;
8635 int err = alc880_parse_auto_config(codec);
8636
8637 if (err < 0)
8638 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008639 else if (!err)
8640 return 0; /* no config found */
8641
8642 err = alc_auto_add_mic_boost(codec);
8643 if (err < 0)
8644 return err;
8645
8646 /* hack - override the init verbs */
8647 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02008648
8649 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008650}
8651
8652/* additional initialization for auto-configuration model */
8653static void alc883_auto_init(struct hda_codec *codec)
8654{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008655 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008656 alc883_auto_init_multi_out(codec);
8657 alc883_auto_init_hp_out(codec);
8658 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008659 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008660 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02008661 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008662}
8663
8664static int patch_alc883(struct hda_codec *codec)
8665{
8666 struct alc_spec *spec;
8667 int err, board_config;
8668
8669 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8670 if (spec == NULL)
8671 return -ENOMEM;
8672
8673 codec->spec = spec;
8674
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008675 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8676
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008677 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8678 alc883_models,
8679 alc883_cfg_tbl);
8680 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008681 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8682 "trying auto-probe from BIOS...\n");
8683 board_config = ALC883_AUTO;
8684 }
8685
8686 if (board_config == ALC883_AUTO) {
8687 /* automatic parse from the BIOS config */
8688 err = alc883_parse_auto_config(codec);
8689 if (err < 0) {
8690 alc_free(codec);
8691 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008692 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008693 printk(KERN_INFO
8694 "hda_codec: Cannot set up configuration "
8695 "from BIOS. Using base mode...\n");
8696 board_config = ALC883_3ST_2ch_DIG;
8697 }
8698 }
8699
8700 if (board_config != ALC883_AUTO)
8701 setup_preset(spec, &alc883_presets[board_config]);
8702
Kailang Yang2f893282008-05-27 12:14:47 +02008703 switch (codec->vendor_id) {
8704 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02008705 if (codec->revision_id == 0x100101) {
8706 spec->stream_name_analog = "ALC1200 Analog";
8707 spec->stream_name_digital = "ALC1200 Digital";
8708 } else {
8709 spec->stream_name_analog = "ALC888 Analog";
8710 spec->stream_name_digital = "ALC888 Digital";
8711 }
Kailang Yang2f893282008-05-27 12:14:47 +02008712 break;
8713 case 0x10ec0889:
8714 spec->stream_name_analog = "ALC889 Analog";
8715 spec->stream_name_digital = "ALC889 Digital";
8716 break;
8717 default:
8718 spec->stream_name_analog = "ALC883 Analog";
8719 spec->stream_name_digital = "ALC883 Digital";
8720 break;
8721 }
8722
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008723 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8724 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008725 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008726
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008727 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8728 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8729
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008730 if (!spec->num_adc_nids) {
8731 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8732 spec->adc_nids = alc883_adc_nids;
8733 }
8734 if (!spec->capsrc_nids)
8735 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008736 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008737 if (!spec->cap_mixer)
8738 set_capture_mixer(spec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008739
Takashi Iwai2134ea42008-01-10 16:53:55 +01008740 spec->vmaster_nid = 0x0c;
8741
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008742 codec->patch_ops = alc_patch_ops;
8743 if (board_config == ALC883_AUTO)
8744 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008745
Takashi Iwaicb53c622007-08-10 17:21:45 +02008746#ifdef CONFIG_SND_HDA_POWER_SAVE
8747 if (!spec->loopback.amplist)
8748 spec->loopback.amplist = alc883_loopbacks;
8749#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008750
8751 return 0;
8752}
8753
8754/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008755 * ALC262 support
8756 */
8757
8758#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8759#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8760
8761#define alc262_dac_nids alc260_dac_nids
8762#define alc262_adc_nids alc882_adc_nids
8763#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008764#define alc262_capsrc_nids alc882_capsrc_nids
8765#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008766
8767#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008768#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008769
Kailang Yang4e555fe2008-08-26 13:05:55 +02008770static hda_nid_t alc262_dmic_adc_nids[1] = {
8771 /* ADC0 */
8772 0x09
8773};
8774
8775static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
8776
Kailang Yangdf694da2005-12-05 19:42:22 +01008777static struct snd_kcontrol_new alc262_base_mixer[] = {
8778 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8779 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8780 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8781 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8782 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8783 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8785 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008786 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008787 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8788 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008789 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008790 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008791 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008792 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8793 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8794 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8795 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008796 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008797};
8798
Kailang Yangccc656c2006-10-17 12:32:26 +02008799static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8800 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8801 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8802 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8803 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8804 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8805 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8807 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008808 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008809 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8810 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008811 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008812 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008813 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008814 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8816 { } /* end */
8817};
8818
Takashi Iwaice875f02008-01-28 18:17:43 +01008819/* update HP, line and mono-out pins according to the master switch */
8820static void alc262_hp_master_update(struct hda_codec *codec)
8821{
8822 struct alc_spec *spec = codec->spec;
8823 int val = spec->master_sw;
8824
8825 /* HP & line-out */
8826 snd_hda_codec_write_cache(codec, 0x1b, 0,
8827 AC_VERB_SET_PIN_WIDGET_CONTROL,
8828 val ? PIN_HP : 0);
8829 snd_hda_codec_write_cache(codec, 0x15, 0,
8830 AC_VERB_SET_PIN_WIDGET_CONTROL,
8831 val ? PIN_HP : 0);
8832 /* mono (speaker) depending on the HP jack sense */
8833 val = val && !spec->jack_present;
8834 snd_hda_codec_write_cache(codec, 0x16, 0,
8835 AC_VERB_SET_PIN_WIDGET_CONTROL,
8836 val ? PIN_OUT : 0);
8837}
8838
8839static void alc262_hp_bpc_automute(struct hda_codec *codec)
8840{
8841 struct alc_spec *spec = codec->spec;
8842 unsigned int presence;
8843 presence = snd_hda_codec_read(codec, 0x1b, 0,
8844 AC_VERB_GET_PIN_SENSE, 0);
8845 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8846 alc262_hp_master_update(codec);
8847}
8848
8849static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8850{
8851 if ((res >> 26) != ALC880_HP_EVENT)
8852 return;
8853 alc262_hp_bpc_automute(codec);
8854}
8855
8856static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8857{
8858 struct alc_spec *spec = codec->spec;
8859 unsigned int presence;
8860 presence = snd_hda_codec_read(codec, 0x15, 0,
8861 AC_VERB_GET_PIN_SENSE, 0);
8862 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8863 alc262_hp_master_update(codec);
8864}
8865
8866static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8867 unsigned int res)
8868{
8869 if ((res >> 26) != ALC880_HP_EVENT)
8870 return;
8871 alc262_hp_wildwest_automute(codec);
8872}
8873
8874static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8875 struct snd_ctl_elem_value *ucontrol)
8876{
8877 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8878 struct alc_spec *spec = codec->spec;
8879 *ucontrol->value.integer.value = spec->master_sw;
8880 return 0;
8881}
8882
8883static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8884 struct snd_ctl_elem_value *ucontrol)
8885{
8886 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8887 struct alc_spec *spec = codec->spec;
8888 int val = !!*ucontrol->value.integer.value;
8889
8890 if (val == spec->master_sw)
8891 return 0;
8892 spec->master_sw = val;
8893 alc262_hp_master_update(codec);
8894 return 1;
8895}
8896
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008897static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008898 {
8899 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8900 .name = "Master Playback Switch",
8901 .info = snd_ctl_boolean_mono_info,
8902 .get = alc262_hp_master_sw_get,
8903 .put = alc262_hp_master_sw_put,
8904 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008905 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8906 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8907 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008908 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8909 HDA_OUTPUT),
8910 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8911 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008914 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008915 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8916 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008917 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008918 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8919 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8920 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8921 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8922 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8923 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8924 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8925 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8926 { } /* end */
8927};
8928
Kailang Yangcd7509a2007-01-26 18:33:17 +01008929static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008930 {
8931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8932 .name = "Master Playback Switch",
8933 .info = snd_ctl_boolean_mono_info,
8934 .get = alc262_hp_master_sw_get,
8935 .put = alc262_hp_master_sw_put,
8936 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008937 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8938 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8939 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8940 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008941 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8942 HDA_OUTPUT),
8943 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8944 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008945 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8946 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008947 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008948 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8949 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8952 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8953 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8954 { } /* end */
8955};
8956
8957static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8958 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8959 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008960 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008961 { } /* end */
8962};
8963
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008964/* mute/unmute internal speaker according to the hp jack and mute state */
8965static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8966{
8967 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008968
8969 if (force || !spec->sense_updated) {
8970 unsigned int present;
8971 present = snd_hda_codec_read(codec, 0x15, 0,
8972 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008973 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008974 spec->sense_updated = 1;
8975 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008976 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8977 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008978}
8979
8980static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8981 unsigned int res)
8982{
8983 if ((res >> 26) != ALC880_HP_EVENT)
8984 return;
8985 alc262_hp_t5735_automute(codec, 1);
8986}
8987
8988static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8989{
8990 alc262_hp_t5735_automute(codec, 1);
8991}
8992
8993static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008994 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8995 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008996 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8997 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9000 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9001 { } /* end */
9002};
9003
9004static struct hda_verb alc262_hp_t5735_verbs[] = {
9005 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9006 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9007
9008 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9009 { }
9010};
9011
Kailang Yang8c427222008-01-10 13:03:59 +01009012static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009013 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9014 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009015 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9016 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009017 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9018 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9019 { } /* end */
9020};
9021
9022static struct hda_verb alc262_hp_rp5700_verbs[] = {
9023 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9024 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9025 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9026 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9027 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9028 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9029 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9030 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9032 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9033 {}
9034};
9035
9036static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9037 .num_items = 1,
9038 .items = {
9039 { "Line", 0x1 },
9040 },
9041};
9042
Takashi Iwai0724ea22007-08-23 00:31:43 +02009043/* bind hp and internal speaker mute (with plug check) */
9044static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9045 struct snd_ctl_elem_value *ucontrol)
9046{
9047 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9048 long *valp = ucontrol->value.integer.value;
9049 int change;
9050
9051 /* change hp mute */
9052 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9053 HDA_AMP_MUTE,
9054 valp[0] ? 0 : HDA_AMP_MUTE);
9055 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9056 HDA_AMP_MUTE,
9057 valp[1] ? 0 : HDA_AMP_MUTE);
9058 if (change) {
9059 /* change speaker according to HP jack state */
9060 struct alc_spec *spec = codec->spec;
9061 unsigned int mute;
9062 if (spec->jack_present)
9063 mute = HDA_AMP_MUTE;
9064 else
9065 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9066 HDA_OUTPUT, 0);
9067 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9068 HDA_AMP_MUTE, mute);
9069 }
9070 return change;
9071}
Takashi Iwai5b319542007-07-26 11:49:22 +02009072
Kailang Yang272a5272007-05-14 11:00:38 +02009073static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009074 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9075 {
9076 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9077 .name = "Master Playback Switch",
9078 .info = snd_hda_mixer_amp_switch_info,
9079 .get = snd_hda_mixer_amp_switch_get,
9080 .put = alc262_sony_master_sw_put,
9081 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9082 },
Kailang Yang272a5272007-05-14 11:00:38 +02009083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9084 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9085 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9086 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9087 { } /* end */
9088};
9089
Kailang Yang83c34212007-07-05 11:43:05 +02009090static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9092 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9093 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9094 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9095 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9096 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9097 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9098 { } /* end */
9099};
Kailang Yang272a5272007-05-14 11:00:38 +02009100
Kailang Yangdf694da2005-12-05 19:42:22 +01009101#define alc262_capture_mixer alc882_capture_mixer
9102#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9103
9104/*
9105 * generic initialization of ADC, input mixers and output mixers
9106 */
9107static struct hda_verb alc262_init_verbs[] = {
9108 /*
9109 * Unmute ADC0-2 and set the default input to mic-in
9110 */
9111 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9112 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9113 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9115 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9117
Takashi Iwaicb53c622007-08-10 17:21:45 +02009118 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009119 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009120 * Note: PASD motherboards uses the Line In 2 as the input for
9121 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009122 */
9123 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009124 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9125 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009129
9130 /*
9131 * Set up output mixers (0x0c - 0x0e)
9132 */
9133 /* set vol=0 to output mixers */
9134 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9136 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9137 /* set up input amps for analog loopback */
9138 /* Amp Indices: DAC = 0, mixer = 1 */
9139 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9140 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9141 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9142 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9143 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9144 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9145
9146 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9147 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9148 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9149 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9150 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9151 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9152
9153 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9154 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9155 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9156 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9157 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009158
Kailang Yangdf694da2005-12-05 19:42:22 +01009159 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9160 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009161
Kailang Yangdf694da2005-12-05 19:42:22 +01009162 /* FIXME: use matrix-type input source selection */
9163 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9164 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9165 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9166 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9167 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9169 /* Input mixer2 */
9170 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9171 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9173 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9174 /* Input mixer3 */
9175 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9176 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009179
9180 { }
9181};
9182
Kailang Yang4e555fe2008-08-26 13:05:55 +02009183static struct hda_verb alc262_eapd_verbs[] = {
9184 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9185 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9186 { }
9187};
9188
Kailang Yangccc656c2006-10-17 12:32:26 +02009189static struct hda_verb alc262_hippo_unsol_verbs[] = {
9190 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9192 {}
9193};
9194
9195static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9196 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9197 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9198 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9199
9200 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9201 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9202 {}
9203};
9204
Kailang Yang272a5272007-05-14 11:00:38 +02009205static struct hda_verb alc262_sony_unsol_verbs[] = {
9206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9207 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9208 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9209
9210 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009212 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009213};
9214
Kailang Yang4e555fe2008-08-26 13:05:55 +02009215static struct hda_input_mux alc262_dmic_capture_source = {
9216 .num_items = 2,
9217 .items = {
9218 { "Int DMic", 0x9 },
9219 { "Mic", 0x0 },
9220 },
9221};
9222
9223static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9224 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9225 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9227 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9228 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009229 { } /* end */
9230};
9231
9232static struct hda_verb alc262_toshiba_s06_verbs[] = {
9233 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9236 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9237 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9238 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9239 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9240 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9241 {}
9242};
9243
9244static void alc262_dmic_automute(struct hda_codec *codec)
9245{
9246 unsigned int present;
9247
9248 present = snd_hda_codec_read(codec, 0x18, 0,
9249 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9250 snd_hda_codec_write(codec, 0x22, 0,
9251 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9252}
9253
9254/* toggle speaker-output according to the hp-jack state */
9255static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9256{
9257 unsigned int present;
9258 unsigned char bits;
9259
9260 present = snd_hda_codec_read(codec, 0x15, 0,
9261 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9262 bits = present ? 0 : PIN_OUT;
9263 snd_hda_codec_write(codec, 0x14, 0,
9264 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9265}
9266
9267
9268
9269/* unsolicited event for HP jack sensing */
9270static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9271 unsigned int res)
9272{
9273 if ((res >> 26) == ALC880_HP_EVENT)
9274 alc262_toshiba_s06_speaker_automute(codec);
9275 if ((res >> 26) == ALC880_MIC_EVENT)
9276 alc262_dmic_automute(codec);
9277
9278}
9279
9280static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9281{
9282 alc262_toshiba_s06_speaker_automute(codec);
9283 alc262_dmic_automute(codec);
9284}
9285
Kailang Yangccc656c2006-10-17 12:32:26 +02009286/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009287static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009288{
9289 struct alc_spec *spec = codec->spec;
9290 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009291 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009292
Takashi Iwai5b319542007-07-26 11:49:22 +02009293 /* need to execute and sync at first */
9294 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9295 present = snd_hda_codec_read(codec, 0x15, 0,
9296 AC_VERB_GET_PIN_SENSE, 0);
9297 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009298 if (spec->jack_present) {
9299 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009300 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9301 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009302 } else {
9303 /* unmute internal speaker if necessary */
9304 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009305 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9306 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009307 }
9308}
9309
9310/* unsolicited event for HP jack sensing */
9311static void alc262_hippo_unsol_event(struct hda_codec *codec,
9312 unsigned int res)
9313{
9314 if ((res >> 26) != ALC880_HP_EVENT)
9315 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009316 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009317}
9318
Takashi Iwai5b319542007-07-26 11:49:22 +02009319static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009320{
Kailang Yangccc656c2006-10-17 12:32:26 +02009321 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009322 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009323
Takashi Iwai5b319542007-07-26 11:49:22 +02009324 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9325 present = snd_hda_codec_read(codec, 0x1b, 0,
9326 AC_VERB_GET_PIN_SENSE, 0);
9327 present = (present & 0x80000000) != 0;
9328 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009329 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009330 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9331 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009332 } else {
9333 /* unmute internal speaker if necessary */
9334 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009335 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9336 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009337 }
9338}
9339
9340/* unsolicited event for HP jack sensing */
9341static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9342 unsigned int res)
9343{
9344 if ((res >> 26) != ALC880_HP_EVENT)
9345 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009346 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009347}
9348
Takashi Iwai834be882006-03-01 14:16:17 +01009349/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009350 * nec model
9351 * 0x15 = headphone
9352 * 0x16 = internal speaker
9353 * 0x18 = external mic
9354 */
9355
9356static struct snd_kcontrol_new alc262_nec_mixer[] = {
9357 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9358 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9359
9360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9361 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9362 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9363
9364 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9365 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9366 { } /* end */
9367};
9368
9369static struct hda_verb alc262_nec_verbs[] = {
9370 /* Unmute Speaker */
9371 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9372
9373 /* Headphone */
9374 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9375 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9376
9377 /* External mic to headphone */
9378 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9379 /* External mic to speaker */
9380 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9381 {}
9382};
9383
9384/*
Takashi Iwai834be882006-03-01 14:16:17 +01009385 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009386 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9387 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009388 */
9389
9390#define ALC_HP_EVENT 0x37
9391
9392static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9393 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9394 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009395 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9396 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009397 {}
9398};
9399
Jiang zhe0e31daf2008-03-20 12:12:39 +01009400static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9401 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9402 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9403 {}
9404};
9405
Takashi Iwai834be882006-03-01 14:16:17 +01009406static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009407 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009408 .items = {
9409 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009410 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009411 { "CD", 0x4 },
9412 },
9413};
9414
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009415static struct hda_input_mux alc262_HP_capture_source = {
9416 .num_items = 5,
9417 .items = {
9418 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009419 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009420 { "Line", 0x2 },
9421 { "CD", 0x4 },
9422 { "AUX IN", 0x6 },
9423 },
9424};
9425
zhejiangaccbe492007-08-31 12:36:05 +02009426static struct hda_input_mux alc262_HP_D7000_capture_source = {
9427 .num_items = 4,
9428 .items = {
9429 { "Mic", 0x0 },
9430 { "Front Mic", 0x2 },
9431 { "Line", 0x1 },
9432 { "CD", 0x4 },
9433 },
9434};
9435
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009436/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009437static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9438{
9439 struct alc_spec *spec = codec->spec;
9440 unsigned int mute;
9441
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009442 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009443 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009444 /* need to execute and sync at first */
9445 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009446 /* check laptop HP jack */
9447 present = snd_hda_codec_read(codec, 0x14, 0,
9448 AC_VERB_GET_PIN_SENSE, 0);
9449 /* need to execute and sync at first */
9450 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9451 /* check docking HP jack */
9452 present |= snd_hda_codec_read(codec, 0x1b, 0,
9453 AC_VERB_GET_PIN_SENSE, 0);
9454 if (present & AC_PINSENSE_PRESENCE)
9455 spec->jack_present = 1;
9456 else
9457 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009458 spec->sense_updated = 1;
9459 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009460 /* unmute internal speaker only if both HPs are unplugged and
9461 * master switch is on
9462 */
9463 if (spec->jack_present)
9464 mute = HDA_AMP_MUTE;
9465 else
Takashi Iwai834be882006-03-01 14:16:17 +01009466 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009467 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9468 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009469}
9470
9471/* unsolicited event for HP jack sensing */
9472static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9473 unsigned int res)
9474{
9475 if ((res >> 26) != ALC_HP_EVENT)
9476 return;
9477 alc262_fujitsu_automute(codec, 1);
9478}
9479
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009480static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9481{
9482 alc262_fujitsu_automute(codec, 1);
9483}
9484
Takashi Iwai834be882006-03-01 14:16:17 +01009485/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009486static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9487 .ops = &snd_hda_bind_vol,
9488 .values = {
9489 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9490 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9491 0
9492 },
9493};
Takashi Iwai834be882006-03-01 14:16:17 +01009494
Jiang zhe0e31daf2008-03-20 12:12:39 +01009495/* mute/unmute internal speaker according to the hp jack and mute state */
9496static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9497{
9498 struct alc_spec *spec = codec->spec;
9499 unsigned int mute;
9500
9501 if (force || !spec->sense_updated) {
9502 unsigned int present_int_hp;
9503 /* need to execute and sync at first */
9504 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9505 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9506 AC_VERB_GET_PIN_SENSE, 0);
9507 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9508 spec->sense_updated = 1;
9509 }
9510 if (spec->jack_present) {
9511 /* mute internal speaker */
9512 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9513 HDA_AMP_MUTE, HDA_AMP_MUTE);
9514 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9515 HDA_AMP_MUTE, HDA_AMP_MUTE);
9516 } else {
9517 /* unmute internal speaker if necessary */
9518 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9519 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9520 HDA_AMP_MUTE, mute);
9521 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9522 HDA_AMP_MUTE, mute);
9523 }
9524}
9525
9526/* unsolicited event for HP jack sensing */
9527static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9528 unsigned int res)
9529{
9530 if ((res >> 26) != ALC_HP_EVENT)
9531 return;
9532 alc262_lenovo_3000_automute(codec, 1);
9533}
9534
Takashi Iwai834be882006-03-01 14:16:17 +01009535/* bind hp and internal speaker mute (with plug check) */
9536static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9537 struct snd_ctl_elem_value *ucontrol)
9538{
9539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9540 long *valp = ucontrol->value.integer.value;
9541 int change;
9542
Tony Vroon5d9fab22008-03-14 17:09:18 +01009543 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9544 HDA_AMP_MUTE,
9545 valp ? 0 : HDA_AMP_MUTE);
9546 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9547 HDA_AMP_MUTE,
9548 valp ? 0 : HDA_AMP_MUTE);
9549
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009550 if (change)
9551 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009552 return change;
9553}
9554
9555static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009556 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009557 {
9558 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9559 .name = "Master Playback Switch",
9560 .info = snd_hda_mixer_amp_switch_info,
9561 .get = snd_hda_mixer_amp_switch_get,
9562 .put = alc262_fujitsu_master_sw_put,
9563 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9564 },
9565 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9566 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009567 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9568 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009569 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9570 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9571 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009572 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9573 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9574 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009575 { } /* end */
9576};
9577
Jiang zhe0e31daf2008-03-20 12:12:39 +01009578/* bind hp and internal speaker mute (with plug check) */
9579static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9580 struct snd_ctl_elem_value *ucontrol)
9581{
9582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9583 long *valp = ucontrol->value.integer.value;
9584 int change;
9585
9586 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9587 HDA_AMP_MUTE,
9588 valp ? 0 : HDA_AMP_MUTE);
9589
9590 if (change)
9591 alc262_lenovo_3000_automute(codec, 0);
9592 return change;
9593}
9594
9595static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9596 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9597 {
9598 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9599 .name = "Master Playback Switch",
9600 .info = snd_hda_mixer_amp_switch_info,
9601 .get = snd_hda_mixer_amp_switch_get,
9602 .put = alc262_lenovo_3000_master_sw_put,
9603 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9604 },
9605 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9606 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9607 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9610 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9611 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9612 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9613 { } /* end */
9614};
9615
Hiroshi Miura9f99a632008-08-28 16:09:06 +02009616static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
9617 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9618 {
9619 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9620 .name = "Master Playback Switch",
9621 .info = snd_hda_mixer_amp_switch_info,
9622 .get = snd_hda_mixer_amp_switch_get,
9623 .put = alc262_sony_master_sw_put,
9624 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9625 },
9626 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9627 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9628 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9629 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9630 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9631 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9632 { } /* end */
9633};
9634
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009635/* additional init verbs for Benq laptops */
9636static struct hda_verb alc262_EAPD_verbs[] = {
9637 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9638 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9639 {}
9640};
9641
Kailang Yang83c34212007-07-05 11:43:05 +02009642static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9643 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9644 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9645
9646 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9647 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9648 {}
9649};
9650
Tobin Davisf651b502007-10-26 12:40:47 +02009651/* Samsung Q1 Ultra Vista model setup */
9652static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009653 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9654 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009655 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9656 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9657 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009658 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009659 { } /* end */
9660};
9661
9662static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009663 /* output mixer */
9664 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9665 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9666 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9667 /* speaker */
9668 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9669 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9670 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9671 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9672 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009673 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9676 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9677 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9678 /* internal mic */
9679 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9681 /* ADC, choose mic */
9682 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9683 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9684 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9685 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9686 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9687 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9688 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9689 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009692 {}
9693};
9694
Tobin Davisf651b502007-10-26 12:40:47 +02009695/* mute/unmute internal speaker according to the hp jack and mute state */
9696static void alc262_ultra_automute(struct hda_codec *codec)
9697{
9698 struct alc_spec *spec = codec->spec;
9699 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009700
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009701 mute = 0;
9702 /* auto-mute only when HP is used as HP */
9703 if (!spec->cur_mux[0]) {
9704 unsigned int present;
9705 /* need to execute and sync at first */
9706 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9707 present = snd_hda_codec_read(codec, 0x15, 0,
9708 AC_VERB_GET_PIN_SENSE, 0);
9709 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9710 if (spec->jack_present)
9711 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009712 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009713 /* mute/unmute internal speaker */
9714 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9715 HDA_AMP_MUTE, mute);
9716 /* mute/unmute HP */
9717 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9718 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009719}
9720
9721/* unsolicited event for HP jack sensing */
9722static void alc262_ultra_unsol_event(struct hda_codec *codec,
9723 unsigned int res)
9724{
9725 if ((res >> 26) != ALC880_HP_EVENT)
9726 return;
9727 alc262_ultra_automute(codec);
9728}
9729
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009730static struct hda_input_mux alc262_ultra_capture_source = {
9731 .num_items = 2,
9732 .items = {
9733 { "Mic", 0x1 },
9734 { "Headphone", 0x7 },
9735 },
9736};
9737
9738static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9739 struct snd_ctl_elem_value *ucontrol)
9740{
9741 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9742 struct alc_spec *spec = codec->spec;
9743 int ret;
9744
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009745 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009746 if (!ret)
9747 return 0;
9748 /* reprogram the HP pin as mic or HP according to the input source */
9749 snd_hda_codec_write_cache(codec, 0x15, 0,
9750 AC_VERB_SET_PIN_WIDGET_CONTROL,
9751 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9752 alc262_ultra_automute(codec); /* mute/unmute HP */
9753 return ret;
9754}
9755
9756static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9757 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9758 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9759 {
9760 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9761 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009762 .info = alc_mux_enum_info,
9763 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009764 .put = alc262_ultra_mux_enum_put,
9765 },
9766 { } /* end */
9767};
9768
Kailang Yangdf694da2005-12-05 19:42:22 +01009769/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009770static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9771 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009772{
9773 hda_nid_t nid;
9774 int err;
9775
9776 spec->multiout.num_dacs = 1; /* only use one dac */
9777 spec->multiout.dac_nids = spec->private_dac_nids;
9778 spec->multiout.dac_nids[0] = 2;
9779
9780 nid = cfg->line_out_pins[0];
9781 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009782 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9783 "Front Playback Volume",
9784 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9785 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009786 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009787 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9788 "Front Playback Switch",
9789 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9790 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009791 return err;
9792 }
9793
Takashi Iwai82bc9552006-03-21 11:24:42 +01009794 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009795 if (nid) {
9796 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009797 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9798 "Speaker Playback Volume",
9799 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9800 HDA_OUTPUT));
9801 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009802 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009803 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9804 "Speaker Playback Switch",
9805 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9806 HDA_OUTPUT));
9807 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009808 return err;
9809 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009810 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9811 "Speaker Playback Switch",
9812 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9813 HDA_OUTPUT));
9814 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009815 return err;
9816 }
9817 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009818 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009819 if (nid) {
9820 /* spec->multiout.hp_nid = 2; */
9821 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009822 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9823 "Headphone Playback Volume",
9824 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9825 HDA_OUTPUT));
9826 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009827 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009828 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9829 "Headphone Playback Switch",
9830 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9831 HDA_OUTPUT));
9832 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009833 return err;
9834 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009835 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9836 "Headphone Playback Switch",
9837 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9838 HDA_OUTPUT));
9839 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009840 return err;
9841 }
9842 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009843 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009844}
9845
9846/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009847#define alc262_auto_create_analog_input_ctls \
9848 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009849
9850/*
9851 * generic initialization of ADC, input mixers and output mixers
9852 */
9853static struct hda_verb alc262_volume_init_verbs[] = {
9854 /*
9855 * Unmute ADC0-2 and set the default input to mic-in
9856 */
9857 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9859 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9860 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9861 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9863
Takashi Iwaicb53c622007-08-10 17:21:45 +02009864 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009865 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009866 * Note: PASD motherboards uses the Line In 2 as the input for
9867 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009868 */
9869 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009875
9876 /*
9877 * Set up output mixers (0x0c - 0x0f)
9878 */
9879 /* set vol=0 to output mixers */
9880 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9881 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9882 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +02009883
Kailang Yangdf694da2005-12-05 19:42:22 +01009884 /* set up input amps for analog loopback */
9885 /* Amp Indices: DAC = 0, mixer = 1 */
9886 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9888 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9890 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9892
9893 /* FIXME: use matrix-type input source selection */
9894 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9895 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9896 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9897 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9898 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9899 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9900 /* Input mixer2 */
9901 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9902 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9903 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9904 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9905 /* Input mixer3 */
9906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9910
9911 { }
9912};
9913
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009914static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9915 /*
9916 * Unmute ADC0-2 and set the default input to mic-in
9917 */
9918 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9919 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9920 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9921 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9922 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9923 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9924
Takashi Iwaicb53c622007-08-10 17:21:45 +02009925 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009926 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009927 * Note: PASD motherboards uses the Line In 2 as the input for
9928 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009929 */
9930 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9937 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +02009938
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009939 /*
9940 * Set up output mixers (0x0c - 0x0e)
9941 */
9942 /* set vol=0 to output mixers */
9943 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9944 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9946
9947 /* set up input amps for analog loopback */
9948 /* Amp Indices: DAC = 0, mixer = 1 */
9949 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9950 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9951 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9952 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9953 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9954 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9955
Takashi Iwaice875f02008-01-28 18:17:43 +01009956 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009957 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9958 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9959
9960 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9962
9963 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9964 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9965
9966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9967 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9968 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9969 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9970 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9971
9972 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9973 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9974 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9975 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9976 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9977 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9978
9979
9980 /* FIXME: use matrix-type input source selection */
9981 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9982 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9983 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9987 /* Input mixer2 */
9988 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9989 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9990 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9991 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9992 /* Input mixer3 */
9993 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9994 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9995 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9996 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9997
Takashi Iwaice875f02008-01-28 18:17:43 +01009998 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9999
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010000 { }
10001};
10002
Kailang Yangcd7509a2007-01-26 18:33:17 +010010003static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10004 /*
10005 * Unmute ADC0-2 and set the default input to mic-in
10006 */
10007 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10008 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10009 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10010 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10011 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10012 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10013
Takashi Iwaicb53c622007-08-10 17:21:45 +020010014 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010015 * mixer widget
10016 * Note: PASD motherboards uses the Line In 2 as the input for front
10017 * panel mic (mic 2)
10018 */
10019 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10022 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10023 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10024 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10025 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10026 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10027 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010028 /*
10029 * Set up output mixers (0x0c - 0x0e)
10030 */
10031 /* set vol=0 to output mixers */
10032 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10033 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10034 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10035
10036 /* set up input amps for analog loopback */
10037 /* Amp Indices: DAC = 0, mixer = 1 */
10038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10040 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10042 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10043 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10044
10045
10046 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10047 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10048 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10049 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10050 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10051 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10052 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10053
10054 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10055 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10056
10057 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10058 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10059
10060 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10061 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10062 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10063 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10064 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10065 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10066
10067 /* FIXME: use matrix-type input source selection */
10068 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10069 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10070 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10071 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10072 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10073 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10074 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10075 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10076 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10077 /* Input mixer2 */
10078 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10079 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10080 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10081 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10082 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10083 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10085 /* Input mixer3 */
10086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10091 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10093
Takashi Iwaice875f02008-01-28 18:17:43 +010010094 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10095
Kailang Yangcd7509a2007-01-26 18:33:17 +010010096 { }
10097};
10098
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010099static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10100
10101 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10102 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10103 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10104
10105 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10106 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10107 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10108 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10109
10110 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10111 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10112 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10113 {}
10114};
10115
10116
Takashi Iwaicb53c622007-08-10 17:21:45 +020010117#ifdef CONFIG_SND_HDA_POWER_SAVE
10118#define alc262_loopbacks alc880_loopbacks
10119#endif
10120
Kailang Yangdf694da2005-12-05 19:42:22 +010010121/* pcm configuration: identiacal with ALC880 */
10122#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10123#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10124#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10125#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10126
10127/*
10128 * BIOS auto configuration
10129 */
10130static int alc262_parse_auto_config(struct hda_codec *codec)
10131{
10132 struct alc_spec *spec = codec->spec;
10133 int err;
10134 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10135
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010136 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10137 alc262_ignore);
10138 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010139 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010140 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010010141 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010142 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10143 if (err < 0)
10144 return err;
10145 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10146 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010147 return err;
10148
10149 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10150
10151 if (spec->autocfg.dig_out_pin)
10152 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10153 if (spec->autocfg.dig_in_pin)
10154 spec->dig_in_nid = ALC262_DIGIN_NID;
10155
Takashi Iwai603c4012008-07-30 15:01:44 +020010156 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010157 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010158
Takashi Iwaid88897e2008-10-31 15:01:37 +010010159 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010160 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010161 spec->input_mux = &spec->private_imux;
10162
Takashi Iwai776e1842007-08-29 15:07:11 +020010163 err = alc_auto_add_mic_boost(codec);
10164 if (err < 0)
10165 return err;
10166
Takashi Iwaie044c392008-10-27 16:56:24 +010010167 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010168 return 1;
10169}
10170
10171#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10172#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10173#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010174#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010175
10176
10177/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010178static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010179{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010180 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010181 alc262_auto_init_multi_out(codec);
10182 alc262_auto_init_hp_out(codec);
10183 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010184 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010185 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010186 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010187}
10188
10189/*
10190 * configuration and preset
10191 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010192static const char *alc262_models[ALC262_MODEL_LAST] = {
10193 [ALC262_BASIC] = "basic",
10194 [ALC262_HIPPO] = "hippo",
10195 [ALC262_HIPPO_1] = "hippo_1",
10196 [ALC262_FUJITSU] = "fujitsu",
10197 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010198 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010199 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010200 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010201 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010202 [ALC262_BENQ_T31] = "benq-t31",
10203 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010204 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010205 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010206 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010207 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010208 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010209 [ALC262_AUTO] = "auto",
10210};
10211
10212static struct snd_pci_quirk alc262_cfg_tbl[] = {
10213 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010214 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010215 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010216 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010217 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10218 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010219 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010220 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010221 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010222 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010223 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010224 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010225 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010226 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010227 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010228 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010229 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010230 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010231 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10232 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10233 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010234 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10235 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010236 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010237 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010238 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010239 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10240 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10241 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010242 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010243 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010244 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010245 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010246 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010247 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010248 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010249 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010250 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010251 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010252 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010253 {}
10254};
10255
10256static struct alc_config_preset alc262_presets[] = {
10257 [ALC262_BASIC] = {
10258 .mixers = { alc262_base_mixer },
10259 .init_verbs = { alc262_init_verbs },
10260 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10261 .dac_nids = alc262_dac_nids,
10262 .hp_nid = 0x03,
10263 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10264 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010265 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010266 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010267 [ALC262_HIPPO] = {
10268 .mixers = { alc262_base_mixer },
10269 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10270 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10271 .dac_nids = alc262_dac_nids,
10272 .hp_nid = 0x03,
10273 .dig_out_nid = ALC262_DIGOUT_NID,
10274 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10275 .channel_mode = alc262_modes,
10276 .input_mux = &alc262_capture_source,
10277 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010278 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010279 },
10280 [ALC262_HIPPO_1] = {
10281 .mixers = { alc262_hippo1_mixer },
10282 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10283 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10284 .dac_nids = alc262_dac_nids,
10285 .hp_nid = 0x02,
10286 .dig_out_nid = ALC262_DIGOUT_NID,
10287 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10288 .channel_mode = alc262_modes,
10289 .input_mux = &alc262_capture_source,
10290 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010291 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010292 },
Takashi Iwai834be882006-03-01 14:16:17 +010010293 [ALC262_FUJITSU] = {
10294 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010295 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10296 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010297 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10298 .dac_nids = alc262_dac_nids,
10299 .hp_nid = 0x03,
10300 .dig_out_nid = ALC262_DIGOUT_NID,
10301 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10302 .channel_mode = alc262_modes,
10303 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010304 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010305 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010306 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010307 [ALC262_HP_BPC] = {
10308 .mixers = { alc262_HP_BPC_mixer },
10309 .init_verbs = { alc262_HP_BPC_init_verbs },
10310 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10311 .dac_nids = alc262_dac_nids,
10312 .hp_nid = 0x03,
10313 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10314 .channel_mode = alc262_modes,
10315 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010316 .unsol_event = alc262_hp_bpc_unsol_event,
10317 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010318 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010319 [ALC262_HP_BPC_D7000_WF] = {
10320 .mixers = { alc262_HP_BPC_WildWest_mixer },
10321 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10322 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10323 .dac_nids = alc262_dac_nids,
10324 .hp_nid = 0x03,
10325 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10326 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010327 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010328 .unsol_event = alc262_hp_wildwest_unsol_event,
10329 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010330 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010331 [ALC262_HP_BPC_D7000_WL] = {
10332 .mixers = { alc262_HP_BPC_WildWest_mixer,
10333 alc262_HP_BPC_WildWest_option_mixer },
10334 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10335 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10336 .dac_nids = alc262_dac_nids,
10337 .hp_nid = 0x03,
10338 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10339 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010340 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010341 .unsol_event = alc262_hp_wildwest_unsol_event,
10342 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010343 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010344 [ALC262_HP_TC_T5735] = {
10345 .mixers = { alc262_hp_t5735_mixer },
10346 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10347 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10348 .dac_nids = alc262_dac_nids,
10349 .hp_nid = 0x03,
10350 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10351 .channel_mode = alc262_modes,
10352 .input_mux = &alc262_capture_source,
10353 .unsol_event = alc262_hp_t5735_unsol_event,
10354 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010355 },
10356 [ALC262_HP_RP5700] = {
10357 .mixers = { alc262_hp_rp5700_mixer },
10358 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10359 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10360 .dac_nids = alc262_dac_nids,
10361 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10362 .channel_mode = alc262_modes,
10363 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010364 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010365 [ALC262_BENQ_ED8] = {
10366 .mixers = { alc262_base_mixer },
10367 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10368 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10369 .dac_nids = alc262_dac_nids,
10370 .hp_nid = 0x03,
10371 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10372 .channel_mode = alc262_modes,
10373 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010374 },
Kailang Yang272a5272007-05-14 11:00:38 +020010375 [ALC262_SONY_ASSAMD] = {
10376 .mixers = { alc262_sony_mixer },
10377 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10378 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10379 .dac_nids = alc262_dac_nids,
10380 .hp_nid = 0x02,
10381 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10382 .channel_mode = alc262_modes,
10383 .input_mux = &alc262_capture_source,
10384 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010385 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010386 },
10387 [ALC262_BENQ_T31] = {
10388 .mixers = { alc262_benq_t31_mixer },
10389 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10390 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10391 .dac_nids = alc262_dac_nids,
10392 .hp_nid = 0x03,
10393 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10394 .channel_mode = alc262_modes,
10395 .input_mux = &alc262_capture_source,
10396 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010397 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010398 },
Tobin Davisf651b502007-10-26 12:40:47 +020010399 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010400 .mixers = { alc262_ultra_mixer },
10401 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010402 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010403 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10404 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010405 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10406 .channel_mode = alc262_modes,
10407 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010408 .adc_nids = alc262_adc_nids, /* ADC0 */
10409 .capsrc_nids = alc262_capsrc_nids,
10410 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010411 .unsol_event = alc262_ultra_unsol_event,
10412 .init_hook = alc262_ultra_automute,
10413 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010414 [ALC262_LENOVO_3000] = {
10415 .mixers = { alc262_lenovo_3000_mixer },
10416 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10417 alc262_lenovo_3000_unsol_verbs },
10418 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10419 .dac_nids = alc262_dac_nids,
10420 .hp_nid = 0x03,
10421 .dig_out_nid = ALC262_DIGOUT_NID,
10422 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10423 .channel_mode = alc262_modes,
10424 .input_mux = &alc262_fujitsu_capture_source,
10425 .unsol_event = alc262_lenovo_3000_unsol_event,
10426 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010427 [ALC262_NEC] = {
10428 .mixers = { alc262_nec_mixer },
10429 .init_verbs = { alc262_nec_verbs },
10430 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10431 .dac_nids = alc262_dac_nids,
10432 .hp_nid = 0x03,
10433 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10434 .channel_mode = alc262_modes,
10435 .input_mux = &alc262_capture_source,
10436 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010437 [ALC262_TOSHIBA_S06] = {
10438 .mixers = { alc262_toshiba_s06_mixer },
10439 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10440 alc262_eapd_verbs },
10441 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10442 .capsrc_nids = alc262_dmic_capsrc_nids,
10443 .dac_nids = alc262_dac_nids,
10444 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10445 .dig_out_nid = ALC262_DIGOUT_NID,
10446 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10447 .channel_mode = alc262_modes,
10448 .input_mux = &alc262_dmic_capture_source,
10449 .unsol_event = alc262_toshiba_s06_unsol_event,
10450 .init_hook = alc262_toshiba_s06_init_hook,
10451 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010452 [ALC262_TOSHIBA_RX1] = {
10453 .mixers = { alc262_toshiba_rx1_mixer },
10454 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10455 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10456 .dac_nids = alc262_dac_nids,
10457 .hp_nid = 0x03,
10458 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10459 .channel_mode = alc262_modes,
10460 .input_mux = &alc262_capture_source,
10461 .unsol_event = alc262_hippo_unsol_event,
10462 .init_hook = alc262_hippo_automute,
10463 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010464};
10465
10466static int patch_alc262(struct hda_codec *codec)
10467{
10468 struct alc_spec *spec;
10469 int board_config;
10470 int err;
10471
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010472 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010473 if (spec == NULL)
10474 return -ENOMEM;
10475
10476 codec->spec = spec;
10477#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010478 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10479 * under-run
10480 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010481 {
10482 int tmp;
10483 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10484 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10485 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10486 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10487 }
10488#endif
10489
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010490 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10491
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010492 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10493 alc262_models,
10494 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010495
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010496 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010497 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10498 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010499 board_config = ALC262_AUTO;
10500 }
10501
10502 if (board_config == ALC262_AUTO) {
10503 /* automatic parse from the BIOS config */
10504 err = alc262_parse_auto_config(codec);
10505 if (err < 0) {
10506 alc_free(codec);
10507 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010508 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010509 printk(KERN_INFO
10510 "hda_codec: Cannot set up configuration "
10511 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010512 board_config = ALC262_BASIC;
10513 }
10514 }
10515
10516 if (board_config != ALC262_AUTO)
10517 setup_preset(spec, &alc262_presets[board_config]);
10518
10519 spec->stream_name_analog = "ALC262 Analog";
10520 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10521 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010522
Kailang Yangdf694da2005-12-05 19:42:22 +010010523 spec->stream_name_digital = "ALC262 Digital";
10524 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10525 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10526
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010527 spec->is_mix_capture = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010528 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010529 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010530 unsigned int wcap = get_wcaps(codec, 0x07);
10531
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010532 /* get type */
10533 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010534 if (wcap != AC_WID_AUD_IN) {
10535 spec->adc_nids = alc262_adc_nids_alt;
10536 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010537 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010010538 } else {
10539 spec->adc_nids = alc262_adc_nids;
10540 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010541 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010542 }
10543 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010544 if (!spec->cap_mixer)
10545 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010546
Takashi Iwai2134ea42008-01-10 16:53:55 +010010547 spec->vmaster_nid = 0x0c;
10548
Kailang Yangdf694da2005-12-05 19:42:22 +010010549 codec->patch_ops = alc_patch_ops;
10550 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010551 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010552#ifdef CONFIG_SND_HDA_POWER_SAVE
10553 if (!spec->loopback.amplist)
10554 spec->loopback.amplist = alc262_loopbacks;
10555#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020010556
Kailang Yangdf694da2005-12-05 19:42:22 +010010557 return 0;
10558}
10559
Kailang Yangdf694da2005-12-05 19:42:22 +010010560/*
Kailang Yanga361d842007-06-05 12:30:55 +020010561 * ALC268 channel source setting (2 channel)
10562 */
10563#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10564#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010565
Kailang Yanga361d842007-06-05 12:30:55 +020010566static hda_nid_t alc268_dac_nids[2] = {
10567 /* front, hp */
10568 0x02, 0x03
10569};
10570
10571static hda_nid_t alc268_adc_nids[2] = {
10572 /* ADC0-1 */
10573 0x08, 0x07
10574};
10575
10576static hda_nid_t alc268_adc_nids_alt[1] = {
10577 /* ADC0 */
10578 0x08
10579};
10580
Takashi Iwaie1406342008-02-11 18:32:32 +010010581static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10582
Kailang Yanga361d842007-06-05 12:30:55 +020010583static struct snd_kcontrol_new alc268_base_mixer[] = {
10584 /* output mixer control */
10585 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10586 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10587 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010589 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10590 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10591 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010592 { }
10593};
10594
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010595/* bind Beep switches of both NID 0x0f and 0x10 */
10596static struct hda_bind_ctls alc268_bind_beep_sw = {
10597 .ops = &snd_hda_bind_sw,
10598 .values = {
10599 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10600 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10601 0
10602 },
10603};
10604
10605static struct snd_kcontrol_new alc268_beep_mixer[] = {
10606 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10607 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10608 { }
10609};
10610
Kailang Yangd1a991a2007-08-15 16:21:59 +020010611static struct hda_verb alc268_eapd_verbs[] = {
10612 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10613 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10614 { }
10615};
10616
Takashi Iwaid2738092007-08-16 14:59:45 +020010617/* Toshiba specific */
10618#define alc268_toshiba_automute alc262_hippo_automute
10619
10620static struct hda_verb alc268_toshiba_verbs[] = {
10621 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10622 { } /* end */
10623};
10624
Kailang Yang8ef355d2008-08-26 13:10:22 +020010625static struct hda_input_mux alc268_acer_lc_capture_source = {
10626 .num_items = 2,
10627 .items = {
10628 { "i-Mic", 0x6 },
10629 { "E-Mic", 0x0 },
10630 },
10631};
10632
Takashi Iwaid2738092007-08-16 14:59:45 +020010633/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010634/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010635static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10636 .ops = &snd_hda_bind_vol,
10637 .values = {
10638 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10639 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10640 0
10641 },
10642};
10643
Takashi Iwai889c4392007-08-23 18:56:52 +020010644/* mute/unmute internal speaker according to the hp jack and mute state */
10645static void alc268_acer_automute(struct hda_codec *codec, int force)
10646{
10647 struct alc_spec *spec = codec->spec;
10648 unsigned int mute;
10649
10650 if (force || !spec->sense_updated) {
10651 unsigned int present;
10652 present = snd_hda_codec_read(codec, 0x14, 0,
10653 AC_VERB_GET_PIN_SENSE, 0);
10654 spec->jack_present = (present & 0x80000000) != 0;
10655 spec->sense_updated = 1;
10656 }
10657 if (spec->jack_present)
10658 mute = HDA_AMP_MUTE; /* mute internal speaker */
10659 else /* unmute internal speaker if necessary */
10660 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10661 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10662 HDA_AMP_MUTE, mute);
10663}
10664
10665
10666/* bind hp and internal speaker mute (with plug check) */
10667static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10668 struct snd_ctl_elem_value *ucontrol)
10669{
10670 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10671 long *valp = ucontrol->value.integer.value;
10672 int change;
10673
10674 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10675 HDA_AMP_MUTE,
10676 valp[0] ? 0 : HDA_AMP_MUTE);
10677 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10678 HDA_AMP_MUTE,
10679 valp[1] ? 0 : HDA_AMP_MUTE);
10680 if (change)
10681 alc268_acer_automute(codec, 0);
10682 return change;
10683}
Takashi Iwaid2738092007-08-16 14:59:45 +020010684
Kailang Yang8ef355d2008-08-26 13:10:22 +020010685static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
10686 /* output mixer control */
10687 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10688 {
10689 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10690 .name = "Master Playback Switch",
10691 .info = snd_hda_mixer_amp_switch_info,
10692 .get = snd_hda_mixer_amp_switch_get,
10693 .put = alc268_acer_master_sw_put,
10694 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10695 },
10696 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
10697 { }
10698};
10699
Takashi Iwaid2738092007-08-16 14:59:45 +020010700static struct snd_kcontrol_new alc268_acer_mixer[] = {
10701 /* output mixer control */
10702 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10703 {
10704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10705 .name = "Master Playback Switch",
10706 .info = snd_hda_mixer_amp_switch_info,
10707 .get = snd_hda_mixer_amp_switch_get,
10708 .put = alc268_acer_master_sw_put,
10709 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10710 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010711 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10712 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10713 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010714 { }
10715};
10716
Kailang Yang8ef355d2008-08-26 13:10:22 +020010717static struct hda_verb alc268_acer_aspire_one_verbs[] = {
10718 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10719 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10720 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10721 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10722 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
10723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
10724 { }
10725};
10726
Takashi Iwaid2738092007-08-16 14:59:45 +020010727static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010728 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10729 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010730 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010732 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010734 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10735 { }
10736};
10737
10738/* unsolicited event for HP jack sensing */
10739static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10740 unsigned int res)
10741{
Takashi Iwai889c4392007-08-23 18:56:52 +020010742 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010743 return;
10744 alc268_toshiba_automute(codec);
10745}
10746
10747static void alc268_acer_unsol_event(struct hda_codec *codec,
10748 unsigned int res)
10749{
Takashi Iwai889c4392007-08-23 18:56:52 +020010750 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010751 return;
10752 alc268_acer_automute(codec, 1);
10753}
10754
Takashi Iwai889c4392007-08-23 18:56:52 +020010755static void alc268_acer_init_hook(struct hda_codec *codec)
10756{
10757 alc268_acer_automute(codec, 1);
10758}
10759
Kailang Yang8ef355d2008-08-26 13:10:22 +020010760/* toggle speaker-output according to the hp-jack state */
10761static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
10762{
10763 unsigned int present;
10764 unsigned char bits;
10765
10766 present = snd_hda_codec_read(codec, 0x15, 0,
10767 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10768 bits = present ? AMP_IN_MUTE(0) : 0;
10769 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
10770 AMP_IN_MUTE(0), bits);
10771 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
10772 AMP_IN_MUTE(0), bits);
10773}
10774
10775
10776static void alc268_acer_mic_automute(struct hda_codec *codec)
10777{
10778 unsigned int present;
10779
10780 present = snd_hda_codec_read(codec, 0x18, 0,
10781 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10782 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
10783 present ? 0x0 : 0x6);
10784}
10785
10786static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
10787 unsigned int res)
10788{
10789 if ((res >> 26) == ALC880_HP_EVENT)
10790 alc268_aspire_one_speaker_automute(codec);
10791 if ((res >> 26) == ALC880_MIC_EVENT)
10792 alc268_acer_mic_automute(codec);
10793}
10794
10795static void alc268_acer_lc_init_hook(struct hda_codec *codec)
10796{
10797 alc268_aspire_one_speaker_automute(codec);
10798 alc268_acer_mic_automute(codec);
10799}
10800
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010801static struct snd_kcontrol_new alc268_dell_mixer[] = {
10802 /* output mixer control */
10803 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10804 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10805 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10807 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10808 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10809 { }
10810};
10811
10812static struct hda_verb alc268_dell_verbs[] = {
10813 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10814 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10815 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10816 { }
10817};
10818
10819/* mute/unmute internal speaker according to the hp jack and mute state */
10820static void alc268_dell_automute(struct hda_codec *codec)
10821{
10822 unsigned int present;
10823 unsigned int mute;
10824
10825 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10826 if (present & 0x80000000)
10827 mute = HDA_AMP_MUTE;
10828 else
10829 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10830 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10831 HDA_AMP_MUTE, mute);
10832}
10833
10834static void alc268_dell_unsol_event(struct hda_codec *codec,
10835 unsigned int res)
10836{
10837 if ((res >> 26) != ALC880_HP_EVENT)
10838 return;
10839 alc268_dell_automute(codec);
10840}
10841
10842#define alc268_dell_init_hook alc268_dell_automute
10843
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010844static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10845 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10846 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10847 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10848 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10849 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10850 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10851 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10852 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10853 { }
10854};
10855
10856static struct hda_verb alc267_quanta_il1_verbs[] = {
10857 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10858 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10859 { }
10860};
10861
10862static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10863{
10864 unsigned int present;
10865
10866 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10867 & AC_PINSENSE_PRESENCE;
10868 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10869 present ? 0 : PIN_OUT);
10870}
10871
10872static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10873{
10874 unsigned int present;
10875
10876 present = snd_hda_codec_read(codec, 0x18, 0,
10877 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10878 snd_hda_codec_write(codec, 0x23, 0,
10879 AC_VERB_SET_CONNECT_SEL,
10880 present ? 0x00 : 0x01);
10881}
10882
10883static void alc267_quanta_il1_automute(struct hda_codec *codec)
10884{
10885 alc267_quanta_il1_hp_automute(codec);
10886 alc267_quanta_il1_mic_automute(codec);
10887}
10888
10889static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10890 unsigned int res)
10891{
10892 switch (res >> 26) {
10893 case ALC880_HP_EVENT:
10894 alc267_quanta_il1_hp_automute(codec);
10895 break;
10896 case ALC880_MIC_EVENT:
10897 alc267_quanta_il1_mic_automute(codec);
10898 break;
10899 }
10900}
10901
Kailang Yanga361d842007-06-05 12:30:55 +020010902/*
10903 * generic initialization of ADC, input mixers and output mixers
10904 */
10905static struct hda_verb alc268_base_init_verbs[] = {
10906 /* Unmute DAC0-1 and set vol = 0 */
10907 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10908 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10909 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10910 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10911 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10912 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10913
10914 /*
10915 * Set up output mixers (0x0c - 0x0e)
10916 */
10917 /* set vol=0 to output mixers */
10918 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10920 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10921 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10922
10923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10924 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10925
10926 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10927 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10928 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10929 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10931 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10932 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10933 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10934
10935 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10936 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10937 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10938 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10939 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10940 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10941 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010942
10943 /* set PCBEEP vol = 0, mute connections */
10944 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10945 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10946 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010947
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010948 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020010949
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010950 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10951 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10952 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10953 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020010954
Kailang Yanga361d842007-06-05 12:30:55 +020010955 { }
10956};
10957
10958/*
10959 * generic initialization of ADC, input mixers and output mixers
10960 */
10961static struct hda_verb alc268_volume_init_verbs[] = {
10962 /* set output DAC */
10963 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10964 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10965 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10966 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10967
10968 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10969 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10970 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10971 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10972 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10973
10974 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10975 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10976 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10977 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10978 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10979
10980 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10981 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10982 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10983 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10984
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010985 /* set PCBEEP vol = 0, mute connections */
10986 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10987 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10988 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010989
10990 { }
10991};
10992
Kailang Yanga361d842007-06-05 12:30:55 +020010993static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10994 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10995 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10996 {
10997 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10998 /* The multiple "Capture Source" controls confuse alsamixer
10999 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011000 */
11001 /* .name = "Capture Source", */
11002 .name = "Input Source",
11003 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011004 .info = alc_mux_enum_info,
11005 .get = alc_mux_enum_get,
11006 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011007 },
11008 { } /* end */
11009};
11010
11011static struct snd_kcontrol_new alc268_capture_mixer[] = {
11012 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11013 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11014 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11015 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11016 {
11017 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11018 /* The multiple "Capture Source" controls confuse alsamixer
11019 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011020 */
11021 /* .name = "Capture Source", */
11022 .name = "Input Source",
11023 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011024 .info = alc_mux_enum_info,
11025 .get = alc_mux_enum_get,
11026 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011027 },
11028 { } /* end */
11029};
11030
11031static struct hda_input_mux alc268_capture_source = {
11032 .num_items = 4,
11033 .items = {
11034 { "Mic", 0x0 },
11035 { "Front Mic", 0x1 },
11036 { "Line", 0x2 },
11037 { "CD", 0x3 },
11038 },
11039};
11040
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011041static struct hda_input_mux alc268_acer_capture_source = {
11042 .num_items = 3,
11043 .items = {
11044 { "Mic", 0x0 },
11045 { "Internal Mic", 0x6 },
11046 { "Line", 0x2 },
11047 },
11048};
11049
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011050#ifdef CONFIG_SND_DEBUG
11051static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011052 /* Volume widgets */
11053 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11054 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11055 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11056 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11057 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11058 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11059 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11060 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11061 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11062 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11063 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11064 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11065 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011066 /* The below appears problematic on some hardwares */
11067 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011068 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11069 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11070 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11071 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11072
11073 /* Modes for retasking pin widgets */
11074 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11075 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11076 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11077 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11078
11079 /* Controls for GPIO pins, assuming they are configured as outputs */
11080 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11081 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11082 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11083 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11084
11085 /* Switches to allow the digital SPDIF output pin to be enabled.
11086 * The ALC268 does not have an SPDIF input.
11087 */
11088 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11089
11090 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11091 * this output to turn on an external amplifier.
11092 */
11093 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11094 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11095
11096 { } /* end */
11097};
11098#endif
11099
Kailang Yanga361d842007-06-05 12:30:55 +020011100/* create input playback/capture controls for the given pin */
11101static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11102 const char *ctlname, int idx)
11103{
11104 char name[32];
11105 int err;
11106
11107 sprintf(name, "%s Playback Volume", ctlname);
11108 if (nid == 0x14) {
11109 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11110 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11111 HDA_OUTPUT));
11112 if (err < 0)
11113 return err;
11114 } else if (nid == 0x15) {
11115 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11116 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11117 HDA_OUTPUT));
11118 if (err < 0)
11119 return err;
11120 } else
11121 return -1;
11122 sprintf(name, "%s Playback Switch", ctlname);
11123 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11124 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11125 if (err < 0)
11126 return err;
11127 return 0;
11128}
11129
11130/* add playback controls from the parsed DAC table */
11131static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11132 const struct auto_pin_cfg *cfg)
11133{
11134 hda_nid_t nid;
11135 int err;
11136
11137 spec->multiout.num_dacs = 2; /* only use one dac */
11138 spec->multiout.dac_nids = spec->private_dac_nids;
11139 spec->multiout.dac_nids[0] = 2;
11140 spec->multiout.dac_nids[1] = 3;
11141
11142 nid = cfg->line_out_pins[0];
11143 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011144 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011145
11146 nid = cfg->speaker_pins[0];
11147 if (nid == 0x1d) {
11148 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11149 "Speaker Playback Volume",
11150 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11151 if (err < 0)
11152 return err;
11153 }
11154 nid = cfg->hp_pins[0];
11155 if (nid)
11156 alc268_new_analog_output(spec, nid, "Headphone", 0);
11157
11158 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11159 if (nid == 0x16) {
11160 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11161 "Mono Playback Switch",
11162 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11163 if (err < 0)
11164 return err;
11165 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011166 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011167}
11168
11169/* create playback/capture controls for input pins */
11170static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11171 const struct auto_pin_cfg *cfg)
11172{
11173 struct hda_input_mux *imux = &spec->private_imux;
11174 int i, idx1;
11175
11176 for (i = 0; i < AUTO_PIN_LAST; i++) {
11177 switch(cfg->input_pins[i]) {
11178 case 0x18:
11179 idx1 = 0; /* Mic 1 */
11180 break;
11181 case 0x19:
11182 idx1 = 1; /* Mic 2 */
11183 break;
11184 case 0x1a:
11185 idx1 = 2; /* Line In */
11186 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011187 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011188 idx1 = 3; /* CD */
11189 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011190 case 0x12:
11191 case 0x13:
11192 idx1 = 6; /* digital mics */
11193 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011194 default:
11195 continue;
11196 }
11197 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11198 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011199 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011200 }
11201 return 0;
11202}
11203
11204static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11205{
11206 struct alc_spec *spec = codec->spec;
11207 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11208 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11209 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11210 unsigned int dac_vol1, dac_vol2;
11211
11212 if (speaker_nid) {
11213 snd_hda_codec_write(codec, speaker_nid, 0,
11214 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11215 snd_hda_codec_write(codec, 0x0f, 0,
11216 AC_VERB_SET_AMP_GAIN_MUTE,
11217 AMP_IN_UNMUTE(1));
11218 snd_hda_codec_write(codec, 0x10, 0,
11219 AC_VERB_SET_AMP_GAIN_MUTE,
11220 AMP_IN_UNMUTE(1));
11221 } else {
11222 snd_hda_codec_write(codec, 0x0f, 0,
11223 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11224 snd_hda_codec_write(codec, 0x10, 0,
11225 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11226 }
11227
11228 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011229 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011230 dac_vol2 = AMP_OUT_ZERO;
11231 else if (line_nid == 0x15)
11232 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011233 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011234 dac_vol2 = AMP_OUT_ZERO;
11235 else if (hp_nid == 0x15)
11236 dac_vol1 = AMP_OUT_ZERO;
11237 if (line_nid != 0x16 || hp_nid != 0x16 ||
11238 spec->autocfg.line_out_pins[1] != 0x16 ||
11239 spec->autocfg.line_out_pins[2] != 0x16)
11240 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11241
11242 snd_hda_codec_write(codec, 0x02, 0,
11243 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11244 snd_hda_codec_write(codec, 0x03, 0,
11245 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11246}
11247
11248/* pcm configuration: identiacal with ALC880 */
11249#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11250#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011251#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011252#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11253
11254/*
11255 * BIOS auto configuration
11256 */
11257static int alc268_parse_auto_config(struct hda_codec *codec)
11258{
11259 struct alc_spec *spec = codec->spec;
11260 int err;
11261 static hda_nid_t alc268_ignore[] = { 0 };
11262
11263 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11264 alc268_ignore);
11265 if (err < 0)
11266 return err;
11267 if (!spec->autocfg.line_outs)
11268 return 0; /* can't find valid BIOS pin config */
11269
11270 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11271 if (err < 0)
11272 return err;
11273 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11274 if (err < 0)
11275 return err;
11276
11277 spec->multiout.max_channels = 2;
11278
11279 /* digital only support output */
11280 if (spec->autocfg.dig_out_pin)
11281 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11282
Takashi Iwai603c4012008-07-30 15:01:44 +020011283 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011284 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011285
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011286 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011287 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011288
Takashi Iwaid88897e2008-10-31 15:01:37 +010011289 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011290 spec->num_mux_defs = 1;
11291 spec->input_mux = &spec->private_imux;
11292
Takashi Iwai776e1842007-08-29 15:07:11 +020011293 err = alc_auto_add_mic_boost(codec);
11294 if (err < 0)
11295 return err;
11296
Takashi Iwaie044c392008-10-27 16:56:24 +010011297 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011298 return 1;
11299}
11300
11301#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11302#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11303#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11304
11305/* init callback for auto-configuration model -- overriding the default init */
11306static void alc268_auto_init(struct hda_codec *codec)
11307{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011308 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011309 alc268_auto_init_multi_out(codec);
11310 alc268_auto_init_hp_out(codec);
11311 alc268_auto_init_mono_speaker_out(codec);
11312 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011313 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011314 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011315}
11316
11317/*
11318 * configuration and preset
11319 */
11320static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011321 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011322 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011323 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011324 [ALC268_ACER] = "acer",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011325 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011326 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011327 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011328#ifdef CONFIG_SND_DEBUG
11329 [ALC268_TEST] = "test",
11330#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011331 [ALC268_AUTO] = "auto",
11332};
11333
11334static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011335 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011336 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011337 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011338 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011339 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011340 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11341 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011342 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011343 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011344 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011345 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011346 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011347 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011348 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011349 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011350 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011351 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011352 {}
11353};
11354
11355static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011356 [ALC267_QUANTA_IL1] = {
11357 .mixers = { alc267_quanta_il1_mixer },
11358 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11359 alc267_quanta_il1_verbs },
11360 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11361 .dac_nids = alc268_dac_nids,
11362 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11363 .adc_nids = alc268_adc_nids_alt,
11364 .hp_nid = 0x03,
11365 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11366 .channel_mode = alc268_modes,
11367 .input_mux = &alc268_capture_source,
11368 .unsol_event = alc267_quanta_il1_unsol_event,
11369 .init_hook = alc267_quanta_il1_automute,
11370 },
Kailang Yanga361d842007-06-05 12:30:55 +020011371 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011372 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11373 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011374 .init_verbs = { alc268_base_init_verbs },
11375 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11376 .dac_nids = alc268_dac_nids,
11377 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11378 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011379 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011380 .hp_nid = 0x03,
11381 .dig_out_nid = ALC268_DIGOUT_NID,
11382 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11383 .channel_mode = alc268_modes,
11384 .input_mux = &alc268_capture_source,
11385 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011386 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011387 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11388 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011389 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11390 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011391 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11392 .dac_nids = alc268_dac_nids,
11393 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11394 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011395 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011396 .hp_nid = 0x03,
11397 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11398 .channel_mode = alc268_modes,
11399 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011400 .unsol_event = alc268_toshiba_unsol_event,
11401 .init_hook = alc268_toshiba_automute,
11402 },
11403 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011404 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11405 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011406 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11407 alc268_acer_verbs },
11408 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11409 .dac_nids = alc268_dac_nids,
11410 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11411 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011412 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011413 .hp_nid = 0x02,
11414 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11415 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011416 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011417 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011418 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011419 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011420 [ALC268_ACER_ASPIRE_ONE] = {
11421 .mixers = { alc268_acer_aspire_one_mixer,
11422 alc268_capture_alt_mixer },
11423 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11424 alc268_acer_aspire_one_verbs },
11425 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11426 .dac_nids = alc268_dac_nids,
11427 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11428 .adc_nids = alc268_adc_nids_alt,
11429 .capsrc_nids = alc268_capsrc_nids,
11430 .hp_nid = 0x03,
11431 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11432 .channel_mode = alc268_modes,
11433 .input_mux = &alc268_acer_lc_capture_source,
11434 .unsol_event = alc268_acer_lc_unsol_event,
11435 .init_hook = alc268_acer_lc_init_hook,
11436 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011437 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011438 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011439 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11440 alc268_dell_verbs },
11441 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11442 .dac_nids = alc268_dac_nids,
11443 .hp_nid = 0x02,
11444 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11445 .channel_mode = alc268_modes,
11446 .unsol_event = alc268_dell_unsol_event,
11447 .init_hook = alc268_dell_init_hook,
11448 .input_mux = &alc268_capture_source,
11449 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011450 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011451 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11452 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011453 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11454 alc268_toshiba_verbs },
11455 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11456 .dac_nids = alc268_dac_nids,
11457 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11458 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011459 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011460 .hp_nid = 0x03,
11461 .dig_out_nid = ALC268_DIGOUT_NID,
11462 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11463 .channel_mode = alc268_modes,
11464 .input_mux = &alc268_capture_source,
11465 .unsol_event = alc268_toshiba_unsol_event,
11466 .init_hook = alc268_toshiba_automute
11467 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011468#ifdef CONFIG_SND_DEBUG
11469 [ALC268_TEST] = {
11470 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11471 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11472 alc268_volume_init_verbs },
11473 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11474 .dac_nids = alc268_dac_nids,
11475 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11476 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011477 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011478 .hp_nid = 0x03,
11479 .dig_out_nid = ALC268_DIGOUT_NID,
11480 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11481 .channel_mode = alc268_modes,
11482 .input_mux = &alc268_capture_source,
11483 },
11484#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011485};
11486
11487static int patch_alc268(struct hda_codec *codec)
11488{
11489 struct alc_spec *spec;
11490 int board_config;
11491 int err;
11492
11493 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11494 if (spec == NULL)
11495 return -ENOMEM;
11496
11497 codec->spec = spec;
11498
11499 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11500 alc268_models,
11501 alc268_cfg_tbl);
11502
11503 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11504 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11505 "trying auto-probe from BIOS...\n");
11506 board_config = ALC268_AUTO;
11507 }
11508
11509 if (board_config == ALC268_AUTO) {
11510 /* automatic parse from the BIOS config */
11511 err = alc268_parse_auto_config(codec);
11512 if (err < 0) {
11513 alc_free(codec);
11514 return err;
11515 } else if (!err) {
11516 printk(KERN_INFO
11517 "hda_codec: Cannot set up configuration "
11518 "from BIOS. Using base mode...\n");
11519 board_config = ALC268_3ST;
11520 }
11521 }
11522
11523 if (board_config != ALC268_AUTO)
11524 setup_preset(spec, &alc268_presets[board_config]);
11525
Kailang Yang2f893282008-05-27 12:14:47 +020011526 if (codec->vendor_id == 0x10ec0267) {
11527 spec->stream_name_analog = "ALC267 Analog";
11528 spec->stream_name_digital = "ALC267 Digital";
11529 } else {
11530 spec->stream_name_analog = "ALC268 Analog";
11531 spec->stream_name_digital = "ALC268 Digital";
11532 }
11533
Kailang Yanga361d842007-06-05 12:30:55 +020011534 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11535 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011536 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011537
Kailang Yanga361d842007-06-05 12:30:55 +020011538 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11539
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011540 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11541 /* override the amp caps for beep generator */
11542 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11543 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11544 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11545 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11546 (0 << AC_AMPCAP_MUTE_SHIFT));
11547
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011548 if (!spec->adc_nids && spec->input_mux) {
11549 /* check whether NID 0x07 is valid */
11550 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011551 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011552
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011553 /* get type */
11554 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011555 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011556 spec->adc_nids = alc268_adc_nids_alt;
11557 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011558 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011559 } else {
11560 spec->adc_nids = alc268_adc_nids;
11561 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011562 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020011563 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011564 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011565 /* set default input source */
11566 for (i = 0; i < spec->num_adc_nids; i++)
11567 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11568 0, AC_VERB_SET_CONNECT_SEL,
11569 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011570 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011571
11572 spec->vmaster_nid = 0x02;
11573
Kailang Yanga361d842007-06-05 12:30:55 +020011574 codec->patch_ops = alc_patch_ops;
11575 if (board_config == ALC268_AUTO)
11576 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011577
Kailang Yanga361d842007-06-05 12:30:55 +020011578 return 0;
11579}
11580
11581/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011582 * ALC269 channel source setting (2 channel)
11583 */
11584#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11585
11586#define alc269_dac_nids alc260_dac_nids
11587
11588static hda_nid_t alc269_adc_nids[1] = {
11589 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011590 0x08,
11591};
11592
Takashi Iwaie01bf502008-08-21 16:25:07 +020011593static hda_nid_t alc269_capsrc_nids[1] = {
11594 0x23,
11595};
11596
11597/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11598 * not a mux!
11599 */
11600
Kailang Yangf53281e2008-07-18 12:36:43 +020011601static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11602 .num_items = 2,
11603 .items = {
11604 { "i-Mic", 0x5 },
11605 { "e-Mic", 0x0 },
11606 },
11607};
11608
11609static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11610 .num_items = 2,
11611 .items = {
11612 { "i-Mic", 0x1 },
11613 { "e-Mic", 0x0 },
11614 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011615};
11616
11617#define alc269_modes alc260_modes
11618#define alc269_capture_source alc880_lg_lw_capture_source
11619
11620static struct snd_kcontrol_new alc269_base_mixer[] = {
11621 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11622 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11623 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11624 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11626 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020011627 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11628 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011629 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11630 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11631 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11632 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11634 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11635 { } /* end */
11636};
11637
Kailang Yang60db6b52008-08-26 13:13:00 +020011638static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
11639 /* output mixer control */
11640 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11641 {
11642 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11643 .name = "Master Playback Switch",
11644 .info = snd_hda_mixer_amp_switch_info,
11645 .get = snd_hda_mixer_amp_switch_get,
11646 .put = alc268_acer_master_sw_put,
11647 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11648 },
11649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11650 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11651 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11652 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11653 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11654 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11655 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
11656 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
11657 { }
11658};
11659
Kailang Yangf53281e2008-07-18 12:36:43 +020011660/* bind volumes of both NID 0x0c and 0x0d */
11661static struct hda_bind_ctls alc269_epc_bind_vol = {
11662 .ops = &snd_hda_bind_vol,
11663 .values = {
11664 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11665 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11666 0
11667 },
11668};
11669
11670static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11671 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11672 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11673 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11674 { } /* end */
11675};
11676
Kailang Yangf6a92242007-12-13 16:52:54 +010011677/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020011678static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11679 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11680 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010011681 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11682 { } /* end */
11683};
11684
11685/* FSC amilo */
11686static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
11687 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11688 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11689 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020011690 { } /* end */
11691};
11692
Takashi Iwai2005af22008-08-20 18:38:26 +020011693/* beep control */
11694static struct snd_kcontrol_new alc269_beep_mixer[] = {
11695 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11696 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
11697 { } /* end */
11698};
11699
Kailang Yang60db6b52008-08-26 13:13:00 +020011700static struct hda_verb alc269_quanta_fl1_verbs[] = {
11701 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11702 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11703 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11704 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11705 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11706 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11707 { }
11708};
11709
11710/* toggle speaker-output according to the hp-jack state */
11711static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
11712{
11713 unsigned int present;
11714 unsigned char bits;
11715
11716 present = snd_hda_codec_read(codec, 0x15, 0,
11717 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11718 bits = present ? AMP_IN_MUTE(0) : 0;
11719 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11720 AMP_IN_MUTE(0), bits);
11721 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11722 AMP_IN_MUTE(0), bits);
11723
11724 snd_hda_codec_write(codec, 0x20, 0,
11725 AC_VERB_SET_COEF_INDEX, 0x0c);
11726 snd_hda_codec_write(codec, 0x20, 0,
11727 AC_VERB_SET_PROC_COEF, 0x680);
11728
11729 snd_hda_codec_write(codec, 0x20, 0,
11730 AC_VERB_SET_COEF_INDEX, 0x0c);
11731 snd_hda_codec_write(codec, 0x20, 0,
11732 AC_VERB_SET_PROC_COEF, 0x480);
11733}
11734
11735static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
11736{
11737 unsigned int present;
11738
11739 present = snd_hda_codec_read(codec, 0x18, 0,
11740 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11741 snd_hda_codec_write(codec, 0x23, 0,
11742 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
11743}
11744
11745static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
11746 unsigned int res)
11747{
11748 if ((res >> 26) == ALC880_HP_EVENT)
11749 alc269_quanta_fl1_speaker_automute(codec);
11750 if ((res >> 26) == ALC880_MIC_EVENT)
11751 alc269_quanta_fl1_mic_automute(codec);
11752}
11753
11754static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
11755{
11756 alc269_quanta_fl1_speaker_automute(codec);
11757 alc269_quanta_fl1_mic_automute(codec);
11758}
11759
11760static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11761 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11762 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11763 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11764 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11765 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11766 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11767 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11768 {}
11769};
11770
11771static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11772 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11773 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11774 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11775 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11776 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11777 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11778 {}
11779};
11780
11781/* toggle speaker-output according to the hp-jack state */
11782static void alc269_speaker_automute(struct hda_codec *codec)
11783{
11784 unsigned int present;
11785 unsigned char bits;
11786
11787 present = snd_hda_codec_read(codec, 0x15, 0,
11788 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11789 bits = present ? AMP_IN_MUTE(0) : 0;
11790 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11791 AMP_IN_MUTE(0), bits);
11792 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11793 AMP_IN_MUTE(0), bits);
11794}
11795
11796static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11797{
11798 unsigned int present;
11799
11800 present = snd_hda_codec_read(codec, 0x18, 0,
11801 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11802 snd_hda_codec_write(codec, 0x23, 0,
11803 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
11804}
11805
11806static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11807{
11808 unsigned int present;
11809
11810 present = snd_hda_codec_read(codec, 0x18, 0,
11811 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11812 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11813 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
11814 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11815 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
11816}
11817
11818/* unsolicited event for HP jack sensing */
11819static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11820 unsigned int res)
11821{
11822 if ((res >> 26) == ALC880_HP_EVENT)
11823 alc269_speaker_automute(codec);
11824
11825 if ((res >> 26) == ALC880_MIC_EVENT)
11826 alc269_eeepc_dmic_automute(codec);
11827}
11828
11829static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11830{
11831 alc269_speaker_automute(codec);
11832 alc269_eeepc_dmic_automute(codec);
11833}
11834
11835/* unsolicited event for HP jack sensing */
11836static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
11837 unsigned int res)
11838{
11839 if ((res >> 26) == ALC880_HP_EVENT)
11840 alc269_speaker_automute(codec);
11841
11842 if ((res >> 26) == ALC880_MIC_EVENT)
11843 alc269_eeepc_amic_automute(codec);
11844}
11845
11846static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
11847{
11848 alc269_speaker_automute(codec);
11849 alc269_eeepc_amic_automute(codec);
11850}
11851
Kailang Yangf6a92242007-12-13 16:52:54 +010011852/*
11853 * generic initialization of ADC, input mixers and output mixers
11854 */
11855static struct hda_verb alc269_init_verbs[] = {
11856 /*
11857 * Unmute ADC0 and set the default input to mic-in
11858 */
Kailang Yang60db6b52008-08-26 13:13:00 +020011859 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011860
11861 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
11862 * analog-loopback mixer widget
11863 * Note: PASD motherboards uses the Line In 2 as the input for
11864 * front panel mic (mic 2)
11865 */
11866 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11867 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11868 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11869 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11872
11873 /*
11874 * Set up output mixers (0x0c - 0x0e)
11875 */
11876 /* set vol=0 to output mixers */
11877 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11878 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11879
11880 /* set up input amps for analog loopback */
11881 /* Amp Indices: DAC = 0, mixer = 1 */
11882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11883 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11884 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11885 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11886 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11887 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11888
11889 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11890 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11891 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11892 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11893 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11894 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11895 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11896
11897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11898 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11899 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11900 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11901 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11902 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11903 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11904
11905 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11906 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11907
11908 /* FIXME: use matrix-type input source selection */
11909 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11910 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020011911 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11912 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011913 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11914 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11915
11916 /* set EAPD */
11917 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11918 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11919 { }
11920};
11921
11922/* add playback controls from the parsed DAC table */
11923static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11924 const struct auto_pin_cfg *cfg)
11925{
11926 hda_nid_t nid;
11927 int err;
11928
11929 spec->multiout.num_dacs = 1; /* only use one dac */
11930 spec->multiout.dac_nids = spec->private_dac_nids;
11931 spec->multiout.dac_nids[0] = 2;
11932
11933 nid = cfg->line_out_pins[0];
11934 if (nid) {
11935 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11936 "Front Playback Volume",
11937 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
11938 if (err < 0)
11939 return err;
11940 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11941 "Front Playback Switch",
11942 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11943 if (err < 0)
11944 return err;
11945 }
11946
11947 nid = cfg->speaker_pins[0];
11948 if (nid) {
11949 if (!cfg->line_out_pins[0]) {
11950 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11951 "Speaker Playback Volume",
11952 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11953 HDA_OUTPUT));
11954 if (err < 0)
11955 return err;
11956 }
11957 if (nid == 0x16) {
11958 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11959 "Speaker Playback Switch",
11960 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11961 HDA_OUTPUT));
11962 if (err < 0)
11963 return err;
11964 } else {
11965 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11966 "Speaker Playback Switch",
11967 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11968 HDA_OUTPUT));
11969 if (err < 0)
11970 return err;
11971 }
11972 }
11973 nid = cfg->hp_pins[0];
11974 if (nid) {
11975 /* spec->multiout.hp_nid = 2; */
11976 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
11977 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11978 "Headphone Playback Volume",
11979 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11980 HDA_OUTPUT));
11981 if (err < 0)
11982 return err;
11983 }
11984 if (nid == 0x16) {
11985 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11986 "Headphone Playback Switch",
11987 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11988 HDA_OUTPUT));
11989 if (err < 0)
11990 return err;
11991 } else {
11992 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11993 "Headphone Playback Switch",
11994 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11995 HDA_OUTPUT));
11996 if (err < 0)
11997 return err;
11998 }
11999 }
12000 return 0;
12001}
12002
Takashi Iwaiee956e02008-10-31 17:16:31 +010012003static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12004 const struct auto_pin_cfg *cfg)
12005{
12006 int err;
12007
12008 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12009 if (err < 0)
12010 return err;
12011 /* digital-mic input pin is excluded in alc880_auto_create..()
12012 * because it's under 0x18
12013 */
12014 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12015 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
12016 struct hda_input_mux *imux = &spec->private_imux;
12017 imux->items[imux->num_items].label = "Int Mic";
12018 imux->items[imux->num_items].index = 0x05;
12019 imux->num_items++;
12020 }
12021 return 0;
12022}
Kailang Yangf6a92242007-12-13 16:52:54 +010012023
12024#ifdef CONFIG_SND_HDA_POWER_SAVE
12025#define alc269_loopbacks alc880_loopbacks
12026#endif
12027
12028/* pcm configuration: identiacal with ALC880 */
12029#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12030#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12031#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12032#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12033
12034/*
12035 * BIOS auto configuration
12036 */
12037static int alc269_parse_auto_config(struct hda_codec *codec)
12038{
12039 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020012040 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012041 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12042
12043 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12044 alc269_ignore);
12045 if (err < 0)
12046 return err;
12047
12048 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12049 if (err < 0)
12050 return err;
12051 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12052 if (err < 0)
12053 return err;
12054
12055 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12056
12057 if (spec->autocfg.dig_out_pin)
12058 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12059
Takashi Iwai603c4012008-07-30 15:01:44 +020012060 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012061 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012062
Takashi Iwai2005af22008-08-20 18:38:26 +020012063 /* create a beep mixer control if the pin 0x1d isn't assigned */
12064 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12065 if (spec->autocfg.input_pins[i] == 0x1d)
12066 break;
12067 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
Takashi Iwaid88897e2008-10-31 15:01:37 +010012068 add_mixer(spec, alc269_beep_mixer);
Takashi Iwai2005af22008-08-20 18:38:26 +020012069
Takashi Iwaid88897e2008-10-31 15:01:37 +010012070 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012071 spec->num_mux_defs = 1;
12072 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020012073 /* set default input source */
12074 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12075 0, AC_VERB_SET_CONNECT_SEL,
12076 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012077
12078 err = alc_auto_add_mic_boost(codec);
12079 if (err < 0)
12080 return err;
12081
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012082 if (!spec->cap_mixer)
12083 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012084
Takashi Iwaie044c392008-10-27 16:56:24 +010012085 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012086 return 1;
12087}
12088
12089#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12090#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12091#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12092
12093
12094/* init callback for auto-configuration model -- overriding the default init */
12095static void alc269_auto_init(struct hda_codec *codec)
12096{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012097 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012098 alc269_auto_init_multi_out(codec);
12099 alc269_auto_init_hp_out(codec);
12100 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012101 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012102 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012103}
12104
12105/*
12106 * configuration and preset
12107 */
12108static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012109 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012110 [ALC269_QUANTA_FL1] = "quanta",
12111 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012112 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
12113 [ALC269_FUJITSU] = "fujitsu"
Kailang Yangf6a92242007-12-13 16:52:54 +010012114};
12115
12116static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012117 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012118 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12119 ALC269_ASUS_EEEPC_P703),
12120 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12121 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012122 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12123 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012124 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Kailang Yangf6a92242007-12-13 16:52:54 +010012125 {}
12126};
12127
12128static struct alc_config_preset alc269_presets[] = {
12129 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012130 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012131 .init_verbs = { alc269_init_verbs },
12132 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12133 .dac_nids = alc269_dac_nids,
12134 .hp_nid = 0x03,
12135 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12136 .channel_mode = alc269_modes,
12137 .input_mux = &alc269_capture_source,
12138 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012139 [ALC269_QUANTA_FL1] = {
12140 .mixers = { alc269_quanta_fl1_mixer },
12141 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12142 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12143 .dac_nids = alc269_dac_nids,
12144 .hp_nid = 0x03,
12145 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12146 .channel_mode = alc269_modes,
12147 .input_mux = &alc269_capture_source,
12148 .unsol_event = alc269_quanta_fl1_unsol_event,
12149 .init_hook = alc269_quanta_fl1_init_hook,
12150 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012151 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012152 .mixers = { alc269_eeepc_mixer },
12153 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012154 .init_verbs = { alc269_init_verbs,
12155 alc269_eeepc_amic_init_verbs },
12156 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12157 .dac_nids = alc269_dac_nids,
12158 .hp_nid = 0x03,
12159 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12160 .channel_mode = alc269_modes,
12161 .input_mux = &alc269_eeepc_amic_capture_source,
12162 .unsol_event = alc269_eeepc_amic_unsol_event,
12163 .init_hook = alc269_eeepc_amic_inithook,
12164 },
12165 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012166 .mixers = { alc269_eeepc_mixer },
12167 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012168 .init_verbs = { alc269_init_verbs,
12169 alc269_eeepc_dmic_init_verbs },
12170 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12171 .dac_nids = alc269_dac_nids,
12172 .hp_nid = 0x03,
12173 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12174 .channel_mode = alc269_modes,
12175 .input_mux = &alc269_eeepc_dmic_capture_source,
12176 .unsol_event = alc269_eeepc_dmic_unsol_event,
12177 .init_hook = alc269_eeepc_dmic_inithook,
12178 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012179 [ALC269_FUJITSU] = {
12180 .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer },
12181 .cap_mixer = alc269_epc_capture_mixer,
12182 .init_verbs = { alc269_init_verbs,
12183 alc269_eeepc_dmic_init_verbs },
12184 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12185 .dac_nids = alc269_dac_nids,
12186 .hp_nid = 0x03,
12187 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12188 .channel_mode = alc269_modes,
12189 .input_mux = &alc269_eeepc_dmic_capture_source,
12190 .unsol_event = alc269_eeepc_dmic_unsol_event,
12191 .init_hook = alc269_eeepc_dmic_inithook,
12192 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012193};
12194
12195static int patch_alc269(struct hda_codec *codec)
12196{
12197 struct alc_spec *spec;
12198 int board_config;
12199 int err;
12200
12201 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12202 if (spec == NULL)
12203 return -ENOMEM;
12204
12205 codec->spec = spec;
12206
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012207 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12208
Kailang Yangf6a92242007-12-13 16:52:54 +010012209 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12210 alc269_models,
12211 alc269_cfg_tbl);
12212
12213 if (board_config < 0) {
12214 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12215 "trying auto-probe from BIOS...\n");
12216 board_config = ALC269_AUTO;
12217 }
12218
12219 if (board_config == ALC269_AUTO) {
12220 /* automatic parse from the BIOS config */
12221 err = alc269_parse_auto_config(codec);
12222 if (err < 0) {
12223 alc_free(codec);
12224 return err;
12225 } else if (!err) {
12226 printk(KERN_INFO
12227 "hda_codec: Cannot set up configuration "
12228 "from BIOS. Using base mode...\n");
12229 board_config = ALC269_BASIC;
12230 }
12231 }
12232
12233 if (board_config != ALC269_AUTO)
12234 setup_preset(spec, &alc269_presets[board_config]);
12235
12236 spec->stream_name_analog = "ALC269 Analog";
12237 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12238 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12239
12240 spec->stream_name_digital = "ALC269 Digital";
12241 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12242 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12243
12244 spec->adc_nids = alc269_adc_nids;
12245 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012246 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012247 if (!spec->cap_mixer)
12248 set_capture_mixer(spec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012249
12250 codec->patch_ops = alc_patch_ops;
12251 if (board_config == ALC269_AUTO)
12252 spec->init_hook = alc269_auto_init;
12253#ifdef CONFIG_SND_HDA_POWER_SAVE
12254 if (!spec->loopback.amplist)
12255 spec->loopback.amplist = alc269_loopbacks;
12256#endif
12257
12258 return 0;
12259}
12260
12261/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012262 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12263 */
12264
12265/*
12266 * set the path ways for 2 channel output
12267 * need to set the codec line out and mic 1 pin widgets to inputs
12268 */
12269static struct hda_verb alc861_threestack_ch2_init[] = {
12270 /* set pin widget 1Ah (line in) for input */
12271 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012272 /* set pin widget 18h (mic1/2) for input, for mic also enable
12273 * the vref
12274 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012275 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12276
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012277 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12278#if 0
12279 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12280 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12281#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012282 { } /* end */
12283};
12284/*
12285 * 6ch mode
12286 * need to set the codec line out and mic 1 pin widgets to outputs
12287 */
12288static struct hda_verb alc861_threestack_ch6_init[] = {
12289 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12290 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12291 /* set pin widget 18h (mic1) for output (CLFE)*/
12292 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12293
12294 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012295 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012296
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012297 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12298#if 0
12299 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12300 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12301#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012302 { } /* end */
12303};
12304
12305static struct hda_channel_mode alc861_threestack_modes[2] = {
12306 { 2, alc861_threestack_ch2_init },
12307 { 6, alc861_threestack_ch6_init },
12308};
Takashi Iwai22309c32006-08-09 16:57:28 +020012309/* Set mic1 as input and unmute the mixer */
12310static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12311 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12312 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12313 { } /* end */
12314};
12315/* Set mic1 as output and mute mixer */
12316static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12317 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12318 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12319 { } /* end */
12320};
12321
12322static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12323 { 2, alc861_uniwill_m31_ch2_init },
12324 { 4, alc861_uniwill_m31_ch4_init },
12325};
Kailang Yangdf694da2005-12-05 19:42:22 +010012326
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012327/* Set mic1 and line-in as input and unmute the mixer */
12328static struct hda_verb alc861_asus_ch2_init[] = {
12329 /* set pin widget 1Ah (line in) for input */
12330 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012331 /* set pin widget 18h (mic1/2) for input, for mic also enable
12332 * the vref
12333 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012334 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12335
12336 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12337#if 0
12338 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12339 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12340#endif
12341 { } /* end */
12342};
12343/* Set mic1 nad line-in as output and mute mixer */
12344static struct hda_verb alc861_asus_ch6_init[] = {
12345 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12346 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12347 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12348 /* set pin widget 18h (mic1) for output (CLFE)*/
12349 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12350 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12351 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12352 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12353
12354 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12355#if 0
12356 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12357 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12358#endif
12359 { } /* end */
12360};
12361
12362static struct hda_channel_mode alc861_asus_modes[2] = {
12363 { 2, alc861_asus_ch2_init },
12364 { 6, alc861_asus_ch6_init },
12365};
12366
Kailang Yangdf694da2005-12-05 19:42:22 +010012367/* patch-ALC861 */
12368
12369static struct snd_kcontrol_new alc861_base_mixer[] = {
12370 /* output mixer control */
12371 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12372 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12373 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12374 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12375 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12376
12377 /*Input mixer control */
12378 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12379 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12380 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12381 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12382 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12383 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12384 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12385 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12386 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12387 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012388
Kailang Yangdf694da2005-12-05 19:42:22 +010012389 { } /* end */
12390};
12391
12392static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12393 /* output mixer control */
12394 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12395 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12396 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12397 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12398 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12399
12400 /* Input mixer control */
12401 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12402 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12403 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12404 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12405 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12406 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12407 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12408 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12409 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12410 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012411
Kailang Yangdf694da2005-12-05 19:42:22 +010012412 {
12413 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12414 .name = "Channel Mode",
12415 .info = alc_ch_mode_info,
12416 .get = alc_ch_mode_get,
12417 .put = alc_ch_mode_put,
12418 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12419 },
12420 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012421};
12422
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012423static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012424 /* output mixer control */
12425 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12426 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12427 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012428
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012429 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012430};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012431
Takashi Iwai22309c32006-08-09 16:57:28 +020012432static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12433 /* output mixer control */
12434 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12435 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12436 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12437 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12438 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12439
12440 /* Input mixer control */
12441 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12442 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12443 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12444 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12445 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12446 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12447 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12448 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12449 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12450 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012451
Takashi Iwai22309c32006-08-09 16:57:28 +020012452 {
12453 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12454 .name = "Channel Mode",
12455 .info = alc_ch_mode_info,
12456 .get = alc_ch_mode_get,
12457 .put = alc_ch_mode_put,
12458 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12459 },
12460 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012461};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012462
12463static struct snd_kcontrol_new alc861_asus_mixer[] = {
12464 /* output mixer control */
12465 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12466 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12467 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12468 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12469 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12470
12471 /* Input mixer control */
12472 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12473 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12474 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12475 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12476 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12477 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12479 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12480 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012481 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12482
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012483 {
12484 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12485 .name = "Channel Mode",
12486 .info = alc_ch_mode_info,
12487 .get = alc_ch_mode_get,
12488 .put = alc_ch_mode_put,
12489 .private_value = ARRAY_SIZE(alc861_asus_modes),
12490 },
12491 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012492};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012493
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012494/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012495static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012496 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12497 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12498 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12499 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12500 { }
12501};
12502
Kailang Yangdf694da2005-12-05 19:42:22 +010012503/*
12504 * generic initialization of ADC, input mixers and output mixers
12505 */
12506static struct hda_verb alc861_base_init_verbs[] = {
12507 /*
12508 * Unmute ADC0 and set the default input to mic-in
12509 */
12510 /* port-A for surround (rear panel) */
12511 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12512 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
12513 /* port-B for mic-in (rear panel) with vref */
12514 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12515 /* port-C for line-in (rear panel) */
12516 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12517 /* port-D for Front */
12518 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12519 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12520 /* port-E for HP out (front panel) */
12521 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12522 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012523 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012524 /* port-F for mic-in (front panel) with vref */
12525 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12526 /* port-G for CLFE (rear panel) */
12527 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12528 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
12529 /* port-H for side (rear panel) */
12530 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12531 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
12532 /* CD-in */
12533 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12534 /* route front mic to ADC1*/
12535 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12536 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012537
Kailang Yangdf694da2005-12-05 19:42:22 +010012538 /* Unmute DAC0~3 & spdif out*/
12539 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12540 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12541 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12542 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012544
Kailang Yangdf694da2005-12-05 19:42:22 +010012545 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12546 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12547 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12548 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12549 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012550
Kailang Yangdf694da2005-12-05 19:42:22 +010012551 /* Unmute Stereo Mixer 15 */
12552 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12553 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12554 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012555 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012556
12557 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12558 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12559 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12560 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12561 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12562 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12563 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12564 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012565 /* hp used DAC 3 (Front) */
12566 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012567 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12568
12569 { }
12570};
12571
12572static struct hda_verb alc861_threestack_init_verbs[] = {
12573 /*
12574 * Unmute ADC0 and set the default input to mic-in
12575 */
12576 /* port-A for surround (rear panel) */
12577 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12578 /* port-B for mic-in (rear panel) with vref */
12579 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12580 /* port-C for line-in (rear panel) */
12581 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12582 /* port-D for Front */
12583 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12584 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12585 /* port-E for HP out (front panel) */
12586 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12587 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012588 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012589 /* port-F for mic-in (front panel) with vref */
12590 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12591 /* port-G for CLFE (rear panel) */
12592 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12593 /* port-H for side (rear panel) */
12594 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12595 /* CD-in */
12596 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12597 /* route front mic to ADC1*/
12598 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12599 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12600 /* Unmute DAC0~3 & spdif out*/
12601 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12602 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12603 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12604 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12605 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012606
Kailang Yangdf694da2005-12-05 19:42:22 +010012607 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12608 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12609 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12610 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12611 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012612
Kailang Yangdf694da2005-12-05 19:42:22 +010012613 /* Unmute Stereo Mixer 15 */
12614 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12615 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12616 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012617 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012618
12619 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12620 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12621 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12622 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12623 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12624 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12625 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12626 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012627 /* hp used DAC 3 (Front) */
12628 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012629 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12630 { }
12631};
Takashi Iwai22309c32006-08-09 16:57:28 +020012632
12633static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
12634 /*
12635 * Unmute ADC0 and set the default input to mic-in
12636 */
12637 /* port-A for surround (rear panel) */
12638 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12639 /* port-B for mic-in (rear panel) with vref */
12640 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12641 /* port-C for line-in (rear panel) */
12642 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12643 /* port-D for Front */
12644 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12645 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12646 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012647 /* this has to be set to VREF80 */
12648 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012649 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012650 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012651 /* port-F for mic-in (front panel) with vref */
12652 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12653 /* port-G for CLFE (rear panel) */
12654 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12655 /* port-H for side (rear panel) */
12656 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12657 /* CD-in */
12658 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12659 /* route front mic to ADC1*/
12660 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12661 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12662 /* Unmute DAC0~3 & spdif out*/
12663 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12664 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12665 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12666 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12667 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012668
Takashi Iwai22309c32006-08-09 16:57:28 +020012669 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12670 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12671 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12672 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12673 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012674
Takashi Iwai22309c32006-08-09 16:57:28 +020012675 /* Unmute Stereo Mixer 15 */
12676 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12677 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12678 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012679 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012680
12681 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12682 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12683 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12684 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12686 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12687 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12688 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012689 /* hp used DAC 3 (Front) */
12690 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12692 { }
12693};
12694
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012695static struct hda_verb alc861_asus_init_verbs[] = {
12696 /*
12697 * Unmute ADC0 and set the default input to mic-in
12698 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012699 /* port-A for surround (rear panel)
12700 * according to codec#0 this is the HP jack
12701 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012702 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12703 /* route front PCM to HP */
12704 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12705 /* port-B for mic-in (rear panel) with vref */
12706 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12707 /* port-C for line-in (rear panel) */
12708 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12709 /* port-D for Front */
12710 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12711 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12712 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012713 /* this has to be set to VREF80 */
12714 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012715 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012716 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012717 /* port-F for mic-in (front panel) with vref */
12718 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12719 /* port-G for CLFE (rear panel) */
12720 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12721 /* port-H for side (rear panel) */
12722 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12723 /* CD-in */
12724 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12725 /* route front mic to ADC1*/
12726 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12727 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12728 /* Unmute DAC0~3 & spdif out*/
12729 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12730 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12731 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12732 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12734 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12735 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12736 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12737 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12738 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012739
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012740 /* Unmute Stereo Mixer 15 */
12741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12743 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012745
12746 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12747 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12748 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12749 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12750 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12751 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12752 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12753 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012754 /* hp used DAC 3 (Front) */
12755 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012756 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12757 { }
12758};
12759
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012760/* additional init verbs for ASUS laptops */
12761static struct hda_verb alc861_asus_laptop_init_verbs[] = {
12762 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
12763 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
12764 { }
12765};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012766
Kailang Yangdf694da2005-12-05 19:42:22 +010012767/*
12768 * generic initialization of ADC, input mixers and output mixers
12769 */
12770static struct hda_verb alc861_auto_init_verbs[] = {
12771 /*
12772 * Unmute ADC0 and set the default input to mic-in
12773 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012774 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010012775 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012776
Kailang Yangdf694da2005-12-05 19:42:22 +010012777 /* Unmute DAC0~3 & spdif out*/
12778 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12779 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12780 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12781 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012783
Kailang Yangdf694da2005-12-05 19:42:22 +010012784 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12785 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12786 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12787 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12788 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012789
Kailang Yangdf694da2005-12-05 19:42:22 +010012790 /* Unmute Stereo Mixer 15 */
12791 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12794 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
12795
12796 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12797 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12798 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12799 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12800 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12801 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12802 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12803 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12804
12805 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12806 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012807 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12808 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012809 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12810 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012811 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12812 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012813
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012814 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012815
12816 { }
12817};
12818
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012819static struct hda_verb alc861_toshiba_init_verbs[] = {
12820 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012821
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012822 { }
12823};
12824
12825/* toggle speaker-output according to the hp-jack state */
12826static void alc861_toshiba_automute(struct hda_codec *codec)
12827{
12828 unsigned int present;
12829
12830 present = snd_hda_codec_read(codec, 0x0f, 0,
12831 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012832 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
12833 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12834 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
12835 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012836}
12837
12838static void alc861_toshiba_unsol_event(struct hda_codec *codec,
12839 unsigned int res)
12840{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012841 if ((res >> 26) == ALC880_HP_EVENT)
12842 alc861_toshiba_automute(codec);
12843}
12844
Kailang Yangdf694da2005-12-05 19:42:22 +010012845/* pcm configuration: identiacal with ALC880 */
12846#define alc861_pcm_analog_playback alc880_pcm_analog_playback
12847#define alc861_pcm_analog_capture alc880_pcm_analog_capture
12848#define alc861_pcm_digital_playback alc880_pcm_digital_playback
12849#define alc861_pcm_digital_capture alc880_pcm_digital_capture
12850
12851
12852#define ALC861_DIGOUT_NID 0x07
12853
12854static struct hda_channel_mode alc861_8ch_modes[1] = {
12855 { 8, NULL }
12856};
12857
12858static hda_nid_t alc861_dac_nids[4] = {
12859 /* front, surround, clfe, side */
12860 0x03, 0x06, 0x05, 0x04
12861};
12862
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012863static hda_nid_t alc660_dac_nids[3] = {
12864 /* front, clfe, surround */
12865 0x03, 0x05, 0x06
12866};
12867
Kailang Yangdf694da2005-12-05 19:42:22 +010012868static hda_nid_t alc861_adc_nids[1] = {
12869 /* ADC0-2 */
12870 0x08,
12871};
12872
12873static struct hda_input_mux alc861_capture_source = {
12874 .num_items = 5,
12875 .items = {
12876 { "Mic", 0x0 },
12877 { "Front Mic", 0x3 },
12878 { "Line", 0x1 },
12879 { "CD", 0x4 },
12880 { "Mixer", 0x5 },
12881 },
12882};
12883
12884/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012885static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
12886 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012887{
12888 int i;
12889 hda_nid_t nid;
12890
12891 spec->multiout.dac_nids = spec->private_dac_nids;
12892 for (i = 0; i < cfg->line_outs; i++) {
12893 nid = cfg->line_out_pins[i];
12894 if (nid) {
12895 if (i >= ARRAY_SIZE(alc861_dac_nids))
12896 continue;
12897 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
12898 }
12899 }
12900 spec->multiout.num_dacs = cfg->line_outs;
12901 return 0;
12902}
12903
12904/* add playback controls from the parsed DAC table */
12905static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
12906 const struct auto_pin_cfg *cfg)
12907{
12908 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012909 static const char *chname[4] = {
12910 "Front", "Surround", NULL /*CLFE*/, "Side"
12911 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012912 hda_nid_t nid;
12913 int i, idx, err;
12914
12915 for (i = 0; i < cfg->line_outs; i++) {
12916 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012917 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010012918 continue;
12919 if (nid == 0x05) {
12920 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012921 err = add_control(spec, ALC_CTL_BIND_MUTE,
12922 "Center Playback Switch",
12923 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12924 HDA_OUTPUT));
12925 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012926 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012927 err = add_control(spec, ALC_CTL_BIND_MUTE,
12928 "LFE Playback Switch",
12929 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12930 HDA_OUTPUT));
12931 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012932 return err;
12933 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012934 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
12935 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010012936 if (nid == alc861_dac_nids[idx])
12937 break;
12938 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012939 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12940 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12941 HDA_OUTPUT));
12942 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012943 return err;
12944 }
12945 }
12946 return 0;
12947}
12948
12949static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
12950{
12951 int err;
12952 hda_nid_t nid;
12953
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012954 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010012955 return 0;
12956
12957 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
12958 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012959 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12960 "Headphone Playback Switch",
12961 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12962 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012963 return err;
12964 spec->multiout.hp_nid = nid;
12965 }
12966 return 0;
12967}
12968
12969/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012970static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
12971 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012972{
Kailang Yangdf694da2005-12-05 19:42:22 +010012973 struct hda_input_mux *imux = &spec->private_imux;
12974 int i, err, idx, idx1;
12975
12976 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012977 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012978 case 0x0c:
12979 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012980 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012981 break;
12982 case 0x0f:
12983 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012984 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012985 break;
12986 case 0x0d:
12987 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012988 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012989 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012990 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010012991 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012992 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012993 break;
12994 case 0x11:
12995 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012996 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010012997 break;
12998 default:
12999 continue;
13000 }
13001
Takashi Iwai4a471b72005-12-07 13:56:29 +010013002 err = new_analog_input(spec, cfg->input_pins[i],
13003 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013004 if (err < 0)
13005 return err;
13006
Takashi Iwai4a471b72005-12-07 13:56:29 +010013007 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013008 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013009 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013010 }
13011 return 0;
13012}
13013
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013014static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13015 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013016 int pin_type, int dac_idx)
13017{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013018 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13019 pin_type);
13020 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13021 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013022}
13023
13024static void alc861_auto_init_multi_out(struct hda_codec *codec)
13025{
13026 struct alc_spec *spec = codec->spec;
13027 int i;
13028
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013029 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013030 for (i = 0; i < spec->autocfg.line_outs; i++) {
13031 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013032 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013033 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013034 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013035 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013036 }
13037}
13038
13039static void alc861_auto_init_hp_out(struct hda_codec *codec)
13040{
13041 struct alc_spec *spec = codec->spec;
13042 hda_nid_t pin;
13043
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013044 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013045 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013046 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13047 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013048 pin = spec->autocfg.speaker_pins[0];
13049 if (pin)
13050 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013051}
13052
13053static void alc861_auto_init_analog_input(struct hda_codec *codec)
13054{
13055 struct alc_spec *spec = codec->spec;
13056 int i;
13057
13058 for (i = 0; i < AUTO_PIN_LAST; i++) {
13059 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013060 if (nid >= 0x0c && nid <= 0x11) {
13061 snd_hda_codec_write(codec, nid, 0,
13062 AC_VERB_SET_PIN_WIDGET_CONTROL,
13063 i <= AUTO_PIN_FRONT_MIC ?
13064 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013065 }
13066 }
13067}
13068
13069/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013070/* return 1 if successful, 0 if the proper config is not found,
13071 * or a negative error code
13072 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013073static int alc861_parse_auto_config(struct hda_codec *codec)
13074{
13075 struct alc_spec *spec = codec->spec;
13076 int err;
13077 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13078
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013079 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13080 alc861_ignore);
13081 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013082 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013083 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013084 return 0; /* can't find valid BIOS pin config */
13085
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013086 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13087 if (err < 0)
13088 return err;
13089 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13090 if (err < 0)
13091 return err;
13092 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13093 if (err < 0)
13094 return err;
13095 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13096 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013097 return err;
13098
13099 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13100
13101 if (spec->autocfg.dig_out_pin)
13102 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13103
Takashi Iwai603c4012008-07-30 15:01:44 +020013104 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013105 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013106
Takashi Iwaid88897e2008-10-31 15:01:37 +010013107 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013108
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013109 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010013110 spec->input_mux = &spec->private_imux;
13111
13112 spec->adc_nids = alc861_adc_nids;
13113 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013114 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013115
Takashi Iwaie044c392008-10-27 16:56:24 +010013116 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013117 return 1;
13118}
13119
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013120/* additional initialization for auto-configuration model */
13121static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013122{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013123 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013124 alc861_auto_init_multi_out(codec);
13125 alc861_auto_init_hp_out(codec);
13126 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013127 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013128 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013129}
13130
Takashi Iwaicb53c622007-08-10 17:21:45 +020013131#ifdef CONFIG_SND_HDA_POWER_SAVE
13132static struct hda_amp_list alc861_loopbacks[] = {
13133 { 0x15, HDA_INPUT, 0 },
13134 { 0x15, HDA_INPUT, 1 },
13135 { 0x15, HDA_INPUT, 2 },
13136 { 0x15, HDA_INPUT, 3 },
13137 { } /* end */
13138};
13139#endif
13140
Kailang Yangdf694da2005-12-05 19:42:22 +010013141
13142/*
13143 * configuration and preset
13144 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013145static const char *alc861_models[ALC861_MODEL_LAST] = {
13146 [ALC861_3ST] = "3stack",
13147 [ALC660_3ST] = "3stack-660",
13148 [ALC861_3ST_DIG] = "3stack-dig",
13149 [ALC861_6ST_DIG] = "6stack-dig",
13150 [ALC861_UNIWILL_M31] = "uniwill-m31",
13151 [ALC861_TOSHIBA] = "toshiba",
13152 [ALC861_ASUS] = "asus",
13153 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13154 [ALC861_AUTO] = "auto",
13155};
13156
13157static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013158 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013159 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13160 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13161 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013162 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013163 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013164 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013165 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13166 * Any other models that need this preset?
13167 */
13168 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013169 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13170 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013171 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13172 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13173 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13174 /* FIXME: the below seems conflict */
13175 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13176 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13177 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013178 {}
13179};
13180
13181static struct alc_config_preset alc861_presets[] = {
13182 [ALC861_3ST] = {
13183 .mixers = { alc861_3ST_mixer },
13184 .init_verbs = { alc861_threestack_init_verbs },
13185 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13186 .dac_nids = alc861_dac_nids,
13187 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13188 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013189 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013190 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13191 .adc_nids = alc861_adc_nids,
13192 .input_mux = &alc861_capture_source,
13193 },
13194 [ALC861_3ST_DIG] = {
13195 .mixers = { alc861_base_mixer },
13196 .init_verbs = { alc861_threestack_init_verbs },
13197 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13198 .dac_nids = alc861_dac_nids,
13199 .dig_out_nid = ALC861_DIGOUT_NID,
13200 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13201 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013202 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013203 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13204 .adc_nids = alc861_adc_nids,
13205 .input_mux = &alc861_capture_source,
13206 },
13207 [ALC861_6ST_DIG] = {
13208 .mixers = { alc861_base_mixer },
13209 .init_verbs = { alc861_base_init_verbs },
13210 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13211 .dac_nids = alc861_dac_nids,
13212 .dig_out_nid = ALC861_DIGOUT_NID,
13213 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13214 .channel_mode = alc861_8ch_modes,
13215 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13216 .adc_nids = alc861_adc_nids,
13217 .input_mux = &alc861_capture_source,
13218 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013219 [ALC660_3ST] = {
13220 .mixers = { alc861_3ST_mixer },
13221 .init_verbs = { alc861_threestack_init_verbs },
13222 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13223 .dac_nids = alc660_dac_nids,
13224 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13225 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013226 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013227 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13228 .adc_nids = alc861_adc_nids,
13229 .input_mux = &alc861_capture_source,
13230 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013231 [ALC861_UNIWILL_M31] = {
13232 .mixers = { alc861_uniwill_m31_mixer },
13233 .init_verbs = { alc861_uniwill_m31_init_verbs },
13234 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13235 .dac_nids = alc861_dac_nids,
13236 .dig_out_nid = ALC861_DIGOUT_NID,
13237 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13238 .channel_mode = alc861_uniwill_m31_modes,
13239 .need_dac_fix = 1,
13240 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13241 .adc_nids = alc861_adc_nids,
13242 .input_mux = &alc861_capture_source,
13243 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013244 [ALC861_TOSHIBA] = {
13245 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013246 .init_verbs = { alc861_base_init_verbs,
13247 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013248 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13249 .dac_nids = alc861_dac_nids,
13250 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13251 .channel_mode = alc883_3ST_2ch_modes,
13252 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13253 .adc_nids = alc861_adc_nids,
13254 .input_mux = &alc861_capture_source,
13255 .unsol_event = alc861_toshiba_unsol_event,
13256 .init_hook = alc861_toshiba_automute,
13257 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013258 [ALC861_ASUS] = {
13259 .mixers = { alc861_asus_mixer },
13260 .init_verbs = { alc861_asus_init_verbs },
13261 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13262 .dac_nids = alc861_dac_nids,
13263 .dig_out_nid = ALC861_DIGOUT_NID,
13264 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13265 .channel_mode = alc861_asus_modes,
13266 .need_dac_fix = 1,
13267 .hp_nid = 0x06,
13268 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13269 .adc_nids = alc861_adc_nids,
13270 .input_mux = &alc861_capture_source,
13271 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013272 [ALC861_ASUS_LAPTOP] = {
13273 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13274 .init_verbs = { alc861_asus_init_verbs,
13275 alc861_asus_laptop_init_verbs },
13276 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13277 .dac_nids = alc861_dac_nids,
13278 .dig_out_nid = ALC861_DIGOUT_NID,
13279 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13280 .channel_mode = alc883_3ST_2ch_modes,
13281 .need_dac_fix = 1,
13282 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13283 .adc_nids = alc861_adc_nids,
13284 .input_mux = &alc861_capture_source,
13285 },
13286};
Kailang Yangdf694da2005-12-05 19:42:22 +010013287
13288
13289static int patch_alc861(struct hda_codec *codec)
13290{
13291 struct alc_spec *spec;
13292 int board_config;
13293 int err;
13294
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013295 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013296 if (spec == NULL)
13297 return -ENOMEM;
13298
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013299 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013300
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013301 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13302 alc861_models,
13303 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013304
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013305 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013306 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13307 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013308 board_config = ALC861_AUTO;
13309 }
13310
13311 if (board_config == ALC861_AUTO) {
13312 /* automatic parse from the BIOS config */
13313 err = alc861_parse_auto_config(codec);
13314 if (err < 0) {
13315 alc_free(codec);
13316 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013317 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013318 printk(KERN_INFO
13319 "hda_codec: Cannot set up configuration "
13320 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013321 board_config = ALC861_3ST_DIG;
13322 }
13323 }
13324
13325 if (board_config != ALC861_AUTO)
13326 setup_preset(spec, &alc861_presets[board_config]);
13327
13328 spec->stream_name_analog = "ALC861 Analog";
13329 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13330 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13331
13332 spec->stream_name_digital = "ALC861 Digital";
13333 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13334 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13335
Takashi Iwai2134ea42008-01-10 16:53:55 +010013336 spec->vmaster_nid = 0x03;
13337
Kailang Yangdf694da2005-12-05 19:42:22 +010013338 codec->patch_ops = alc_patch_ops;
13339 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013340 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013341#ifdef CONFIG_SND_HDA_POWER_SAVE
13342 if (!spec->loopback.amplist)
13343 spec->loopback.amplist = alc861_loopbacks;
13344#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013345
Kailang Yangdf694da2005-12-05 19:42:22 +010013346 return 0;
13347}
13348
13349/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013350 * ALC861-VD support
13351 *
13352 * Based on ALC882
13353 *
13354 * In addition, an independent DAC
13355 */
13356#define ALC861VD_DIGOUT_NID 0x06
13357
13358static hda_nid_t alc861vd_dac_nids[4] = {
13359 /* front, surr, clfe, side surr */
13360 0x02, 0x03, 0x04, 0x05
13361};
13362
13363/* dac_nids for ALC660vd are in a different order - according to
13364 * Realtek's driver.
13365 * This should probably tesult in a different mixer for 6stack models
13366 * of ALC660vd codecs, but for now there is only 3stack mixer
13367 * - and it is the same as in 861vd.
13368 * adc_nids in ALC660vd are (is) the same as in 861vd
13369 */
13370static hda_nid_t alc660vd_dac_nids[3] = {
13371 /* front, rear, clfe, rear_surr */
13372 0x02, 0x04, 0x03
13373};
13374
13375static hda_nid_t alc861vd_adc_nids[1] = {
13376 /* ADC0 */
13377 0x09,
13378};
13379
Takashi Iwaie1406342008-02-11 18:32:32 +010013380static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13381
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013382/* input MUX */
13383/* FIXME: should be a matrix-type input source selection */
13384static struct hda_input_mux alc861vd_capture_source = {
13385 .num_items = 4,
13386 .items = {
13387 { "Mic", 0x0 },
13388 { "Front Mic", 0x1 },
13389 { "Line", 0x2 },
13390 { "CD", 0x4 },
13391 },
13392};
13393
Kailang Yang272a5272007-05-14 11:00:38 +020013394static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013395 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013396 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013397 { "Ext Mic", 0x0 },
13398 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013399 },
13400};
13401
Kailang Yangd1a991a2007-08-15 16:21:59 +020013402static struct hda_input_mux alc861vd_hp_capture_source = {
13403 .num_items = 2,
13404 .items = {
13405 { "Front Mic", 0x0 },
13406 { "ATAPI Mic", 0x1 },
13407 },
13408};
13409
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013410/*
13411 * 2ch mode
13412 */
13413static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13414 { 2, NULL }
13415};
13416
13417/*
13418 * 6ch mode
13419 */
13420static struct hda_verb alc861vd_6stack_ch6_init[] = {
13421 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13422 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13423 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13424 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13425 { } /* end */
13426};
13427
13428/*
13429 * 8ch mode
13430 */
13431static struct hda_verb alc861vd_6stack_ch8_init[] = {
13432 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13433 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13434 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13435 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13436 { } /* end */
13437};
13438
13439static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13440 { 6, alc861vd_6stack_ch6_init },
13441 { 8, alc861vd_6stack_ch8_init },
13442};
13443
13444static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13445 {
13446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13447 .name = "Channel Mode",
13448 .info = alc_ch_mode_info,
13449 .get = alc_ch_mode_get,
13450 .put = alc_ch_mode_put,
13451 },
13452 { } /* end */
13453};
13454
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013455/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13456 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13457 */
13458static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13459 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13460 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13461
13462 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13463 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13464
13465 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13466 HDA_OUTPUT),
13467 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13468 HDA_OUTPUT),
13469 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13470 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13471
13472 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13473 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13474
13475 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13476
13477 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13479 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13480
13481 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13482 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13483 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13484
13485 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13486 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13487
13488 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13489 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13490
13491 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13492 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13493
13494 { } /* end */
13495};
13496
13497static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13498 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13499 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13500
13501 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13502
13503 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13504 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13505 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13506
13507 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13508 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13509 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13510
13511 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13512 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13513
13514 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13515 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13516
13517 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13518 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13519
13520 { } /* end */
13521};
13522
Kailang Yangbdd148a2007-05-08 15:19:08 +020013523static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
13524 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13525 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
13526 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13527
13528 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13529
13530 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13532 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13533
13534 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13535 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13536 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13537
13538 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13539 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13540
13541 { } /* end */
13542};
13543
Tobin Davisb419f342008-03-07 11:57:51 +010013544/* Pin assignment: Speaker=0x14, HP = 0x15,
13545 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020013546 */
13547static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010013548 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13549 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013550 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13551 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010013552 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13553 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13554 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13555 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13556 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13557 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13558 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
13559 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013560 { } /* end */
13561};
13562
Kailang Yangd1a991a2007-08-15 16:21:59 +020013563/* Pin assignment: Speaker=0x14, Line-out = 0x15,
13564 * Front Mic=0x18, ATAPI Mic = 0x19,
13565 */
13566static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
13567 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13568 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13569 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13570 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
13571 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13572 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13573 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13574 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013575
Kailang Yangd1a991a2007-08-15 16:21:59 +020013576 { } /* end */
13577};
13578
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013579/*
13580 * generic initialization of ADC, input mixers and output mixers
13581 */
13582static struct hda_verb alc861vd_volume_init_verbs[] = {
13583 /*
13584 * Unmute ADC0 and set the default input to mic-in
13585 */
13586 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13587 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13588
13589 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
13590 * the analog-loopback mixer widget
13591 */
13592 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013593 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13594 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13595 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13596 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13597 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013598
13599 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020013600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13601 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013603 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013604
13605 /*
13606 * Set up output mixers (0x02 - 0x05)
13607 */
13608 /* set vol=0 to output mixers */
13609 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13610 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13611 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13612 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13613
13614 /* set up input amps for analog loopback */
13615 /* Amp Indices: DAC = 0, mixer = 1 */
13616 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13618 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13619 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13620 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13621 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13622 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13623 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13624
13625 { }
13626};
13627
13628/*
13629 * 3-stack pin configuration:
13630 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13631 */
13632static struct hda_verb alc861vd_3stack_init_verbs[] = {
13633 /*
13634 * Set pin mode and muting
13635 */
13636 /* set front pin widgets 0x14 for output */
13637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13638 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13639 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13640
13641 /* Mic (rear) pin: input vref at 80% */
13642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13644 /* Front Mic pin: input vref at 80% */
13645 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13646 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13647 /* Line In pin: input */
13648 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13649 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13650 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13651 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13652 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13653 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13654 /* CD pin widget for input */
13655 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13656
13657 { }
13658};
13659
13660/*
13661 * 6-stack pin configuration:
13662 */
13663static struct hda_verb alc861vd_6stack_init_verbs[] = {
13664 /*
13665 * Set pin mode and muting
13666 */
13667 /* set front pin widgets 0x14 for output */
13668 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13669 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13670 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13671
13672 /* Rear Pin: output 1 (0x0d) */
13673 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13675 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13676 /* CLFE Pin: output 2 (0x0e) */
13677 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13678 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13679 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13680 /* Side Pin: output 3 (0x0f) */
13681 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13682 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13683 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13684
13685 /* Mic (rear) pin: input vref at 80% */
13686 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13687 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13688 /* Front Mic pin: input vref at 80% */
13689 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13690 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13691 /* Line In pin: input */
13692 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13693 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13694 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13695 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13696 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13697 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13698 /* CD pin widget for input */
13699 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13700
13701 { }
13702};
13703
Kailang Yangbdd148a2007-05-08 15:19:08 +020013704static struct hda_verb alc861vd_eapd_verbs[] = {
13705 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13706 { }
13707};
13708
Kailang Yangf9423e72008-05-27 12:32:25 +020013709static struct hda_verb alc660vd_eapd_verbs[] = {
13710 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13711 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13712 { }
13713};
13714
Kailang Yangbdd148a2007-05-08 15:19:08 +020013715static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
13716 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13717 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13718 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
13719 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020013720 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020013721 {}
13722};
13723
13724/* toggle speaker-output according to the hp-jack state */
13725static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
13726{
13727 unsigned int present;
13728 unsigned char bits;
13729
13730 present = snd_hda_codec_read(codec, 0x1b, 0,
13731 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013732 bits = present ? HDA_AMP_MUTE : 0;
13733 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13734 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013735}
13736
13737static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
13738{
13739 unsigned int present;
13740 unsigned char bits;
13741
13742 present = snd_hda_codec_read(codec, 0x18, 0,
13743 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013744 bits = present ? HDA_AMP_MUTE : 0;
13745 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
13746 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013747}
13748
13749static void alc861vd_lenovo_automute(struct hda_codec *codec)
13750{
13751 alc861vd_lenovo_hp_automute(codec);
13752 alc861vd_lenovo_mic_automute(codec);
13753}
13754
13755static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
13756 unsigned int res)
13757{
13758 switch (res >> 26) {
13759 case ALC880_HP_EVENT:
13760 alc861vd_lenovo_hp_automute(codec);
13761 break;
13762 case ALC880_MIC_EVENT:
13763 alc861vd_lenovo_mic_automute(codec);
13764 break;
13765 }
13766}
13767
Kailang Yang272a5272007-05-14 11:00:38 +020013768static struct hda_verb alc861vd_dallas_verbs[] = {
13769 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13770 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13771 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13772 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13773
13774 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13775 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13776 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13777 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13778 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13779 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13780 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13781 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013782
Kailang Yang272a5272007-05-14 11:00:38 +020013783 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13784 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13785 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13786 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13787 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13788 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13789 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13790 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13791
13792 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13793 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13794 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13795 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13796 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13798 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13799 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13800
13801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13804 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13805
13806 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013807 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020013808 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13809
13810 { } /* end */
13811};
13812
13813/* toggle speaker-output according to the hp-jack state */
13814static void alc861vd_dallas_automute(struct hda_codec *codec)
13815{
13816 unsigned int present;
13817
13818 present = snd_hda_codec_read(codec, 0x15, 0,
13819 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013820 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13821 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020013822}
13823
13824static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
13825{
13826 if ((res >> 26) == ALC880_HP_EVENT)
13827 alc861vd_dallas_automute(codec);
13828}
13829
Takashi Iwaicb53c622007-08-10 17:21:45 +020013830#ifdef CONFIG_SND_HDA_POWER_SAVE
13831#define alc861vd_loopbacks alc880_loopbacks
13832#endif
13833
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013834/* pcm configuration: identiacal with ALC880 */
13835#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
13836#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
13837#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
13838#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
13839
13840/*
13841 * configuration and preset
13842 */
13843static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
13844 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013845 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010013846 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013847 [ALC861VD_3ST] = "3stack",
13848 [ALC861VD_3ST_DIG] = "3stack-digout",
13849 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020013850 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020013851 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013852 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013853 [ALC861VD_AUTO] = "auto",
13854};
13855
13856static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013857 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
13858 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010013859 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013860 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010013861 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020013862 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013863 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013864 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020013865 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020013866 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020013867 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010013868 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020013869 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013870 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
13871 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020013872 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020013873 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013874 {}
13875};
13876
13877static struct alc_config_preset alc861vd_presets[] = {
13878 [ALC660VD_3ST] = {
13879 .mixers = { alc861vd_3st_mixer },
13880 .init_verbs = { alc861vd_volume_init_verbs,
13881 alc861vd_3stack_init_verbs },
13882 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13883 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013884 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13885 .channel_mode = alc861vd_3stack_2ch_modes,
13886 .input_mux = &alc861vd_capture_source,
13887 },
Mike Crash6963f842007-06-25 12:12:51 +020013888 [ALC660VD_3ST_DIG] = {
13889 .mixers = { alc861vd_3st_mixer },
13890 .init_verbs = { alc861vd_volume_init_verbs,
13891 alc861vd_3stack_init_verbs },
13892 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13893 .dac_nids = alc660vd_dac_nids,
13894 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020013895 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13896 .channel_mode = alc861vd_3stack_2ch_modes,
13897 .input_mux = &alc861vd_capture_source,
13898 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013899 [ALC861VD_3ST] = {
13900 .mixers = { alc861vd_3st_mixer },
13901 .init_verbs = { alc861vd_volume_init_verbs,
13902 alc861vd_3stack_init_verbs },
13903 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13904 .dac_nids = alc861vd_dac_nids,
13905 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13906 .channel_mode = alc861vd_3stack_2ch_modes,
13907 .input_mux = &alc861vd_capture_source,
13908 },
13909 [ALC861VD_3ST_DIG] = {
13910 .mixers = { alc861vd_3st_mixer },
13911 .init_verbs = { alc861vd_volume_init_verbs,
13912 alc861vd_3stack_init_verbs },
13913 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13914 .dac_nids = alc861vd_dac_nids,
13915 .dig_out_nid = ALC861VD_DIGOUT_NID,
13916 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13917 .channel_mode = alc861vd_3stack_2ch_modes,
13918 .input_mux = &alc861vd_capture_source,
13919 },
13920 [ALC861VD_6ST_DIG] = {
13921 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
13922 .init_verbs = { alc861vd_volume_init_verbs,
13923 alc861vd_6stack_init_verbs },
13924 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13925 .dac_nids = alc861vd_dac_nids,
13926 .dig_out_nid = ALC861VD_DIGOUT_NID,
13927 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
13928 .channel_mode = alc861vd_6stack_modes,
13929 .input_mux = &alc861vd_capture_source,
13930 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020013931 [ALC861VD_LENOVO] = {
13932 .mixers = { alc861vd_lenovo_mixer },
13933 .init_verbs = { alc861vd_volume_init_verbs,
13934 alc861vd_3stack_init_verbs,
13935 alc861vd_eapd_verbs,
13936 alc861vd_lenovo_unsol_verbs },
13937 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13938 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013939 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13940 .channel_mode = alc861vd_3stack_2ch_modes,
13941 .input_mux = &alc861vd_capture_source,
13942 .unsol_event = alc861vd_lenovo_unsol_event,
13943 .init_hook = alc861vd_lenovo_automute,
13944 },
Kailang Yang272a5272007-05-14 11:00:38 +020013945 [ALC861VD_DALLAS] = {
13946 .mixers = { alc861vd_dallas_mixer },
13947 .init_verbs = { alc861vd_dallas_verbs },
13948 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13949 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020013950 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13951 .channel_mode = alc861vd_3stack_2ch_modes,
13952 .input_mux = &alc861vd_dallas_capture_source,
13953 .unsol_event = alc861vd_dallas_unsol_event,
13954 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013955 },
13956 [ALC861VD_HP] = {
13957 .mixers = { alc861vd_hp_mixer },
13958 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
13959 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13960 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013961 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013962 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13963 .channel_mode = alc861vd_3stack_2ch_modes,
13964 .input_mux = &alc861vd_hp_capture_source,
13965 .unsol_event = alc861vd_dallas_unsol_event,
13966 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020013967 },
Takashi Iwai13c94742008-11-05 08:06:08 +010013968 [ALC660VD_ASUS_V1S] = {
13969 .mixers = { alc861vd_lenovo_mixer },
13970 .init_verbs = { alc861vd_volume_init_verbs,
13971 alc861vd_3stack_init_verbs,
13972 alc861vd_eapd_verbs,
13973 alc861vd_lenovo_unsol_verbs },
13974 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13975 .dac_nids = alc660vd_dac_nids,
13976 .dig_out_nid = ALC861VD_DIGOUT_NID,
13977 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13978 .channel_mode = alc861vd_3stack_2ch_modes,
13979 .input_mux = &alc861vd_capture_source,
13980 .unsol_event = alc861vd_lenovo_unsol_event,
13981 .init_hook = alc861vd_lenovo_automute,
13982 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013983};
13984
13985/*
13986 * BIOS auto configuration
13987 */
13988static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
13989 hda_nid_t nid, int pin_type, int dac_idx)
13990{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013991 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013992}
13993
13994static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
13995{
13996 struct alc_spec *spec = codec->spec;
13997 int i;
13998
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013999 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014000 for (i = 0; i <= HDA_SIDE; i++) {
14001 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014002 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014003 if (nid)
14004 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014005 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014006 }
14007}
14008
14009
14010static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14011{
14012 struct alc_spec *spec = codec->spec;
14013 hda_nid_t pin;
14014
14015 pin = spec->autocfg.hp_pins[0];
14016 if (pin) /* connect to front and use dac 0 */
14017 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014018 pin = spec->autocfg.speaker_pins[0];
14019 if (pin)
14020 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014021}
14022
14023#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14024#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14025
14026static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14027{
14028 struct alc_spec *spec = codec->spec;
14029 int i;
14030
14031 for (i = 0; i < AUTO_PIN_LAST; i++) {
14032 hda_nid_t nid = spec->autocfg.input_pins[i];
14033 if (alc861vd_is_input_pin(nid)) {
14034 snd_hda_codec_write(codec, nid, 0,
14035 AC_VERB_SET_PIN_WIDGET_CONTROL,
14036 i <= AUTO_PIN_FRONT_MIC ?
14037 PIN_VREF80 : PIN_IN);
14038 if (nid != ALC861VD_PIN_CD_NID)
14039 snd_hda_codec_write(codec, nid, 0,
14040 AC_VERB_SET_AMP_GAIN_MUTE,
14041 AMP_OUT_MUTE);
14042 }
14043 }
14044}
14045
Takashi Iwaif511b012008-08-15 16:46:42 +020014046#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14047
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014048#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14049#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14050
14051/* add playback controls from the parsed DAC table */
14052/* Based on ALC880 version. But ALC861VD has separate,
14053 * different NIDs for mute/unmute switch and volume control */
14054static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14055 const struct auto_pin_cfg *cfg)
14056{
14057 char name[32];
14058 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14059 hda_nid_t nid_v, nid_s;
14060 int i, err;
14061
14062 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014063 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014064 continue;
14065 nid_v = alc861vd_idx_to_mixer_vol(
14066 alc880_dac_to_idx(
14067 spec->multiout.dac_nids[i]));
14068 nid_s = alc861vd_idx_to_mixer_switch(
14069 alc880_dac_to_idx(
14070 spec->multiout.dac_nids[i]));
14071
14072 if (i == 2) {
14073 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014074 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14075 "Center Playback Volume",
14076 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14077 HDA_OUTPUT));
14078 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014079 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014080 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14081 "LFE Playback Volume",
14082 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14083 HDA_OUTPUT));
14084 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014085 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014086 err = add_control(spec, ALC_CTL_BIND_MUTE,
14087 "Center Playback Switch",
14088 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14089 HDA_INPUT));
14090 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014091 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014092 err = add_control(spec, ALC_CTL_BIND_MUTE,
14093 "LFE Playback Switch",
14094 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14095 HDA_INPUT));
14096 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014097 return err;
14098 } else {
14099 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014100 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14101 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14102 HDA_OUTPUT));
14103 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014104 return err;
14105 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014106 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014107 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014108 HDA_INPUT));
14109 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014110 return err;
14111 }
14112 }
14113 return 0;
14114}
14115
14116/* add playback controls for speaker and HP outputs */
14117/* Based on ALC880 version. But ALC861VD has separate,
14118 * different NIDs for mute/unmute switch and volume control */
14119static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14120 hda_nid_t pin, const char *pfx)
14121{
14122 hda_nid_t nid_v, nid_s;
14123 int err;
14124 char name[32];
14125
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014126 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014127 return 0;
14128
14129 if (alc880_is_fixed_pin(pin)) {
14130 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14131 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014132 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014133 spec->multiout.hp_nid = nid_v;
14134 else
14135 spec->multiout.extra_out_nid[0] = nid_v;
14136 /* control HP volume/switch on the output mixer amp */
14137 nid_v = alc861vd_idx_to_mixer_vol(
14138 alc880_fixed_pin_idx(pin));
14139 nid_s = alc861vd_idx_to_mixer_switch(
14140 alc880_fixed_pin_idx(pin));
14141
14142 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014143 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14144 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14145 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014146 return err;
14147 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014148 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14149 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14150 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014151 return err;
14152 } else if (alc880_is_multi_pin(pin)) {
14153 /* set manual connection */
14154 /* we have only a switch on HP-out PIN */
14155 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014156 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14157 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14158 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014159 return err;
14160 }
14161 return 0;
14162}
14163
14164/* parse the BIOS configuration and set up the alc_spec
14165 * return 1 if successful, 0 if the proper config is not found,
14166 * or a negative error code
14167 * Based on ALC880 version - had to change it to override
14168 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14169static int alc861vd_parse_auto_config(struct hda_codec *codec)
14170{
14171 struct alc_spec *spec = codec->spec;
14172 int err;
14173 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14174
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014175 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14176 alc861vd_ignore);
14177 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014178 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014179 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014180 return 0; /* can't find valid BIOS pin config */
14181
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014182 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14183 if (err < 0)
14184 return err;
14185 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14186 if (err < 0)
14187 return err;
14188 err = alc861vd_auto_create_extra_out(spec,
14189 spec->autocfg.speaker_pins[0],
14190 "Speaker");
14191 if (err < 0)
14192 return err;
14193 err = alc861vd_auto_create_extra_out(spec,
14194 spec->autocfg.hp_pins[0],
14195 "Headphone");
14196 if (err < 0)
14197 return err;
14198 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14199 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014200 return err;
14201
14202 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14203
14204 if (spec->autocfg.dig_out_pin)
14205 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14206
Takashi Iwai603c4012008-07-30 15:01:44 +020014207 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014208 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014209
Takashi Iwaid88897e2008-10-31 15:01:37 +010014210 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014211
14212 spec->num_mux_defs = 1;
14213 spec->input_mux = &spec->private_imux;
14214
Takashi Iwai776e1842007-08-29 15:07:11 +020014215 err = alc_auto_add_mic_boost(codec);
14216 if (err < 0)
14217 return err;
14218
Takashi Iwaie044c392008-10-27 16:56:24 +010014219 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014220 return 1;
14221}
14222
14223/* additional initialization for auto-configuration model */
14224static void alc861vd_auto_init(struct hda_codec *codec)
14225{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014226 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014227 alc861vd_auto_init_multi_out(codec);
14228 alc861vd_auto_init_hp_out(codec);
14229 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014230 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014231 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014232 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014233}
14234
14235static int patch_alc861vd(struct hda_codec *codec)
14236{
14237 struct alc_spec *spec;
14238 int err, board_config;
14239
14240 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14241 if (spec == NULL)
14242 return -ENOMEM;
14243
14244 codec->spec = spec;
14245
14246 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14247 alc861vd_models,
14248 alc861vd_cfg_tbl);
14249
14250 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14251 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14252 "ALC861VD, trying auto-probe from BIOS...\n");
14253 board_config = ALC861VD_AUTO;
14254 }
14255
14256 if (board_config == ALC861VD_AUTO) {
14257 /* automatic parse from the BIOS config */
14258 err = alc861vd_parse_auto_config(codec);
14259 if (err < 0) {
14260 alc_free(codec);
14261 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014262 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014263 printk(KERN_INFO
14264 "hda_codec: Cannot set up configuration "
14265 "from BIOS. Using base mode...\n");
14266 board_config = ALC861VD_3ST;
14267 }
14268 }
14269
14270 if (board_config != ALC861VD_AUTO)
14271 setup_preset(spec, &alc861vd_presets[board_config]);
14272
Kailang Yang2f893282008-05-27 12:14:47 +020014273 if (codec->vendor_id == 0x10ec0660) {
14274 spec->stream_name_analog = "ALC660-VD Analog";
14275 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014276 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014277 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014278 } else {
14279 spec->stream_name_analog = "ALC861VD Analog";
14280 spec->stream_name_digital = "ALC861VD Digital";
14281 }
14282
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014283 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14284 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14285
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014286 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14287 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14288
14289 spec->adc_nids = alc861vd_adc_nids;
14290 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014291 spec->capsrc_nids = alc861vd_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010014292 spec->is_mix_capture = 1;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014293
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014294 set_capture_mixer(spec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014295
Takashi Iwai2134ea42008-01-10 16:53:55 +010014296 spec->vmaster_nid = 0x02;
14297
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014298 codec->patch_ops = alc_patch_ops;
14299
14300 if (board_config == ALC861VD_AUTO)
14301 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014302#ifdef CONFIG_SND_HDA_POWER_SAVE
14303 if (!spec->loopback.amplist)
14304 spec->loopback.amplist = alc861vd_loopbacks;
14305#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014306
14307 return 0;
14308}
14309
14310/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014311 * ALC662 support
14312 *
14313 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14314 * configuration. Each pin widget can choose any input DACs and a mixer.
14315 * Each ADC is connected from a mixer of all inputs. This makes possible
14316 * 6-channel independent captures.
14317 *
14318 * In addition, an independent DAC for the multi-playback (not used in this
14319 * driver yet).
14320 */
14321#define ALC662_DIGOUT_NID 0x06
14322#define ALC662_DIGIN_NID 0x0a
14323
14324static hda_nid_t alc662_dac_nids[4] = {
14325 /* front, rear, clfe, rear_surr */
14326 0x02, 0x03, 0x04
14327};
14328
14329static hda_nid_t alc662_adc_nids[1] = {
14330 /* ADC1-2 */
14331 0x09,
14332};
Takashi Iwaie1406342008-02-11 18:32:32 +010014333
Kailang Yang77a261b2008-02-19 11:38:05 +010014334static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014335
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014336/* input MUX */
14337/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014338static struct hda_input_mux alc662_capture_source = {
14339 .num_items = 4,
14340 .items = {
14341 { "Mic", 0x0 },
14342 { "Front Mic", 0x1 },
14343 { "Line", 0x2 },
14344 { "CD", 0x4 },
14345 },
14346};
14347
14348static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14349 .num_items = 2,
14350 .items = {
14351 { "Mic", 0x1 },
14352 { "Line", 0x2 },
14353 },
14354};
Kailang Yang291702f2007-10-16 14:28:03 +020014355
14356static struct hda_input_mux alc662_eeepc_capture_source = {
14357 .num_items = 2,
14358 .items = {
14359 { "i-Mic", 0x1 },
14360 { "e-Mic", 0x0 },
14361 },
14362};
14363
Kailang Yang6dda9f42008-05-27 12:05:31 +020014364static struct hda_input_mux alc663_capture_source = {
14365 .num_items = 3,
14366 .items = {
14367 { "Mic", 0x0 },
14368 { "Front Mic", 0x1 },
14369 { "Line", 0x2 },
14370 },
14371};
14372
14373static struct hda_input_mux alc663_m51va_capture_source = {
14374 .num_items = 2,
14375 .items = {
14376 { "Ext-Mic", 0x0 },
14377 { "D-Mic", 0x9 },
14378 },
14379};
14380
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014381/*
14382 * 2ch mode
14383 */
14384static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14385 { 2, NULL }
14386};
14387
14388/*
14389 * 2ch mode
14390 */
14391static struct hda_verb alc662_3ST_ch2_init[] = {
14392 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14393 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14394 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14395 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14396 { } /* end */
14397};
14398
14399/*
14400 * 6ch mode
14401 */
14402static struct hda_verb alc662_3ST_ch6_init[] = {
14403 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14404 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14405 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14406 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14407 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14408 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14409 { } /* end */
14410};
14411
14412static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14413 { 2, alc662_3ST_ch2_init },
14414 { 6, alc662_3ST_ch6_init },
14415};
14416
14417/*
14418 * 2ch mode
14419 */
14420static struct hda_verb alc662_sixstack_ch6_init[] = {
14421 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14422 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14423 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14424 { } /* end */
14425};
14426
14427/*
14428 * 6ch mode
14429 */
14430static struct hda_verb alc662_sixstack_ch8_init[] = {
14431 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14432 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14433 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14434 { } /* end */
14435};
14436
14437static struct hda_channel_mode alc662_5stack_modes[2] = {
14438 { 2, alc662_sixstack_ch6_init },
14439 { 6, alc662_sixstack_ch8_init },
14440};
14441
14442/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14443 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14444 */
14445
14446static struct snd_kcontrol_new alc662_base_mixer[] = {
14447 /* output mixer control */
14448 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014449 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014450 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014451 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014452 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14453 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014454 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14455 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014456 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14457
14458 /*Input mixer control */
14459 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14460 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14461 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14462 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14463 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14464 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14465 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14466 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014467 { } /* end */
14468};
14469
14470static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14471 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014472 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014473 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14474 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14475 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14476 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14477 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14479 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14480 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14481 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14482 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14483 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014484 { } /* end */
14485};
14486
14487static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14488 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014489 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014490 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014491 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014492 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14493 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014494 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14495 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014496 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14497 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14498 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14499 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14500 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14502 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14503 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14505 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14506 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014507 { } /* end */
14508};
14509
14510static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
14511 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14512 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014513 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14514 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14516 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14517 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14518 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14519 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014520 { } /* end */
14521};
14522
Kailang Yang291702f2007-10-16 14:28:03 +020014523static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010014524 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014525
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010014526 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14527 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014528
14529 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
14530 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14531 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14532
14533 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
14534 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14535 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14536 { } /* end */
14537};
14538
Kailang Yang8c427222008-01-10 13:03:59 +010014539static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010014540 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14541 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014542 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14543 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
14544 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14545 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
14546 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
14547 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014548 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014549 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
14550 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14551 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14552 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14553 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14554 { } /* end */
14555};
14556
Kailang Yangf1d4e282008-08-26 14:03:29 +020014557static struct hda_bind_ctls alc663_asus_bind_master_vol = {
14558 .ops = &snd_hda_bind_vol,
14559 .values = {
14560 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14561 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
14562 0
14563 },
14564};
14565
14566static struct hda_bind_ctls alc663_asus_one_bind_switch = {
14567 .ops = &snd_hda_bind_sw,
14568 .values = {
14569 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14570 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14571 0
14572 },
14573};
14574
Kailang Yang6dda9f42008-05-27 12:05:31 +020014575static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020014576 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14577 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
14578 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14579 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14580 { } /* end */
14581};
14582
14583static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
14584 .ops = &snd_hda_bind_sw,
14585 .values = {
14586 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14587 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14588 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14589 0
14590 },
14591};
14592
14593static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
14594 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14595 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
14596 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14597 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14598 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14599 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14600
14601 { } /* end */
14602};
14603
14604static struct hda_bind_ctls alc663_asus_four_bind_switch = {
14605 .ops = &snd_hda_bind_sw,
14606 .values = {
14607 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14608 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14609 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
14610 0
14611 },
14612};
14613
14614static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
14615 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14616 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
14617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14619 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14620 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14621 { } /* end */
14622};
14623
14624static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014625 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14626 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014627 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14628 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14630 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14631 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14632 { } /* end */
14633};
14634
14635static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
14636 .ops = &snd_hda_bind_vol,
14637 .values = {
14638 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14639 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
14640 0
14641 },
14642};
14643
14644static struct hda_bind_ctls alc663_asus_two_bind_switch = {
14645 .ops = &snd_hda_bind_sw,
14646 .values = {
14647 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14648 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
14649 0
14650 },
14651};
14652
14653static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
14654 HDA_BIND_VOL("Master Playback Volume",
14655 &alc663_asus_two_bind_master_vol),
14656 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14657 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014658 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14660 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014661 { } /* end */
14662};
14663
14664static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
14665 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14666 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14667 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14668 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014671 { } /* end */
14672};
14673
14674static struct snd_kcontrol_new alc663_g71v_mixer[] = {
14675 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14676 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14677 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14678 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14679 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14680
14681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14682 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14683 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14684 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14685 { } /* end */
14686};
14687
14688static struct snd_kcontrol_new alc663_g50v_mixer[] = {
14689 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14690 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14691 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14692
14693 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14694 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14695 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14696 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14697 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14698 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14699 { } /* end */
14700};
14701
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014702static struct snd_kcontrol_new alc662_chmode_mixer[] = {
14703 {
14704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14705 .name = "Channel Mode",
14706 .info = alc_ch_mode_info,
14707 .get = alc_ch_mode_get,
14708 .put = alc_ch_mode_put,
14709 },
14710 { } /* end */
14711};
14712
14713static struct hda_verb alc662_init_verbs[] = {
14714 /* ADC: mute amp left and right */
14715 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14716 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14717 /* Front mixer: unmute input/output amp left and right (volume = 0) */
14718
Takashi Iwaicb53c622007-08-10 17:21:45 +020014719 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014724
Kailang Yangb60dd392007-09-20 12:50:29 +020014725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14726 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14727 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14728 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14729 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14730 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014731
14732 /* Front Pin: output 0 (0x0c) */
14733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14734 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14735
14736 /* Rear Pin: output 1 (0x0d) */
14737 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14738 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14739
14740 /* CLFE Pin: output 2 (0x0e) */
14741 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14742 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14743
14744 /* Mic (rear) pin: input vref at 80% */
14745 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14746 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14747 /* Front Mic pin: input vref at 80% */
14748 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14749 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14750 /* Line In pin: input */
14751 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14752 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14753 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14754 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14755 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14756 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14757 /* CD pin widget for input */
14758 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14759
14760 /* FIXME: use matrix-type input source selection */
14761 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14762 /* Input mixer */
14763 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14764 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14765 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14766 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020014767
14768 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14769 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14770 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14771 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014772
14773 /* always trun on EAPD */
14774 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14775 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14776
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014777 { }
14778};
14779
14780static struct hda_verb alc662_sue_init_verbs[] = {
14781 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14782 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020014783 {}
14784};
14785
14786static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
14787 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14788 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14789 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014790};
14791
Kailang Yang8c427222008-01-10 13:03:59 +010014792/* Set Unsolicited Event*/
14793static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
14794 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14795 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14796 {}
14797};
14798
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014799/*
14800 * generic initialization of ADC, input mixers and output mixers
14801 */
14802static struct hda_verb alc662_auto_init_verbs[] = {
14803 /*
14804 * Unmute ADC and set the default input to mic-in
14805 */
14806 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14807 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14808
14809 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
14810 * mixer widget
14811 * Note: PASD motherboards uses the Line In 2 as the input for front
14812 * panel mic (mic 2)
14813 */
14814 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014815 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14817 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14818 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14819 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014820
14821 /*
14822 * Set up output mixers (0x0c - 0x0f)
14823 */
14824 /* set vol=0 to output mixers */
14825 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14826 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14827 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14828
14829 /* set up input amps for analog loopback */
14830 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020014831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14832 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14833 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14836 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014837
14838
14839 /* FIXME: use matrix-type input source selection */
14840 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14841 /* Input mixer */
14842 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020014843 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014844 { }
14845};
14846
Takashi Iwai24fb9172008-09-02 14:48:20 +020014847/* additional verbs for ALC663 */
14848static struct hda_verb alc663_auto_init_verbs[] = {
14849 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14850 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14851 { }
14852};
14853
Kailang Yang6dda9f42008-05-27 12:05:31 +020014854static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020014855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14856 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014857 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14858 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020014859 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
14860 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14861 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014862 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14863 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14864 {}
14865};
14866
Kailang Yangf1d4e282008-08-26 14:03:29 +020014867static struct hda_verb alc663_21jd_amic_init_verbs[] = {
14868 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14869 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14870 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
14871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14873 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14874 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14875 {}
14876};
14877
14878static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
14879 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14880 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14881 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14882 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14884 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14885 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14886 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14887 {}
14888};
14889
14890static struct hda_verb alc663_15jd_amic_init_verbs[] = {
14891 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14892 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14893 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
14894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14895 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14896 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14897 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14898 {}
14899};
14900
14901static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
14902 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14903 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14904 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14905 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
14906 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14907 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14908 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
14909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14910 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14911 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14912 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14913 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14914 {}
14915};
14916
14917static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
14918 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14919 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14920 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14921 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
14922 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14923 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14924 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
14925 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14927 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14928 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14929 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14930 {}
14931};
14932
Kailang Yang6dda9f42008-05-27 12:05:31 +020014933static struct hda_verb alc663_g71v_init_verbs[] = {
14934 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14935 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
14936 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
14937
14938 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14939 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14940 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14941
14942 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14943 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
14944 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
14945 {}
14946};
14947
14948static struct hda_verb alc663_g50v_init_verbs[] = {
14949 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14950 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14951 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14952
14953 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14954 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14955 {}
14956};
14957
Kailang Yangf1d4e282008-08-26 14:03:29 +020014958static struct hda_verb alc662_ecs_init_verbs[] = {
14959 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
14960 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14961 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14962 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14963 {}
14964};
14965
Kailang Yangf1d4e282008-08-26 14:03:29 +020014966static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
14967 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14968 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14969 { } /* end */
14970};
14971
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014972static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
14973{
14974 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014975 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014976
14977 present = snd_hda_codec_read(codec, 0x14, 0,
14978 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014979 bits = present ? HDA_AMP_MUTE : 0;
14980 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14981 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014982}
14983
14984static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
14985{
14986 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014987 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014988
14989 present = snd_hda_codec_read(codec, 0x1b, 0,
14990 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014991 bits = present ? HDA_AMP_MUTE : 0;
14992 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14993 HDA_AMP_MUTE, bits);
14994 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14995 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014996}
14997
14998static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
14999 unsigned int res)
15000{
15001 if ((res >> 26) == ALC880_HP_EVENT)
15002 alc662_lenovo_101e_all_automute(codec);
15003 if ((res >> 26) == ALC880_FRONT_EVENT)
15004 alc662_lenovo_101e_ispeaker_automute(codec);
15005}
15006
Kailang Yang291702f2007-10-16 14:28:03 +020015007static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15008{
15009 unsigned int present;
15010
15011 present = snd_hda_codec_read(codec, 0x18, 0,
15012 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15013 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15014 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15015 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15016 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15017 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15018 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15019 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15020 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15021}
15022
15023/* unsolicited event for HP jack sensing */
15024static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15025 unsigned int res)
15026{
15027 if ((res >> 26) == ALC880_HP_EVENT)
15028 alc262_hippo1_automute( codec );
15029
15030 if ((res >> 26) == ALC880_MIC_EVENT)
15031 alc662_eeepc_mic_automute(codec);
15032}
15033
15034static void alc662_eeepc_inithook(struct hda_codec *codec)
15035{
15036 alc262_hippo1_automute( codec );
15037 alc662_eeepc_mic_automute(codec);
15038}
15039
Kailang Yang8c427222008-01-10 13:03:59 +010015040static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15041{
15042 unsigned int mute;
15043 unsigned int present;
15044
15045 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15046 present = snd_hda_codec_read(codec, 0x14, 0,
15047 AC_VERB_GET_PIN_SENSE, 0);
15048 present = (present & 0x80000000) != 0;
15049 if (present) {
15050 /* mute internal speaker */
15051 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015052 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015053 } else {
15054 /* unmute internal speaker if necessary */
15055 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15056 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015057 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015058 }
15059}
15060
15061/* unsolicited event for HP jack sensing */
15062static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15063 unsigned int res)
15064{
15065 if ((res >> 26) == ALC880_HP_EVENT)
15066 alc662_eeepc_ep20_automute(codec);
15067}
15068
15069static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15070{
15071 alc662_eeepc_ep20_automute(codec);
15072}
15073
Kailang Yang6dda9f42008-05-27 12:05:31 +020015074static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15075{
15076 unsigned int present;
15077 unsigned char bits;
15078
15079 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015080 AC_VERB_GET_PIN_SENSE, 0)
15081 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015082 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015083 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15084 AMP_IN_MUTE(0), bits);
15085 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15086 AMP_IN_MUTE(0), bits);
15087}
15088
15089static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15090{
15091 unsigned int present;
15092 unsigned char bits;
15093
15094 present = snd_hda_codec_read(codec, 0x21, 0,
15095 AC_VERB_GET_PIN_SENSE, 0)
15096 & AC_PINSENSE_PRESENCE;
15097 bits = present ? HDA_AMP_MUTE : 0;
15098 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15099 AMP_IN_MUTE(0), bits);
15100 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15101 AMP_IN_MUTE(0), bits);
15102 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15103 AMP_IN_MUTE(0), bits);
15104 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15105 AMP_IN_MUTE(0), bits);
15106}
15107
15108static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15109{
15110 unsigned int present;
15111 unsigned char bits;
15112
15113 present = snd_hda_codec_read(codec, 0x15, 0,
15114 AC_VERB_GET_PIN_SENSE, 0)
15115 & AC_PINSENSE_PRESENCE;
15116 bits = present ? HDA_AMP_MUTE : 0;
15117 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15118 AMP_IN_MUTE(0), bits);
15119 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15120 AMP_IN_MUTE(0), bits);
15121 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15122 AMP_IN_MUTE(0), bits);
15123 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15124 AMP_IN_MUTE(0), bits);
15125}
15126
15127static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15128{
15129 unsigned int present;
15130 unsigned char bits;
15131
15132 present = snd_hda_codec_read(codec, 0x1b, 0,
15133 AC_VERB_GET_PIN_SENSE, 0)
15134 & AC_PINSENSE_PRESENCE;
15135 bits = present ? 0 : PIN_OUT;
15136 snd_hda_codec_write(codec, 0x14, 0,
15137 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15138}
15139
15140static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15141{
15142 unsigned int present1, present2;
15143
15144 present1 = snd_hda_codec_read(codec, 0x21, 0,
15145 AC_VERB_GET_PIN_SENSE, 0)
15146 & AC_PINSENSE_PRESENCE;
15147 present2 = snd_hda_codec_read(codec, 0x15, 0,
15148 AC_VERB_GET_PIN_SENSE, 0)
15149 & AC_PINSENSE_PRESENCE;
15150
15151 if (present1 || present2) {
15152 snd_hda_codec_write_cache(codec, 0x14, 0,
15153 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15154 } else {
15155 snd_hda_codec_write_cache(codec, 0x14, 0,
15156 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15157 }
15158}
15159
15160static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15161{
15162 unsigned int present1, present2;
15163
15164 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15165 AC_VERB_GET_PIN_SENSE, 0)
15166 & AC_PINSENSE_PRESENCE;
15167 present2 = snd_hda_codec_read(codec, 0x15, 0,
15168 AC_VERB_GET_PIN_SENSE, 0)
15169 & AC_PINSENSE_PRESENCE;
15170
15171 if (present1 || present2) {
15172 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15173 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15174 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15175 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15176 } else {
15177 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15178 AMP_IN_MUTE(0), 0);
15179 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15180 AMP_IN_MUTE(0), 0);
15181 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015182}
15183
15184static void alc663_m51va_mic_automute(struct hda_codec *codec)
15185{
15186 unsigned int present;
15187
15188 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015189 AC_VERB_GET_PIN_SENSE, 0)
15190 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015191 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015192 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015193 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015194 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015195 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015196 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015197 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015198 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015199}
15200
15201static void alc663_m51va_unsol_event(struct hda_codec *codec,
15202 unsigned int res)
15203{
15204 switch (res >> 26) {
15205 case ALC880_HP_EVENT:
15206 alc663_m51va_speaker_automute(codec);
15207 break;
15208 case ALC880_MIC_EVENT:
15209 alc663_m51va_mic_automute(codec);
15210 break;
15211 }
15212}
15213
15214static void alc663_m51va_inithook(struct hda_codec *codec)
15215{
15216 alc663_m51va_speaker_automute(codec);
15217 alc663_m51va_mic_automute(codec);
15218}
15219
Kailang Yangf1d4e282008-08-26 14:03:29 +020015220/* ***************** Mode1 ******************************/
15221static void alc663_mode1_unsol_event(struct hda_codec *codec,
15222 unsigned int res)
15223{
15224 switch (res >> 26) {
15225 case ALC880_HP_EVENT:
15226 alc663_m51va_speaker_automute(codec);
15227 break;
15228 case ALC880_MIC_EVENT:
15229 alc662_eeepc_mic_automute(codec);
15230 break;
15231 }
15232}
15233
15234static void alc663_mode1_inithook(struct hda_codec *codec)
15235{
15236 alc663_m51va_speaker_automute(codec);
15237 alc662_eeepc_mic_automute(codec);
15238}
15239/* ***************** Mode2 ******************************/
15240static void alc662_mode2_unsol_event(struct hda_codec *codec,
15241 unsigned int res)
15242{
15243 switch (res >> 26) {
15244 case ALC880_HP_EVENT:
15245 alc662_f5z_speaker_automute(codec);
15246 break;
15247 case ALC880_MIC_EVENT:
15248 alc662_eeepc_mic_automute(codec);
15249 break;
15250 }
15251}
15252
15253static void alc662_mode2_inithook(struct hda_codec *codec)
15254{
15255 alc662_f5z_speaker_automute(codec);
15256 alc662_eeepc_mic_automute(codec);
15257}
15258/* ***************** Mode3 ******************************/
15259static void alc663_mode3_unsol_event(struct hda_codec *codec,
15260 unsigned int res)
15261{
15262 switch (res >> 26) {
15263 case ALC880_HP_EVENT:
15264 alc663_two_hp_m1_speaker_automute(codec);
15265 break;
15266 case ALC880_MIC_EVENT:
15267 alc662_eeepc_mic_automute(codec);
15268 break;
15269 }
15270}
15271
15272static void alc663_mode3_inithook(struct hda_codec *codec)
15273{
15274 alc663_two_hp_m1_speaker_automute(codec);
15275 alc662_eeepc_mic_automute(codec);
15276}
15277/* ***************** Mode4 ******************************/
15278static void alc663_mode4_unsol_event(struct hda_codec *codec,
15279 unsigned int res)
15280{
15281 switch (res >> 26) {
15282 case ALC880_HP_EVENT:
15283 alc663_21jd_two_speaker_automute(codec);
15284 break;
15285 case ALC880_MIC_EVENT:
15286 alc662_eeepc_mic_automute(codec);
15287 break;
15288 }
15289}
15290
15291static void alc663_mode4_inithook(struct hda_codec *codec)
15292{
15293 alc663_21jd_two_speaker_automute(codec);
15294 alc662_eeepc_mic_automute(codec);
15295}
15296/* ***************** Mode5 ******************************/
15297static void alc663_mode5_unsol_event(struct hda_codec *codec,
15298 unsigned int res)
15299{
15300 switch (res >> 26) {
15301 case ALC880_HP_EVENT:
15302 alc663_15jd_two_speaker_automute(codec);
15303 break;
15304 case ALC880_MIC_EVENT:
15305 alc662_eeepc_mic_automute(codec);
15306 break;
15307 }
15308}
15309
15310static void alc663_mode5_inithook(struct hda_codec *codec)
15311{
15312 alc663_15jd_two_speaker_automute(codec);
15313 alc662_eeepc_mic_automute(codec);
15314}
15315/* ***************** Mode6 ******************************/
15316static void alc663_mode6_unsol_event(struct hda_codec *codec,
15317 unsigned int res)
15318{
15319 switch (res >> 26) {
15320 case ALC880_HP_EVENT:
15321 alc663_two_hp_m2_speaker_automute(codec);
15322 break;
15323 case ALC880_MIC_EVENT:
15324 alc662_eeepc_mic_automute(codec);
15325 break;
15326 }
15327}
15328
15329static void alc663_mode6_inithook(struct hda_codec *codec)
15330{
15331 alc663_two_hp_m2_speaker_automute(codec);
15332 alc662_eeepc_mic_automute(codec);
15333}
15334
Kailang Yang6dda9f42008-05-27 12:05:31 +020015335static void alc663_g71v_hp_automute(struct hda_codec *codec)
15336{
15337 unsigned int present;
15338 unsigned char bits;
15339
15340 present = snd_hda_codec_read(codec, 0x21, 0,
15341 AC_VERB_GET_PIN_SENSE, 0)
15342 & AC_PINSENSE_PRESENCE;
15343 bits = present ? HDA_AMP_MUTE : 0;
15344 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15345 HDA_AMP_MUTE, bits);
15346 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15347 HDA_AMP_MUTE, bits);
15348}
15349
15350static void alc663_g71v_front_automute(struct hda_codec *codec)
15351{
15352 unsigned int present;
15353 unsigned char bits;
15354
15355 present = snd_hda_codec_read(codec, 0x15, 0,
15356 AC_VERB_GET_PIN_SENSE, 0)
15357 & AC_PINSENSE_PRESENCE;
15358 bits = present ? HDA_AMP_MUTE : 0;
15359 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15360 HDA_AMP_MUTE, bits);
15361}
15362
15363static void alc663_g71v_unsol_event(struct hda_codec *codec,
15364 unsigned int res)
15365{
15366 switch (res >> 26) {
15367 case ALC880_HP_EVENT:
15368 alc663_g71v_hp_automute(codec);
15369 break;
15370 case ALC880_FRONT_EVENT:
15371 alc663_g71v_front_automute(codec);
15372 break;
15373 case ALC880_MIC_EVENT:
15374 alc662_eeepc_mic_automute(codec);
15375 break;
15376 }
15377}
15378
15379static void alc663_g71v_inithook(struct hda_codec *codec)
15380{
15381 alc663_g71v_front_automute(codec);
15382 alc663_g71v_hp_automute(codec);
15383 alc662_eeepc_mic_automute(codec);
15384}
15385
15386static void alc663_g50v_unsol_event(struct hda_codec *codec,
15387 unsigned int res)
15388{
15389 switch (res >> 26) {
15390 case ALC880_HP_EVENT:
15391 alc663_m51va_speaker_automute(codec);
15392 break;
15393 case ALC880_MIC_EVENT:
15394 alc662_eeepc_mic_automute(codec);
15395 break;
15396 }
15397}
15398
15399static void alc663_g50v_inithook(struct hda_codec *codec)
15400{
15401 alc663_m51va_speaker_automute(codec);
15402 alc662_eeepc_mic_automute(codec);
15403}
15404
Kailang Yangf1d4e282008-08-26 14:03:29 +020015405/* bind hp and internal speaker mute (with plug check) */
15406static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
15407 struct snd_ctl_elem_value *ucontrol)
15408{
15409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
15410 long *valp = ucontrol->value.integer.value;
15411 int change;
15412
15413 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
15414 HDA_AMP_MUTE,
15415 valp[0] ? 0 : HDA_AMP_MUTE);
15416 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
15417 HDA_AMP_MUTE,
15418 valp[1] ? 0 : HDA_AMP_MUTE);
15419 if (change)
15420 alc262_hippo1_automute(codec);
15421 return change;
15422}
15423
15424static struct snd_kcontrol_new alc662_ecs_mixer[] = {
15425 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15426 {
15427 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15428 .name = "Master Playback Switch",
15429 .info = snd_hda_mixer_amp_switch_info,
15430 .get = snd_hda_mixer_amp_switch_get,
15431 .put = alc662_ecs_master_sw_put,
15432 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15433 },
15434
15435 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
15436 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
15437 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
15438
15439 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15440 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15441 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15442 { } /* end */
15443};
15444
Takashi Iwaicb53c622007-08-10 17:21:45 +020015445#ifdef CONFIG_SND_HDA_POWER_SAVE
15446#define alc662_loopbacks alc880_loopbacks
15447#endif
15448
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015449
15450/* pcm configuration: identiacal with ALC880 */
15451#define alc662_pcm_analog_playback alc880_pcm_analog_playback
15452#define alc662_pcm_analog_capture alc880_pcm_analog_capture
15453#define alc662_pcm_digital_playback alc880_pcm_digital_playback
15454#define alc662_pcm_digital_capture alc880_pcm_digital_capture
15455
15456/*
15457 * configuration and preset
15458 */
15459static const char *alc662_models[ALC662_MODEL_LAST] = {
15460 [ALC662_3ST_2ch_DIG] = "3stack-dig",
15461 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
15462 [ALC662_3ST_6ch] = "3stack-6ch",
15463 [ALC662_5ST_DIG] = "6stack-dig",
15464 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020015465 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010015466 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015467 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020015468 [ALC663_ASUS_M51VA] = "m51va",
15469 [ALC663_ASUS_G71V] = "g71v",
15470 [ALC663_ASUS_H13] = "h13",
15471 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015472 [ALC663_ASUS_MODE1] = "asus-mode1",
15473 [ALC662_ASUS_MODE2] = "asus-mode2",
15474 [ALC663_ASUS_MODE3] = "asus-mode3",
15475 [ALC663_ASUS_MODE4] = "asus-mode4",
15476 [ALC663_ASUS_MODE5] = "asus-mode5",
15477 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015478 [ALC662_AUTO] = "auto",
15479};
15480
15481static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015482 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Kailang Yang80ffe862008-10-15 11:23:27 +020015483 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010015484 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020015485 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010015486 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015487 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
15488 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
15489 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
15490 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
15491 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
15492 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
15493 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
15494 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
15495 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020015496 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015497 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
15498 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
15499 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
15500 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
15501 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
15502 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
15503 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
15504 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
15505 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
15506 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
15507 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
15508 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
15509 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
15510 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
15511 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
15512 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
15513 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
15514 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
15515 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
15516 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
15517 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
15518 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030015519 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
15520 ALC662_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015521 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015522 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
15523 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030015524 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
15525 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020015526 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai238713d2008-10-05 10:57:39 +020015527 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020015528 ALC662_3ST_6ch_DIG),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015529 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
15530 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
15531 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015532 {}
15533};
15534
15535static struct alc_config_preset alc662_presets[] = {
15536 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015537 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015538 .init_verbs = { alc662_init_verbs },
15539 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15540 .dac_nids = alc662_dac_nids,
15541 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015542 .dig_in_nid = ALC662_DIGIN_NID,
15543 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15544 .channel_mode = alc662_3ST_2ch_modes,
15545 .input_mux = &alc662_capture_source,
15546 },
15547 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015548 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015549 .init_verbs = { alc662_init_verbs },
15550 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15551 .dac_nids = alc662_dac_nids,
15552 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015553 .dig_in_nid = ALC662_DIGIN_NID,
15554 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15555 .channel_mode = alc662_3ST_6ch_modes,
15556 .need_dac_fix = 1,
15557 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015558 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015559 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015560 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015561 .init_verbs = { alc662_init_verbs },
15562 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15563 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015564 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15565 .channel_mode = alc662_3ST_6ch_modes,
15566 .need_dac_fix = 1,
15567 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015568 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015569 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015570 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015571 .init_verbs = { alc662_init_verbs },
15572 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15573 .dac_nids = alc662_dac_nids,
15574 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015575 .dig_in_nid = ALC662_DIGIN_NID,
15576 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
15577 .channel_mode = alc662_5stack_modes,
15578 .input_mux = &alc662_capture_source,
15579 },
15580 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015581 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015582 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
15583 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15584 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015585 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15586 .channel_mode = alc662_3ST_2ch_modes,
15587 .input_mux = &alc662_lenovo_101e_capture_source,
15588 .unsol_event = alc662_lenovo_101e_unsol_event,
15589 .init_hook = alc662_lenovo_101e_all_automute,
15590 },
Kailang Yang291702f2007-10-16 14:28:03 +020015591 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015592 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020015593 .init_verbs = { alc662_init_verbs,
15594 alc662_eeepc_sue_init_verbs },
15595 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15596 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020015597 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15598 .channel_mode = alc662_3ST_2ch_modes,
15599 .input_mux = &alc662_eeepc_capture_source,
15600 .unsol_event = alc662_eeepc_unsol_event,
15601 .init_hook = alc662_eeepc_inithook,
15602 },
Kailang Yang8c427222008-01-10 13:03:59 +010015603 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015604 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010015605 alc662_chmode_mixer },
15606 .init_verbs = { alc662_init_verbs,
15607 alc662_eeepc_ep20_sue_init_verbs },
15608 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15609 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010015610 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15611 .channel_mode = alc662_3ST_6ch_modes,
15612 .input_mux = &alc662_lenovo_101e_capture_source,
15613 .unsol_event = alc662_eeepc_ep20_unsol_event,
15614 .init_hook = alc662_eeepc_ep20_inithook,
15615 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015616 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015617 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015618 .init_verbs = { alc662_init_verbs,
15619 alc662_ecs_init_verbs },
15620 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15621 .dac_nids = alc662_dac_nids,
15622 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15623 .channel_mode = alc662_3ST_2ch_modes,
15624 .input_mux = &alc662_eeepc_capture_source,
15625 .unsol_event = alc662_eeepc_unsol_event,
15626 .init_hook = alc662_eeepc_inithook,
15627 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015628 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015629 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015630 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15631 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15632 .dac_nids = alc662_dac_nids,
15633 .dig_out_nid = ALC662_DIGOUT_NID,
15634 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15635 .channel_mode = alc662_3ST_2ch_modes,
15636 .input_mux = &alc663_m51va_capture_source,
15637 .unsol_event = alc663_m51va_unsol_event,
15638 .init_hook = alc663_m51va_inithook,
15639 },
15640 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015641 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015642 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
15643 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15644 .dac_nids = alc662_dac_nids,
15645 .dig_out_nid = ALC662_DIGOUT_NID,
15646 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15647 .channel_mode = alc662_3ST_2ch_modes,
15648 .input_mux = &alc662_eeepc_capture_source,
15649 .unsol_event = alc663_g71v_unsol_event,
15650 .init_hook = alc663_g71v_inithook,
15651 },
15652 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015653 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015654 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15655 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15656 .dac_nids = alc662_dac_nids,
15657 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15658 .channel_mode = alc662_3ST_2ch_modes,
15659 .input_mux = &alc663_m51va_capture_source,
15660 .unsol_event = alc663_m51va_unsol_event,
15661 .init_hook = alc663_m51va_inithook,
15662 },
15663 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015664 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015665 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
15666 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15667 .dac_nids = alc662_dac_nids,
15668 .dig_out_nid = ALC662_DIGOUT_NID,
15669 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15670 .channel_mode = alc662_3ST_6ch_modes,
15671 .input_mux = &alc663_capture_source,
15672 .unsol_event = alc663_g50v_unsol_event,
15673 .init_hook = alc663_g50v_inithook,
15674 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015675 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015676 .mixers = { alc663_m51va_mixer },
15677 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015678 .init_verbs = { alc662_init_verbs,
15679 alc663_21jd_amic_init_verbs },
15680 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15681 .hp_nid = 0x03,
15682 .dac_nids = alc662_dac_nids,
15683 .dig_out_nid = ALC662_DIGOUT_NID,
15684 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15685 .channel_mode = alc662_3ST_2ch_modes,
15686 .input_mux = &alc662_eeepc_capture_source,
15687 .unsol_event = alc663_mode1_unsol_event,
15688 .init_hook = alc663_mode1_inithook,
15689 },
15690 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015691 .mixers = { alc662_1bjd_mixer },
15692 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015693 .init_verbs = { alc662_init_verbs,
15694 alc662_1bjd_amic_init_verbs },
15695 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15696 .dac_nids = alc662_dac_nids,
15697 .dig_out_nid = ALC662_DIGOUT_NID,
15698 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15699 .channel_mode = alc662_3ST_2ch_modes,
15700 .input_mux = &alc662_eeepc_capture_source,
15701 .unsol_event = alc662_mode2_unsol_event,
15702 .init_hook = alc662_mode2_inithook,
15703 },
15704 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015705 .mixers = { alc663_two_hp_m1_mixer },
15706 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015707 .init_verbs = { alc662_init_verbs,
15708 alc663_two_hp_amic_m1_init_verbs },
15709 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15710 .hp_nid = 0x03,
15711 .dac_nids = alc662_dac_nids,
15712 .dig_out_nid = ALC662_DIGOUT_NID,
15713 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15714 .channel_mode = alc662_3ST_2ch_modes,
15715 .input_mux = &alc662_eeepc_capture_source,
15716 .unsol_event = alc663_mode3_unsol_event,
15717 .init_hook = alc663_mode3_inithook,
15718 },
15719 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015720 .mixers = { alc663_asus_21jd_clfe_mixer },
15721 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015722 .init_verbs = { alc662_init_verbs,
15723 alc663_21jd_amic_init_verbs},
15724 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15725 .hp_nid = 0x03,
15726 .dac_nids = alc662_dac_nids,
15727 .dig_out_nid = ALC662_DIGOUT_NID,
15728 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15729 .channel_mode = alc662_3ST_2ch_modes,
15730 .input_mux = &alc662_eeepc_capture_source,
15731 .unsol_event = alc663_mode4_unsol_event,
15732 .init_hook = alc663_mode4_inithook,
15733 },
15734 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015735 .mixers = { alc663_asus_15jd_clfe_mixer },
15736 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015737 .init_verbs = { alc662_init_verbs,
15738 alc663_15jd_amic_init_verbs },
15739 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15740 .hp_nid = 0x03,
15741 .dac_nids = alc662_dac_nids,
15742 .dig_out_nid = ALC662_DIGOUT_NID,
15743 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15744 .channel_mode = alc662_3ST_2ch_modes,
15745 .input_mux = &alc662_eeepc_capture_source,
15746 .unsol_event = alc663_mode5_unsol_event,
15747 .init_hook = alc663_mode5_inithook,
15748 },
15749 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015750 .mixers = { alc663_two_hp_m2_mixer },
15751 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015752 .init_verbs = { alc662_init_verbs,
15753 alc663_two_hp_amic_m2_init_verbs },
15754 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15755 .hp_nid = 0x03,
15756 .dac_nids = alc662_dac_nids,
15757 .dig_out_nid = ALC662_DIGOUT_NID,
15758 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15759 .channel_mode = alc662_3ST_2ch_modes,
15760 .input_mux = &alc662_eeepc_capture_source,
15761 .unsol_event = alc663_mode6_unsol_event,
15762 .init_hook = alc663_mode6_inithook,
15763 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015764};
15765
15766
15767/*
15768 * BIOS auto configuration
15769 */
15770
15771/* add playback controls from the parsed DAC table */
15772static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
15773 const struct auto_pin_cfg *cfg)
15774{
15775 char name[32];
15776 static const char *chname[4] = {
15777 "Front", "Surround", NULL /*CLFE*/, "Side"
15778 };
15779 hda_nid_t nid;
15780 int i, err;
15781
15782 for (i = 0; i < cfg->line_outs; i++) {
15783 if (!spec->multiout.dac_nids[i])
15784 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020015785 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015786 if (i == 2) {
15787 /* Center/LFE */
15788 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15789 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015790 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
15791 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015792 if (err < 0)
15793 return err;
15794 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15795 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015796 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
15797 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015798 if (err < 0)
15799 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015800 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015801 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015802 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015803 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015804 if (err < 0)
15805 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015806 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015807 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015808 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015809 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015810 if (err < 0)
15811 return err;
15812 } else {
15813 sprintf(name, "%s Playback Volume", chname[i]);
15814 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015815 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
15816 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015817 if (err < 0)
15818 return err;
15819 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015820 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15821 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
15822 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015823 if (err < 0)
15824 return err;
15825 }
15826 }
15827 return 0;
15828}
15829
15830/* add playback controls for speaker and HP outputs */
15831static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
15832 const char *pfx)
15833{
15834 hda_nid_t nid;
15835 int err;
15836 char name[32];
15837
15838 if (!pin)
15839 return 0;
15840
Takashi Iwai24fb9172008-09-02 14:48:20 +020015841 if (pin == 0x17) {
15842 /* ALC663 has a mono output pin on 0x17 */
15843 sprintf(name, "%s Playback Switch", pfx);
15844 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15845 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
15846 return err;
15847 }
15848
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015849 if (alc880_is_fixed_pin(pin)) {
15850 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15851 /* printk("DAC nid=%x\n",nid); */
15852 /* specify the DAC as the extra output */
15853 if (!spec->multiout.hp_nid)
15854 spec->multiout.hp_nid = nid;
15855 else
15856 spec->multiout.extra_out_nid[0] = nid;
15857 /* control HP volume/switch on the output mixer amp */
15858 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15859 sprintf(name, "%s Playback Volume", pfx);
15860 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15861 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
15862 if (err < 0)
15863 return err;
15864 sprintf(name, "%s Playback Switch", pfx);
15865 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15866 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
15867 if (err < 0)
15868 return err;
15869 } else if (alc880_is_multi_pin(pin)) {
15870 /* set manual connection */
15871 /* we have only a switch on HP-out PIN */
15872 sprintf(name, "%s Playback Switch", pfx);
15873 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15874 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15875 if (err < 0)
15876 return err;
15877 }
15878 return 0;
15879}
15880
15881/* create playback/capture controls for input pins */
15882static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
15883 const struct auto_pin_cfg *cfg)
15884{
15885 struct hda_input_mux *imux = &spec->private_imux;
15886 int i, err, idx;
15887
15888 for (i = 0; i < AUTO_PIN_LAST; i++) {
15889 if (alc880_is_input_pin(cfg->input_pins[i])) {
15890 idx = alc880_input_pin_idx(cfg->input_pins[i]);
15891 err = new_analog_input(spec, cfg->input_pins[i],
15892 auto_pin_cfg_labels[i],
15893 idx, 0x0b);
15894 if (err < 0)
15895 return err;
15896 imux->items[imux->num_items].label =
15897 auto_pin_cfg_labels[i];
15898 imux->items[imux->num_items].index =
15899 alc880_input_pin_idx(cfg->input_pins[i]);
15900 imux->num_items++;
15901 }
15902 }
15903 return 0;
15904}
15905
15906static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
15907 hda_nid_t nid, int pin_type,
15908 int dac_idx)
15909{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015910 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015911 /* need the manual connection? */
15912 if (alc880_is_multi_pin(nid)) {
15913 struct alc_spec *spec = codec->spec;
15914 int idx = alc880_multi_pin_idx(nid);
15915 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
15916 AC_VERB_SET_CONNECT_SEL,
15917 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
15918 }
15919}
15920
15921static void alc662_auto_init_multi_out(struct hda_codec *codec)
15922{
15923 struct alc_spec *spec = codec->spec;
15924 int i;
15925
Kailang Yang8c427222008-01-10 13:03:59 +010015926 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015927 for (i = 0; i <= HDA_SIDE; i++) {
15928 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015929 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015930 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015931 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015932 i);
15933 }
15934}
15935
15936static void alc662_auto_init_hp_out(struct hda_codec *codec)
15937{
15938 struct alc_spec *spec = codec->spec;
15939 hda_nid_t pin;
15940
15941 pin = spec->autocfg.hp_pins[0];
15942 if (pin) /* connect to front */
15943 /* use dac 0 */
15944 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015945 pin = spec->autocfg.speaker_pins[0];
15946 if (pin)
15947 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015948}
15949
15950#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
15951#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
15952
15953static void alc662_auto_init_analog_input(struct hda_codec *codec)
15954{
15955 struct alc_spec *spec = codec->spec;
15956 int i;
15957
15958 for (i = 0; i < AUTO_PIN_LAST; i++) {
15959 hda_nid_t nid = spec->autocfg.input_pins[i];
15960 if (alc662_is_input_pin(nid)) {
15961 snd_hda_codec_write(codec, nid, 0,
15962 AC_VERB_SET_PIN_WIDGET_CONTROL,
15963 (i <= AUTO_PIN_FRONT_MIC ?
15964 PIN_VREF80 : PIN_IN));
15965 if (nid != ALC662_PIN_CD_NID)
15966 snd_hda_codec_write(codec, nid, 0,
15967 AC_VERB_SET_AMP_GAIN_MUTE,
15968 AMP_OUT_MUTE);
15969 }
15970 }
15971}
15972
Takashi Iwaif511b012008-08-15 16:46:42 +020015973#define alc662_auto_init_input_src alc882_auto_init_input_src
15974
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015975static int alc662_parse_auto_config(struct hda_codec *codec)
15976{
15977 struct alc_spec *spec = codec->spec;
15978 int err;
15979 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
15980
15981 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15982 alc662_ignore);
15983 if (err < 0)
15984 return err;
15985 if (!spec->autocfg.line_outs)
15986 return 0; /* can't find valid BIOS pin config */
15987
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015988 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15989 if (err < 0)
15990 return err;
15991 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
15992 if (err < 0)
15993 return err;
15994 err = alc662_auto_create_extra_out(spec,
15995 spec->autocfg.speaker_pins[0],
15996 "Speaker");
15997 if (err < 0)
15998 return err;
15999 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16000 "Headphone");
16001 if (err < 0)
16002 return err;
16003 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16004 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016005 return err;
16006
16007 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16008
16009 if (spec->autocfg.dig_out_pin)
16010 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16011
Takashi Iwai603c4012008-07-30 15:01:44 +020016012 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016013 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016014
16015 spec->num_mux_defs = 1;
16016 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020016017
Takashi Iwaid88897e2008-10-31 15:01:37 +010016018 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016019 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016020 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016021
16022 err = alc_auto_add_mic_boost(codec);
16023 if (err < 0)
16024 return err;
16025
Takashi Iwaie044c392008-10-27 16:56:24 +010016026 store_pin_configs(codec);
Takashi Iwai8c872862007-06-19 12:11:16 +020016027 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016028}
16029
16030/* additional initialization for auto-configuration model */
16031static void alc662_auto_init(struct hda_codec *codec)
16032{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016033 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016034 alc662_auto_init_multi_out(codec);
16035 alc662_auto_init_hp_out(codec);
16036 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016037 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016038 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016039 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016040}
16041
16042static int patch_alc662(struct hda_codec *codec)
16043{
16044 struct alc_spec *spec;
16045 int err, board_config;
16046
16047 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16048 if (!spec)
16049 return -ENOMEM;
16050
16051 codec->spec = spec;
16052
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016053 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16054
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016055 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16056 alc662_models,
16057 alc662_cfg_tbl);
16058 if (board_config < 0) {
16059 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16060 "trying auto-probe from BIOS...\n");
16061 board_config = ALC662_AUTO;
16062 }
16063
16064 if (board_config == ALC662_AUTO) {
16065 /* automatic parse from the BIOS config */
16066 err = alc662_parse_auto_config(codec);
16067 if (err < 0) {
16068 alc_free(codec);
16069 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020016070 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016071 printk(KERN_INFO
16072 "hda_codec: Cannot set up configuration "
16073 "from BIOS. Using base mode...\n");
16074 board_config = ALC662_3ST_2ch_DIG;
16075 }
16076 }
16077
16078 if (board_config != ALC662_AUTO)
16079 setup_preset(spec, &alc662_presets[board_config]);
16080
Kailang Yang6dda9f42008-05-27 12:05:31 +020016081 if (codec->vendor_id == 0x10ec0663) {
16082 spec->stream_name_analog = "ALC663 Analog";
16083 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016084 } else if (codec->vendor_id == 0x10ec0272) {
16085 spec->stream_name_analog = "ALC272 Analog";
16086 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016087 } else {
16088 spec->stream_name_analog = "ALC662 Analog";
16089 spec->stream_name_digital = "ALC662 Digital";
16090 }
16091
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016092 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16093 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16094
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016095 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16096 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16097
Takashi Iwaie1406342008-02-11 18:32:32 +010016098 spec->adc_nids = alc662_adc_nids;
16099 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16100 spec->capsrc_nids = alc662_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010016101 spec->is_mix_capture = 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016102
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016103 if (!spec->cap_mixer)
16104 set_capture_mixer(spec);
16105
Takashi Iwai2134ea42008-01-10 16:53:55 +010016106 spec->vmaster_nid = 0x02;
16107
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016108 codec->patch_ops = alc_patch_ops;
16109 if (board_config == ALC662_AUTO)
16110 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016111#ifdef CONFIG_SND_HDA_POWER_SAVE
16112 if (!spec->loopback.amplist)
16113 spec->loopback.amplist = alc662_loopbacks;
16114#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016115
16116 return 0;
16117}
16118
16119/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016120 * patch entries
16121 */
16122struct hda_codec_preset snd_hda_preset_realtek[] = {
16123 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016124 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016125 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016126 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016127 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016128 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016129 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016130 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016131 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16132 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16133 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016134 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16135 .patch = patch_alc883 },
16136 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16137 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016138 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016139 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016140 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016141 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016142 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16143 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016144 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016145 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016146 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016147 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016148 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016149 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16150 .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016151 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016152 {} /* terminator */
16153};