blob: 834dae74d7ee73e08f972348e6c4af9fa93484ea [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010033#include "hda_patch.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010081#ifdef CONFIG_SND_DEBUG
82 ALC260_TEST,
83#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010084 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020085 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
Kailang Yangdf694da2005-12-05 19:42:22 +010088/* ALC262 models */
89enum {
90 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020091 ALC262_HIPPO,
92 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010093 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020094 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010095 ALC262_HP_BPC_D7000_WL,
96 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010097 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010098 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020099 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200100 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200101 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200102 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100103 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200104 ALC262_NEC,
Kailang Yangdf694da2005-12-05 19:42:22 +0100105 ALC262_AUTO,
106 ALC262_MODEL_LAST /* last tag */
107};
108
Kailang Yanga361d842007-06-05 12:30:55 +0200109/* ALC268 models */
110enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200111 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200112 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200113 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200114 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100115 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100116 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100117#ifdef CONFIG_SND_DEBUG
118 ALC268_TEST,
119#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200120 ALC268_AUTO,
121 ALC268_MODEL_LAST /* last tag */
122};
123
Kailang Yangf6a92242007-12-13 16:52:54 +0100124/* ALC269 models */
125enum {
126 ALC269_BASIC,
Kailang Yangf53281e2008-07-18 12:36:43 +0200127 ALC269_ASUS_EEEPC_P703,
128 ALC269_ASUS_EEEPC_P901,
Kailang Yangf6a92242007-12-13 16:52:54 +0100129 ALC269_AUTO,
130 ALC269_MODEL_LAST /* last tag */
131};
132
Kailang Yangdf694da2005-12-05 19:42:22 +0100133/* ALC861 models */
134enum {
135 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200136 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100137 ALC861_3ST_DIG,
138 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200139 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200140 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200141 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100142 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100143 ALC861_AUTO,
144 ALC861_MODEL_LAST,
145};
146
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100147/* ALC861-VD models */
148enum {
149 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200150 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100151 ALC861VD_3ST,
152 ALC861VD_3ST_DIG,
153 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200154 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200155 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200156 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100157 ALC861VD_AUTO,
158 ALC861VD_MODEL_LAST,
159};
160
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200161/* ALC662 models */
162enum {
163 ALC662_3ST_2ch_DIG,
164 ALC662_3ST_6ch_DIG,
165 ALC662_3ST_6ch,
166 ALC662_5ST_DIG,
167 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200168 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100169 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200170 ALC663_ASUS_M51VA,
171 ALC663_ASUS_G71V,
172 ALC663_ASUS_H13,
173 ALC663_ASUS_G50V,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200174 ALC662_AUTO,
175 ALC662_MODEL_LAST,
176};
177
Kailang Yangdf694da2005-12-05 19:42:22 +0100178/* ALC882 models */
179enum {
180 ALC882_3ST_DIG,
181 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200182 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200183 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200184 ALC882_TARGA,
185 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200186 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100187 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200188 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200189 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200190 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100191 ALC882_MODEL_LAST,
192};
193
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200194/* ALC883 models */
195enum {
196 ALC883_3ST_2ch_DIG,
197 ALC883_3ST_6ch_DIG,
198 ALC883_3ST_6ch,
199 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200200 ALC883_TARGA_DIG,
201 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200202 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200203 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200204 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200205 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100206 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200207 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200208 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200209 ALC888_LENOVO_MS7195_DIG,
Kailang Yangea1fb292008-08-26 12:58:38 +0200210 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200211 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100212 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100213 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100214 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100215 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200216 ALC883_3ST_6ch_INTEL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200217 ALC883_AUTO,
218 ALC883_MODEL_LAST,
219};
220
Kailang Yangdf694da2005-12-05 19:42:22 +0100221/* for GPIO Poll */
222#define GPIO_MASK 0x03
223
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224struct alc_spec {
225 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100226 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 unsigned int num_mixers;
228
Kailang Yangdf694da2005-12-05 19:42:22 +0100229 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200230 * don't forget NULL
231 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200232 */
233 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234
Takashi Iwai16ded522005-06-10 19:58:24 +0200235 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 struct hda_pcm_stream *stream_analog_playback;
237 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100238 struct hda_pcm_stream *stream_analog_alt_playback;
239 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200241 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 struct hda_pcm_stream *stream_digital_playback;
243 struct hda_pcm_stream *stream_digital_capture;
244
245 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200246 struct hda_multi_out multiout; /* playback set-up
247 * max_channels, dacs must be set
248 * dig_out_nid and hp_nid are optional
249 */
Takashi Iwai63300792008-01-24 15:31:36 +0100250 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
252 /* capture */
253 unsigned int num_adc_nids;
254 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100255 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200256 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
258 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200259 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 const struct hda_input_mux *input_mux;
261 unsigned int cur_mux[3];
262
263 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100264 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200266 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267
268 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100269 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200270
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200271 /* dynamic controls, init_verbs and input_mux */
272 struct auto_pin_cfg autocfg;
273 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100274 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200275 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200276 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100277
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100278 /* hooks */
279 void (*init_hook)(struct hda_codec *codec);
280 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
281
Takashi Iwai834be882006-03-01 14:16:17 +0100282 /* for pin sensing */
283 unsigned int sense_updated: 1;
284 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100285 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200286
Takashi Iwai2134ea42008-01-10 16:53:55 +0100287 /* for virtual master */
288 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200289#ifdef CONFIG_SND_HDA_POWER_SAVE
290 struct hda_loopback_check loopback;
291#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200292
293 /* for PLL fix */
294 hda_nid_t pll_nid;
295 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100296};
297
298/*
299 * configuration template - to be copied to the spec instance
300 */
301struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200302 struct snd_kcontrol_new *mixers[5]; /* should be identical size
303 * with spec
304 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100305 const struct hda_verb *init_verbs[5];
306 unsigned int num_dacs;
307 hda_nid_t *dac_nids;
308 hda_nid_t dig_out_nid; /* optional */
309 hda_nid_t hp_nid; /* optional */
310 unsigned int num_adc_nids;
311 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100312 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100313 hda_nid_t dig_in_nid;
314 unsigned int num_channel_mode;
315 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200316 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200317 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100318 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100319 void (*unsol_event)(struct hda_codec *, unsigned int);
320 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200321#ifdef CONFIG_SND_HDA_POWER_SAVE
322 struct hda_amp_list *loopbacks;
323#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324};
325
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326
327/*
328 * input MUX handling
329 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200330static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
331 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332{
333 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
334 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200335 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
336 if (mux_idx >= spec->num_mux_defs)
337 mux_idx = 0;
338 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339}
340
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200341static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
342 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343{
344 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
345 struct alc_spec *spec = codec->spec;
346 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
347
348 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
349 return 0;
350}
351
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200352static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
353 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354{
355 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
356 struct alc_spec *spec = codec->spec;
357 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200358 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100359 hda_nid_t nid = spec->capsrc_nids ?
360 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200361 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100362 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363}
364
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200365
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366/*
367 * channel mode setting
368 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200369static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
370 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371{
372 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
373 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100374 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
375 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376}
377
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200378static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
379 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380{
381 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
382 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100383 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200384 spec->num_channel_mode,
385 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386}
387
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200388static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
389 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390{
391 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
392 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200393 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
394 spec->num_channel_mode,
395 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200396 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200397 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
398 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399}
400
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100402 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200403 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100404 * being part of a format specifier. Maximum allowed length of a value is
405 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100406 *
407 * Note: some retasking pin complexes seem to ignore requests for input
408 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
409 * are requested. Therefore order this list so that this behaviour will not
410 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200411 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
412 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200413 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100414static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100415 "Mic 50pc bias", "Mic 80pc bias",
416 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100417};
418static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100419 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100420};
421/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200422 * in the pin being assumed to be exclusively an input or an output pin. In
423 * addition, "input" pins may or may not process the mic bias option
424 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
425 * accept requests for bias as of chip versions up to March 2006) and/or
426 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100427 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200428#define ALC_PIN_DIR_IN 0x00
429#define ALC_PIN_DIR_OUT 0x01
430#define ALC_PIN_DIR_INOUT 0x02
431#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
432#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100433
Kailang Yangea1fb292008-08-26 12:58:38 +0200434/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100435 * For each direction the minimum and maximum values are given.
436 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200437static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100438 { 0, 2 }, /* ALC_PIN_DIR_IN */
439 { 3, 4 }, /* ALC_PIN_DIR_OUT */
440 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200441 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
442 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100443};
444#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
445#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
446#define alc_pin_mode_n_items(_dir) \
447 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
448
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200449static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
450 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200451{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100452 unsigned int item_num = uinfo->value.enumerated.item;
453 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
454
455 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200456 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100457 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
458
459 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
460 item_num = alc_pin_mode_min(dir);
461 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200462 return 0;
463}
464
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200465static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
466 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200467{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100468 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
470 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100471 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200472 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200473 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
474 AC_VERB_GET_PIN_WIDGET_CONTROL,
475 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200476
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100477 /* Find enumerated value for current pinctl setting */
478 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200479 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100480 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200481 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100482 return 0;
483}
484
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200485static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
486 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100487{
488 signed int change;
489 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
490 hda_nid_t nid = kcontrol->private_value & 0xffff;
491 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
492 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200493 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
494 AC_VERB_GET_PIN_WIDGET_CONTROL,
495 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100496
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200497 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100498 val = alc_pin_mode_min(dir);
499
500 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100501 if (change) {
502 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200503 snd_hda_codec_write_cache(codec, nid, 0,
504 AC_VERB_SET_PIN_WIDGET_CONTROL,
505 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100506
Kailang Yangea1fb292008-08-26 12:58:38 +0200507 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100508 * for the requested pin mode. Enum values of 2 or less are
509 * input modes.
510 *
511 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200512 * reduces noise slightly (particularly on input) so we'll
513 * do it. However, having both input and output buffers
514 * enabled simultaneously doesn't seem to be problematic if
515 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100516 */
517 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200518 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
519 HDA_AMP_MUTE, HDA_AMP_MUTE);
520 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
521 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100522 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200523 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
524 HDA_AMP_MUTE, HDA_AMP_MUTE);
525 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
526 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100527 }
528 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200529 return change;
530}
531
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100532#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200533 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100534 .info = alc_pin_mode_info, \
535 .get = alc_pin_mode_get, \
536 .put = alc_pin_mode_put, \
537 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100538
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100539/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
540 * together using a mask with more than one bit set. This control is
541 * currently used only by the ALC260 test model. At this stage they are not
542 * needed for any "production" models.
543 */
544#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200545#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200546
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200547static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
548 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100549{
550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
551 hda_nid_t nid = kcontrol->private_value & 0xffff;
552 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
553 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200554 unsigned int val = snd_hda_codec_read(codec, nid, 0,
555 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100556
557 *valp = (val & mask) != 0;
558 return 0;
559}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200560static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100562{
563 signed int change;
564 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
565 hda_nid_t nid = kcontrol->private_value & 0xffff;
566 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
567 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200568 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
569 AC_VERB_GET_GPIO_DATA,
570 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100571
572 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200573 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
574 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100575 gpio_data &= ~mask;
576 else
577 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200578 snd_hda_codec_write_cache(codec, nid, 0,
579 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100580
581 return change;
582}
583#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
584 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
585 .info = alc_gpio_data_info, \
586 .get = alc_gpio_data_get, \
587 .put = alc_gpio_data_put, \
588 .private_value = nid | (mask<<16) }
589#endif /* CONFIG_SND_DEBUG */
590
Jonathan Woithe92621f12006-02-28 11:47:47 +0100591/* A switch control to allow the enabling of the digital IO pins on the
592 * ALC260. This is incredibly simplistic; the intention of this control is
593 * to provide something in the test model allowing digital outputs to be
594 * identified if present. If models are found which can utilise these
595 * outputs a more complete mixer control can be devised for those models if
596 * necessary.
597 */
598#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200599#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200600
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200601static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
602 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100603{
604 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
605 hda_nid_t nid = kcontrol->private_value & 0xffff;
606 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
607 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200608 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100609 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100610
611 *valp = (val & mask) != 0;
612 return 0;
613}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200614static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100616{
617 signed int change;
618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
619 hda_nid_t nid = kcontrol->private_value & 0xffff;
620 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
621 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200622 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100623 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200624 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100625
626 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200627 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100628 if (val==0)
629 ctrl_data &= ~mask;
630 else
631 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200632 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
633 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100634
635 return change;
636}
637#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
638 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
639 .info = alc_spdif_ctrl_info, \
640 .get = alc_spdif_ctrl_get, \
641 .put = alc_spdif_ctrl_put, \
642 .private_value = nid | (mask<<16) }
643#endif /* CONFIG_SND_DEBUG */
644
Jonathan Woithef8225f62008-01-08 12:16:54 +0100645/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
646 * Again, this is only used in the ALC26x test models to help identify when
647 * the EAPD line must be asserted for features to work.
648 */
649#ifdef CONFIG_SND_DEBUG
650#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
651
652static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_value *ucontrol)
654{
655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
656 hda_nid_t nid = kcontrol->private_value & 0xffff;
657 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
658 long *valp = ucontrol->value.integer.value;
659 unsigned int val = snd_hda_codec_read(codec, nid, 0,
660 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
661
662 *valp = (val & mask) != 0;
663 return 0;
664}
665
666static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
667 struct snd_ctl_elem_value *ucontrol)
668{
669 int change;
670 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
671 hda_nid_t nid = kcontrol->private_value & 0xffff;
672 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
673 long val = *ucontrol->value.integer.value;
674 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
675 AC_VERB_GET_EAPD_BTLENABLE,
676 0x00);
677
678 /* Set/unset the masked control bit(s) as needed */
679 change = (!val ? 0 : mask) != (ctrl_data & mask);
680 if (!val)
681 ctrl_data &= ~mask;
682 else
683 ctrl_data |= mask;
684 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
685 ctrl_data);
686
687 return change;
688}
689
690#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
691 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
692 .info = alc_eapd_ctrl_info, \
693 .get = alc_eapd_ctrl_get, \
694 .put = alc_eapd_ctrl_put, \
695 .private_value = nid | (mask<<16) }
696#endif /* CONFIG_SND_DEBUG */
697
Kailang Yangdf694da2005-12-05 19:42:22 +0100698/*
699 * set up from the preset table
700 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200701static void setup_preset(struct alc_spec *spec,
702 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100703{
704 int i;
705
706 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
707 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200708 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
709 i++)
710 spec->init_verbs[spec->num_init_verbs++] =
711 preset->init_verbs[i];
Kailang Yangea1fb292008-08-26 12:58:38 +0200712
Kailang Yangdf694da2005-12-05 19:42:22 +0100713 spec->channel_mode = preset->channel_mode;
714 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200715 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100716
717 spec->multiout.max_channels = spec->channel_mode[0].channels;
718
719 spec->multiout.num_dacs = preset->num_dacs;
720 spec->multiout.dac_nids = preset->dac_nids;
721 spec->multiout.dig_out_nid = preset->dig_out_nid;
722 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200723
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200724 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200725 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200726 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100727 spec->input_mux = preset->input_mux;
728
729 spec->num_adc_nids = preset->num_adc_nids;
730 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100731 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100732 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100733
734 spec->unsol_event = preset->unsol_event;
735 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200736#ifdef CONFIG_SND_HDA_POWER_SAVE
737 spec->loopback.amplist = preset->loopbacks;
738#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100739}
740
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200741/* Enable GPIO mask and set output */
742static struct hda_verb alc_gpio1_init_verbs[] = {
743 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
744 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
745 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
746 { }
747};
748
749static struct hda_verb alc_gpio2_init_verbs[] = {
750 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
751 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
752 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
753 { }
754};
755
Kailang Yangbdd148a2007-05-08 15:19:08 +0200756static struct hda_verb alc_gpio3_init_verbs[] = {
757 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
758 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
759 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
760 { }
761};
762
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200763/*
764 * Fix hardware PLL issue
765 * On some codecs, the analog PLL gating control must be off while
766 * the default value is 1.
767 */
768static void alc_fix_pll(struct hda_codec *codec)
769{
770 struct alc_spec *spec = codec->spec;
771 unsigned int val;
772
773 if (!spec->pll_nid)
774 return;
775 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
776 spec->pll_coef_idx);
777 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
778 AC_VERB_GET_PROC_COEF, 0);
779 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
780 spec->pll_coef_idx);
781 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
782 val & ~(1 << spec->pll_coef_bit));
783}
784
785static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
786 unsigned int coef_idx, unsigned int coef_bit)
787{
788 struct alc_spec *spec = codec->spec;
789 spec->pll_nid = nid;
790 spec->pll_coef_idx = coef_idx;
791 spec->pll_coef_bit = coef_bit;
792 alc_fix_pll(codec);
793}
794
Kailang Yangc9b58002007-10-16 14:30:01 +0200795static void alc_sku_automute(struct hda_codec *codec)
796{
797 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200798 unsigned int present;
799 unsigned int hp_nid = spec->autocfg.hp_pins[0];
800 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
801
802 /* need to execute and sync at first */
803 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
804 present = snd_hda_codec_read(codec, hp_nid, 0,
805 AC_VERB_GET_PIN_SENSE, 0);
806 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100807 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
808 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200809}
810
811/* unsolicited event for HP jack sensing */
812static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
813{
814 if (codec->vendor_id == 0x10ec0880)
815 res >>= 28;
816 else
817 res >>= 26;
818 if (res != ALC880_HP_EVENT)
819 return;
820
821 alc_sku_automute(codec);
822}
823
Kailang Yangf9423e72008-05-27 12:32:25 +0200824/* additional initialization for ALC888 variants */
825static void alc888_coef_init(struct hda_codec *codec)
826{
827 unsigned int tmp;
828
829 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
830 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
831 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
832 if ((tmp & 0xf0) == 2)
833 /* alc888S-VC */
834 snd_hda_codec_read(codec, 0x20, 0,
835 AC_VERB_SET_PROC_COEF, 0x830);
836 else
837 /* alc888-VB */
838 snd_hda_codec_read(codec, 0x20, 0,
839 AC_VERB_SET_PROC_COEF, 0x3030);
840}
841
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200842/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
843 * 31 ~ 16 : Manufacture ID
844 * 15 ~ 8 : SKU ID
845 * 7 ~ 0 : Assembly ID
846 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
847 */
848static void alc_subsystem_id(struct hda_codec *codec,
849 unsigned int porta, unsigned int porte,
850 unsigned int portd)
851{
Kailang Yangc9b58002007-10-16 14:30:01 +0200852 unsigned int ass, tmp, i;
853 unsigned nid;
854 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200855
Kailang Yangc9b58002007-10-16 14:30:01 +0200856 ass = codec->subsystem_id & 0xffff;
857 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
858 goto do_sku;
859
Kailang Yangea1fb292008-08-26 12:58:38 +0200860 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200861 * 31~30 : port conetcivity
862 * 29~21 : reserve
863 * 20 : PCBEEP input
864 * 19~16 : Check sum (15:1)
865 * 15~1 : Custom
866 * 0 : override
867 */
868 nid = 0x1d;
869 if (codec->vendor_id == 0x10ec0260)
870 nid = 0x17;
871 ass = snd_hda_codec_read(codec, nid, 0,
872 AC_VERB_GET_CONFIG_DEFAULT, 0);
873 if (!(ass & 1) && !(ass & 0x100000))
874 return;
875 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200876 return;
877
Kailang Yangc9b58002007-10-16 14:30:01 +0200878 /* check sum */
879 tmp = 0;
880 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100881 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200882 tmp++;
883 }
884 if (((ass >> 16) & 0xf) != tmp)
885 return;
886do_sku:
887 /*
888 * 0 : override
889 * 1 : Swap Jack
890 * 2 : 0 --> Desktop, 1 --> Laptop
891 * 3~5 : External Amplifier control
892 * 7~6 : Reserved
893 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200894 tmp = (ass & 0x38) >> 3; /* external Amp control */
895 switch (tmp) {
896 case 1:
897 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
898 break;
899 case 3:
900 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
901 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200902 case 7:
903 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
904 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200905 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200906 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200907 case 0x10ec0260:
908 snd_hda_codec_write(codec, 0x0f, 0,
909 AC_VERB_SET_EAPD_BTLENABLE, 2);
910 snd_hda_codec_write(codec, 0x10, 0,
911 AC_VERB_SET_EAPD_BTLENABLE, 2);
912 break;
913 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200914 case 0x10ec0267:
915 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200916 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +0200917 case 0x10ec0660:
918 case 0x10ec0662:
919 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +0200920 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200921 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200922 snd_hda_codec_write(codec, 0x14, 0,
923 AC_VERB_SET_EAPD_BTLENABLE, 2);
924 snd_hda_codec_write(codec, 0x15, 0,
925 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200926 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200927 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200928 switch (codec->vendor_id) {
929 case 0x10ec0260:
930 snd_hda_codec_write(codec, 0x1a, 0,
931 AC_VERB_SET_COEF_INDEX, 7);
932 tmp = snd_hda_codec_read(codec, 0x1a, 0,
933 AC_VERB_GET_PROC_COEF, 0);
934 snd_hda_codec_write(codec, 0x1a, 0,
935 AC_VERB_SET_COEF_INDEX, 7);
936 snd_hda_codec_write(codec, 0x1a, 0,
937 AC_VERB_SET_PROC_COEF,
938 tmp | 0x2010);
939 break;
940 case 0x10ec0262:
941 case 0x10ec0880:
942 case 0x10ec0882:
943 case 0x10ec0883:
944 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200945 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +0200946 snd_hda_codec_write(codec, 0x20, 0,
947 AC_VERB_SET_COEF_INDEX, 7);
948 tmp = snd_hda_codec_read(codec, 0x20, 0,
949 AC_VERB_GET_PROC_COEF, 0);
950 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200951 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200952 snd_hda_codec_write(codec, 0x20, 0,
953 AC_VERB_SET_PROC_COEF,
954 tmp | 0x2010);
955 break;
Kailang Yangf9423e72008-05-27 12:32:25 +0200956 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +0200957 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +0200958 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200959 case 0x10ec0267:
960 case 0x10ec0268:
961 snd_hda_codec_write(codec, 0x20, 0,
962 AC_VERB_SET_COEF_INDEX, 7);
963 tmp = snd_hda_codec_read(codec, 0x20, 0,
964 AC_VERB_GET_PROC_COEF, 0);
965 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200966 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200967 snd_hda_codec_write(codec, 0x20, 0,
968 AC_VERB_SET_PROC_COEF,
969 tmp | 0x3000);
970 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200971 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200972 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200973 break;
974 }
Kailang Yangea1fb292008-08-26 12:58:38 +0200975
Kailang Yang8c427222008-01-10 13:03:59 +0100976 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200977 * when the external headphone out jack is plugged"
978 */
Kailang Yang8c427222008-01-10 13:03:59 +0100979 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200980 return;
981 /*
982 * 10~8 : Jack location
983 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
984 * 14~13: Resvered
985 * 15 : 1 --> enable the function "Mute internal speaker
986 * when the external headphone out jack is plugged"
987 */
988 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100989 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200990 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100991 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200992 else
993 return;
994 }
995
996 if (!spec->autocfg.hp_pins[0]) {
997 tmp = (ass >> 11) & 0x3; /* HP to chassis */
998 if (tmp == 0)
999 spec->autocfg.hp_pins[0] = porta;
1000 else if (tmp == 1)
1001 spec->autocfg.hp_pins[0] = porte;
1002 else if (tmp == 2)
1003 spec->autocfg.hp_pins[0] = portd;
1004 else
1005 return;
1006 }
1007
1008 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1009 AC_VERB_SET_UNSOLICITED_ENABLE,
1010 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangea1fb292008-08-26 12:58:38 +02001011
Kailang Yangc9b58002007-10-16 14:30:01 +02001012 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001013}
1014
Takashi Iwai41e41f12005-06-08 14:48:49 +02001015/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001016 * Fix-up pin default configurations
1017 */
1018
1019struct alc_pincfg {
1020 hda_nid_t nid;
1021 u32 val;
1022};
1023
1024static void alc_fix_pincfg(struct hda_codec *codec,
1025 const struct snd_pci_quirk *quirk,
1026 const struct alc_pincfg **pinfix)
1027{
1028 const struct alc_pincfg *cfg;
1029
1030 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1031 if (!quirk)
1032 return;
1033
1034 cfg = pinfix[quirk->value];
1035 for (; cfg->nid; cfg++) {
1036 int i;
1037 u32 val = cfg->val;
1038 for (i = 0; i < 4; i++) {
1039 snd_hda_codec_write(codec, cfg->nid, 0,
1040 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1041 val & 0xff);
1042 val >>= 8;
1043 }
1044 }
1045}
1046
1047/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001048 * ALC880 3-stack model
1049 *
1050 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001051 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1052 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 */
1054
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001055static hda_nid_t alc880_dac_nids[4] = {
1056 /* front, rear, clfe, rear_surr */
1057 0x02, 0x05, 0x04, 0x03
1058};
1059
1060static hda_nid_t alc880_adc_nids[3] = {
1061 /* ADC0-2 */
1062 0x07, 0x08, 0x09,
1063};
1064
1065/* The datasheet says the node 0x07 is connected from inputs,
1066 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001067 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001069static hda_nid_t alc880_adc_nids_alt[2] = {
1070 /* ADC1-2 */
1071 0x08, 0x09,
1072};
1073
1074#define ALC880_DIGOUT_NID 0x06
1075#define ALC880_DIGIN_NID 0x0a
1076
1077static struct hda_input_mux alc880_capture_source = {
1078 .num_items = 4,
1079 .items = {
1080 { "Mic", 0x0 },
1081 { "Front Mic", 0x3 },
1082 { "Line", 0x2 },
1083 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001085};
1086
1087/* channel source setting (2/6 channel selection for 3-stack) */
1088/* 2ch mode */
1089static struct hda_verb alc880_threestack_ch2_init[] = {
1090 /* set line-in to input, mute it */
1091 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1092 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1093 /* set mic-in to input vref 80%, mute it */
1094 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1095 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096 { } /* end */
1097};
1098
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001099/* 6ch mode */
1100static struct hda_verb alc880_threestack_ch6_init[] = {
1101 /* set line-in to output, unmute it */
1102 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1103 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1104 /* set mic-in to output, unmute it */
1105 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1106 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1107 { } /* end */
1108};
1109
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001110static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001111 { 2, alc880_threestack_ch2_init },
1112 { 6, alc880_threestack_ch6_init },
1113};
1114
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001115static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001116 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001117 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001118 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001119 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001120 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1121 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001122 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1123 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1125 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1126 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1127 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1129 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1130 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1131 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1132 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1133 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001135 {
1136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1137 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001138 .info = alc_ch_mode_info,
1139 .get = alc_ch_mode_get,
1140 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001141 },
1142 { } /* end */
1143};
1144
1145/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001146static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001147 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1148 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1149 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1150 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1151 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1152 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1153 {
1154 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1155 /* The multiple "Capture Source" controls confuse alsamixer
1156 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001157 */
1158 /* .name = "Capture Source", */
1159 .name = "Input Source",
1160 .count = 3,
1161 .info = alc_mux_enum_info,
1162 .get = alc_mux_enum_get,
1163 .put = alc_mux_enum_put,
1164 },
1165 { } /* end */
1166};
1167
1168/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001169static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001170 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1171 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1172 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1173 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 {
1175 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1176 /* The multiple "Capture Source" controls confuse alsamixer
1177 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178 */
1179 /* .name = "Capture Source", */
1180 .name = "Input Source",
1181 .count = 2,
1182 .info = alc_mux_enum_info,
1183 .get = alc_mux_enum_get,
1184 .put = alc_mux_enum_put,
1185 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 { } /* end */
1187};
1188
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001189
1190
1191/*
1192 * ALC880 5-stack model
1193 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001194 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1195 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001196 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1197 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1198 */
1199
1200/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001201static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001202 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001203 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204 { } /* end */
1205};
1206
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001207/* channel source setting (6/8 channel selection for 5-stack) */
1208/* 6ch mode */
1209static struct hda_verb alc880_fivestack_ch6_init[] = {
1210 /* set line-in to input, mute it */
1211 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1212 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001213 { } /* end */
1214};
1215
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001216/* 8ch mode */
1217static struct hda_verb alc880_fivestack_ch8_init[] = {
1218 /* set line-in to output, unmute it */
1219 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1220 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1221 { } /* end */
1222};
1223
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001224static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001225 { 6, alc880_fivestack_ch6_init },
1226 { 8, alc880_fivestack_ch8_init },
1227};
1228
1229
1230/*
1231 * ALC880 6-stack model
1232 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001233 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1234 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001235 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1236 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1237 */
1238
1239static hda_nid_t alc880_6st_dac_nids[4] = {
1240 /* front, rear, clfe, rear_surr */
1241 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001242};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001243
1244static struct hda_input_mux alc880_6stack_capture_source = {
1245 .num_items = 4,
1246 .items = {
1247 { "Mic", 0x0 },
1248 { "Front Mic", 0x1 },
1249 { "Line", 0x2 },
1250 { "CD", 0x4 },
1251 },
1252};
1253
1254/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001255static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001256 { 8, NULL },
1257};
1258
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001259static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001260 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001261 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001262 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001263 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001264 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1265 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001266 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1267 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001268 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001269 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001270 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1271 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1272 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1273 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1275 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1276 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1277 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1278 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1279 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001280 {
1281 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1282 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001283 .info = alc_ch_mode_info,
1284 .get = alc_ch_mode_get,
1285 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001286 },
1287 { } /* end */
1288};
1289
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001290
1291/*
1292 * ALC880 W810 model
1293 *
1294 * W810 has rear IO for:
1295 * Front (DAC 02)
1296 * Surround (DAC 03)
1297 * Center/LFE (DAC 04)
1298 * Digital out (06)
1299 *
1300 * The system also has a pair of internal speakers, and a headphone jack.
1301 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001302 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001303 * There is a variable resistor to control the speaker or headphone
1304 * volume. This is a hardware-only device without a software API.
1305 *
1306 * Plugging headphones in will disable the internal speakers. This is
1307 * implemented in hardware, not via the driver using jack sense. In
1308 * a similar fashion, plugging into the rear socket marked "front" will
1309 * disable both the speakers and headphones.
1310 *
1311 * For input, there's a microphone jack, and an "audio in" jack.
1312 * These may not do anything useful with this driver yet, because I
1313 * haven't setup any initialization verbs for these yet...
1314 */
1315
1316static hda_nid_t alc880_w810_dac_nids[3] = {
1317 /* front, rear/surround, clfe */
1318 0x02, 0x03, 0x04
1319};
1320
1321/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001322static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001323 { 6, NULL }
1324};
1325
1326/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001327static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001328 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001329 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001330 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001331 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001332 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1333 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001334 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1335 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001336 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1337 { } /* end */
1338};
1339
1340
1341/*
1342 * Z710V model
1343 *
1344 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001345 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1346 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001347 */
1348
1349static hda_nid_t alc880_z71v_dac_nids[1] = {
1350 0x02
1351};
1352#define ALC880_Z71V_HP_DAC 0x03
1353
1354/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001355static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001356 { 2, NULL }
1357};
1358
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001359static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001360 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001361 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001362 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001363 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001364 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1365 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1368 { } /* end */
1369};
1370
1371
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001372/*
1373 * ALC880 F1734 model
1374 *
1375 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1376 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1377 */
1378
1379static hda_nid_t alc880_f1734_dac_nids[1] = {
1380 0x03
1381};
1382#define ALC880_F1734_HP_DAC 0x02
1383
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001384static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001385 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001386 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001387 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1388 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001389 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1390 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1392 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001393 { } /* end */
1394};
1395
Takashi Iwai937b4162008-02-11 14:52:36 +01001396static struct hda_input_mux alc880_f1734_capture_source = {
1397 .num_items = 2,
1398 .items = {
1399 { "Mic", 0x1 },
1400 { "CD", 0x4 },
1401 },
1402};
1403
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001404
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001405/*
1406 * ALC880 ASUS model
1407 *
1408 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1409 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1410 * Mic = 0x18, Line = 0x1a
1411 */
1412
1413#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1414#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1415
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001416static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001417 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001418 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001419 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001420 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001421 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1422 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001423 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1424 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001425 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1426 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1427 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1428 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1429 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1430 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001431 {
1432 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1433 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001434 .info = alc_ch_mode_info,
1435 .get = alc_ch_mode_get,
1436 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001437 },
1438 { } /* end */
1439};
1440
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001441/*
1442 * ALC880 ASUS W1V model
1443 *
1444 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1445 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1446 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1447 */
1448
1449/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001450static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001451 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1452 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001453 { } /* end */
1454};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001455
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001456/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001457static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001458 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1459 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1460 { } /* end */
1461};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001462
Kailang Yangdf694da2005-12-05 19:42:22 +01001463/* TCL S700 */
1464static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1465 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1466 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1467 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1468 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1469 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1470 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1471 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1472 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1473 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1474 {
1475 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1476 /* The multiple "Capture Source" controls confuse alsamixer
1477 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001478 */
1479 /* .name = "Capture Source", */
1480 .name = "Input Source",
1481 .count = 1,
1482 .info = alc_mux_enum_info,
1483 .get = alc_mux_enum_get,
1484 .put = alc_mux_enum_put,
1485 },
1486 { } /* end */
1487};
1488
Kailang Yangccc656c2006-10-17 12:32:26 +02001489/* Uniwill */
1490static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001491 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1492 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1493 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1494 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001495 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1496 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1497 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1498 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1499 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1500 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1501 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1502 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1504 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1505 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1506 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1507 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1508 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1509 {
1510 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1511 .name = "Channel Mode",
1512 .info = alc_ch_mode_info,
1513 .get = alc_ch_mode_get,
1514 .put = alc_ch_mode_put,
1515 },
1516 { } /* end */
1517};
1518
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001519static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1520 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1521 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1522 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1523 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1524 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1525 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1526 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1527 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1528 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1529 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1530 { } /* end */
1531};
1532
Kailang Yangccc656c2006-10-17 12:32:26 +02001533static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001534 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1535 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1536 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1537 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1540 { } /* end */
1541};
1542
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001544 * virtual master controls
1545 */
1546
1547/*
1548 * slave controls for virtual master
1549 */
1550static const char *alc_slave_vols[] = {
1551 "Front Playback Volume",
1552 "Surround Playback Volume",
1553 "Center Playback Volume",
1554 "LFE Playback Volume",
1555 "Side Playback Volume",
1556 "Headphone Playback Volume",
1557 "Speaker Playback Volume",
1558 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001559 "Line-Out Playback Volume",
1560 NULL,
1561};
1562
1563static const char *alc_slave_sws[] = {
1564 "Front Playback Switch",
1565 "Surround Playback Switch",
1566 "Center Playback Switch",
1567 "LFE Playback Switch",
1568 "Side Playback Switch",
1569 "Headphone Playback Switch",
1570 "Speaker Playback Switch",
1571 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001572 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001573 NULL,
1574};
1575
1576/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001577 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578 */
1579static int alc_build_controls(struct hda_codec *codec)
1580{
1581 struct alc_spec *spec = codec->spec;
1582 int err;
1583 int i;
1584
1585 for (i = 0; i < spec->num_mixers; i++) {
1586 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1587 if (err < 0)
1588 return err;
1589 }
1590
1591 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001592 err = snd_hda_create_spdif_out_ctls(codec,
1593 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001594 if (err < 0)
1595 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001596 err = snd_hda_create_spdif_share_sw(codec,
1597 &spec->multiout);
1598 if (err < 0)
1599 return err;
1600 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001601 }
1602 if (spec->dig_in_nid) {
1603 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1604 if (err < 0)
1605 return err;
1606 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001607
1608 /* if we have no master control, let's create it */
1609 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001610 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001611 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001612 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001613 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001614 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001615 if (err < 0)
1616 return err;
1617 }
1618 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1619 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1620 NULL, alc_slave_sws);
1621 if (err < 0)
1622 return err;
1623 }
1624
Linus Torvalds1da177e2005-04-16 15:20:36 -07001625 return 0;
1626}
1627
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001628
Linus Torvalds1da177e2005-04-16 15:20:36 -07001629/*
1630 * initialize the codec volumes, etc
1631 */
1632
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001633/*
1634 * generic initialization of ADC, input mixers and output mixers
1635 */
1636static struct hda_verb alc880_volume_init_verbs[] = {
1637 /*
1638 * Unmute ADC0-2 and set the default input to mic-in
1639 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001640 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001641 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001642 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001643 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001644 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001645 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001647 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1648 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001649 * Note: PASD motherboards uses the Line In 2 as the input for front
1650 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001651 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001652 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1658 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1659 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001661 /*
1662 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001663 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001664 /* set vol=0 to output mixers */
1665 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1666 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1667 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1668 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1669 /* set up input amps for analog loopback */
1670 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001671 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1672 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001673 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1674 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001675 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1676 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001677 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1678 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001679
1680 { }
1681};
1682
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001683/*
1684 * 3-stack pin configuration:
1685 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1686 */
1687static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1688 /*
1689 * preset connection lists of input pins
1690 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1691 */
1692 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1693 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1694 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1695
1696 /*
1697 * Set pin mode and muting
1698 */
1699 /* set front pin widgets 0x14 for output */
1700 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1701 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1702 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1703 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1704 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1705 /* Mic2 (as headphone out) for HP output */
1706 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1707 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1708 /* Line In pin widget for input */
1709 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1711 /* Line2 (as front mic) pin widget for input and vref at 80% */
1712 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1713 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1714 /* CD pin widget for input */
1715 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1716
1717 { }
1718};
1719
1720/*
1721 * 5-stack pin configuration:
1722 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1723 * line-in/side = 0x1a, f-mic = 0x1b
1724 */
1725static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1726 /*
1727 * preset connection lists of input pins
1728 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1729 */
1730 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1731 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1732
1733 /*
1734 * Set pin mode and muting
1735 */
1736 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001737 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1738 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1739 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1740 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001741 /* unmute pins for output (no gain on this amp) */
1742 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1743 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1744 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1745 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1746
Linus Torvalds1da177e2005-04-16 15:20:36 -07001747 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001748 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001749 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1750 /* Mic2 (as headphone out) for HP output */
1751 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001752 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001753 /* Line In pin widget for input */
1754 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1755 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1756 /* Line2 (as front mic) pin widget for input and vref at 80% */
1757 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1758 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1759 /* CD pin widget for input */
1760 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001761
1762 { }
1763};
1764
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001765/*
1766 * W810 pin configuration:
1767 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1768 */
1769static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001770 /* hphone/speaker input selector: front DAC */
1771 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1772
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001773 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1774 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1775 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1776 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1777 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1778 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1779
1780 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001781 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001782
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783 { }
1784};
1785
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001786/*
1787 * Z71V pin configuration:
1788 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1789 */
1790static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001791 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001793 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001794 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001795
Takashi Iwai16ded522005-06-10 19:58:24 +02001796 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001797 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001798 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001799 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001800
1801 { }
1802};
1803
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001804/*
1805 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001806 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1807 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001808 */
1809static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1810 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1811
Takashi Iwai16ded522005-06-10 19:58:24 +02001812 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001813 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001814 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001815 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001816 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001817 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001818 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001819 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1820
Takashi Iwai16ded522005-06-10 19:58:24 +02001821 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001822 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001823 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001824 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001825 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001826 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001827 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001828 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001829 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02001830
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001831 { }
1832};
Takashi Iwai16ded522005-06-10 19:58:24 +02001833
Kailang Yangccc656c2006-10-17 12:32:26 +02001834/*
1835 * Uniwill pin configuration:
1836 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1837 * line = 0x1a
1838 */
1839static struct hda_verb alc880_uniwill_init_verbs[] = {
1840 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1841
1842 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1843 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1846 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1847 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1848 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1849 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1850 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1852 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1853 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1854 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1855 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1856
1857 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1858 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1859 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1860 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1861 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1862 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1863 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1864 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1865 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1866
1867 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1868 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1869
1870 { }
1871};
1872
1873/*
1874* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02001875* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02001876 */
1877static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1878 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1879
1880 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1881 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1882 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1884 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1885 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1886 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1888 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1890 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1892
1893 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1894 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1895 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1896 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1897 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1898 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1899
1900 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1901 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1902
1903 { }
1904};
1905
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001906static struct hda_verb alc880_beep_init_verbs[] = {
1907 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1908 { }
1909};
1910
Kailang Yangccc656c2006-10-17 12:32:26 +02001911/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001912static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001913{
1914 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001915 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001916
1917 present = snd_hda_codec_read(codec, 0x14, 0,
1918 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001919 bits = present ? HDA_AMP_MUTE : 0;
1920 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1921 HDA_AMP_MUTE, bits);
1922 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1923 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001924}
1925
1926/* auto-toggle front mic */
1927static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1928{
1929 unsigned int present;
1930 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001931
1932 present = snd_hda_codec_read(codec, 0x18, 0,
1933 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001934 bits = present ? HDA_AMP_MUTE : 0;
1935 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001936}
1937
1938static void alc880_uniwill_automute(struct hda_codec *codec)
1939{
1940 alc880_uniwill_hp_automute(codec);
1941 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001942}
1943
1944static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1945 unsigned int res)
1946{
1947 /* Looks like the unsol event is incompatible with the standard
1948 * definition. 4bit tag is placed at 28 bit!
1949 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001950 switch (res >> 28) {
1951 case ALC880_HP_EVENT:
1952 alc880_uniwill_hp_automute(codec);
1953 break;
1954 case ALC880_MIC_EVENT:
1955 alc880_uniwill_mic_automute(codec);
1956 break;
1957 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001958}
1959
1960static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1961{
1962 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001963 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001964
1965 present = snd_hda_codec_read(codec, 0x14, 0,
1966 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001967 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02001968 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001969}
1970
1971static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1972{
1973 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02001974
Kailang Yangccc656c2006-10-17 12:32:26 +02001975 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001976 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1977 present &= HDA_AMP_VOLMASK;
1978 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1979 HDA_AMP_VOLMASK, present);
1980 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1981 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001982}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001983
Kailang Yangccc656c2006-10-17 12:32:26 +02001984static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1985 unsigned int res)
1986{
1987 /* Looks like the unsol event is incompatible with the standard
1988 * definition. 4bit tag is placed at 28 bit!
1989 */
1990 if ((res >> 28) == ALC880_HP_EVENT)
1991 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001992 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001993 alc880_uniwill_p53_dcvol_automute(codec);
1994}
1995
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001996/*
1997 * F1734 pin configuration:
1998 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1999 */
2000static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002001 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002002 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2003 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2004 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2005 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2006
2007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2008 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2009 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2011
2012 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2013 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002014 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002015 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2016 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2017 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2018 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2019 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2020 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002021
Takashi Iwai937b4162008-02-11 14:52:36 +01002022 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2023 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2024
Takashi Iwai16ded522005-06-10 19:58:24 +02002025 { }
2026};
2027
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002028/*
2029 * ASUS pin configuration:
2030 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2031 */
2032static struct hda_verb alc880_pin_asus_init_verbs[] = {
2033 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2034 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2035 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2036 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2037
2038 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2039 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2040 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2041 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2042 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2043 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2044 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2045 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2046
2047 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2049 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2050 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2051 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2052 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2053 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2054 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2055 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002056
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002057 { }
2058};
2059
2060/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002061#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2062#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002063
Kailang Yangdf694da2005-12-05 19:42:22 +01002064/* Clevo m520g init */
2065static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2066 /* headphone output */
2067 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2068 /* line-out */
2069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2070 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2071 /* Line-in */
2072 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2073 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2074 /* CD */
2075 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2076 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2077 /* Mic1 (rear panel) */
2078 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2079 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2080 /* Mic2 (front panel) */
2081 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2082 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2083 /* headphone */
2084 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2085 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2086 /* change to EAPD mode */
2087 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2088 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2089
2090 { }
2091};
2092
2093static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002094 /* change to EAPD mode */
2095 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2096 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2097
Kailang Yangdf694da2005-12-05 19:42:22 +01002098 /* Headphone output */
2099 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2100 /* Front output*/
2101 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2102 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2103
2104 /* Line In pin widget for input */
2105 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2106 /* CD pin widget for input */
2107 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2108 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2109 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2110
2111 /* change to EAPD mode */
2112 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2113 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2114
2115 { }
2116};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002117
2118/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002119 * LG m1 express dual
2120 *
2121 * Pin assignment:
2122 * Rear Line-In/Out (blue): 0x14
2123 * Build-in Mic-In: 0x15
2124 * Speaker-out: 0x17
2125 * HP-Out (green): 0x1b
2126 * Mic-In/Out (red): 0x19
2127 * SPDIF-Out: 0x1e
2128 */
2129
2130/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2131static hda_nid_t alc880_lg_dac_nids[3] = {
2132 0x05, 0x02, 0x03
2133};
2134
2135/* seems analog CD is not working */
2136static struct hda_input_mux alc880_lg_capture_source = {
2137 .num_items = 3,
2138 .items = {
2139 { "Mic", 0x1 },
2140 { "Line", 0x5 },
2141 { "Internal Mic", 0x6 },
2142 },
2143};
2144
2145/* 2,4,6 channel modes */
2146static struct hda_verb alc880_lg_ch2_init[] = {
2147 /* set line-in and mic-in to input */
2148 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2149 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2150 { }
2151};
2152
2153static struct hda_verb alc880_lg_ch4_init[] = {
2154 /* set line-in to out and mic-in to input */
2155 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2156 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2157 { }
2158};
2159
2160static struct hda_verb alc880_lg_ch6_init[] = {
2161 /* set line-in and mic-in to output */
2162 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2163 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2164 { }
2165};
2166
2167static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2168 { 2, alc880_lg_ch2_init },
2169 { 4, alc880_lg_ch4_init },
2170 { 6, alc880_lg_ch6_init },
2171};
2172
2173static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002174 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2175 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002176 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2177 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2178 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2179 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2180 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2181 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2184 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2185 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2186 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2187 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2188 {
2189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2190 .name = "Channel Mode",
2191 .info = alc_ch_mode_info,
2192 .get = alc_ch_mode_get,
2193 .put = alc_ch_mode_put,
2194 },
2195 { } /* end */
2196};
2197
2198static struct hda_verb alc880_lg_init_verbs[] = {
2199 /* set capture source to mic-in */
2200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2201 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2203 /* mute all amp mixer inputs */
2204 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002205 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002207 /* line-in to input */
2208 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2210 /* built-in mic */
2211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2213 /* speaker-out */
2214 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2215 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2216 /* mic-in to input */
2217 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2218 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2219 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2220 /* HP-out */
2221 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2222 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2223 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2224 /* jack sense */
2225 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2226 { }
2227};
2228
2229/* toggle speaker-output according to the hp-jack state */
2230static void alc880_lg_automute(struct hda_codec *codec)
2231{
2232 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002233 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002234
2235 present = snd_hda_codec_read(codec, 0x1b, 0,
2236 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002237 bits = present ? HDA_AMP_MUTE : 0;
2238 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2239 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002240}
2241
2242static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2243{
2244 /* Looks like the unsol event is incompatible with the standard
2245 * definition. 4bit tag is placed at 28 bit!
2246 */
2247 if ((res >> 28) == 0x01)
2248 alc880_lg_automute(codec);
2249}
2250
2251/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002252 * LG LW20
2253 *
2254 * Pin assignment:
2255 * Speaker-out: 0x14
2256 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002257 * Built-in Mic-In: 0x19
2258 * Line-In: 0x1b
2259 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002260 * SPDIF-Out: 0x1e
2261 */
2262
Takashi Iwaid6815182006-03-23 16:06:23 +01002263static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002264 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002265 .items = {
2266 { "Mic", 0x0 },
2267 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002268 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002269 },
2270};
2271
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002272#define alc880_lg_lw_modes alc880_threestack_modes
2273
Takashi Iwaid6815182006-03-23 16:06:23 +01002274static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002275 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2276 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2277 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2278 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2279 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2280 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2281 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2282 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2283 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2284 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002285 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2286 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2287 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2288 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002289 {
2290 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2291 .name = "Channel Mode",
2292 .info = alc_ch_mode_info,
2293 .get = alc_ch_mode_get,
2294 .put = alc_ch_mode_put,
2295 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002296 { } /* end */
2297};
2298
2299static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002300 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2301 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2302 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2303
Takashi Iwaid6815182006-03-23 16:06:23 +01002304 /* set capture source to mic-in */
2305 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2307 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002309 /* speaker-out */
2310 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2311 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2312 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002313 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2314 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2315 /* mic-in to input */
2316 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2317 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2318 /* built-in mic */
2319 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2320 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2321 /* jack sense */
2322 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2323 { }
2324};
2325
2326/* toggle speaker-output according to the hp-jack state */
2327static void alc880_lg_lw_automute(struct hda_codec *codec)
2328{
2329 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002330 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002331
2332 present = snd_hda_codec_read(codec, 0x1b, 0,
2333 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002334 bits = present ? HDA_AMP_MUTE : 0;
2335 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2336 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002337}
2338
2339static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2340{
2341 /* Looks like the unsol event is incompatible with the standard
2342 * definition. 4bit tag is placed at 28 bit!
2343 */
2344 if ((res >> 28) == 0x01)
2345 alc880_lg_lw_automute(codec);
2346}
2347
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002348static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2349 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2350 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2353 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2354 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2355 { } /* end */
2356};
2357
2358static struct hda_input_mux alc880_medion_rim_capture_source = {
2359 .num_items = 2,
2360 .items = {
2361 { "Mic", 0x0 },
2362 { "Internal Mic", 0x1 },
2363 },
2364};
2365
2366static struct hda_verb alc880_medion_rim_init_verbs[] = {
2367 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2368
2369 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2370 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2371
2372 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2373 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2374 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2375 /* Mic2 (as headphone out) for HP output */
2376 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2377 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2378 /* Internal Speaker */
2379 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2380 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2381
2382 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2383 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2384
2385 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2386 { }
2387};
2388
2389/* toggle speaker-output according to the hp-jack state */
2390static void alc880_medion_rim_automute(struct hda_codec *codec)
2391{
2392 unsigned int present;
2393 unsigned char bits;
2394
2395 present = snd_hda_codec_read(codec, 0x14, 0,
2396 AC_VERB_GET_PIN_SENSE, 0)
2397 & AC_PINSENSE_PRESENCE;
2398 bits = present ? HDA_AMP_MUTE : 0;
2399 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2400 HDA_AMP_MUTE, bits);
2401 if (present)
2402 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2403 else
2404 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2405}
2406
2407static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2408 unsigned int res)
2409{
2410 /* Looks like the unsol event is incompatible with the standard
2411 * definition. 4bit tag is placed at 28 bit!
2412 */
2413 if ((res >> 28) == ALC880_HP_EVENT)
2414 alc880_medion_rim_automute(codec);
2415}
2416
Takashi Iwaicb53c622007-08-10 17:21:45 +02002417#ifdef CONFIG_SND_HDA_POWER_SAVE
2418static struct hda_amp_list alc880_loopbacks[] = {
2419 { 0x0b, HDA_INPUT, 0 },
2420 { 0x0b, HDA_INPUT, 1 },
2421 { 0x0b, HDA_INPUT, 2 },
2422 { 0x0b, HDA_INPUT, 3 },
2423 { 0x0b, HDA_INPUT, 4 },
2424 { } /* end */
2425};
2426
2427static struct hda_amp_list alc880_lg_loopbacks[] = {
2428 { 0x0b, HDA_INPUT, 1 },
2429 { 0x0b, HDA_INPUT, 6 },
2430 { 0x0b, HDA_INPUT, 7 },
2431 { } /* end */
2432};
2433#endif
2434
Takashi Iwaid6815182006-03-23 16:06:23 +01002435/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002436 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002437 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002438
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439static int alc_init(struct hda_codec *codec)
2440{
2441 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002442 unsigned int i;
2443
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002444 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002445 if (codec->vendor_id == 0x10ec0888)
2446 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002447
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002448 for (i = 0; i < spec->num_init_verbs; i++)
2449 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002450
2451 if (spec->init_hook)
2452 spec->init_hook(codec);
2453
Linus Torvalds1da177e2005-04-16 15:20:36 -07002454 return 0;
2455}
2456
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002457static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2458{
2459 struct alc_spec *spec = codec->spec;
2460
2461 if (spec->unsol_event)
2462 spec->unsol_event(codec, res);
2463}
2464
Takashi Iwaicb53c622007-08-10 17:21:45 +02002465#ifdef CONFIG_SND_HDA_POWER_SAVE
2466static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2467{
2468 struct alc_spec *spec = codec->spec;
2469 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2470}
2471#endif
2472
Linus Torvalds1da177e2005-04-16 15:20:36 -07002473/*
2474 * Analog playback callbacks
2475 */
2476static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2477 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002478 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002479{
2480 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002481 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2482 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483}
2484
2485static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2486 struct hda_codec *codec,
2487 unsigned int stream_tag,
2488 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002489 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490{
2491 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002492 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2493 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494}
2495
2496static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2497 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002498 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002499{
2500 struct alc_spec *spec = codec->spec;
2501 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2502}
2503
2504/*
2505 * Digital out
2506 */
2507static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2508 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002509 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002510{
2511 struct alc_spec *spec = codec->spec;
2512 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2513}
2514
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002515static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2516 struct hda_codec *codec,
2517 unsigned int stream_tag,
2518 unsigned int format,
2519 struct snd_pcm_substream *substream)
2520{
2521 struct alc_spec *spec = codec->spec;
2522 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2523 stream_tag, format, substream);
2524}
2525
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2527 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002528 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002529{
2530 struct alc_spec *spec = codec->spec;
2531 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2532}
2533
2534/*
2535 * Analog capture
2536 */
Takashi Iwai63300792008-01-24 15:31:36 +01002537static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002538 struct hda_codec *codec,
2539 unsigned int stream_tag,
2540 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002541 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002542{
2543 struct alc_spec *spec = codec->spec;
2544
Takashi Iwai63300792008-01-24 15:31:36 +01002545 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546 stream_tag, 0, format);
2547 return 0;
2548}
2549
Takashi Iwai63300792008-01-24 15:31:36 +01002550static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002552 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553{
2554 struct alc_spec *spec = codec->spec;
2555
Takashi Iwai888afa12008-03-18 09:57:50 +01002556 snd_hda_codec_cleanup_stream(codec,
2557 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002558 return 0;
2559}
2560
2561
2562/*
2563 */
2564static struct hda_pcm_stream alc880_pcm_analog_playback = {
2565 .substreams = 1,
2566 .channels_min = 2,
2567 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002568 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002569 .ops = {
2570 .open = alc880_playback_pcm_open,
2571 .prepare = alc880_playback_pcm_prepare,
2572 .cleanup = alc880_playback_pcm_cleanup
2573 },
2574};
2575
2576static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002577 .substreams = 1,
2578 .channels_min = 2,
2579 .channels_max = 2,
2580 /* NID is set in alc_build_pcms */
2581};
2582
2583static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2584 .substreams = 1,
2585 .channels_min = 2,
2586 .channels_max = 2,
2587 /* NID is set in alc_build_pcms */
2588};
2589
2590static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2591 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002592 .channels_min = 2,
2593 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002594 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002595 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002596 .prepare = alc880_alt_capture_pcm_prepare,
2597 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002598 },
2599};
2600
2601static struct hda_pcm_stream alc880_pcm_digital_playback = {
2602 .substreams = 1,
2603 .channels_min = 2,
2604 .channels_max = 2,
2605 /* NID is set in alc_build_pcms */
2606 .ops = {
2607 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002608 .close = alc880_dig_playback_pcm_close,
2609 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002610 },
2611};
2612
2613static struct hda_pcm_stream alc880_pcm_digital_capture = {
2614 .substreams = 1,
2615 .channels_min = 2,
2616 .channels_max = 2,
2617 /* NID is set in alc_build_pcms */
2618};
2619
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002620/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002621static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002622 .substreams = 0,
2623 .channels_min = 0,
2624 .channels_max = 0,
2625};
2626
Linus Torvalds1da177e2005-04-16 15:20:36 -07002627static int alc_build_pcms(struct hda_codec *codec)
2628{
2629 struct alc_spec *spec = codec->spec;
2630 struct hda_pcm *info = spec->pcm_rec;
2631 int i;
2632
2633 codec->num_pcms = 1;
2634 codec->pcm_info = info;
2635
2636 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002637 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002638 if (snd_BUG_ON(!spec->multiout.dac_nids))
2639 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002640 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2641 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2642 }
2643 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002644 if (snd_BUG_ON(!spec->adc_nids))
2645 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002646 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2647 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2648 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002649
Takashi Iwai4a471b72005-12-07 13:56:29 +01002650 if (spec->channel_mode) {
2651 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2652 for (i = 0; i < spec->num_channel_mode; i++) {
2653 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2654 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2655 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002656 }
2657 }
2658
Takashi Iwaie08a0072006-09-07 17:52:14 +02002659 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002660 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002661 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002662 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002663 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002664 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002665 if (spec->multiout.dig_out_nid &&
2666 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2668 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2669 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002670 if (spec->dig_in_nid &&
2671 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002672 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2673 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2674 }
Takashi Iwai963f8032008-08-11 10:04:40 +02002675 /* FIXME: do we need this for all Realtek codec models? */
2676 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677 }
2678
Takashi Iwaie08a0072006-09-07 17:52:14 +02002679 /* If the use of more than one ADC is requested for the current
2680 * model, configure a second analog capture-only PCM.
2681 */
2682 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002683 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2684 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002685 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002686 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002687 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002688 if (spec->alt_dac_nid) {
2689 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2690 *spec->stream_analog_alt_playback;
2691 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2692 spec->alt_dac_nid;
2693 } else {
2694 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2695 alc_pcm_null_stream;
2696 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2697 }
2698 if (spec->num_adc_nids > 1) {
2699 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2700 *spec->stream_analog_alt_capture;
2701 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2702 spec->adc_nids[1];
2703 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2704 spec->num_adc_nids - 1;
2705 } else {
2706 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2707 alc_pcm_null_stream;
2708 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002709 }
2710 }
2711
Linus Torvalds1da177e2005-04-16 15:20:36 -07002712 return 0;
2713}
2714
2715static void alc_free(struct hda_codec *codec)
2716{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002717 struct alc_spec *spec = codec->spec;
2718 unsigned int i;
2719
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002720 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002721 return;
2722
2723 if (spec->kctl_alloc) {
2724 for (i = 0; i < spec->num_kctl_used; i++)
2725 kfree(spec->kctl_alloc[i].name);
2726 kfree(spec->kctl_alloc);
2727 }
2728 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002729 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002730}
2731
2732/*
2733 */
2734static struct hda_codec_ops alc_patch_ops = {
2735 .build_controls = alc_build_controls,
2736 .build_pcms = alc_build_pcms,
2737 .init = alc_init,
2738 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002739 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002740#ifdef CONFIG_SND_HDA_POWER_SAVE
2741 .check_power_status = alc_check_power_status,
2742#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002743};
2744
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002745
2746/*
2747 * Test configuration for debugging
2748 *
2749 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2750 * enum controls.
2751 */
2752#ifdef CONFIG_SND_DEBUG
2753static hda_nid_t alc880_test_dac_nids[4] = {
2754 0x02, 0x03, 0x04, 0x05
2755};
2756
2757static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002758 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002759 .items = {
2760 { "In-1", 0x0 },
2761 { "In-2", 0x1 },
2762 { "In-3", 0x2 },
2763 { "In-4", 0x3 },
2764 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002765 { "Front", 0x5 },
2766 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002767 },
2768};
2769
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002770static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002771 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002772 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002773 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002774 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002775};
2776
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002777static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2778 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002779{
2780 static char *texts[] = {
2781 "N/A", "Line Out", "HP Out",
2782 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2783 };
2784 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2785 uinfo->count = 1;
2786 uinfo->value.enumerated.items = 8;
2787 if (uinfo->value.enumerated.item >= 8)
2788 uinfo->value.enumerated.item = 7;
2789 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2790 return 0;
2791}
2792
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002793static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2794 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002795{
2796 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2797 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2798 unsigned int pin_ctl, item = 0;
2799
2800 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2801 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2802 if (pin_ctl & AC_PINCTL_OUT_EN) {
2803 if (pin_ctl & AC_PINCTL_HP_EN)
2804 item = 2;
2805 else
2806 item = 1;
2807 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2808 switch (pin_ctl & AC_PINCTL_VREFEN) {
2809 case AC_PINCTL_VREF_HIZ: item = 3; break;
2810 case AC_PINCTL_VREF_50: item = 4; break;
2811 case AC_PINCTL_VREF_GRD: item = 5; break;
2812 case AC_PINCTL_VREF_80: item = 6; break;
2813 case AC_PINCTL_VREF_100: item = 7; break;
2814 }
2815 }
2816 ucontrol->value.enumerated.item[0] = item;
2817 return 0;
2818}
2819
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002820static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2821 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002822{
2823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2824 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2825 static unsigned int ctls[] = {
2826 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2827 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2828 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2829 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2830 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2831 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2832 };
2833 unsigned int old_ctl, new_ctl;
2834
2835 old_ctl = snd_hda_codec_read(codec, nid, 0,
2836 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2837 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2838 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002839 int val;
2840 snd_hda_codec_write_cache(codec, nid, 0,
2841 AC_VERB_SET_PIN_WIDGET_CONTROL,
2842 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002843 val = ucontrol->value.enumerated.item[0] >= 3 ?
2844 HDA_AMP_MUTE : 0;
2845 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2846 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002847 return 1;
2848 }
2849 return 0;
2850}
2851
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002852static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2853 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002854{
2855 static char *texts[] = {
2856 "Front", "Surround", "CLFE", "Side"
2857 };
2858 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2859 uinfo->count = 1;
2860 uinfo->value.enumerated.items = 4;
2861 if (uinfo->value.enumerated.item >= 4)
2862 uinfo->value.enumerated.item = 3;
2863 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2864 return 0;
2865}
2866
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002867static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2868 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002869{
2870 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2871 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2872 unsigned int sel;
2873
2874 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2875 ucontrol->value.enumerated.item[0] = sel & 3;
2876 return 0;
2877}
2878
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002879static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2880 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002881{
2882 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2883 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2884 unsigned int sel;
2885
2886 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2887 if (ucontrol->value.enumerated.item[0] != sel) {
2888 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002889 snd_hda_codec_write_cache(codec, nid, 0,
2890 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002891 return 1;
2892 }
2893 return 0;
2894}
2895
2896#define PIN_CTL_TEST(xname,nid) { \
2897 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2898 .name = xname, \
2899 .info = alc_test_pin_ctl_info, \
2900 .get = alc_test_pin_ctl_get, \
2901 .put = alc_test_pin_ctl_put, \
2902 .private_value = nid \
2903 }
2904
2905#define PIN_SRC_TEST(xname,nid) { \
2906 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2907 .name = xname, \
2908 .info = alc_test_pin_src_info, \
2909 .get = alc_test_pin_src_get, \
2910 .put = alc_test_pin_src_put, \
2911 .private_value = nid \
2912 }
2913
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002914static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002915 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2916 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2917 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2918 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002919 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2920 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2921 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2922 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002923 PIN_CTL_TEST("Front Pin Mode", 0x14),
2924 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2925 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2926 PIN_CTL_TEST("Side Pin Mode", 0x17),
2927 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2928 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2929 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2930 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2931 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2932 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2933 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2934 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2935 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2936 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2937 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2938 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2939 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2940 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2941 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2942 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2943 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2944 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002945 {
2946 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2947 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002948 .info = alc_ch_mode_info,
2949 .get = alc_ch_mode_get,
2950 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002951 },
2952 { } /* end */
2953};
2954
2955static struct hda_verb alc880_test_init_verbs[] = {
2956 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2959 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2961 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2963 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2964 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002965 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002966 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2967 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2968 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2969 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002970 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002971 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2972 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2973 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2974 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002975 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002976 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2977 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2978 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2979 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002980 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002981 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2982 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002983 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2984 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2985 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002986 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002987 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2988 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2989 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2990 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002991 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002992 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002993 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002994 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002995 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002996 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002997 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002998 /* Analog input/passthru */
2999 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3000 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3001 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003004 { }
3005};
3006#endif
3007
Linus Torvalds1da177e2005-04-16 15:20:36 -07003008/*
3009 */
3010
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003011static const char *alc880_models[ALC880_MODEL_LAST] = {
3012 [ALC880_3ST] = "3stack",
3013 [ALC880_TCL_S700] = "tcl",
3014 [ALC880_3ST_DIG] = "3stack-digout",
3015 [ALC880_CLEVO] = "clevo",
3016 [ALC880_5ST] = "5stack",
3017 [ALC880_5ST_DIG] = "5stack-digout",
3018 [ALC880_W810] = "w810",
3019 [ALC880_Z71V] = "z71v",
3020 [ALC880_6ST] = "6stack",
3021 [ALC880_6ST_DIG] = "6stack-digout",
3022 [ALC880_ASUS] = "asus",
3023 [ALC880_ASUS_W1V] = "asus-w1v",
3024 [ALC880_ASUS_DIG] = "asus-dig",
3025 [ALC880_ASUS_DIG2] = "asus-dig2",
3026 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003027 [ALC880_UNIWILL_P53] = "uniwill-p53",
3028 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003029 [ALC880_F1734] = "F1734",
3030 [ALC880_LG] = "lg",
3031 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003032 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003033#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003034 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003035#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003036 [ALC880_AUTO] = "auto",
3037};
3038
3039static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003040 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003041 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3042 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3043 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3044 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3045 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3046 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3047 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3048 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003049 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3050 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003051 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3052 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3053 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3054 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3055 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3056 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3057 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3058 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3059 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3060 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003061 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003062 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3063 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3064 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003065 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003066 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003067 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3068 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003069 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3070 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003071 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3072 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3073 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3074 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003075 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3076 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003077 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003078 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003079 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003080 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003081 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3082 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003083 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003084 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003085 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003086 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003087 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003088 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003089 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003090 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003091 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003092 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3093 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003094 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003095 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3096 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3097 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3098 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003099 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3100 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003101 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003102 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003103 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3104 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003105 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3106 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3107 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003108 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3109 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3110 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003111 {}
3112};
3113
Takashi Iwai16ded522005-06-10 19:58:24 +02003114/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003115 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003116 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003117static struct alc_config_preset alc880_presets[] = {
3118 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003119 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003120 .init_verbs = { alc880_volume_init_verbs,
3121 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003122 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003123 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003124 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3125 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003126 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003127 .input_mux = &alc880_capture_source,
3128 },
3129 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003130 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003131 .init_verbs = { alc880_volume_init_verbs,
3132 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003133 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003134 .dac_nids = alc880_dac_nids,
3135 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003136 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3137 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003138 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003139 .input_mux = &alc880_capture_source,
3140 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003141 [ALC880_TCL_S700] = {
3142 .mixers = { alc880_tcl_s700_mixer },
3143 .init_verbs = { alc880_volume_init_verbs,
3144 alc880_pin_tcl_S700_init_verbs,
3145 alc880_gpio2_init_verbs },
3146 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3147 .dac_nids = alc880_dac_nids,
3148 .hp_nid = 0x03,
3149 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3150 .channel_mode = alc880_2_jack_modes,
3151 .input_mux = &alc880_capture_source,
3152 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003153 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003154 .mixers = { alc880_three_stack_mixer,
3155 alc880_five_stack_mixer},
3156 .init_verbs = { alc880_volume_init_verbs,
3157 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003158 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3159 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003160 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3161 .channel_mode = alc880_fivestack_modes,
3162 .input_mux = &alc880_capture_source,
3163 },
3164 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003165 .mixers = { alc880_three_stack_mixer,
3166 alc880_five_stack_mixer },
3167 .init_verbs = { alc880_volume_init_verbs,
3168 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003169 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3170 .dac_nids = alc880_dac_nids,
3171 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003172 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3173 .channel_mode = alc880_fivestack_modes,
3174 .input_mux = &alc880_capture_source,
3175 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003176 [ALC880_6ST] = {
3177 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003178 .init_verbs = { alc880_volume_init_verbs,
3179 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003180 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3181 .dac_nids = alc880_6st_dac_nids,
3182 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3183 .channel_mode = alc880_sixstack_modes,
3184 .input_mux = &alc880_6stack_capture_source,
3185 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003186 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003187 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003188 .init_verbs = { alc880_volume_init_verbs,
3189 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003190 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3191 .dac_nids = alc880_6st_dac_nids,
3192 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003193 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3194 .channel_mode = alc880_sixstack_modes,
3195 .input_mux = &alc880_6stack_capture_source,
3196 },
3197 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003198 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003199 .init_verbs = { alc880_volume_init_verbs,
3200 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003201 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003202 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3203 .dac_nids = alc880_w810_dac_nids,
3204 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003205 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3206 .channel_mode = alc880_w810_modes,
3207 .input_mux = &alc880_capture_source,
3208 },
3209 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003210 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003211 .init_verbs = { alc880_volume_init_verbs,
3212 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003213 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3214 .dac_nids = alc880_z71v_dac_nids,
3215 .dig_out_nid = ALC880_DIGOUT_NID,
3216 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003217 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3218 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003219 .input_mux = &alc880_capture_source,
3220 },
3221 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003222 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003223 .init_verbs = { alc880_volume_init_verbs,
3224 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003225 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3226 .dac_nids = alc880_f1734_dac_nids,
3227 .hp_nid = 0x02,
3228 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3229 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003230 .input_mux = &alc880_f1734_capture_source,
3231 .unsol_event = alc880_uniwill_p53_unsol_event,
3232 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003233 },
3234 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003236 .init_verbs = { alc880_volume_init_verbs,
3237 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238 alc880_gpio1_init_verbs },
3239 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3240 .dac_nids = alc880_asus_dac_nids,
3241 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3242 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003243 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003244 .input_mux = &alc880_capture_source,
3245 },
3246 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003247 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003248 .init_verbs = { alc880_volume_init_verbs,
3249 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003250 alc880_gpio1_init_verbs },
3251 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3252 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003253 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003254 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3255 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003256 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003257 .input_mux = &alc880_capture_source,
3258 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003259 [ALC880_ASUS_DIG2] = {
3260 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003261 .init_verbs = { alc880_volume_init_verbs,
3262 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003263 alc880_gpio2_init_verbs }, /* use GPIO2 */
3264 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3265 .dac_nids = alc880_asus_dac_nids,
3266 .dig_out_nid = ALC880_DIGOUT_NID,
3267 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3268 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003269 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003270 .input_mux = &alc880_capture_source,
3271 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003272 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003273 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003274 .init_verbs = { alc880_volume_init_verbs,
3275 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003276 alc880_gpio1_init_verbs },
3277 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3278 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003279 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3281 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003282 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003283 .input_mux = &alc880_capture_source,
3284 },
3285 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003286 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003287 .init_verbs = { alc880_volume_init_verbs,
3288 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003289 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3290 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003291 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003292 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3293 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003294 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003295 .input_mux = &alc880_capture_source,
3296 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003297 [ALC880_UNIWILL] = {
3298 .mixers = { alc880_uniwill_mixer },
3299 .init_verbs = { alc880_volume_init_verbs,
3300 alc880_uniwill_init_verbs },
3301 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3302 .dac_nids = alc880_asus_dac_nids,
3303 .dig_out_nid = ALC880_DIGOUT_NID,
3304 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3305 .channel_mode = alc880_threestack_modes,
3306 .need_dac_fix = 1,
3307 .input_mux = &alc880_capture_source,
3308 .unsol_event = alc880_uniwill_unsol_event,
3309 .init_hook = alc880_uniwill_automute,
3310 },
3311 [ALC880_UNIWILL_P53] = {
3312 .mixers = { alc880_uniwill_p53_mixer },
3313 .init_verbs = { alc880_volume_init_verbs,
3314 alc880_uniwill_p53_init_verbs },
3315 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3316 .dac_nids = alc880_asus_dac_nids,
3317 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003318 .channel_mode = alc880_threestack_modes,
3319 .input_mux = &alc880_capture_source,
3320 .unsol_event = alc880_uniwill_p53_unsol_event,
3321 .init_hook = alc880_uniwill_p53_hp_automute,
3322 },
3323 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003324 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003325 alc880_pcbeep_mixer, },
3326 .init_verbs = { alc880_volume_init_verbs,
3327 alc880_uniwill_p53_init_verbs,
3328 alc880_beep_init_verbs },
3329 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3330 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003331 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003332 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3333 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003334 .input_mux = &alc880_capture_source,
3335 .unsol_event = alc880_uniwill_p53_unsol_event,
3336 .init_hook = alc880_uniwill_p53_hp_automute,
3337 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003338 [ALC880_CLEVO] = {
3339 .mixers = { alc880_three_stack_mixer },
3340 .init_verbs = { alc880_volume_init_verbs,
3341 alc880_pin_clevo_init_verbs },
3342 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3343 .dac_nids = alc880_dac_nids,
3344 .hp_nid = 0x03,
3345 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3346 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003347 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003348 .input_mux = &alc880_capture_source,
3349 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003350 [ALC880_LG] = {
3351 .mixers = { alc880_lg_mixer },
3352 .init_verbs = { alc880_volume_init_verbs,
3353 alc880_lg_init_verbs },
3354 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3355 .dac_nids = alc880_lg_dac_nids,
3356 .dig_out_nid = ALC880_DIGOUT_NID,
3357 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3358 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003359 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003360 .input_mux = &alc880_lg_capture_source,
3361 .unsol_event = alc880_lg_unsol_event,
3362 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003363#ifdef CONFIG_SND_HDA_POWER_SAVE
3364 .loopbacks = alc880_lg_loopbacks,
3365#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003366 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003367 [ALC880_LG_LW] = {
3368 .mixers = { alc880_lg_lw_mixer },
3369 .init_verbs = { alc880_volume_init_verbs,
3370 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003371 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003372 .dac_nids = alc880_dac_nids,
3373 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003374 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3375 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003376 .input_mux = &alc880_lg_lw_capture_source,
3377 .unsol_event = alc880_lg_lw_unsol_event,
3378 .init_hook = alc880_lg_lw_automute,
3379 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003380 [ALC880_MEDION_RIM] = {
3381 .mixers = { alc880_medion_rim_mixer },
3382 .init_verbs = { alc880_volume_init_verbs,
3383 alc880_medion_rim_init_verbs,
3384 alc_gpio2_init_verbs },
3385 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3386 .dac_nids = alc880_dac_nids,
3387 .dig_out_nid = ALC880_DIGOUT_NID,
3388 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3389 .channel_mode = alc880_2_jack_modes,
3390 .input_mux = &alc880_medion_rim_capture_source,
3391 .unsol_event = alc880_medion_rim_unsol_event,
3392 .init_hook = alc880_medion_rim_automute,
3393 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003394#ifdef CONFIG_SND_DEBUG
3395 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003396 .mixers = { alc880_test_mixer },
3397 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003398 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3399 .dac_nids = alc880_test_dac_nids,
3400 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003401 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3402 .channel_mode = alc880_test_modes,
3403 .input_mux = &alc880_test_capture_source,
3404 },
3405#endif
3406};
3407
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003408/*
3409 * Automatic parse of I/O pins from the BIOS configuration
3410 */
3411
3412#define NUM_CONTROL_ALLOC 32
3413#define NUM_VERB_ALLOC 32
3414
3415enum {
3416 ALC_CTL_WIDGET_VOL,
3417 ALC_CTL_WIDGET_MUTE,
3418 ALC_CTL_BIND_MUTE,
3419};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003420static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003421 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3422 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003423 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003424};
3425
3426/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003427static int add_control(struct alc_spec *spec, int type, const char *name,
3428 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003429{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003430 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431
3432 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3433 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3434
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003435 /* array + terminator */
3436 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3437 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003438 return -ENOMEM;
3439 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003440 memcpy(knew, spec->kctl_alloc,
3441 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003442 kfree(spec->kctl_alloc);
3443 }
3444 spec->kctl_alloc = knew;
3445 spec->num_kctl_alloc = num;
3446 }
3447
3448 knew = &spec->kctl_alloc[spec->num_kctl_used];
3449 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003450 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003451 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003452 return -ENOMEM;
3453 knew->private_value = val;
3454 spec->num_kctl_used++;
3455 return 0;
3456}
3457
3458#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3459#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3460#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3461#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3462#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3463#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3464#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3465#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3466#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3467#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3468#define ALC880_PIN_CD_NID 0x1c
3469
3470/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003471static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3472 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003473{
3474 hda_nid_t nid;
3475 int assigned[4];
3476 int i, j;
3477
3478 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003479 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003480
3481 /* check the pins hardwired to audio widget */
3482 for (i = 0; i < cfg->line_outs; i++) {
3483 nid = cfg->line_out_pins[i];
3484 if (alc880_is_fixed_pin(nid)) {
3485 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003486 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003487 assigned[idx] = 1;
3488 }
3489 }
3490 /* left pins can be connect to any audio widget */
3491 for (i = 0; i < cfg->line_outs; i++) {
3492 nid = cfg->line_out_pins[i];
3493 if (alc880_is_fixed_pin(nid))
3494 continue;
3495 /* search for an empty channel */
3496 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003497 if (!assigned[j]) {
3498 spec->multiout.dac_nids[i] =
3499 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003500 assigned[j] = 1;
3501 break;
3502 }
3503 }
3504 }
3505 spec->multiout.num_dacs = cfg->line_outs;
3506 return 0;
3507}
3508
3509/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003510static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3511 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003512{
3513 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003514 static const char *chname[4] = {
3515 "Front", "Surround", NULL /*CLFE*/, "Side"
3516 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003517 hda_nid_t nid;
3518 int i, err;
3519
3520 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003521 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003522 continue;
3523 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3524 if (i == 2) {
3525 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003526 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3527 "Center Playback Volume",
3528 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3529 HDA_OUTPUT));
3530 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003531 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003532 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3533 "LFE Playback Volume",
3534 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3535 HDA_OUTPUT));
3536 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003537 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003538 err = add_control(spec, ALC_CTL_BIND_MUTE,
3539 "Center Playback Switch",
3540 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3541 HDA_INPUT));
3542 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003543 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003544 err = add_control(spec, ALC_CTL_BIND_MUTE,
3545 "LFE Playback Switch",
3546 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3547 HDA_INPUT));
3548 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003549 return err;
3550 } else {
3551 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003552 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3553 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3554 HDA_OUTPUT));
3555 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003556 return err;
3557 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003558 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3559 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3560 HDA_INPUT));
3561 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003562 return err;
3563 }
3564 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003565 return 0;
3566}
3567
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003568/* add playback controls for speaker and HP outputs */
3569static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3570 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003571{
3572 hda_nid_t nid;
3573 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003574 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003575
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003576 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003577 return 0;
3578
3579 if (alc880_is_fixed_pin(pin)) {
3580 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003581 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003582 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003583 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003584 else
3585 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003586 /* control HP volume/switch on the output mixer amp */
3587 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003588 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003589 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3590 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3591 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003592 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003593 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003594 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3595 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3596 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003597 return err;
3598 } else if (alc880_is_multi_pin(pin)) {
3599 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003600 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003601 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003602 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3603 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3604 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003605 return err;
3606 }
3607 return 0;
3608}
3609
3610/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003611static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3612 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003613 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003614{
3615 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003616 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003617
3618 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003619 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3620 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3621 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003622 return err;
3623 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003624 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3625 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3626 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003627 return err;
3628 return 0;
3629}
3630
3631/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003632static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3633 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003634{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003635 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003636 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003637
3638 for (i = 0; i < AUTO_PIN_LAST; i++) {
3639 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003640 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003641 err = new_analog_input(spec, cfg->input_pins[i],
3642 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003643 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003644 if (err < 0)
3645 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003646 imux->items[imux->num_items].label =
3647 auto_pin_cfg_labels[i];
3648 imux->items[imux->num_items].index =
3649 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003650 imux->num_items++;
3651 }
3652 }
3653 return 0;
3654}
3655
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003656static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3657 unsigned int pin_type)
3658{
3659 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3660 pin_type);
3661 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003662 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3663 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003664}
3665
Kailang Yangdf694da2005-12-05 19:42:22 +01003666static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3667 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003668 int dac_idx)
3669{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003670 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003671 /* need the manual connection? */
3672 if (alc880_is_multi_pin(nid)) {
3673 struct alc_spec *spec = codec->spec;
3674 int idx = alc880_multi_pin_idx(nid);
3675 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3676 AC_VERB_SET_CONNECT_SEL,
3677 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3678 }
3679}
3680
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003681static int get_pin_type(int line_out_type)
3682{
3683 if (line_out_type == AUTO_PIN_HP_OUT)
3684 return PIN_HP;
3685 else
3686 return PIN_OUT;
3687}
3688
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003689static void alc880_auto_init_multi_out(struct hda_codec *codec)
3690{
3691 struct alc_spec *spec = codec->spec;
3692 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02003693
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003694 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003695 for (i = 0; i < spec->autocfg.line_outs; i++) {
3696 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003697 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3698 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003699 }
3700}
3701
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003702static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003703{
3704 struct alc_spec *spec = codec->spec;
3705 hda_nid_t pin;
3706
Takashi Iwai82bc9552006-03-21 11:24:42 +01003707 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003708 if (pin) /* connect to front */
3709 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003710 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003711 if (pin) /* connect to front */
3712 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3713}
3714
3715static void alc880_auto_init_analog_input(struct hda_codec *codec)
3716{
3717 struct alc_spec *spec = codec->spec;
3718 int i;
3719
3720 for (i = 0; i < AUTO_PIN_LAST; i++) {
3721 hda_nid_t nid = spec->autocfg.input_pins[i];
3722 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003723 snd_hda_codec_write(codec, nid, 0,
3724 AC_VERB_SET_PIN_WIDGET_CONTROL,
3725 i <= AUTO_PIN_FRONT_MIC ?
3726 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003727 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003728 snd_hda_codec_write(codec, nid, 0,
3729 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003730 AMP_OUT_MUTE);
3731 }
3732 }
3733}
3734
3735/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003736/* return 1 if successful, 0 if the proper config is not found,
3737 * or a negative error code
3738 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003739static int alc880_parse_auto_config(struct hda_codec *codec)
3740{
3741 struct alc_spec *spec = codec->spec;
3742 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003743 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003744
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003745 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3746 alc880_ignore);
3747 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003748 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003749 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003750 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003751
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003752 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3753 if (err < 0)
3754 return err;
3755 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3756 if (err < 0)
3757 return err;
3758 err = alc880_auto_create_extra_out(spec,
3759 spec->autocfg.speaker_pins[0],
3760 "Speaker");
3761 if (err < 0)
3762 return err;
3763 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3764 "Headphone");
3765 if (err < 0)
3766 return err;
3767 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3768 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003769 return err;
3770
3771 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3772
3773 if (spec->autocfg.dig_out_pin)
3774 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3775 if (spec->autocfg.dig_in_pin)
3776 spec->dig_in_nid = ALC880_DIGIN_NID;
3777
3778 if (spec->kctl_alloc)
3779 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3780
3781 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3782
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003783 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003784 spec->input_mux = &spec->private_imux;
3785
3786 return 1;
3787}
3788
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003789/* additional initialization for auto-configuration model */
3790static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003791{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003792 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003793 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003794 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003795 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003796 if (spec->unsol_event)
3797 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003798}
3799
3800/*
3801 * OK, here we have finally the patch for ALC880
3802 */
3803
Linus Torvalds1da177e2005-04-16 15:20:36 -07003804static int patch_alc880(struct hda_codec *codec)
3805{
3806 struct alc_spec *spec;
3807 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003808 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003809
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003810 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003811 if (spec == NULL)
3812 return -ENOMEM;
3813
3814 codec->spec = spec;
3815
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003816 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3817 alc880_models,
3818 alc880_cfg_tbl);
3819 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003820 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3821 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003822 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003823 }
3824
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003825 if (board_config == ALC880_AUTO) {
3826 /* automatic parse from the BIOS config */
3827 err = alc880_parse_auto_config(codec);
3828 if (err < 0) {
3829 alc_free(codec);
3830 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003831 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003832 printk(KERN_INFO
3833 "hda_codec: Cannot set up configuration "
3834 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003835 board_config = ALC880_3ST;
3836 }
3837 }
3838
Kailang Yangdf694da2005-12-05 19:42:22 +01003839 if (board_config != ALC880_AUTO)
3840 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003841
3842 spec->stream_name_analog = "ALC880 Analog";
3843 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3844 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003845 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003846
3847 spec->stream_name_digital = "ALC880 Digital";
3848 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3849 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3850
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003851 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003852 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003853 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003854 /* get type */
3855 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003856 if (wcap != AC_WID_AUD_IN) {
3857 spec->adc_nids = alc880_adc_nids_alt;
3858 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003859 spec->mixers[spec->num_mixers] =
3860 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003861 spec->num_mixers++;
3862 } else {
3863 spec->adc_nids = alc880_adc_nids;
3864 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3865 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3866 spec->num_mixers++;
3867 }
3868 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003869
Takashi Iwai2134ea42008-01-10 16:53:55 +01003870 spec->vmaster_nid = 0x0c;
3871
Linus Torvalds1da177e2005-04-16 15:20:36 -07003872 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003873 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003874 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003875#ifdef CONFIG_SND_HDA_POWER_SAVE
3876 if (!spec->loopback.amplist)
3877 spec->loopback.amplist = alc880_loopbacks;
3878#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003879
3880 return 0;
3881}
3882
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003883
Linus Torvalds1da177e2005-04-16 15:20:36 -07003884/*
3885 * ALC260 support
3886 */
3887
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003888static hda_nid_t alc260_dac_nids[1] = {
3889 /* front */
3890 0x02,
3891};
3892
3893static hda_nid_t alc260_adc_nids[1] = {
3894 /* ADC0 */
3895 0x04,
3896};
3897
Kailang Yangdf694da2005-12-05 19:42:22 +01003898static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003899 /* ADC1 */
3900 0x05,
3901};
3902
Kailang Yangdf694da2005-12-05 19:42:22 +01003903static hda_nid_t alc260_hp_adc_nids[2] = {
3904 /* ADC1, 0 */
3905 0x05, 0x04
3906};
3907
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003908/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3909 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3910 */
3911static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003912 /* ADC0, ADC1 */
3913 0x04, 0x05
3914};
3915
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003916#define ALC260_DIGOUT_NID 0x03
3917#define ALC260_DIGIN_NID 0x06
3918
3919static struct hda_input_mux alc260_capture_source = {
3920 .num_items = 4,
3921 .items = {
3922 { "Mic", 0x0 },
3923 { "Front Mic", 0x1 },
3924 { "Line", 0x2 },
3925 { "CD", 0x4 },
3926 },
3927};
3928
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003929/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003930 * headphone jack and the internal CD lines since these are the only pins at
3931 * which audio can appear. For flexibility, also allow the option of
3932 * recording the mixer output on the second ADC (ADC0 doesn't have a
3933 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003934 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003935static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3936 {
3937 .num_items = 3,
3938 .items = {
3939 { "Mic/Line", 0x0 },
3940 { "CD", 0x4 },
3941 { "Headphone", 0x2 },
3942 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003943 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003944 {
3945 .num_items = 4,
3946 .items = {
3947 { "Mic/Line", 0x0 },
3948 { "CD", 0x4 },
3949 { "Headphone", 0x2 },
3950 { "Mixer", 0x5 },
3951 },
3952 },
3953
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003954};
3955
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003956/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3957 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003958 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003959static struct hda_input_mux alc260_acer_capture_sources[2] = {
3960 {
3961 .num_items = 4,
3962 .items = {
3963 { "Mic", 0x0 },
3964 { "Line", 0x2 },
3965 { "CD", 0x4 },
3966 { "Headphone", 0x5 },
3967 },
3968 },
3969 {
3970 .num_items = 5,
3971 .items = {
3972 { "Mic", 0x0 },
3973 { "Line", 0x2 },
3974 { "CD", 0x4 },
3975 { "Headphone", 0x6 },
3976 { "Mixer", 0x5 },
3977 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003978 },
3979};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003980/*
3981 * This is just place-holder, so there's something for alc_build_pcms to look
3982 * at when it calculates the maximum number of channels. ALC260 has no mixer
3983 * element which allows changing the channel mode, so the verb list is
3984 * never used.
3985 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003986static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003987 { 2, NULL },
3988};
3989
Kailang Yangdf694da2005-12-05 19:42:22 +01003990
3991/* Mixer combinations
3992 *
3993 * basic: base_output + input + pc_beep + capture
3994 * HP: base_output + input + capture_alt
3995 * HP_3013: hp_3013 + input + capture
3996 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003997 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003998 */
3999
4000static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004001 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004002 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004003 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4004 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4005 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4006 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4007 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004008};
Kailang Yangdf694da2005-12-05 19:42:22 +01004009
4010static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004011 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4012 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4013 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4014 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4015 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4016 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4017 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4018 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004019 { } /* end */
4020};
4021
Kailang Yangdf694da2005-12-05 19:42:22 +01004022static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4023 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4024 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4025 { } /* end */
4026};
4027
Takashi Iwaibec15c32008-01-28 18:16:30 +01004028/* update HP, line and mono out pins according to the master switch */
4029static void alc260_hp_master_update(struct hda_codec *codec,
4030 hda_nid_t hp, hda_nid_t line,
4031 hda_nid_t mono)
4032{
4033 struct alc_spec *spec = codec->spec;
4034 unsigned int val = spec->master_sw ? PIN_HP : 0;
4035 /* change HP and line-out pins */
4036 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4037 val);
4038 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4039 val);
4040 /* mono (speaker) depending on the HP jack sense */
4041 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4042 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4043 val);
4044}
4045
4046static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4047 struct snd_ctl_elem_value *ucontrol)
4048{
4049 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4050 struct alc_spec *spec = codec->spec;
4051 *ucontrol->value.integer.value = spec->master_sw;
4052 return 0;
4053}
4054
4055static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4056 struct snd_ctl_elem_value *ucontrol)
4057{
4058 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4059 struct alc_spec *spec = codec->spec;
4060 int val = !!*ucontrol->value.integer.value;
4061 hda_nid_t hp, line, mono;
4062
4063 if (val == spec->master_sw)
4064 return 0;
4065 spec->master_sw = val;
4066 hp = (kcontrol->private_value >> 16) & 0xff;
4067 line = (kcontrol->private_value >> 8) & 0xff;
4068 mono = kcontrol->private_value & 0xff;
4069 alc260_hp_master_update(codec, hp, line, mono);
4070 return 1;
4071}
4072
4073static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4074 {
4075 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4076 .name = "Master Playback Switch",
4077 .info = snd_ctl_boolean_mono_info,
4078 .get = alc260_hp_master_sw_get,
4079 .put = alc260_hp_master_sw_put,
4080 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4081 },
4082 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4083 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4084 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4085 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4086 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4087 HDA_OUTPUT),
4088 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4089 { } /* end */
4090};
4091
4092static struct hda_verb alc260_hp_unsol_verbs[] = {
4093 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4094 {},
4095};
4096
4097static void alc260_hp_automute(struct hda_codec *codec)
4098{
4099 struct alc_spec *spec = codec->spec;
4100 unsigned int present;
4101
4102 present = snd_hda_codec_read(codec, 0x10, 0,
4103 AC_VERB_GET_PIN_SENSE, 0);
4104 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4105 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4106}
4107
4108static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4109{
4110 if ((res >> 26) == ALC880_HP_EVENT)
4111 alc260_hp_automute(codec);
4112}
4113
Kailang Yangdf694da2005-12-05 19:42:22 +01004114static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004115 {
4116 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4117 .name = "Master Playback Switch",
4118 .info = snd_ctl_boolean_mono_info,
4119 .get = alc260_hp_master_sw_get,
4120 .put = alc260_hp_master_sw_put,
4121 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4122 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004123 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4124 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4125 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4126 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4127 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4128 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004129 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4130 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004131 { } /* end */
4132};
4133
Kailang Yang3f878302008-08-26 13:02:23 +02004134static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4135 .ops = &snd_hda_bind_vol,
4136 .values = {
4137 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4138 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4139 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4140 0
4141 },
4142};
4143
4144static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4145 .ops = &snd_hda_bind_sw,
4146 .values = {
4147 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4148 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4149 0
4150 },
4151};
4152
4153static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4154 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4155 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4156 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4157 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4158 { } /* end */
4159};
4160
Takashi Iwaibec15c32008-01-28 18:16:30 +01004161static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4162 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4163 {},
4164};
4165
4166static void alc260_hp_3013_automute(struct hda_codec *codec)
4167{
4168 struct alc_spec *spec = codec->spec;
4169 unsigned int present;
4170
4171 present = snd_hda_codec_read(codec, 0x15, 0,
4172 AC_VERB_GET_PIN_SENSE, 0);
4173 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4174 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4175}
4176
4177static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4178 unsigned int res)
4179{
4180 if ((res >> 26) == ALC880_HP_EVENT)
4181 alc260_hp_3013_automute(codec);
4182}
4183
Kailang Yang3f878302008-08-26 13:02:23 +02004184static void alc260_hp_3012_automute(struct hda_codec *codec)
4185{
4186 unsigned int present, bits;
4187
4188 present = snd_hda_codec_read(codec, 0x10, 0,
4189 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4190
4191 bits = present ? 0 : PIN_OUT;
4192 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4193 bits);
4194 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4195 bits);
4196 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4197 bits);
4198}
4199
4200static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4201 unsigned int res)
4202{
4203 if ((res >> 26) == ALC880_HP_EVENT)
4204 alc260_hp_3012_automute(codec);
4205}
4206
4207/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004208 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4209 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004210static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004211 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004212 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004213 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004214 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4215 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4216 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4217 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004218 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004219 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4220 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004221 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4222 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004223 { } /* end */
4224};
4225
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004226/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4227 * versions of the ALC260 don't act on requests to enable mic bias from NID
4228 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4229 * datasheet doesn't mention this restriction. At this stage it's not clear
4230 * whether this behaviour is intentional or is a hardware bug in chip
4231 * revisions available in early 2006. Therefore for now allow the
4232 * "Headphone Jack Mode" control to span all choices, but if it turns out
4233 * that the lack of mic bias for this NID is intentional we could change the
4234 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4235 *
4236 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4237 * don't appear to make the mic bias available from the "line" jack, even
4238 * though the NID used for this jack (0x14) can supply it. The theory is
4239 * that perhaps Acer have included blocking capacitors between the ALC260
4240 * and the output jack. If this turns out to be the case for all such
4241 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4242 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004243 *
4244 * The C20x Tablet series have a mono internal speaker which is controlled
4245 * via the chip's Mono sum widget and pin complex, so include the necessary
4246 * controls for such models. On models without a "mono speaker" the control
4247 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004248 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004249static struct snd_kcontrol_new alc260_acer_mixer[] = {
4250 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4251 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004252 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004253 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004254 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004255 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004256 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004257 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4258 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4259 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4260 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4261 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4262 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4263 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4264 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4265 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4266 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4267 { } /* end */
4268};
4269
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004270/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4271 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4272 */
4273static struct snd_kcontrol_new alc260_will_mixer[] = {
4274 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4275 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4276 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4277 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4278 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4279 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4280 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4281 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4282 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4283 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4284 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4285 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4286 { } /* end */
4287};
4288
4289/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4290 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4291 */
4292static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4293 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4294 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4296 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4297 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4298 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4299 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4300 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4301 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4302 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4303 { } /* end */
4304};
4305
Kailang Yangdf694da2005-12-05 19:42:22 +01004306/* capture mixer elements */
4307static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004308 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4309 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004310 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4311 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004312 {
4313 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004314 /* The multiple "Capture Source" controls confuse alsamixer
4315 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004316 */
4317 /* .name = "Capture Source", */
4318 .name = "Input Source",
4319 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004320 .info = alc_mux_enum_info,
4321 .get = alc_mux_enum_get,
4322 .put = alc_mux_enum_put,
4323 },
4324 { } /* end */
4325};
4326
Kailang Yangdf694da2005-12-05 19:42:22 +01004327static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4328 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4329 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4330 {
4331 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4332 /* The multiple "Capture Source" controls confuse alsamixer
4333 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004334 */
4335 /* .name = "Capture Source", */
4336 .name = "Input Source",
4337 .count = 1,
4338 .info = alc_mux_enum_info,
4339 .get = alc_mux_enum_get,
4340 .put = alc_mux_enum_put,
4341 },
4342 { } /* end */
4343};
4344
4345/*
4346 * initialization verbs
4347 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004348static struct hda_verb alc260_init_verbs[] = {
4349 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004351 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004352 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004353 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004354 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004355 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004356 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004357 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004358 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004359 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004360 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004361 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004362 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004363 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004364 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004365 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004366 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4367 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004368 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004369 /* set connection select to line in (default select for this ADC) */
4370 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004371 /* mute capture amp left and right */
4372 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4373 /* set connection select to line in (default select for this ADC) */
4374 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004375 /* set vol=0 Line-Out mixer amp left and right */
4376 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4377 /* unmute pin widget amp left and right (no gain on this amp) */
4378 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4379 /* set vol=0 HP mixer amp left and right */
4380 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4381 /* unmute pin widget amp left and right (no gain on this amp) */
4382 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4383 /* set vol=0 Mono mixer amp left and right */
4384 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4385 /* unmute pin widget amp left and right (no gain on this amp) */
4386 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4387 /* unmute LINE-2 out pin */
4388 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004389 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4390 * Line In 2 = 0x03
4391 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004392 /* mute analog inputs */
4393 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004398 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004399 /* mute Front out path */
4400 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4401 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4402 /* mute Headphone out path */
4403 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4404 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4405 /* mute Mono out path */
4406 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4407 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004408 { }
4409};
4410
Takashi Iwai474167d2006-05-17 17:17:43 +02004411#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004412static struct hda_verb alc260_hp_init_verbs[] = {
4413 /* Headphone and output */
4414 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4415 /* mono output */
4416 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4417 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4418 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4419 /* Mic2 (front panel) pin widget for input and vref at 80% */
4420 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4421 /* Line In pin widget for input */
4422 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4423 /* Line-2 pin widget for output */
4424 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4425 /* CD pin widget for input */
4426 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4427 /* unmute amp left and right */
4428 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4429 /* set connection select to line in (default select for this ADC) */
4430 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4431 /* unmute Line-Out mixer amp left and right (volume = 0) */
4432 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4433 /* mute pin widget amp left and right (no gain on this amp) */
4434 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4435 /* unmute HP mixer amp left and right (volume = 0) */
4436 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4437 /* mute pin widget amp left and right (no gain on this amp) */
4438 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004439 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4440 * Line In 2 = 0x03
4441 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004442 /* mute analog inputs */
4443 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4444 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4445 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4446 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4447 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004448 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4449 /* Unmute Front out path */
4450 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4451 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4452 /* Unmute Headphone out path */
4453 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4454 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4455 /* Unmute Mono out path */
4456 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4457 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4458 { }
4459};
Takashi Iwai474167d2006-05-17 17:17:43 +02004460#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004461
4462static struct hda_verb alc260_hp_3013_init_verbs[] = {
4463 /* Line out and output */
4464 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4465 /* mono output */
4466 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4467 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4468 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4469 /* Mic2 (front panel) pin widget for input and vref at 80% */
4470 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4471 /* Line In pin widget for input */
4472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4473 /* Headphone pin widget for output */
4474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4475 /* CD pin widget for input */
4476 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4477 /* unmute amp left and right */
4478 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4479 /* set connection select to line in (default select for this ADC) */
4480 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4481 /* unmute Line-Out mixer amp left and right (volume = 0) */
4482 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4483 /* mute pin widget amp left and right (no gain on this amp) */
4484 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4485 /* unmute HP mixer amp left and right (volume = 0) */
4486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4487 /* mute pin widget amp left and right (no gain on this amp) */
4488 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004489 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4490 * Line In 2 = 0x03
4491 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004492 /* mute analog inputs */
4493 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4494 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4495 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4496 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004498 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4499 /* Unmute Front out path */
4500 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4501 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4502 /* Unmute Headphone out path */
4503 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4504 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4505 /* Unmute Mono out path */
4506 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4507 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4508 { }
4509};
4510
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004511/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004512 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4513 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004514 */
4515static struct hda_verb alc260_fujitsu_init_verbs[] = {
4516 /* Disable all GPIOs */
4517 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4518 /* Internal speaker is connected to headphone pin */
4519 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4520 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004522 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4523 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4524 /* Ensure all other unused pins are disabled and muted. */
4525 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4526 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004527 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004528 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004529 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004530 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4531 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4532 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004533
Jonathan Woithef7ace402006-02-28 11:46:14 +01004534 /* Disable digital (SPDIF) pins */
4535 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4536 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004537
Kailang Yangea1fb292008-08-26 12:58:38 +02004538 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004539 * when acting as an output.
4540 */
4541 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4542
4543 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004544 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4545 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4546 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4547 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4548 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4549 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4550 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4551 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4552 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004553
Jonathan Woithef7ace402006-02-28 11:46:14 +01004554 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4555 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4556 /* Unmute Line1 pin widget output buffer since it starts as an output.
4557 * If the pin mode is changed by the user the pin mode control will
4558 * take care of enabling the pin's input/output buffers as needed.
4559 * Therefore there's no need to enable the input buffer at this
4560 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004561 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004562 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02004563 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004564 * mixer ctrl)
4565 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004566 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004567
Jonathan Woithef7ace402006-02-28 11:46:14 +01004568 /* Mute capture amp left and right */
4569 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02004570 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01004571 * in (on mic1 pin)
4572 */
4573 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004574
Jonathan Woithef7ace402006-02-28 11:46:14 +01004575 /* Do the same for the second ADC: mute capture input amp and
4576 * set ADC connection to line in (on mic1 pin)
4577 */
4578 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4579 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004580
Jonathan Woithef7ace402006-02-28 11:46:14 +01004581 /* Mute all inputs to mixer widget (even unconnected ones) */
4582 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4583 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4584 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4585 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4586 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4588 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4589 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004590
4591 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004592};
4593
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004594/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4595 * similar laptops (adapted from Fujitsu init verbs).
4596 */
4597static struct hda_verb alc260_acer_init_verbs[] = {
4598 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4599 * the headphone jack. Turn this on and rely on the standard mute
4600 * methods whenever the user wants to turn these outputs off.
4601 */
4602 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4603 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4604 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4605 /* Internal speaker/Headphone jack is connected to Line-out pin */
4606 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4607 /* Internal microphone/Mic jack is connected to Mic1 pin */
4608 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4609 /* Line In jack is connected to Line1 pin */
4610 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004611 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4612 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004613 /* Ensure all other unused pins are disabled and muted. */
4614 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4615 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004616 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4617 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4618 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4619 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4620 /* Disable digital (SPDIF) pins */
4621 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4622 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4623
Kailang Yangea1fb292008-08-26 12:58:38 +02004624 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004625 * bus when acting as outputs.
4626 */
4627 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4628 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4629
4630 /* Start with output sum widgets muted and their output gains at min */
4631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4632 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4634 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4635 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4637 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4638 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4639 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4640
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004641 /* Unmute Line-out pin widget amp left and right
4642 * (no equiv mixer ctrl)
4643 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004644 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004645 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4646 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004647 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4648 * inputs. If the pin mode is changed by the user the pin mode control
4649 * will take care of enabling the pin's input/output buffers as needed.
4650 * Therefore there's no need to enable the input buffer at this
4651 * stage.
4652 */
4653 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4654 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4655
4656 /* Mute capture amp left and right */
4657 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4658 /* Set ADC connection select to match default mixer setting - mic
4659 * (on mic1 pin)
4660 */
4661 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4662
4663 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004664 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004665 */
4666 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004667 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004668
4669 /* Mute all inputs to mixer widget (even unconnected ones) */
4670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4678
4679 { }
4680};
4681
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004682static struct hda_verb alc260_will_verbs[] = {
4683 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4684 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4685 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4686 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4687 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4688 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4689 {}
4690};
4691
4692static struct hda_verb alc260_replacer_672v_verbs[] = {
4693 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4694 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4695 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4696
4697 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4698 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4699 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4700
4701 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4702 {}
4703};
4704
4705/* toggle speaker-output according to the hp-jack state */
4706static void alc260_replacer_672v_automute(struct hda_codec *codec)
4707{
4708 unsigned int present;
4709
4710 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4711 present = snd_hda_codec_read(codec, 0x0f, 0,
4712 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4713 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004714 snd_hda_codec_write_cache(codec, 0x01, 0,
4715 AC_VERB_SET_GPIO_DATA, 1);
4716 snd_hda_codec_write_cache(codec, 0x0f, 0,
4717 AC_VERB_SET_PIN_WIDGET_CONTROL,
4718 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004719 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004720 snd_hda_codec_write_cache(codec, 0x01, 0,
4721 AC_VERB_SET_GPIO_DATA, 0);
4722 snd_hda_codec_write_cache(codec, 0x0f, 0,
4723 AC_VERB_SET_PIN_WIDGET_CONTROL,
4724 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004725 }
4726}
4727
4728static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4729 unsigned int res)
4730{
4731 if ((res >> 26) == ALC880_HP_EVENT)
4732 alc260_replacer_672v_automute(codec);
4733}
4734
Kailang Yang3f878302008-08-26 13:02:23 +02004735static struct hda_verb alc260_hp_dc7600_verbs[] = {
4736 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
4737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4738 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4739 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4740 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4741 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4742 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4743 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4744 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4745 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4746 {}
4747};
4748
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004749/* Test configuration for debugging, modelled after the ALC880 test
4750 * configuration.
4751 */
4752#ifdef CONFIG_SND_DEBUG
4753static hda_nid_t alc260_test_dac_nids[1] = {
4754 0x02,
4755};
4756static hda_nid_t alc260_test_adc_nids[2] = {
4757 0x04, 0x05,
4758};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004759/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02004760 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004761 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004762 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004763static struct hda_input_mux alc260_test_capture_sources[2] = {
4764 {
4765 .num_items = 7,
4766 .items = {
4767 { "MIC1 pin", 0x0 },
4768 { "MIC2 pin", 0x1 },
4769 { "LINE1 pin", 0x2 },
4770 { "LINE2 pin", 0x3 },
4771 { "CD pin", 0x4 },
4772 { "LINE-OUT pin", 0x5 },
4773 { "HP-OUT pin", 0x6 },
4774 },
4775 },
4776 {
4777 .num_items = 8,
4778 .items = {
4779 { "MIC1 pin", 0x0 },
4780 { "MIC2 pin", 0x1 },
4781 { "LINE1 pin", 0x2 },
4782 { "LINE2 pin", 0x3 },
4783 { "CD pin", 0x4 },
4784 { "Mixer", 0x5 },
4785 { "LINE-OUT pin", 0x6 },
4786 { "HP-OUT pin", 0x7 },
4787 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004788 },
4789};
4790static struct snd_kcontrol_new alc260_test_mixer[] = {
4791 /* Output driver widgets */
4792 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4793 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4794 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4795 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4796 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4797 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4798
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004799 /* Modes for retasking pin widgets
4800 * Note: the ALC260 doesn't seem to act on requests to enable mic
4801 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4802 * mention this restriction. At this stage it's not clear whether
4803 * this behaviour is intentional or is a hardware bug in chip
4804 * revisions available at least up until early 2006. Therefore for
4805 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4806 * choices, but if it turns out that the lack of mic bias for these
4807 * NIDs is intentional we could change their modes from
4808 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4809 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004810 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4811 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4812 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4813 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4814 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4815 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4816
4817 /* Loopback mixer controls */
4818 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4819 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4820 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4821 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4822 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4823 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4824 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4825 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4826 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4827 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4828 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4829 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4830 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4831 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4832 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4833 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004834
4835 /* Controls for GPIO pins, assuming they are configured as outputs */
4836 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4837 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4838 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4839 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4840
Jonathan Woithe92621f12006-02-28 11:47:47 +01004841 /* Switches to allow the digital IO pins to be enabled. The datasheet
4842 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02004843 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01004844 */
4845 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4846 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4847
Jonathan Woithef8225f62008-01-08 12:16:54 +01004848 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4849 * this output to turn on an external amplifier.
4850 */
4851 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4852 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4853
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004854 { } /* end */
4855};
4856static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004857 /* Enable all GPIOs as outputs with an initial value of 0 */
4858 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4859 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4860 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4861
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004862 /* Enable retasking pins as output, initially without power amp */
4863 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4864 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4865 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4866 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4867 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4868 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4869
Jonathan Woithe92621f12006-02-28 11:47:47 +01004870 /* Disable digital (SPDIF) pins initially, but users can enable
4871 * them via a mixer switch. In the case of SPDIF-out, this initverb
4872 * payload also sets the generation to 0, output to be in "consumer"
4873 * PCM format, copyright asserted, no pre-emphasis and no validity
4874 * control.
4875 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004876 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4877 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4878
Kailang Yangea1fb292008-08-26 12:58:38 +02004879 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004880 * OUT1 sum bus when acting as an output.
4881 */
4882 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4883 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4884 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4885 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4886
4887 /* Start with output sum widgets muted and their output gains at min */
4888 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4890 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4891 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4892 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4893 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4894 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4895 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4896 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4897
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004898 /* Unmute retasking pin widget output buffers since the default
4899 * state appears to be output. As the pin mode is changed by the
4900 * user the pin mode control will take care of enabling the pin's
4901 * input/output buffers as needed.
4902 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004903 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4904 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4907 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4908 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4909 /* Also unmute the mono-out pin widget */
4910 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4911
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004912 /* Mute capture amp left and right */
4913 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004914 /* Set ADC connection select to match default mixer setting (mic1
4915 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004916 */
4917 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4918
4919 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004920 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004921 */
4922 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4923 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4924
4925 /* Mute all inputs to mixer widget (even unconnected ones) */
4926 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4927 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4931 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4932 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4933 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4934
4935 { }
4936};
4937#endif
4938
Takashi Iwai63300792008-01-24 15:31:36 +01004939#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4940#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004941
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004942#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4943#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4944
Kailang Yangdf694da2005-12-05 19:42:22 +01004945/*
4946 * for BIOS auto-configuration
4947 */
4948
4949static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4950 const char *pfx)
4951{
4952 hda_nid_t nid_vol;
4953 unsigned long vol_val, sw_val;
4954 char name[32];
4955 int err;
4956
4957 if (nid >= 0x0f && nid < 0x11) {
4958 nid_vol = nid - 0x7;
4959 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4960 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4961 } else if (nid == 0x11) {
4962 nid_vol = nid - 0x7;
4963 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4964 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4965 } else if (nid >= 0x12 && nid <= 0x15) {
4966 nid_vol = 0x08;
4967 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4968 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4969 } else
4970 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02004971
Kailang Yangdf694da2005-12-05 19:42:22 +01004972 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004973 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4974 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004975 return err;
4976 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004977 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4978 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004979 return err;
4980 return 1;
4981}
4982
4983/* add playback controls from the parsed DAC table */
4984static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4985 const struct auto_pin_cfg *cfg)
4986{
4987 hda_nid_t nid;
4988 int err;
4989
4990 spec->multiout.num_dacs = 1;
4991 spec->multiout.dac_nids = spec->private_dac_nids;
4992 spec->multiout.dac_nids[0] = 0x02;
4993
4994 nid = cfg->line_out_pins[0];
4995 if (nid) {
4996 err = alc260_add_playback_controls(spec, nid, "Front");
4997 if (err < 0)
4998 return err;
4999 }
5000
Takashi Iwai82bc9552006-03-21 11:24:42 +01005001 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005002 if (nid) {
5003 err = alc260_add_playback_controls(spec, nid, "Speaker");
5004 if (err < 0)
5005 return err;
5006 }
5007
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005008 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005009 if (nid) {
5010 err = alc260_add_playback_controls(spec, nid, "Headphone");
5011 if (err < 0)
5012 return err;
5013 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005014 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005015}
5016
5017/* create playback/capture controls for input pins */
5018static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5019 const struct auto_pin_cfg *cfg)
5020{
Kailang Yangdf694da2005-12-05 19:42:22 +01005021 struct hda_input_mux *imux = &spec->private_imux;
5022 int i, err, idx;
5023
5024 for (i = 0; i < AUTO_PIN_LAST; i++) {
5025 if (cfg->input_pins[i] >= 0x12) {
5026 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005027 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005028 auto_pin_cfg_labels[i], idx,
5029 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005030 if (err < 0)
5031 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005032 imux->items[imux->num_items].label =
5033 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005034 imux->items[imux->num_items].index = idx;
5035 imux->num_items++;
5036 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005038 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005039 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005040 auto_pin_cfg_labels[i], idx,
5041 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005042 if (err < 0)
5043 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005044 imux->items[imux->num_items].label =
5045 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005046 imux->items[imux->num_items].index = idx;
5047 imux->num_items++;
5048 }
5049 }
5050 return 0;
5051}
5052
5053static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5054 hda_nid_t nid, int pin_type,
5055 int sel_idx)
5056{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005057 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005058 /* need the manual connection? */
5059 if (nid >= 0x12) {
5060 int idx = nid - 0x12;
5061 snd_hda_codec_write(codec, idx + 0x0b, 0,
5062 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005063 }
5064}
5065
5066static void alc260_auto_init_multi_out(struct hda_codec *codec)
5067{
5068 struct alc_spec *spec = codec->spec;
5069 hda_nid_t nid;
5070
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005071 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005072 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005073 if (nid) {
5074 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5075 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5076 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005077
Takashi Iwai82bc9552006-03-21 11:24:42 +01005078 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005079 if (nid)
5080 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5081
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005082 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005083 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005084 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005085}
Kailang Yangdf694da2005-12-05 19:42:22 +01005086
5087#define ALC260_PIN_CD_NID 0x16
5088static void alc260_auto_init_analog_input(struct hda_codec *codec)
5089{
5090 struct alc_spec *spec = codec->spec;
5091 int i;
5092
5093 for (i = 0; i < AUTO_PIN_LAST; i++) {
5094 hda_nid_t nid = spec->autocfg.input_pins[i];
5095 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005096 snd_hda_codec_write(codec, nid, 0,
5097 AC_VERB_SET_PIN_WIDGET_CONTROL,
5098 i <= AUTO_PIN_FRONT_MIC ?
5099 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005100 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005101 snd_hda_codec_write(codec, nid, 0,
5102 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005103 AMP_OUT_MUTE);
5104 }
5105 }
5106}
5107
5108/*
5109 * generic initialization of ADC, input mixers and output mixers
5110 */
5111static struct hda_verb alc260_volume_init_verbs[] = {
5112 /*
5113 * Unmute ADC0-1 and set the default input to mic-in
5114 */
5115 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5116 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5117 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5118 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005119
Kailang Yangdf694da2005-12-05 19:42:22 +01005120 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5121 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005122 * Note: PASD motherboards uses the Line In 2 as the input for
5123 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005124 */
5125 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005126 /* mute analog inputs */
5127 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005132
5133 /*
5134 * Set up output mixers (0x08 - 0x0a)
5135 */
5136 /* set vol=0 to output mixers */
5137 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5138 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5139 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5140 /* set up input amps for analog loopback */
5141 /* Amp Indices: DAC = 0, mixer = 1 */
5142 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5143 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5144 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5145 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5146 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5147 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005148
Kailang Yangdf694da2005-12-05 19:42:22 +01005149 { }
5150};
5151
5152static int alc260_parse_auto_config(struct hda_codec *codec)
5153{
5154 struct alc_spec *spec = codec->spec;
5155 unsigned int wcap;
5156 int err;
5157 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5158
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005159 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5160 alc260_ignore);
5161 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005162 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005163 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5164 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005165 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005166 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01005167 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005168 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5169 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005170 return err;
5171
5172 spec->multiout.max_channels = 2;
5173
5174 if (spec->autocfg.dig_out_pin)
5175 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5176 if (spec->kctl_alloc)
5177 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5178
5179 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5180
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005181 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005182 spec->input_mux = &spec->private_imux;
5183
5184 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005185 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005186 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005187 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005188 spec->adc_nids = alc260_adc_nids_alt;
5189 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5190 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005191 } else {
5192 spec->adc_nids = alc260_adc_nids;
5193 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5194 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005195 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005196 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005197
5198 return 1;
5199}
5200
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005201/* additional initialization for auto-configuration model */
5202static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005203{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005204 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005205 alc260_auto_init_multi_out(codec);
5206 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005207 if (spec->unsol_event)
5208 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005209}
5210
Takashi Iwaicb53c622007-08-10 17:21:45 +02005211#ifdef CONFIG_SND_HDA_POWER_SAVE
5212static struct hda_amp_list alc260_loopbacks[] = {
5213 { 0x07, HDA_INPUT, 0 },
5214 { 0x07, HDA_INPUT, 1 },
5215 { 0x07, HDA_INPUT, 2 },
5216 { 0x07, HDA_INPUT, 3 },
5217 { 0x07, HDA_INPUT, 4 },
5218 { } /* end */
5219};
5220#endif
5221
Kailang Yangdf694da2005-12-05 19:42:22 +01005222/*
5223 * ALC260 configurations
5224 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005225static const char *alc260_models[ALC260_MODEL_LAST] = {
5226 [ALC260_BASIC] = "basic",
5227 [ALC260_HP] = "hp",
5228 [ALC260_HP_3013] = "hp-3013",
5229 [ALC260_FUJITSU_S702X] = "fujitsu",
5230 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005231 [ALC260_WILL] = "will",
5232 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005233#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005234 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005235#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005236 [ALC260_AUTO] = "auto",
5237};
5238
5239static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005240 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005241 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005242 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005243 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005244 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005245 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005246 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005247 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5248 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5249 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5250 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5251 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5252 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5253 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5254 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5255 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005256 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005257 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005258 {}
5259};
5260
Kailang Yangdf694da2005-12-05 19:42:22 +01005261static struct alc_config_preset alc260_presets[] = {
5262 [ALC260_BASIC] = {
5263 .mixers = { alc260_base_output_mixer,
5264 alc260_input_mixer,
5265 alc260_pc_beep_mixer,
5266 alc260_capture_mixer },
5267 .init_verbs = { alc260_init_verbs },
5268 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5269 .dac_nids = alc260_dac_nids,
5270 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5271 .adc_nids = alc260_adc_nids,
5272 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5273 .channel_mode = alc260_modes,
5274 .input_mux = &alc260_capture_source,
5275 },
5276 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005277 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005278 alc260_input_mixer,
5279 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005280 .init_verbs = { alc260_init_verbs,
5281 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005282 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5283 .dac_nids = alc260_dac_nids,
5284 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5285 .adc_nids = alc260_hp_adc_nids,
5286 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5287 .channel_mode = alc260_modes,
5288 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005289 .unsol_event = alc260_hp_unsol_event,
5290 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005291 },
Kailang Yang3f878302008-08-26 13:02:23 +02005292 [ALC260_HP_DC7600] = {
5293 .mixers = { alc260_hp_dc7600_mixer,
5294 alc260_input_mixer,
5295 alc260_capture_alt_mixer },
5296 .init_verbs = { alc260_init_verbs,
5297 alc260_hp_dc7600_verbs },
5298 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5299 .dac_nids = alc260_dac_nids,
5300 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5301 .adc_nids = alc260_hp_adc_nids,
5302 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5303 .channel_mode = alc260_modes,
5304 .input_mux = &alc260_capture_source,
5305 .unsol_event = alc260_hp_3012_unsol_event,
5306 .init_hook = alc260_hp_3012_automute,
5307 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005308 [ALC260_HP_3013] = {
5309 .mixers = { alc260_hp_3013_mixer,
5310 alc260_input_mixer,
5311 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005312 .init_verbs = { alc260_hp_3013_init_verbs,
5313 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005314 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5315 .dac_nids = alc260_dac_nids,
5316 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5317 .adc_nids = alc260_hp_adc_nids,
5318 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5319 .channel_mode = alc260_modes,
5320 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005321 .unsol_event = alc260_hp_3013_unsol_event,
5322 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005323 },
5324 [ALC260_FUJITSU_S702X] = {
5325 .mixers = { alc260_fujitsu_mixer,
5326 alc260_capture_mixer },
5327 .init_verbs = { alc260_fujitsu_init_verbs },
5328 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5329 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005330 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5331 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005332 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5333 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005334 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5335 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005336 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005337 [ALC260_ACER] = {
5338 .mixers = { alc260_acer_mixer,
5339 alc260_capture_mixer },
5340 .init_verbs = { alc260_acer_init_verbs },
5341 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5342 .dac_nids = alc260_dac_nids,
5343 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5344 .adc_nids = alc260_dual_adc_nids,
5345 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5346 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005347 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5348 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005349 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005350 [ALC260_WILL] = {
5351 .mixers = { alc260_will_mixer,
5352 alc260_capture_mixer },
5353 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5354 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5355 .dac_nids = alc260_dac_nids,
5356 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5357 .adc_nids = alc260_adc_nids,
5358 .dig_out_nid = ALC260_DIGOUT_NID,
5359 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5360 .channel_mode = alc260_modes,
5361 .input_mux = &alc260_capture_source,
5362 },
5363 [ALC260_REPLACER_672V] = {
5364 .mixers = { alc260_replacer_672v_mixer,
5365 alc260_capture_mixer },
5366 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5367 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5368 .dac_nids = alc260_dac_nids,
5369 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5370 .adc_nids = alc260_adc_nids,
5371 .dig_out_nid = ALC260_DIGOUT_NID,
5372 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5373 .channel_mode = alc260_modes,
5374 .input_mux = &alc260_capture_source,
5375 .unsol_event = alc260_replacer_672v_unsol_event,
5376 .init_hook = alc260_replacer_672v_automute,
5377 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005378#ifdef CONFIG_SND_DEBUG
5379 [ALC260_TEST] = {
5380 .mixers = { alc260_test_mixer,
5381 alc260_capture_mixer },
5382 .init_verbs = { alc260_test_init_verbs },
5383 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5384 .dac_nids = alc260_test_dac_nids,
5385 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5386 .adc_nids = alc260_test_adc_nids,
5387 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5388 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005389 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5390 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005391 },
5392#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005393};
5394
Linus Torvalds1da177e2005-04-16 15:20:36 -07005395static int patch_alc260(struct hda_codec *codec)
5396{
5397 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005398 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005399
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005400 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005401 if (spec == NULL)
5402 return -ENOMEM;
5403
5404 codec->spec = spec;
5405
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005406 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5407 alc260_models,
5408 alc260_cfg_tbl);
5409 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005410 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5411 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005412 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005413 }
5414
Kailang Yangdf694da2005-12-05 19:42:22 +01005415 if (board_config == ALC260_AUTO) {
5416 /* automatic parse from the BIOS config */
5417 err = alc260_parse_auto_config(codec);
5418 if (err < 0) {
5419 alc_free(codec);
5420 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005421 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005422 printk(KERN_INFO
5423 "hda_codec: Cannot set up configuration "
5424 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005425 board_config = ALC260_BASIC;
5426 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005427 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005428
Kailang Yangdf694da2005-12-05 19:42:22 +01005429 if (board_config != ALC260_AUTO)
5430 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005431
5432 spec->stream_name_analog = "ALC260 Analog";
5433 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5434 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5435
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005436 spec->stream_name_digital = "ALC260 Digital";
5437 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5438 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5439
Takashi Iwai2134ea42008-01-10 16:53:55 +01005440 spec->vmaster_nid = 0x08;
5441
Linus Torvalds1da177e2005-04-16 15:20:36 -07005442 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005443 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005444 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005445#ifdef CONFIG_SND_HDA_POWER_SAVE
5446 if (!spec->loopback.amplist)
5447 spec->loopback.amplist = alc260_loopbacks;
5448#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005449
5450 return 0;
5451}
5452
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005453
Linus Torvalds1da177e2005-04-16 15:20:36 -07005454/*
5455 * ALC882 support
5456 *
5457 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5458 * configuration. Each pin widget can choose any input DACs and a mixer.
5459 * Each ADC is connected from a mixer of all inputs. This makes possible
5460 * 6-channel independent captures.
5461 *
5462 * In addition, an independent DAC for the multi-playback (not used in this
5463 * driver yet).
5464 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005465#define ALC882_DIGOUT_NID 0x06
5466#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005467
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005468static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005469 { 8, NULL }
5470};
5471
5472static hda_nid_t alc882_dac_nids[4] = {
5473 /* front, rear, clfe, rear_surr */
5474 0x02, 0x03, 0x04, 0x05
5475};
5476
Kailang Yangdf694da2005-12-05 19:42:22 +01005477/* identical with ALC880 */
5478#define alc882_adc_nids alc880_adc_nids
5479#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005480
Takashi Iwaie1406342008-02-11 18:32:32 +01005481static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5482static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5483
Linus Torvalds1da177e2005-04-16 15:20:36 -07005484/* input MUX */
5485/* FIXME: should be a matrix-type input source selection */
5486
5487static struct hda_input_mux alc882_capture_source = {
5488 .num_items = 4,
5489 .items = {
5490 { "Mic", 0x0 },
5491 { "Front Mic", 0x1 },
5492 { "Line", 0x2 },
5493 { "CD", 0x4 },
5494 },
5495};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005496#define alc882_mux_enum_info alc_mux_enum_info
5497#define alc882_mux_enum_get alc_mux_enum_get
5498
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005499static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5500 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005501{
5502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5503 struct alc_spec *spec = codec->spec;
5504 const struct hda_input_mux *imux = spec->input_mux;
5505 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005506 hda_nid_t nid = spec->capsrc_nids ?
5507 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005508 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5509 unsigned int i, idx;
5510
5511 idx = ucontrol->value.enumerated.item[0];
5512 if (idx >= imux->num_items)
5513 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005514 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005515 return 0;
5516 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005517 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5518 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005519 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005520 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005521 }
5522 *cur_val = idx;
5523 return 1;
5524}
5525
Kailang Yangdf694da2005-12-05 19:42:22 +01005526/*
Kailang Yang272a5272007-05-14 11:00:38 +02005527 * 2ch mode
5528 */
5529static struct hda_verb alc882_3ST_ch2_init[] = {
5530 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5531 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5532 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5533 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5534 { } /* end */
5535};
5536
5537/*
5538 * 6ch mode
5539 */
5540static struct hda_verb alc882_3ST_ch6_init[] = {
5541 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5542 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5543 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5544 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5545 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5546 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5547 { } /* end */
5548};
5549
5550static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5551 { 2, alc882_3ST_ch2_init },
5552 { 6, alc882_3ST_ch6_init },
5553};
5554
5555/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005556 * 6ch mode
5557 */
5558static struct hda_verb alc882_sixstack_ch6_init[] = {
5559 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5560 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5561 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5562 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5563 { } /* end */
5564};
5565
5566/*
5567 * 8ch mode
5568 */
5569static struct hda_verb alc882_sixstack_ch8_init[] = {
5570 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5571 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5572 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5573 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5574 { } /* end */
5575};
5576
5577static struct hda_channel_mode alc882_sixstack_modes[2] = {
5578 { 6, alc882_sixstack_ch6_init },
5579 { 8, alc882_sixstack_ch8_init },
5580};
5581
Takashi Iwai87350ad2007-08-16 18:19:38 +02005582/*
5583 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5584 */
5585
5586/*
5587 * 2ch mode
5588 */
5589static struct hda_verb alc885_mbp_ch2_init[] = {
5590 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5591 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5592 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5593 { } /* end */
5594};
5595
5596/*
5597 * 6ch mode
5598 */
5599static struct hda_verb alc885_mbp_ch6_init[] = {
5600 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5601 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5602 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5603 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5604 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5605 { } /* end */
5606};
5607
5608static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5609 { 2, alc885_mbp_ch2_init },
5610 { 6, alc885_mbp_ch6_init },
5611};
5612
5613
Linus Torvalds1da177e2005-04-16 15:20:36 -07005614/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5615 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5616 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005617static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005618 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005619 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005620 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005621 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005622 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5623 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005624 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5625 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005626 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005627 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005628 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5629 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5630 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5631 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5632 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005634 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005635 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5636 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005637 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005638 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5639 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5640 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005641 { } /* end */
5642};
5643
Takashi Iwai87350ad2007-08-16 18:19:38 +02005644static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005645 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5646 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5647 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5648 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5649 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5650 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5652 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005653 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005654 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5655 { } /* end */
5656};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005657static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5658 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5659 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5660 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5661 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5662 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5663 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5664 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5665 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5666 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5667 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5668 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5669 { } /* end */
5670};
5671
Kailang Yang272a5272007-05-14 11:00:38 +02005672static struct snd_kcontrol_new alc882_targa_mixer[] = {
5673 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5674 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5675 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5676 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5677 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5678 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5679 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005682 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005683 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5684 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005685 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005686 { } /* end */
5687};
5688
5689/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5690 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5691 */
5692static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5693 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5694 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5695 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5696 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5697 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5698 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5699 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5700 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5701 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5702 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5703 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5704 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005705 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005706 { } /* end */
5707};
5708
Takashi Iwai914759b2007-09-06 14:52:04 +02005709static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5710 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5711 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5712 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5713 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5714 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5715 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5716 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5717 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5718 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5719 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5720 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5721 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5722 { } /* end */
5723};
5724
Kailang Yangdf694da2005-12-05 19:42:22 +01005725static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5726 {
5727 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5728 .name = "Channel Mode",
5729 .info = alc_ch_mode_info,
5730 .get = alc_ch_mode_get,
5731 .put = alc_ch_mode_put,
5732 },
5733 { } /* end */
5734};
5735
Linus Torvalds1da177e2005-04-16 15:20:36 -07005736static struct hda_verb alc882_init_verbs[] = {
5737 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005741 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5743 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5744 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005745 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005746 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5747 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005749 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005750 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5751 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5752 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005753
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005754 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005755 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005756 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005757 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005758 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005759 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005760 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005761 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005762 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005763 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005764 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005765 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005766 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005767 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005768 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005769 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005770 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005771 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005772 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5773 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005774 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005775 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5776 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005777 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005778 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5779 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5780 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5781 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5782 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005783 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005784 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005785
5786 /* FIXME: use matrix-type input source selection */
5787 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5788 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005789 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5792 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005793 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005794 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5795 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5797 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005798 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005799 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5800 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5803 /* ADC1: mute amp left and right */
5804 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005805 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005806 /* ADC2: mute amp left and right */
5807 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005808 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005809 /* ADC3: mute amp left and right */
5810 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005811 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005812
5813 { }
5814};
5815
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005816static struct hda_verb alc882_eapd_verbs[] = {
5817 /* change to EAPD mode */
5818 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005819 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005820 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005821};
5822
Tobin Davis9102cd12006-12-15 10:02:12 +01005823/* Mac Pro test */
5824static struct snd_kcontrol_new alc882_macpro_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_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5828 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5829 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5830 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5831 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5832 { } /* end */
5833};
5834
5835static struct hda_verb alc882_macpro_init_verbs[] = {
5836 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5840 /* Front Pin: output 0 (0x0c) */
5841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5843 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5844 /* Front Mic pin: input vref at 80% */
5845 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5846 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5847 /* Speaker: output */
5848 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5849 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5850 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5851 /* Headphone output (output 0 - 0x0c) */
5852 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5853 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5854 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5855
5856 /* FIXME: use matrix-type input source selection */
5857 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5858 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5863 /* Input mixer2 */
5864 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5865 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5866 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5868 /* Input mixer3 */
5869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5873 /* ADC1: mute amp left and right */
5874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5875 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5876 /* ADC2: mute amp left and right */
5877 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5878 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5879 /* ADC3: mute amp left and right */
5880 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5881 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5882
5883 { }
5884};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005885
Takashi Iwai87350ad2007-08-16 18:19:38 +02005886/* Macbook Pro rev3 */
5887static struct hda_verb alc885_mbp3_init_verbs[] = {
5888 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5892 /* Rear mixer */
5893 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5896 /* Front Pin: output 0 (0x0c) */
5897 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5898 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5899 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5900 /* HP Pin: output 0 (0x0d) */
5901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5902 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5903 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5904 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5905 /* Mic (rear) pin: input vref at 80% */
5906 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5907 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5908 /* Front Mic pin: input vref at 80% */
5909 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5910 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5911 /* Line In pin: use output 1 when in LineOut mode */
5912 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5913 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5914 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5915
5916 /* FIXME: use matrix-type input source selection */
5917 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5918 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5919 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5922 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5923 /* Input mixer2 */
5924 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5925 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5926 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5927 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5928 /* Input mixer3 */
5929 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5930 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5932 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5933 /* ADC1: mute amp left and right */
5934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5935 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5936 /* ADC2: mute amp left and right */
5937 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5938 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5939 /* ADC3: mute amp left and right */
5940 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5941 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5942
5943 { }
5944};
5945
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005946/* iMac 24 mixer. */
5947static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5948 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5949 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5950 { } /* end */
5951};
5952
5953/* iMac 24 init verbs. */
5954static struct hda_verb alc885_imac24_init_verbs[] = {
5955 /* Internal speakers: output 0 (0x0c) */
5956 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5957 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5958 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5959 /* Internal speakers: output 0 (0x0c) */
5960 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5961 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5962 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5963 /* Headphone: output 0 (0x0c) */
5964 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5966 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5967 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5968 /* Front Mic: input vref at 80% */
5969 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5970 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5971 { }
5972};
5973
5974/* Toggle speaker-output according to the hp-jack state */
5975static void alc885_imac24_automute(struct hda_codec *codec)
5976{
5977 unsigned int present;
5978
5979 present = snd_hda_codec_read(codec, 0x14, 0,
5980 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005981 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5982 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5983 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5984 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005985}
5986
5987/* Processes unsolicited events. */
5988static void alc885_imac24_unsol_event(struct hda_codec *codec,
5989 unsigned int res)
5990{
5991 /* Headphone insertion or removal. */
5992 if ((res >> 26) == ALC880_HP_EVENT)
5993 alc885_imac24_automute(codec);
5994}
5995
Takashi Iwai87350ad2007-08-16 18:19:38 +02005996static void alc885_mbp3_automute(struct hda_codec *codec)
5997{
5998 unsigned int present;
5999
6000 present = snd_hda_codec_read(codec, 0x15, 0,
6001 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6002 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6003 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6004 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6005 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6006
6007}
6008static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6009 unsigned int res)
6010{
6011 /* Headphone insertion or removal. */
6012 if ((res >> 26) == ALC880_HP_EVENT)
6013 alc885_mbp3_automute(codec);
6014}
6015
6016
Kailang Yang272a5272007-05-14 11:00:38 +02006017static struct hda_verb alc882_targa_verbs[] = {
6018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6020
6021 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6022 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006023
Kailang Yang272a5272007-05-14 11:00:38 +02006024 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6025 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6026 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6027
6028 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6029 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6030 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6031 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6032 { } /* end */
6033};
6034
6035/* toggle speaker-output according to the hp-jack state */
6036static void alc882_targa_automute(struct hda_codec *codec)
6037{
6038 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006039
Kailang Yang272a5272007-05-14 11:00:38 +02006040 present = snd_hda_codec_read(codec, 0x14, 0,
6041 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006042 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6043 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006044 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6045 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006046}
6047
6048static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6049{
6050 /* Looks like the unsol event is incompatible with the standard
6051 * definition. 4bit tag is placed at 26 bit!
6052 */
6053 if (((res >> 26) == ALC880_HP_EVENT)) {
6054 alc882_targa_automute(codec);
6055 }
6056}
6057
6058static struct hda_verb alc882_asus_a7j_verbs[] = {
6059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6060 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6061
6062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6064 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006065
Kailang Yang272a5272007-05-14 11:00:38 +02006066 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6067 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6068 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6069
6070 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6071 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6072 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6073 { } /* end */
6074};
6075
Takashi Iwai914759b2007-09-06 14:52:04 +02006076static struct hda_verb alc882_asus_a7m_verbs[] = {
6077 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6078 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6079
6080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6081 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6082 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006083
Takashi Iwai914759b2007-09-06 14:52:04 +02006084 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6085 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6086 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6087
6088 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6089 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6090 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6091 { } /* end */
6092};
6093
Tobin Davis9102cd12006-12-15 10:02:12 +01006094static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6095{
6096 unsigned int gpiostate, gpiomask, gpiodir;
6097
6098 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6099 AC_VERB_GET_GPIO_DATA, 0);
6100
6101 if (!muted)
6102 gpiostate |= (1 << pin);
6103 else
6104 gpiostate &= ~(1 << pin);
6105
6106 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6107 AC_VERB_GET_GPIO_MASK, 0);
6108 gpiomask |= (1 << pin);
6109
6110 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6111 AC_VERB_GET_GPIO_DIRECTION, 0);
6112 gpiodir |= (1 << pin);
6113
6114
6115 snd_hda_codec_write(codec, codec->afg, 0,
6116 AC_VERB_SET_GPIO_MASK, gpiomask);
6117 snd_hda_codec_write(codec, codec->afg, 0,
6118 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6119
6120 msleep(1);
6121
6122 snd_hda_codec_write(codec, codec->afg, 0,
6123 AC_VERB_SET_GPIO_DATA, gpiostate);
6124}
6125
Takashi Iwai7debbe52007-08-16 15:01:03 +02006126/* set up GPIO at initialization */
6127static void alc885_macpro_init_hook(struct hda_codec *codec)
6128{
6129 alc882_gpio_mute(codec, 0, 0);
6130 alc882_gpio_mute(codec, 1, 0);
6131}
6132
6133/* set up GPIO and update auto-muting at initialization */
6134static void alc885_imac24_init_hook(struct hda_codec *codec)
6135{
6136 alc885_macpro_init_hook(codec);
6137 alc885_imac24_automute(codec);
6138}
6139
Kailang Yangdf694da2005-12-05 19:42:22 +01006140/*
6141 * generic initialization of ADC, input mixers and output mixers
6142 */
6143static struct hda_verb alc882_auto_init_verbs[] = {
6144 /*
6145 * Unmute ADC0-2 and set the default input to mic-in
6146 */
6147 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6149 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6150 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6151 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6152 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6153
Takashi Iwaicb53c622007-08-10 17:21:45 +02006154 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006155 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006156 * Note: PASD motherboards uses the Line In 2 as the input for
6157 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006158 */
6159 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6161 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6162 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6163 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6164 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006165
6166 /*
6167 * Set up output mixers (0x0c - 0x0f)
6168 */
6169 /* set vol=0 to output mixers */
6170 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6171 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6172 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6173 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6174 /* set up input amps for analog loopback */
6175 /* Amp Indices: DAC = 0, mixer = 1 */
6176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6178 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6179 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6180 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6181 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6182 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6183 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6184 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6185 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6186
6187 /* FIXME: use matrix-type input source selection */
6188 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6189 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6190 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6191 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6192 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6194 /* Input mixer2 */
6195 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6196 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6197 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6198 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6199 /* Input mixer3 */
6200 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6201 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6202 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6204
6205 { }
6206};
6207
6208/* capture mixer elements */
6209static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6210 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6211 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6212 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6213 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6214 {
6215 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6216 /* The multiple "Capture Source" controls confuse alsamixer
6217 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006218 */
6219 /* .name = "Capture Source", */
6220 .name = "Input Source",
6221 .count = 2,
6222 .info = alc882_mux_enum_info,
6223 .get = alc882_mux_enum_get,
6224 .put = alc882_mux_enum_put,
6225 },
6226 { } /* end */
6227};
6228
6229static struct snd_kcontrol_new alc882_capture_mixer[] = {
6230 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6231 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6232 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6233 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6234 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6235 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6236 {
6237 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6238 /* The multiple "Capture Source" controls confuse alsamixer
6239 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006240 */
6241 /* .name = "Capture Source", */
6242 .name = "Input Source",
6243 .count = 3,
6244 .info = alc882_mux_enum_info,
6245 .get = alc882_mux_enum_get,
6246 .put = alc882_mux_enum_put,
6247 },
6248 { } /* end */
6249};
6250
Takashi Iwaicb53c622007-08-10 17:21:45 +02006251#ifdef CONFIG_SND_HDA_POWER_SAVE
6252#define alc882_loopbacks alc880_loopbacks
6253#endif
6254
Kailang Yangdf694da2005-12-05 19:42:22 +01006255/* pcm configuration: identiacal with ALC880 */
6256#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6257#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6258#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6259#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6260
6261/*
6262 * configuration and preset
6263 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006264static const char *alc882_models[ALC882_MODEL_LAST] = {
6265 [ALC882_3ST_DIG] = "3stack-dig",
6266 [ALC882_6ST_DIG] = "6stack-dig",
6267 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006268 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006269 [ALC882_TARGA] = "targa",
6270 [ALC882_ASUS_A7J] = "asus-a7j",
6271 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006272 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006273 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006274 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006275 [ALC882_AUTO] = "auto",
6276};
6277
6278static struct snd_pci_quirk alc882_cfg_tbl[] = {
6279 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006280 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006281 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006282 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006283 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006284 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006285 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006286 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006287 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006288 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6289 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6290 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006291 {}
6292};
6293
6294static struct alc_config_preset alc882_presets[] = {
6295 [ALC882_3ST_DIG] = {
6296 .mixers = { alc882_base_mixer },
6297 .init_verbs = { alc882_init_verbs },
6298 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6299 .dac_nids = alc882_dac_nids,
6300 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006301 .dig_in_nid = ALC882_DIGIN_NID,
6302 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6303 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006304 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006305 .input_mux = &alc882_capture_source,
6306 },
6307 [ALC882_6ST_DIG] = {
6308 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6309 .init_verbs = { alc882_init_verbs },
6310 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6311 .dac_nids = alc882_dac_nids,
6312 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006313 .dig_in_nid = ALC882_DIGIN_NID,
6314 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6315 .channel_mode = alc882_sixstack_modes,
6316 .input_mux = &alc882_capture_source,
6317 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006318 [ALC882_ARIMA] = {
6319 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6320 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6321 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6322 .dac_nids = alc882_dac_nids,
6323 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6324 .channel_mode = alc882_sixstack_modes,
6325 .input_mux = &alc882_capture_source,
6326 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006327 [ALC882_W2JC] = {
6328 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6329 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6330 alc880_gpio1_init_verbs },
6331 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6332 .dac_nids = alc882_dac_nids,
6333 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6334 .channel_mode = alc880_threestack_modes,
6335 .need_dac_fix = 1,
6336 .input_mux = &alc882_capture_source,
6337 .dig_out_nid = ALC882_DIGOUT_NID,
6338 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006339 [ALC885_MBP3] = {
6340 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6341 .init_verbs = { alc885_mbp3_init_verbs,
6342 alc880_gpio1_init_verbs },
6343 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6344 .dac_nids = alc882_dac_nids,
6345 .channel_mode = alc885_mbp_6ch_modes,
6346 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6347 .input_mux = &alc882_capture_source,
6348 .dig_out_nid = ALC882_DIGOUT_NID,
6349 .dig_in_nid = ALC882_DIGIN_NID,
6350 .unsol_event = alc885_mbp3_unsol_event,
6351 .init_hook = alc885_mbp3_automute,
6352 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006353 [ALC885_MACPRO] = {
6354 .mixers = { alc882_macpro_mixer },
6355 .init_verbs = { alc882_macpro_init_verbs },
6356 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6357 .dac_nids = alc882_dac_nids,
6358 .dig_out_nid = ALC882_DIGOUT_NID,
6359 .dig_in_nid = ALC882_DIGIN_NID,
6360 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6361 .channel_mode = alc882_ch_modes,
6362 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006363 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006364 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006365 [ALC885_IMAC24] = {
6366 .mixers = { alc885_imac24_mixer },
6367 .init_verbs = { alc885_imac24_init_verbs },
6368 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6369 .dac_nids = alc882_dac_nids,
6370 .dig_out_nid = ALC882_DIGOUT_NID,
6371 .dig_in_nid = ALC882_DIGIN_NID,
6372 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6373 .channel_mode = alc882_ch_modes,
6374 .input_mux = &alc882_capture_source,
6375 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006376 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006377 },
Kailang Yang272a5272007-05-14 11:00:38 +02006378 [ALC882_TARGA] = {
6379 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6380 alc882_capture_mixer },
6381 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6382 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6383 .dac_nids = alc882_dac_nids,
6384 .dig_out_nid = ALC882_DIGOUT_NID,
6385 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6386 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006387 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006388 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6389 .channel_mode = alc882_3ST_6ch_modes,
6390 .need_dac_fix = 1,
6391 .input_mux = &alc882_capture_source,
6392 .unsol_event = alc882_targa_unsol_event,
6393 .init_hook = alc882_targa_automute,
6394 },
6395 [ALC882_ASUS_A7J] = {
6396 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6397 alc882_capture_mixer },
6398 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6399 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6400 .dac_nids = alc882_dac_nids,
6401 .dig_out_nid = ALC882_DIGOUT_NID,
6402 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6403 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006404 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006405 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6406 .channel_mode = alc882_3ST_6ch_modes,
6407 .need_dac_fix = 1,
6408 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006409 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006410 [ALC882_ASUS_A7M] = {
6411 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6412 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6413 alc880_gpio1_init_verbs,
6414 alc882_asus_a7m_verbs },
6415 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6416 .dac_nids = alc882_dac_nids,
6417 .dig_out_nid = ALC882_DIGOUT_NID,
6418 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6419 .channel_mode = alc880_threestack_modes,
6420 .need_dac_fix = 1,
6421 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006422 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006423};
6424
6425
6426/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006427 * Pin config fixes
6428 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006429enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006430 PINFIX_ABIT_AW9D_MAX
6431};
6432
6433static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6434 { 0x15, 0x01080104 }, /* side */
6435 { 0x16, 0x01011012 }, /* rear */
6436 { 0x17, 0x01016011 }, /* clfe */
6437 { }
6438};
6439
6440static const struct alc_pincfg *alc882_pin_fixes[] = {
6441 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6442};
6443
6444static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6445 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6446 {}
6447};
6448
6449/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006450 * BIOS auto configuration
6451 */
6452static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6453 hda_nid_t nid, int pin_type,
6454 int dac_idx)
6455{
6456 /* set as output */
6457 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006458 int idx;
6459
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006460 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006461 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6462 idx = 4;
6463 else
6464 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006465 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6466
6467}
6468
6469static void alc882_auto_init_multi_out(struct hda_codec *codec)
6470{
6471 struct alc_spec *spec = codec->spec;
6472 int i;
6473
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006474 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006475 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006476 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006477 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006478 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006479 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006480 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006481 }
6482}
6483
6484static void alc882_auto_init_hp_out(struct hda_codec *codec)
6485{
6486 struct alc_spec *spec = codec->spec;
6487 hda_nid_t pin;
6488
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006489 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006490 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006491 /* use dac 0 */
6492 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006493 pin = spec->autocfg.speaker_pins[0];
6494 if (pin)
6495 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006496}
6497
6498#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6499#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6500
6501static void alc882_auto_init_analog_input(struct hda_codec *codec)
6502{
6503 struct alc_spec *spec = codec->spec;
6504 int i;
6505
6506 for (i = 0; i < AUTO_PIN_LAST; i++) {
6507 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006508 unsigned int vref;
6509 if (!nid)
6510 continue;
6511 vref = PIN_IN;
6512 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006513 unsigned int pincap;
6514 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6515 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006516 AC_PINCAP_VREF_80)
6517 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006518 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006519 snd_hda_codec_write(codec, nid, 0,
6520 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6521 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6522 snd_hda_codec_write(codec, nid, 0,
6523 AC_VERB_SET_AMP_GAIN_MUTE,
6524 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006525 }
6526}
6527
Takashi Iwaif511b012008-08-15 16:46:42 +02006528static void alc882_auto_init_input_src(struct hda_codec *codec)
6529{
6530 struct alc_spec *spec = codec->spec;
6531 const struct hda_input_mux *imux = spec->input_mux;
6532 int c;
6533
6534 for (c = 0; c < spec->num_adc_nids; c++) {
6535 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6536 hda_nid_t nid = spec->capsrc_nids[c];
6537 int conns, mute, idx, item;
6538
6539 conns = snd_hda_get_connections(codec, nid, conn_list,
6540 ARRAY_SIZE(conn_list));
6541 if (conns < 0)
6542 continue;
6543 for (idx = 0; idx < conns; idx++) {
6544 /* if the current connection is the selected one,
6545 * unmute it as default - otherwise mute it
6546 */
6547 mute = AMP_IN_MUTE(idx);
6548 for (item = 0; item < imux->num_items; item++) {
6549 if (imux->items[item].index == idx) {
6550 if (spec->cur_mux[c] == item)
6551 mute = AMP_IN_UNMUTE(idx);
6552 break;
6553 }
6554 }
6555 snd_hda_codec_write(codec, nid, 0,
6556 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6557 }
6558 }
6559}
6560
Takashi Iwai776e1842007-08-29 15:07:11 +02006561/* add mic boosts if needed */
6562static int alc_auto_add_mic_boost(struct hda_codec *codec)
6563{
6564 struct alc_spec *spec = codec->spec;
6565 int err;
6566 hda_nid_t nid;
6567
6568 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006569 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006570 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6571 "Mic Boost",
6572 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6573 if (err < 0)
6574 return err;
6575 }
6576 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006577 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006578 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6579 "Front Mic Boost",
6580 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6581 if (err < 0)
6582 return err;
6583 }
6584 return 0;
6585}
6586
Kailang Yangdf694da2005-12-05 19:42:22 +01006587/* almost identical with ALC880 parser... */
6588static int alc882_parse_auto_config(struct hda_codec *codec)
6589{
6590 struct alc_spec *spec = codec->spec;
6591 int err = alc880_parse_auto_config(codec);
6592
6593 if (err < 0)
6594 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006595 else if (!err)
6596 return 0; /* no config found */
6597
6598 err = alc_auto_add_mic_boost(codec);
6599 if (err < 0)
6600 return err;
6601
6602 /* hack - override the init verbs */
6603 spec->init_verbs[0] = alc882_auto_init_verbs;
6604
6605 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006606}
6607
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006608/* additional initialization for auto-configuration model */
6609static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006610{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006611 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006612 alc882_auto_init_multi_out(codec);
6613 alc882_auto_init_hp_out(codec);
6614 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006615 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006616 if (spec->unsol_event)
6617 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006618}
6619
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006620static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6621
Linus Torvalds1da177e2005-04-16 15:20:36 -07006622static int patch_alc882(struct hda_codec *codec)
6623{
6624 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006625 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006626
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006627 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006628 if (spec == NULL)
6629 return -ENOMEM;
6630
Linus Torvalds1da177e2005-04-16 15:20:36 -07006631 codec->spec = spec;
6632
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006633 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6634 alc882_models,
6635 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006636
Kailang Yangdf694da2005-12-05 19:42:22 +01006637 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006638 /* Pick up systems that don't supply PCI SSID */
6639 switch (codec->subsystem_id) {
6640 case 0x106b0c00: /* Mac Pro */
6641 board_config = ALC885_MACPRO;
6642 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006643 case 0x106b1000: /* iMac 24 */
6644 board_config = ALC885_IMAC24;
6645 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006646 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006647 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006648 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006649 board_config = ALC885_MBP3;
6650 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006651 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006652 /* ALC889A is handled better as ALC888-compatible */
6653 if (codec->revision_id == 0x100103) {
6654 alc_free(codec);
6655 return patch_alc883(codec);
6656 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006657 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6658 "trying auto-probe from BIOS...\n");
6659 board_config = ALC882_AUTO;
6660 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006661 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006662
Takashi Iwaif95474e2007-07-10 00:47:43 +02006663 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6664
Kailang Yangdf694da2005-12-05 19:42:22 +01006665 if (board_config == ALC882_AUTO) {
6666 /* automatic parse from the BIOS config */
6667 err = alc882_parse_auto_config(codec);
6668 if (err < 0) {
6669 alc_free(codec);
6670 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006671 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006672 printk(KERN_INFO
6673 "hda_codec: Cannot set up configuration "
6674 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006675 board_config = ALC882_3ST_DIG;
6676 }
6677 }
6678
6679 if (board_config != ALC882_AUTO)
6680 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006681
Kailang Yang2f893282008-05-27 12:14:47 +02006682 if (codec->vendor_id == 0x10ec0885) {
6683 spec->stream_name_analog = "ALC885 Analog";
6684 spec->stream_name_digital = "ALC885 Digital";
6685 } else {
6686 spec->stream_name_analog = "ALC882 Analog";
6687 spec->stream_name_digital = "ALC882 Digital";
6688 }
6689
Kailang Yangdf694da2005-12-05 19:42:22 +01006690 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6691 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006692 /* FIXME: setup DAC5 */
6693 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6694 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006695
Kailang Yangdf694da2005-12-05 19:42:22 +01006696 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6697 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006698
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006699 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006700 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006701 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006702 /* get type */
6703 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006704 if (wcap != AC_WID_AUD_IN) {
6705 spec->adc_nids = alc882_adc_nids_alt;
6706 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006707 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006708 spec->mixers[spec->num_mixers] =
6709 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006710 spec->num_mixers++;
6711 } else {
6712 spec->adc_nids = alc882_adc_nids;
6713 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006714 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006715 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6716 spec->num_mixers++;
6717 }
6718 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006719
Takashi Iwai2134ea42008-01-10 16:53:55 +01006720 spec->vmaster_nid = 0x0c;
6721
Linus Torvalds1da177e2005-04-16 15:20:36 -07006722 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006723 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006724 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006725#ifdef CONFIG_SND_HDA_POWER_SAVE
6726 if (!spec->loopback.amplist)
6727 spec->loopback.amplist = alc882_loopbacks;
6728#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006729
6730 return 0;
6731}
6732
6733/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006734 * ALC883 support
6735 *
6736 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6737 * configuration. Each pin widget can choose any input DACs and a mixer.
6738 * Each ADC is connected from a mixer of all inputs. This makes possible
6739 * 6-channel independent captures.
6740 *
6741 * In addition, an independent DAC for the multi-playback (not used in this
6742 * driver yet).
6743 */
6744#define ALC883_DIGOUT_NID 0x06
6745#define ALC883_DIGIN_NID 0x0a
6746
6747static hda_nid_t alc883_dac_nids[4] = {
6748 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006749 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006750};
6751
6752static hda_nid_t alc883_adc_nids[2] = {
6753 /* ADC1-2 */
6754 0x08, 0x09,
6755};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006756
Takashi Iwaie1406342008-02-11 18:32:32 +01006757static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6758
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006759/* input MUX */
6760/* FIXME: should be a matrix-type input source selection */
6761
6762static struct hda_input_mux alc883_capture_source = {
6763 .num_items = 4,
6764 .items = {
6765 { "Mic", 0x0 },
6766 { "Front Mic", 0x1 },
6767 { "Line", 0x2 },
6768 { "CD", 0x4 },
6769 },
6770};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006771
Jiang zhe17bba1b2008-06-04 12:11:07 +02006772static struct hda_input_mux alc883_3stack_6ch_intel = {
6773 .num_items = 4,
6774 .items = {
6775 { "Mic", 0x1 },
6776 { "Front Mic", 0x0 },
6777 { "Line", 0x2 },
6778 { "CD", 0x4 },
6779 },
6780};
6781
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006782static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6783 .num_items = 2,
6784 .items = {
6785 { "Mic", 0x1 },
6786 { "Line", 0x2 },
6787 },
6788};
6789
Kailang Yang272a5272007-05-14 11:00:38 +02006790static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6791 .num_items = 4,
6792 .items = {
6793 { "Mic", 0x0 },
6794 { "iMic", 0x1 },
6795 { "Line", 0x2 },
6796 { "CD", 0x4 },
6797 },
6798};
6799
Jiang zhefb97dc62008-03-06 11:07:11 +01006800static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6801 .num_items = 2,
6802 .items = {
6803 { "Mic", 0x0 },
6804 { "Int Mic", 0x1 },
6805 },
6806};
6807
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006808#define alc883_mux_enum_info alc_mux_enum_info
6809#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006810/* ALC883 has the ALC882-type input selection */
6811#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006812
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006813/*
6814 * 2ch mode
6815 */
6816static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6817 { 2, NULL }
6818};
6819
6820/*
6821 * 2ch mode
6822 */
6823static struct hda_verb alc883_3ST_ch2_init[] = {
6824 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6825 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6826 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6827 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6828 { } /* end */
6829};
6830
6831/*
Tobin Davisb2011312007-09-17 12:45:11 +02006832 * 4ch mode
6833 */
6834static struct hda_verb alc883_3ST_ch4_init[] = {
6835 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6836 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6837 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6838 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6839 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6840 { } /* end */
6841};
6842
6843/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006844 * 6ch mode
6845 */
6846static struct hda_verb alc883_3ST_ch6_init[] = {
6847 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6848 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6849 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6850 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6851 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6852 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6853 { } /* end */
6854};
6855
Tobin Davisb2011312007-09-17 12:45:11 +02006856static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006857 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006858 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006859 { 6, alc883_3ST_ch6_init },
6860};
6861
6862/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02006863 * 2ch mode
6864 */
6865static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6866 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6867 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6868 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6869 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6870 { } /* end */
6871};
6872
6873/*
6874 * 4ch mode
6875 */
6876static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6877 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6878 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6879 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6880 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6881 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6882 { } /* end */
6883};
6884
6885/*
6886 * 6ch mode
6887 */
6888static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6889 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6890 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6891 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6892 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6893 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6894 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6895 { } /* end */
6896};
6897
6898static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6899 { 2, alc883_3ST_ch2_intel_init },
6900 { 4, alc883_3ST_ch4_intel_init },
6901 { 6, alc883_3ST_ch6_intel_init },
6902};
6903
6904/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006905 * 6ch mode
6906 */
6907static struct hda_verb alc883_sixstack_ch6_init[] = {
6908 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6909 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6910 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6911 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6912 { } /* end */
6913};
6914
6915/*
6916 * 8ch mode
6917 */
6918static struct hda_verb alc883_sixstack_ch8_init[] = {
6919 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6920 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6921 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6922 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6923 { } /* end */
6924};
6925
6926static struct hda_channel_mode alc883_sixstack_modes[2] = {
6927 { 6, alc883_sixstack_ch6_init },
6928 { 8, alc883_sixstack_ch8_init },
6929};
6930
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006931static struct hda_verb alc883_medion_eapd_verbs[] = {
6932 /* eanable EAPD on medion laptop */
6933 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6934 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6935 { }
6936};
6937
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006938/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6939 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6940 */
6941
6942static struct snd_kcontrol_new alc883_base_mixer[] = {
6943 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6944 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6946 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6949 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6950 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6951 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6952 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6953 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6954 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6955 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6956 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6957 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006959 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6961 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006962 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006963 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6964 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6965 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6966 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6967 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6968 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6969 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6970 {
6971 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6972 /* .name = "Capture Source", */
6973 .name = "Input Source",
6974 .count = 2,
6975 .info = alc883_mux_enum_info,
6976 .get = alc883_mux_enum_get,
6977 .put = alc883_mux_enum_put,
6978 },
6979 { } /* end */
6980};
6981
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006982static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6984 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6985 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6986 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6987 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6988 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6989 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6990 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6991 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6992 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6993 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6994 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6996 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6997 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6998 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6999 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7000 {
7001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7002 /* .name = "Capture Source", */
7003 .name = "Input Source",
7004 .count = 2,
7005 .info = alc883_mux_enum_info,
7006 .get = alc883_mux_enum_get,
7007 .put = alc883_mux_enum_put,
7008 },
7009 { } /* end */
7010};
7011
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007012static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007013 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7014 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7015 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7016 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7017 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7018 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7019 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7020 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7021 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7022 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7023 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7024 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7025 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7026 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7027 {
7028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7029 /* .name = "Capture Source", */
7030 .name = "Input Source",
7031 .count = 2,
7032 .info = alc883_mux_enum_info,
7033 .get = alc883_mux_enum_get,
7034 .put = alc883_mux_enum_put,
7035 },
7036 { } /* end */
7037};
7038
Jiang zhefb97dc62008-03-06 11:07:11 +01007039static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7040 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7041 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7042 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7043 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7045 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7048 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7049 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7050 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7051 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7052 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7053 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7054 {
7055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7056 /* .name = "Capture Source", */
7057 .name = "Input Source",
7058 .count = 2,
7059 .info = alc883_mux_enum_info,
7060 .get = alc883_mux_enum_get,
7061 .put = alc883_mux_enum_put,
7062 },
7063 { } /* end */
7064};
7065
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007066static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7067 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7068 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7069 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7072 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7073 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7074 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007075 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007076 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7077 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007078 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007079 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7080 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7081 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7082 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7083 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7084 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7085 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7086 {
7087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7088 /* .name = "Capture Source", */
7089 .name = "Input Source",
7090 .count = 2,
7091 .info = alc883_mux_enum_info,
7092 .get = alc883_mux_enum_get,
7093 .put = alc883_mux_enum_put,
7094 },
7095 { } /* end */
7096};
7097
7098static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7099 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7100 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7101 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7102 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7103 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7104 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7105 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7106 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7107 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7115 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007116 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007117 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7118 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7119 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7120 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7121 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7122 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7123 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7124 {
7125 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7126 /* .name = "Capture Source", */
7127 .name = "Input Source",
7128 .count = 2,
7129 .info = alc883_mux_enum_info,
7130 .get = alc883_mux_enum_get,
7131 .put = alc883_mux_enum_put,
7132 },
7133 { } /* end */
7134};
7135
Jiang zhe17bba1b2008-06-04 12:11:07 +02007136static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7137 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7138 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7139 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7140 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7141 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7142 HDA_OUTPUT),
7143 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7144 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7145 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7146 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7147 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7148 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7149 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7150 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7151 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7152 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7153 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7154 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7155 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7156 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7157 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7158 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7159 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7160 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7161 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7162 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7163 {
7164 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7165 /* .name = "Capture Source", */
7166 .name = "Input Source",
7167 .count = 2,
7168 .info = alc883_mux_enum_info,
7169 .get = alc883_mux_enum_get,
7170 .put = alc883_mux_enum_put,
7171 },
7172 { } /* end */
7173};
7174
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007175static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007176 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007177 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007178 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007179 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007180 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7181 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007182 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7183 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007184 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7185 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7186 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7187 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7188 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7189 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007190 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7192 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007193 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007194 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7195 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7196 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7197 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7198 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7199
7200 {
7201 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7202 /* .name = "Capture Source", */
7203 .name = "Input Source",
7204 .count = 1,
7205 .info = alc883_mux_enum_info,
7206 .get = alc883_mux_enum_get,
7207 .put = alc883_mux_enum_put,
7208 },
7209 { } /* end */
7210};
7211
Kailang Yangccc656c2006-10-17 12:32:26 +02007212static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7213 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7214 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7215 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7216 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7217 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7218 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7219 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7220 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7221 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7222 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7223 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7224 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7225 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7226 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007227 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007228 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7229 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7230 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7231 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7232 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7233 {
7234 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7235 /* .name = "Capture Source", */
7236 .name = "Input Source",
7237 .count = 2,
7238 .info = alc883_mux_enum_info,
7239 .get = alc883_mux_enum_get,
7240 .put = alc883_mux_enum_put,
7241 },
7242 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007243};
Kailang Yangccc656c2006-10-17 12:32:26 +02007244
7245static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7246 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7247 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7248 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7249 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7250 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007252 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007253 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007254 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7255 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7256 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007257 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7258 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7259 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7260 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7261 {
7262 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7263 /* .name = "Capture Source", */
7264 .name = "Input Source",
7265 .count = 2,
7266 .info = alc883_mux_enum_info,
7267 .get = alc883_mux_enum_get,
7268 .put = alc883_mux_enum_put,
7269 },
7270 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007271};
Kailang Yangccc656c2006-10-17 12:32:26 +02007272
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007273static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7274 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7275 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007276 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7277 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007278 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7280 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7282 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7283 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7284 {
7285 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7286 /* .name = "Capture Source", */
7287 .name = "Input Source",
7288 .count = 1,
7289 .info = alc883_mux_enum_info,
7290 .get = alc883_mux_enum_get,
7291 .put = alc883_mux_enum_put,
7292 },
7293 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007294};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007295
Kailang Yang272a5272007-05-14 11:00:38 +02007296static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7297 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7298 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7299 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7300 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7301 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7303 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7304 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7305 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7306 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7307 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7308 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7309 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7310 {
7311 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7312 /* .name = "Capture Source", */
7313 .name = "Input Source",
7314 .count = 2,
7315 .info = alc883_mux_enum_info,
7316 .get = alc883_mux_enum_get,
7317 .put = alc883_mux_enum_put,
7318 },
7319 { } /* end */
7320};
7321
7322static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7323 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7324 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7325 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7326 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7327 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7328 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7329 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7330 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7331 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7332 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7333 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7334 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7335 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7336 {
7337 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7338 /* .name = "Capture Source", */
7339 .name = "Input Source",
7340 .count = 2,
7341 .info = alc883_mux_enum_info,
7342 .get = alc883_mux_enum_get,
7343 .put = alc883_mux_enum_put,
7344 },
7345 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007346};
Kailang Yang272a5272007-05-14 11:00:38 +02007347
Tobin Davis2880a862007-08-07 11:50:26 +02007348static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007349 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7350 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007351 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007352 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7353 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7355 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007357 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7358 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7359 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7360 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7361 {
7362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7363 /* .name = "Capture Source", */
7364 .name = "Input Source",
7365 .count = 2,
7366 .info = alc883_mux_enum_info,
7367 .get = alc883_mux_enum_get,
7368 .put = alc883_mux_enum_put,
7369 },
7370 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007371};
Tobin Davis2880a862007-08-07 11:50:26 +02007372
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007373static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7374 {
7375 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7376 .name = "Channel Mode",
7377 .info = alc_ch_mode_info,
7378 .get = alc_ch_mode_get,
7379 .put = alc_ch_mode_put,
7380 },
7381 { } /* end */
7382};
7383
7384static struct hda_verb alc883_init_verbs[] = {
7385 /* ADC1: mute amp left and right */
7386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7387 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7388 /* ADC2: mute amp left and right */
7389 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7390 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7391 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7395 /* Rear mixer */
7396 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7397 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7398 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7399 /* CLFE mixer */
7400 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7401 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7402 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7403 /* Side mixer */
7404 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7405 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7406 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7407
Takashi Iwaicb53c622007-08-10 17:21:45 +02007408 /* mute analog input loopbacks */
7409 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7411 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7412 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7413 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007414
7415 /* Front Pin: output 0 (0x0c) */
7416 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7417 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7418 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7419 /* Rear Pin: output 1 (0x0d) */
7420 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7422 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7423 /* CLFE Pin: output 2 (0x0e) */
7424 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7425 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7426 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7427 /* Side Pin: output 3 (0x0f) */
7428 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7429 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7430 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7431 /* Mic (rear) pin: input vref at 80% */
7432 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7433 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7434 /* Front Mic pin: input vref at 80% */
7435 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7436 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7437 /* Line In pin: input */
7438 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7439 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7440 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7441 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7442 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7443 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7444 /* CD pin widget for input */
7445 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7446
7447 /* FIXME: use matrix-type input source selection */
7448 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7449 /* Input mixer2 */
7450 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7451 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7454 /* Input mixer3 */
7455 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7459 { }
7460};
7461
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007462/* toggle speaker-output according to the hp-jack state */
7463static void alc883_mitac_hp_automute(struct hda_codec *codec)
7464{
7465 unsigned int present;
7466
7467 present = snd_hda_codec_read(codec, 0x15, 0,
7468 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7469 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7470 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7471 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7472 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7473}
7474
7475/* auto-toggle front mic */
7476/*
7477static void alc883_mitac_mic_automute(struct hda_codec *codec)
7478{
7479 unsigned int present;
7480 unsigned char bits;
7481
7482 present = snd_hda_codec_read(codec, 0x18, 0,
7483 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7484 bits = present ? HDA_AMP_MUTE : 0;
7485 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7486}
7487*/
7488
7489static void alc883_mitac_automute(struct hda_codec *codec)
7490{
7491 alc883_mitac_hp_automute(codec);
7492 /* alc883_mitac_mic_automute(codec); */
7493}
7494
7495static void alc883_mitac_unsol_event(struct hda_codec *codec,
7496 unsigned int res)
7497{
7498 switch (res >> 26) {
7499 case ALC880_HP_EVENT:
7500 alc883_mitac_hp_automute(codec);
7501 break;
7502 case ALC880_MIC_EVENT:
7503 /* alc883_mitac_mic_automute(codec); */
7504 break;
7505 }
7506}
7507
7508static struct hda_verb alc883_mitac_verbs[] = {
7509 /* HP */
7510 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7511 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7512 /* Subwoofer */
7513 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7514 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7515
7516 /* enable unsolicited event */
7517 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7518 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7519
7520 { } /* end */
7521};
7522
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007523static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007524 /* HP */
7525 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7527 /* Int speaker */
7528 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7529 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7530
7531 /* enable unsolicited event */
7532 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007533 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007534
7535 { } /* end */
7536};
7537
Jiang zhefb97dc62008-03-06 11:07:11 +01007538static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7539 /* HP */
7540 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7541 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7542 /* Subwoofer */
7543 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7544 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7545
7546 /* enable unsolicited event */
7547 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7548
7549 { } /* end */
7550};
7551
Kailang Yangccc656c2006-10-17 12:32:26 +02007552static struct hda_verb alc883_tagra_verbs[] = {
7553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7555
7556 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7557 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007558
Kailang Yangccc656c2006-10-17 12:32:26 +02007559 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7560 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7561 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7562
7563 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007564 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7565 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7566 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007567
7568 { } /* end */
7569};
7570
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007571static struct hda_verb alc883_lenovo_101e_verbs[] = {
7572 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7573 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7574 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7575 { } /* end */
7576};
7577
Kailang Yang272a5272007-05-14 11:00:38 +02007578static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7579 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7581 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7582 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7583 { } /* end */
7584};
7585
7586static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7589 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7590 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7591 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7592 { } /* end */
7593};
7594
Kailang Yang189609a2007-08-20 11:31:23 +02007595static struct hda_verb alc883_haier_w66_verbs[] = {
7596 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7598
7599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7600
7601 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7602 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7603 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7604 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7605 { } /* end */
7606};
7607
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007608static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007609 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007610 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7611 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007612 { }
7613};
7614
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007615static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007616 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7617 { }
7618};
7619
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007620static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007621 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7622 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7623 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7624 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7625 { }
7626};
7627
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007628static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007629 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7630 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7631 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7632 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7633 { }
7634};
7635
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007636static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7637 { 2, alc888_3st_hp_2ch_init },
7638 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007639};
7640
Kailang Yang272a5272007-05-14 11:00:38 +02007641/* toggle front-jack and RCA according to the hp-jack state */
7642static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7643{
7644 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007645
Kailang Yang272a5272007-05-14 11:00:38 +02007646 present = snd_hda_codec_read(codec, 0x1b, 0,
7647 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007648 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7649 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7650 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7651 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007652}
7653
7654/* toggle RCA according to the front-jack state */
7655static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7656{
7657 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007658
Kailang Yang272a5272007-05-14 11:00:38 +02007659 present = snd_hda_codec_read(codec, 0x14, 0,
7660 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007661 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7662 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007663}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007664
Kailang Yang272a5272007-05-14 11:00:38 +02007665static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7666 unsigned int res)
7667{
7668 if ((res >> 26) == ALC880_HP_EVENT)
7669 alc888_lenovo_ms7195_front_automute(codec);
7670 if ((res >> 26) == ALC880_FRONT_EVENT)
7671 alc888_lenovo_ms7195_rca_automute(codec);
7672}
7673
7674static struct hda_verb alc883_medion_md2_verbs[] = {
7675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7676 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7677
7678 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7679
7680 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7681 { } /* end */
7682};
7683
7684/* toggle speaker-output according to the hp-jack state */
7685static void alc883_medion_md2_automute(struct hda_codec *codec)
7686{
7687 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007688
Kailang Yang272a5272007-05-14 11:00:38 +02007689 present = snd_hda_codec_read(codec, 0x14, 0,
7690 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007691 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7692 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007693}
7694
7695static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7696 unsigned int res)
7697{
7698 if ((res >> 26) == ALC880_HP_EVENT)
7699 alc883_medion_md2_automute(codec);
7700}
7701
Kailang Yangccc656c2006-10-17 12:32:26 +02007702/* toggle speaker-output according to the hp-jack state */
7703static void alc883_tagra_automute(struct hda_codec *codec)
7704{
7705 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007706 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007707
7708 present = snd_hda_codec_read(codec, 0x14, 0,
7709 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007710 bits = present ? HDA_AMP_MUTE : 0;
7711 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7712 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007713 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7714 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007715}
7716
7717static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7718{
7719 if ((res >> 26) == ALC880_HP_EVENT)
7720 alc883_tagra_automute(codec);
7721}
7722
Jiang zhe368c7a92008-03-04 11:20:33 +01007723/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007724static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007725{
7726 unsigned int present;
7727 unsigned char bits;
7728
7729 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7730 & AC_PINSENSE_PRESENCE;
7731 bits = present ? HDA_AMP_MUTE : 0;
7732 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7733 HDA_AMP_MUTE, bits);
7734}
7735
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007736static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7737{
7738 unsigned int present;
7739
7740 present = snd_hda_codec_read(codec, 0x18, 0,
7741 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7742 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7743 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7744}
7745
7746static void alc883_clevo_m720_automute(struct hda_codec *codec)
7747{
7748 alc883_clevo_m720_hp_automute(codec);
7749 alc883_clevo_m720_mic_automute(codec);
7750}
7751
7752static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007753 unsigned int res)
7754{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007755 switch (res >> 26) {
7756 case ALC880_HP_EVENT:
7757 alc883_clevo_m720_hp_automute(codec);
7758 break;
7759 case ALC880_MIC_EVENT:
7760 alc883_clevo_m720_mic_automute(codec);
7761 break;
7762 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007763}
7764
Jiang zhefb97dc62008-03-06 11:07:11 +01007765/* toggle speaker-output according to the hp-jack state */
7766static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7767{
7768 unsigned int present;
7769 unsigned char bits;
7770
7771 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7772 & AC_PINSENSE_PRESENCE;
7773 bits = present ? HDA_AMP_MUTE : 0;
7774 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7775 HDA_AMP_MUTE, bits);
7776}
7777
7778static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7779 unsigned int res)
7780{
7781 if ((res >> 26) == ALC880_HP_EVENT)
7782 alc883_2ch_fujitsu_pi2515_automute(codec);
7783}
7784
Kailang Yang189609a2007-08-20 11:31:23 +02007785static void alc883_haier_w66_automute(struct hda_codec *codec)
7786{
7787 unsigned int present;
7788 unsigned char bits;
7789
7790 present = snd_hda_codec_read(codec, 0x1b, 0,
7791 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7792 bits = present ? 0x80 : 0;
7793 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7794 0x80, bits);
7795}
7796
7797static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7798 unsigned int res)
7799{
7800 if ((res >> 26) == ALC880_HP_EVENT)
7801 alc883_haier_w66_automute(codec);
7802}
7803
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007804static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7805{
7806 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007807 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007808
7809 present = snd_hda_codec_read(codec, 0x14, 0,
7810 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007811 bits = present ? HDA_AMP_MUTE : 0;
7812 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7813 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007814}
7815
7816static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7817{
7818 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007819 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007820
7821 present = snd_hda_codec_read(codec, 0x1b, 0,
7822 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007823 bits = present ? HDA_AMP_MUTE : 0;
7824 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7825 HDA_AMP_MUTE, bits);
7826 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7827 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007828}
7829
7830static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7831 unsigned int res)
7832{
7833 if ((res >> 26) == ALC880_HP_EVENT)
7834 alc883_lenovo_101e_all_automute(codec);
7835 if ((res >> 26) == ALC880_FRONT_EVENT)
7836 alc883_lenovo_101e_ispeaker_automute(codec);
7837}
7838
Takashi Iwai676a9b52007-08-16 15:23:35 +02007839/* toggle speaker-output according to the hp-jack state */
7840static void alc883_acer_aspire_automute(struct hda_codec *codec)
7841{
7842 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007843
Takashi Iwai676a9b52007-08-16 15:23:35 +02007844 present = snd_hda_codec_read(codec, 0x14, 0,
7845 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7846 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7847 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7848 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7849 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7850}
7851
7852static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7853 unsigned int res)
7854{
7855 if ((res >> 26) == ALC880_HP_EVENT)
7856 alc883_acer_aspire_automute(codec);
7857}
7858
Kailang Yangd1a991a2007-08-15 16:21:59 +02007859static struct hda_verb alc883_acer_eapd_verbs[] = {
7860 /* HP Pin: output 0 (0x0c) */
7861 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7862 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7863 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7864 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007865 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7866 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007867 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007868 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7869 /* eanable EAPD on medion laptop */
7870 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7871 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007872 /* enable unsolicited event */
7873 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007874 { }
7875};
7876
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007877static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7878{
7879 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007880
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007881 present = snd_hda_codec_read(codec, 0x1b, 0,
7882 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7883 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7884 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7885 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7886 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7887 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7888 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7889 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7890 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7891}
7892
7893static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7894 unsigned int res)
7895{
7896 switch (res >> 26) {
7897 case ALC880_HP_EVENT:
7898 printk("hp_event\n");
7899 alc888_6st_dell_front_automute(codec);
7900 break;
7901 }
7902}
7903
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007904/*
7905 * generic initialization of ADC, input mixers and output mixers
7906 */
7907static struct hda_verb alc883_auto_init_verbs[] = {
7908 /*
7909 * Unmute ADC0-2 and set the default input to mic-in
7910 */
7911 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7912 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7913 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7914 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7915
Takashi Iwaicb53c622007-08-10 17:21:45 +02007916 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007917 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007918 * Note: PASD motherboards uses the Line In 2 as the input for
7919 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007920 */
7921 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007922 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7923 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007927
7928 /*
7929 * Set up output mixers (0x0c - 0x0f)
7930 */
7931 /* set vol=0 to output mixers */
7932 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7933 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7934 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7935 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7936 /* set up input amps for analog loopback */
7937 /* Amp Indices: DAC = 0, mixer = 1 */
7938 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7939 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7940 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7941 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7942 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7943 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7944 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7945 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7946 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7947 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7948
7949 /* FIXME: use matrix-type input source selection */
7950 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7951 /* Input mixer1 */
7952 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7953 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7954 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007955 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007956 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7957 /* Input mixer2 */
7958 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7959 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7960 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007961 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007962 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007963
7964 { }
7965};
7966
7967/* capture mixer elements */
7968static struct snd_kcontrol_new alc883_capture_mixer[] = {
7969 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7970 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7971 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7972 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7973 {
7974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7975 /* The multiple "Capture Source" controls confuse alsamixer
7976 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007977 */
7978 /* .name = "Capture Source", */
7979 .name = "Input Source",
7980 .count = 2,
7981 .info = alc882_mux_enum_info,
7982 .get = alc882_mux_enum_get,
7983 .put = alc882_mux_enum_put,
7984 },
7985 { } /* end */
7986};
7987
Takashi Iwaicb53c622007-08-10 17:21:45 +02007988#ifdef CONFIG_SND_HDA_POWER_SAVE
7989#define alc883_loopbacks alc880_loopbacks
7990#endif
7991
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007992/* pcm configuration: identiacal with ALC880 */
7993#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7994#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007995#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007996#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7997#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7998
7999/*
8000 * configuration and preset
8001 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008002static const char *alc883_models[ALC883_MODEL_LAST] = {
8003 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8004 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8005 [ALC883_3ST_6ch] = "3stack-6ch",
8006 [ALC883_6ST_DIG] = "6stack-dig",
8007 [ALC883_TARGA_DIG] = "targa-dig",
8008 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008009 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008010 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008011 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008012 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008013 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008014 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008015 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8016 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02008017 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008018 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008019 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008020 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008021 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008022 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008023 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008024 [ALC883_AUTO] = "auto",
8025};
8026
8027static struct snd_pci_quirk alc883_cfg_tbl[] = {
8028 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008029 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8030 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8031 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008032 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008033 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008034 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008035 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008036 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8037 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008038 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008039 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Travis Place97ec7102008-05-23 18:31:46 +02008040 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008041 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008042 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8043 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
8044 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008045 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008046 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8047 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8048 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008049 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008050 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008051 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008052 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8053 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8054 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8055 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8056 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8057 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8058 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8059 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8060 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008061 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8062 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008063 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008064 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008065 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008066 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008067 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008068 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008069 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8070 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008071 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008072 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008073 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008074 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02008075 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008076 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008077 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8078 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02008079 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008080 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008081 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008082 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8083 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008084 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008085 {}
8086};
8087
8088static struct alc_config_preset alc883_presets[] = {
8089 [ALC883_3ST_2ch_DIG] = {
8090 .mixers = { alc883_3ST_2ch_mixer },
8091 .init_verbs = { alc883_init_verbs },
8092 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8093 .dac_nids = alc883_dac_nids,
8094 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008095 .dig_in_nid = ALC883_DIGIN_NID,
8096 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8097 .channel_mode = alc883_3ST_2ch_modes,
8098 .input_mux = &alc883_capture_source,
8099 },
8100 [ALC883_3ST_6ch_DIG] = {
8101 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8102 .init_verbs = { alc883_init_verbs },
8103 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8104 .dac_nids = alc883_dac_nids,
8105 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008106 .dig_in_nid = ALC883_DIGIN_NID,
8107 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8108 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008109 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008110 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008111 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008112 [ALC883_3ST_6ch] = {
8113 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8114 .init_verbs = { alc883_init_verbs },
8115 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8116 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008117 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8118 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008119 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008120 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008121 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008122 [ALC883_3ST_6ch_INTEL] = {
8123 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8124 .init_verbs = { alc883_init_verbs },
8125 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8126 .dac_nids = alc883_dac_nids,
8127 .dig_out_nid = ALC883_DIGOUT_NID,
8128 .dig_in_nid = ALC883_DIGIN_NID,
8129 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8130 .channel_mode = alc883_3ST_6ch_intel_modes,
8131 .need_dac_fix = 1,
8132 .input_mux = &alc883_3stack_6ch_intel,
8133 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008134 [ALC883_6ST_DIG] = {
8135 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8136 .init_verbs = { alc883_init_verbs },
8137 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8138 .dac_nids = alc883_dac_nids,
8139 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008140 .dig_in_nid = ALC883_DIGIN_NID,
8141 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8142 .channel_mode = alc883_sixstack_modes,
8143 .input_mux = &alc883_capture_source,
8144 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008145 [ALC883_TARGA_DIG] = {
8146 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8147 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8148 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8149 .dac_nids = alc883_dac_nids,
8150 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008151 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8152 .channel_mode = alc883_3ST_6ch_modes,
8153 .need_dac_fix = 1,
8154 .input_mux = &alc883_capture_source,
8155 .unsol_event = alc883_tagra_unsol_event,
8156 .init_hook = alc883_tagra_automute,
8157 },
8158 [ALC883_TARGA_2ch_DIG] = {
8159 .mixers = { alc883_tagra_2ch_mixer},
8160 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8161 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8162 .dac_nids = alc883_dac_nids,
8163 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008164 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8165 .channel_mode = alc883_3ST_2ch_modes,
8166 .input_mux = &alc883_capture_source,
8167 .unsol_event = alc883_tagra_unsol_event,
8168 .init_hook = alc883_tagra_automute,
8169 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008170 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008171 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008172 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8173 * and the headphone jack. Turn this on and rely on the
8174 * standard mute methods whenever the user wants to turn
8175 * these outputs off.
8176 */
8177 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8178 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8179 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008180 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8181 .channel_mode = alc883_3ST_2ch_modes,
8182 .input_mux = &alc883_capture_source,
8183 },
Tobin Davis2880a862007-08-07 11:50:26 +02008184 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008185 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008186 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008187 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8188 .dac_nids = alc883_dac_nids,
8189 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008190 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8191 .channel_mode = alc883_3ST_2ch_modes,
8192 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008193 .unsol_event = alc883_acer_aspire_unsol_event,
8194 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008195 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008196 [ALC883_MEDION] = {
8197 .mixers = { alc883_fivestack_mixer,
8198 alc883_chmode_mixer },
8199 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008200 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008201 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8202 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02008203 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8204 .channel_mode = alc883_sixstack_modes,
8205 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008206 },
Kailang Yang272a5272007-05-14 11:00:38 +02008207 [ALC883_MEDION_MD2] = {
8208 .mixers = { alc883_medion_md2_mixer},
8209 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8210 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8211 .dac_nids = alc883_dac_nids,
8212 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008213 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8214 .channel_mode = alc883_3ST_2ch_modes,
8215 .input_mux = &alc883_capture_source,
8216 .unsol_event = alc883_medion_md2_unsol_event,
8217 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008218 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008219 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008220 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008221 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8222 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8223 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008224 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8225 .channel_mode = alc883_3ST_2ch_modes,
8226 .input_mux = &alc883_capture_source,
8227 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008228 [ALC883_CLEVO_M720] = {
8229 .mixers = { alc883_clevo_m720_mixer },
8230 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008231 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8232 .dac_nids = alc883_dac_nids,
8233 .dig_out_nid = ALC883_DIGOUT_NID,
8234 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8235 .channel_mode = alc883_3ST_2ch_modes,
8236 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008237 .unsol_event = alc883_clevo_m720_unsol_event,
8238 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008239 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008240 [ALC883_LENOVO_101E_2ch] = {
8241 .mixers = { alc883_lenovo_101e_2ch_mixer},
8242 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8243 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8244 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008245 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8246 .channel_mode = alc883_3ST_2ch_modes,
8247 .input_mux = &alc883_lenovo_101e_capture_source,
8248 .unsol_event = alc883_lenovo_101e_unsol_event,
8249 .init_hook = alc883_lenovo_101e_all_automute,
8250 },
Kailang Yang272a5272007-05-14 11:00:38 +02008251 [ALC883_LENOVO_NB0763] = {
8252 .mixers = { alc883_lenovo_nb0763_mixer },
8253 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8254 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8255 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008256 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8257 .channel_mode = alc883_3ST_2ch_modes,
8258 .need_dac_fix = 1,
8259 .input_mux = &alc883_lenovo_nb0763_capture_source,
8260 .unsol_event = alc883_medion_md2_unsol_event,
8261 .init_hook = alc883_medion_md2_automute,
8262 },
8263 [ALC888_LENOVO_MS7195_DIG] = {
8264 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8265 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8266 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8267 .dac_nids = alc883_dac_nids,
8268 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008269 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8270 .channel_mode = alc883_3ST_6ch_modes,
8271 .need_dac_fix = 1,
8272 .input_mux = &alc883_capture_source,
8273 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8274 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008275 },
8276 [ALC883_HAIER_W66] = {
8277 .mixers = { alc883_tagra_2ch_mixer},
8278 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8279 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8280 .dac_nids = alc883_dac_nids,
8281 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008282 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8283 .channel_mode = alc883_3ST_2ch_modes,
8284 .input_mux = &alc883_capture_source,
8285 .unsol_event = alc883_haier_w66_unsol_event,
8286 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008287 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008288 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008289 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008290 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008291 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8292 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008293 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8294 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008295 .need_dac_fix = 1,
8296 .input_mux = &alc883_capture_source,
8297 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008298 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008299 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008300 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8301 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8302 .dac_nids = alc883_dac_nids,
8303 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008304 .dig_in_nid = ALC883_DIGIN_NID,
8305 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8306 .channel_mode = alc883_sixstack_modes,
8307 .input_mux = &alc883_capture_source,
8308 .unsol_event = alc888_6st_dell_unsol_event,
8309 .init_hook = alc888_6st_dell_front_automute,
8310 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008311 [ALC883_MITAC] = {
8312 .mixers = { alc883_mitac_mixer },
8313 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8314 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8315 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008316 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8317 .channel_mode = alc883_3ST_2ch_modes,
8318 .input_mux = &alc883_capture_source,
8319 .unsol_event = alc883_mitac_unsol_event,
8320 .init_hook = alc883_mitac_automute,
8321 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008322 [ALC883_FUJITSU_PI2515] = {
8323 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8324 .init_verbs = { alc883_init_verbs,
8325 alc883_2ch_fujitsu_pi2515_verbs},
8326 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8327 .dac_nids = alc883_dac_nids,
8328 .dig_out_nid = ALC883_DIGOUT_NID,
8329 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8330 .channel_mode = alc883_3ST_2ch_modes,
8331 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8332 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8333 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8334 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008335};
8336
8337
8338/*
8339 * BIOS auto configuration
8340 */
8341static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8342 hda_nid_t nid, int pin_type,
8343 int dac_idx)
8344{
8345 /* set as output */
8346 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008347 int idx;
8348
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008349 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008350 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8351 idx = 4;
8352 else
8353 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008354 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8355
8356}
8357
8358static void alc883_auto_init_multi_out(struct hda_codec *codec)
8359{
8360 struct alc_spec *spec = codec->spec;
8361 int i;
8362
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008363 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008364 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008365 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008366 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008367 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008368 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008369 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008370 }
8371}
8372
8373static void alc883_auto_init_hp_out(struct hda_codec *codec)
8374{
8375 struct alc_spec *spec = codec->spec;
8376 hda_nid_t pin;
8377
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008378 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008379 if (pin) /* connect to front */
8380 /* use dac 0 */
8381 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008382 pin = spec->autocfg.speaker_pins[0];
8383 if (pin)
8384 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008385}
8386
8387#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8388#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8389
8390static void alc883_auto_init_analog_input(struct hda_codec *codec)
8391{
8392 struct alc_spec *spec = codec->spec;
8393 int i;
8394
8395 for (i = 0; i < AUTO_PIN_LAST; i++) {
8396 hda_nid_t nid = spec->autocfg.input_pins[i];
8397 if (alc883_is_input_pin(nid)) {
8398 snd_hda_codec_write(codec, nid, 0,
8399 AC_VERB_SET_PIN_WIDGET_CONTROL,
8400 (i <= AUTO_PIN_FRONT_MIC ?
8401 PIN_VREF80 : PIN_IN));
8402 if (nid != ALC883_PIN_CD_NID)
8403 snd_hda_codec_write(codec, nid, 0,
8404 AC_VERB_SET_AMP_GAIN_MUTE,
8405 AMP_OUT_MUTE);
8406 }
8407 }
8408}
8409
Takashi Iwaif511b012008-08-15 16:46:42 +02008410#define alc883_auto_init_input_src alc882_auto_init_input_src
8411
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008412/* almost identical with ALC880 parser... */
8413static int alc883_parse_auto_config(struct hda_codec *codec)
8414{
8415 struct alc_spec *spec = codec->spec;
8416 int err = alc880_parse_auto_config(codec);
8417
8418 if (err < 0)
8419 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008420 else if (!err)
8421 return 0; /* no config found */
8422
8423 err = alc_auto_add_mic_boost(codec);
8424 if (err < 0)
8425 return err;
8426
8427 /* hack - override the init verbs */
8428 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008429 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8430 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008431
8432 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008433}
8434
8435/* additional initialization for auto-configuration model */
8436static void alc883_auto_init(struct hda_codec *codec)
8437{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008438 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008439 alc883_auto_init_multi_out(codec);
8440 alc883_auto_init_hp_out(codec);
8441 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008442 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008443 if (spec->unsol_event)
8444 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008445}
8446
8447static int patch_alc883(struct hda_codec *codec)
8448{
8449 struct alc_spec *spec;
8450 int err, board_config;
8451
8452 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8453 if (spec == NULL)
8454 return -ENOMEM;
8455
8456 codec->spec = spec;
8457
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008458 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8459
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008460 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8461 alc883_models,
8462 alc883_cfg_tbl);
8463 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008464 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8465 "trying auto-probe from BIOS...\n");
8466 board_config = ALC883_AUTO;
8467 }
8468
8469 if (board_config == ALC883_AUTO) {
8470 /* automatic parse from the BIOS config */
8471 err = alc883_parse_auto_config(codec);
8472 if (err < 0) {
8473 alc_free(codec);
8474 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008475 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008476 printk(KERN_INFO
8477 "hda_codec: Cannot set up configuration "
8478 "from BIOS. Using base mode...\n");
8479 board_config = ALC883_3ST_2ch_DIG;
8480 }
8481 }
8482
8483 if (board_config != ALC883_AUTO)
8484 setup_preset(spec, &alc883_presets[board_config]);
8485
Kailang Yang2f893282008-05-27 12:14:47 +02008486 switch (codec->vendor_id) {
8487 case 0x10ec0888:
8488 spec->stream_name_analog = "ALC888 Analog";
8489 spec->stream_name_digital = "ALC888 Digital";
8490 break;
8491 case 0x10ec0889:
8492 spec->stream_name_analog = "ALC889 Analog";
8493 spec->stream_name_digital = "ALC889 Digital";
8494 break;
8495 default:
8496 spec->stream_name_analog = "ALC883 Analog";
8497 spec->stream_name_digital = "ALC883 Digital";
8498 break;
8499 }
8500
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008501 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8502 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008503 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008504
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008505 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8506 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8507
Takashi Iwaie1406342008-02-11 18:32:32 +01008508 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8509 spec->adc_nids = alc883_adc_nids;
8510 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008511
Takashi Iwai2134ea42008-01-10 16:53:55 +01008512 spec->vmaster_nid = 0x0c;
8513
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008514 codec->patch_ops = alc_patch_ops;
8515 if (board_config == ALC883_AUTO)
8516 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008517
Takashi Iwaicb53c622007-08-10 17:21:45 +02008518#ifdef CONFIG_SND_HDA_POWER_SAVE
8519 if (!spec->loopback.amplist)
8520 spec->loopback.amplist = alc883_loopbacks;
8521#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008522
8523 return 0;
8524}
8525
8526/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008527 * ALC262 support
8528 */
8529
8530#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8531#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8532
8533#define alc262_dac_nids alc260_dac_nids
8534#define alc262_adc_nids alc882_adc_nids
8535#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008536#define alc262_capsrc_nids alc882_capsrc_nids
8537#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008538
8539#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008540#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008541
8542static struct snd_kcontrol_new alc262_base_mixer[] = {
8543 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8544 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8545 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8546 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8547 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8548 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008551 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008552 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8553 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008554 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008555 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008556 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008557 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8558 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8559 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8560 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008561 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008562};
8563
Kailang Yangccc656c2006-10-17 12:32:26 +02008564static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8565 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8566 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8567 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8568 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8569 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8570 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008573 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008574 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8575 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008576 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008577 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008578 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008579 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8580 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8581 { } /* end */
8582};
8583
Takashi Iwaice875f02008-01-28 18:17:43 +01008584/* update HP, line and mono-out pins according to the master switch */
8585static void alc262_hp_master_update(struct hda_codec *codec)
8586{
8587 struct alc_spec *spec = codec->spec;
8588 int val = spec->master_sw;
8589
8590 /* HP & line-out */
8591 snd_hda_codec_write_cache(codec, 0x1b, 0,
8592 AC_VERB_SET_PIN_WIDGET_CONTROL,
8593 val ? PIN_HP : 0);
8594 snd_hda_codec_write_cache(codec, 0x15, 0,
8595 AC_VERB_SET_PIN_WIDGET_CONTROL,
8596 val ? PIN_HP : 0);
8597 /* mono (speaker) depending on the HP jack sense */
8598 val = val && !spec->jack_present;
8599 snd_hda_codec_write_cache(codec, 0x16, 0,
8600 AC_VERB_SET_PIN_WIDGET_CONTROL,
8601 val ? PIN_OUT : 0);
8602}
8603
8604static void alc262_hp_bpc_automute(struct hda_codec *codec)
8605{
8606 struct alc_spec *spec = codec->spec;
8607 unsigned int presence;
8608 presence = snd_hda_codec_read(codec, 0x1b, 0,
8609 AC_VERB_GET_PIN_SENSE, 0);
8610 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8611 alc262_hp_master_update(codec);
8612}
8613
8614static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8615{
8616 if ((res >> 26) != ALC880_HP_EVENT)
8617 return;
8618 alc262_hp_bpc_automute(codec);
8619}
8620
8621static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8622{
8623 struct alc_spec *spec = codec->spec;
8624 unsigned int presence;
8625 presence = snd_hda_codec_read(codec, 0x15, 0,
8626 AC_VERB_GET_PIN_SENSE, 0);
8627 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8628 alc262_hp_master_update(codec);
8629}
8630
8631static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8632 unsigned int res)
8633{
8634 if ((res >> 26) != ALC880_HP_EVENT)
8635 return;
8636 alc262_hp_wildwest_automute(codec);
8637}
8638
8639static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8640 struct snd_ctl_elem_value *ucontrol)
8641{
8642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8643 struct alc_spec *spec = codec->spec;
8644 *ucontrol->value.integer.value = spec->master_sw;
8645 return 0;
8646}
8647
8648static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8649 struct snd_ctl_elem_value *ucontrol)
8650{
8651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8652 struct alc_spec *spec = codec->spec;
8653 int val = !!*ucontrol->value.integer.value;
8654
8655 if (val == spec->master_sw)
8656 return 0;
8657 spec->master_sw = val;
8658 alc262_hp_master_update(codec);
8659 return 1;
8660}
8661
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008662static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008663 {
8664 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8665 .name = "Master Playback Switch",
8666 .info = snd_ctl_boolean_mono_info,
8667 .get = alc262_hp_master_sw_get,
8668 .put = alc262_hp_master_sw_put,
8669 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008670 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8671 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8672 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008673 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8674 HDA_OUTPUT),
8675 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8676 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008677 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8678 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008679 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008680 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8681 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008682 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008683 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8684 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8685 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8686 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8687 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8688 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8689 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8690 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8691 { } /* end */
8692};
8693
Kailang Yangcd7509a2007-01-26 18:33:17 +01008694static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008695 {
8696 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8697 .name = "Master Playback Switch",
8698 .info = snd_ctl_boolean_mono_info,
8699 .get = alc262_hp_master_sw_get,
8700 .put = alc262_hp_master_sw_put,
8701 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008702 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8703 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8704 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8705 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008706 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8707 HDA_OUTPUT),
8708 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8709 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008710 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8711 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008712 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008713 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8714 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8715 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8716 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8717 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8718 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8719 { } /* end */
8720};
8721
8722static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8723 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8724 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008725 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008726 { } /* end */
8727};
8728
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008729/* mute/unmute internal speaker according to the hp jack and mute state */
8730static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8731{
8732 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008733
8734 if (force || !spec->sense_updated) {
8735 unsigned int present;
8736 present = snd_hda_codec_read(codec, 0x15, 0,
8737 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008738 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008739 spec->sense_updated = 1;
8740 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008741 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8742 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008743}
8744
8745static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8746 unsigned int res)
8747{
8748 if ((res >> 26) != ALC880_HP_EVENT)
8749 return;
8750 alc262_hp_t5735_automute(codec, 1);
8751}
8752
8753static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8754{
8755 alc262_hp_t5735_automute(codec, 1);
8756}
8757
8758static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008759 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8760 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008761 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8762 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8765 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8766 { } /* end */
8767};
8768
8769static struct hda_verb alc262_hp_t5735_verbs[] = {
8770 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8771 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8772
8773 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8774 { }
8775};
8776
Kailang Yang8c427222008-01-10 13:03:59 +01008777static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008778 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008780 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8781 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008782 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8783 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8784 { } /* end */
8785};
8786
8787static struct hda_verb alc262_hp_rp5700_verbs[] = {
8788 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8789 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8790 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8791 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8792 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8793 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8794 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8795 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8797 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8798 {}
8799};
8800
8801static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8802 .num_items = 1,
8803 .items = {
8804 { "Line", 0x1 },
8805 },
8806};
8807
Takashi Iwai0724ea22007-08-23 00:31:43 +02008808/* bind hp and internal speaker mute (with plug check) */
8809static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8810 struct snd_ctl_elem_value *ucontrol)
8811{
8812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8813 long *valp = ucontrol->value.integer.value;
8814 int change;
8815
8816 /* change hp mute */
8817 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8818 HDA_AMP_MUTE,
8819 valp[0] ? 0 : HDA_AMP_MUTE);
8820 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8821 HDA_AMP_MUTE,
8822 valp[1] ? 0 : HDA_AMP_MUTE);
8823 if (change) {
8824 /* change speaker according to HP jack state */
8825 struct alc_spec *spec = codec->spec;
8826 unsigned int mute;
8827 if (spec->jack_present)
8828 mute = HDA_AMP_MUTE;
8829 else
8830 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8831 HDA_OUTPUT, 0);
8832 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8833 HDA_AMP_MUTE, mute);
8834 }
8835 return change;
8836}
Takashi Iwai5b319542007-07-26 11:49:22 +02008837
Kailang Yang272a5272007-05-14 11:00:38 +02008838static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008839 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8840 {
8841 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8842 .name = "Master Playback Switch",
8843 .info = snd_hda_mixer_amp_switch_info,
8844 .get = snd_hda_mixer_amp_switch_get,
8845 .put = alc262_sony_master_sw_put,
8846 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8847 },
Kailang Yang272a5272007-05-14 11:00:38 +02008848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8849 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8850 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8851 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8852 { } /* end */
8853};
8854
Kailang Yang83c34212007-07-05 11:43:05 +02008855static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8856 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8857 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8858 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8860 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8861 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8862 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8863 { } /* end */
8864};
Kailang Yang272a5272007-05-14 11:00:38 +02008865
Kailang Yangdf694da2005-12-05 19:42:22 +01008866#define alc262_capture_mixer alc882_capture_mixer
8867#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8868
8869/*
8870 * generic initialization of ADC, input mixers and output mixers
8871 */
8872static struct hda_verb alc262_init_verbs[] = {
8873 /*
8874 * Unmute ADC0-2 and set the default input to mic-in
8875 */
8876 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8877 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8878 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8879 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8880 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8881 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8882
Takashi Iwaicb53c622007-08-10 17:21:45 +02008883 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008884 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008885 * Note: PASD motherboards uses the Line In 2 as the input for
8886 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008887 */
8888 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008889 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8890 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8891 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8892 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8893 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008894
8895 /*
8896 * Set up output mixers (0x0c - 0x0e)
8897 */
8898 /* set vol=0 to output mixers */
8899 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8900 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8901 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8902 /* set up input amps for analog loopback */
8903 /* Amp Indices: DAC = 0, mixer = 1 */
8904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8905 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8906 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8907 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8908 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8909 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8910
8911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8912 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8913 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8914 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8915 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8916 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8917
8918 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8919 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8920 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8921 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8922 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02008923
Kailang Yangdf694da2005-12-05 19:42:22 +01008924 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8925 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02008926
Kailang Yangdf694da2005-12-05 19:42:22 +01008927 /* FIXME: use matrix-type input source selection */
8928 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8929 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8930 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8931 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8932 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8933 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8934 /* Input mixer2 */
8935 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8936 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8937 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8938 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8939 /* Input mixer3 */
8940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008944
8945 { }
8946};
8947
Kailang Yangccc656c2006-10-17 12:32:26 +02008948static struct hda_verb alc262_hippo_unsol_verbs[] = {
8949 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8951 {}
8952};
8953
8954static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8955 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8956 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8957 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8958
8959 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8960 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8961 {}
8962};
8963
Kailang Yang272a5272007-05-14 11:00:38 +02008964static struct hda_verb alc262_sony_unsol_verbs[] = {
8965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8966 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8967 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8968
8969 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8970 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09008971 {}
Kailang Yang272a5272007-05-14 11:00:38 +02008972};
8973
Kailang Yangccc656c2006-10-17 12:32:26 +02008974/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008975static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008976{
8977 struct alc_spec *spec = codec->spec;
8978 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008979 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008980
Takashi Iwai5b319542007-07-26 11:49:22 +02008981 /* need to execute and sync at first */
8982 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8983 present = snd_hda_codec_read(codec, 0x15, 0,
8984 AC_VERB_GET_PIN_SENSE, 0);
8985 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008986 if (spec->jack_present) {
8987 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008988 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8989 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008990 } else {
8991 /* unmute internal speaker if necessary */
8992 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008993 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8994 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008995 }
8996}
8997
8998/* unsolicited event for HP jack sensing */
8999static void alc262_hippo_unsol_event(struct hda_codec *codec,
9000 unsigned int res)
9001{
9002 if ((res >> 26) != ALC880_HP_EVENT)
9003 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009004 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009005}
9006
Takashi Iwai5b319542007-07-26 11:49:22 +02009007static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009008{
Kailang Yangccc656c2006-10-17 12:32:26 +02009009 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009010 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009011
Takashi Iwai5b319542007-07-26 11:49:22 +02009012 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9013 present = snd_hda_codec_read(codec, 0x1b, 0,
9014 AC_VERB_GET_PIN_SENSE, 0);
9015 present = (present & 0x80000000) != 0;
9016 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009017 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009018 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9019 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009020 } else {
9021 /* unmute internal speaker if necessary */
9022 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009023 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9024 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009025 }
9026}
9027
9028/* unsolicited event for HP jack sensing */
9029static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9030 unsigned int res)
9031{
9032 if ((res >> 26) != ALC880_HP_EVENT)
9033 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009034 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009035}
9036
Takashi Iwai834be882006-03-01 14:16:17 +01009037/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009038 * nec model
9039 * 0x15 = headphone
9040 * 0x16 = internal speaker
9041 * 0x18 = external mic
9042 */
9043
9044static struct snd_kcontrol_new alc262_nec_mixer[] = {
9045 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9046 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9047
9048 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9049 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9050 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9051
9052 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9053 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9054 { } /* end */
9055};
9056
9057static struct hda_verb alc262_nec_verbs[] = {
9058 /* Unmute Speaker */
9059 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9060
9061 /* Headphone */
9062 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9063 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9064
9065 /* External mic to headphone */
9066 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9067 /* External mic to speaker */
9068 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9069 {}
9070};
9071
9072/*
Takashi Iwai834be882006-03-01 14:16:17 +01009073 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009074 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9075 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009076 */
9077
9078#define ALC_HP_EVENT 0x37
9079
9080static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9081 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9082 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009083 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9084 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009085 {}
9086};
9087
Jiang zhe0e31daf2008-03-20 12:12:39 +01009088static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9089 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9090 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9091 {}
9092};
9093
Takashi Iwai834be882006-03-01 14:16:17 +01009094static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009095 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009096 .items = {
9097 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009098 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009099 { "CD", 0x4 },
9100 },
9101};
9102
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009103static struct hda_input_mux alc262_HP_capture_source = {
9104 .num_items = 5,
9105 .items = {
9106 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009107 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009108 { "Line", 0x2 },
9109 { "CD", 0x4 },
9110 { "AUX IN", 0x6 },
9111 },
9112};
9113
zhejiangaccbe492007-08-31 12:36:05 +02009114static struct hda_input_mux alc262_HP_D7000_capture_source = {
9115 .num_items = 4,
9116 .items = {
9117 { "Mic", 0x0 },
9118 { "Front Mic", 0x2 },
9119 { "Line", 0x1 },
9120 { "CD", 0x4 },
9121 },
9122};
9123
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009124/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009125static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9126{
9127 struct alc_spec *spec = codec->spec;
9128 unsigned int mute;
9129
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009130 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009131 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009132 /* need to execute and sync at first */
9133 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009134 /* check laptop HP jack */
9135 present = snd_hda_codec_read(codec, 0x14, 0,
9136 AC_VERB_GET_PIN_SENSE, 0);
9137 /* need to execute and sync at first */
9138 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9139 /* check docking HP jack */
9140 present |= snd_hda_codec_read(codec, 0x1b, 0,
9141 AC_VERB_GET_PIN_SENSE, 0);
9142 if (present & AC_PINSENSE_PRESENCE)
9143 spec->jack_present = 1;
9144 else
9145 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009146 spec->sense_updated = 1;
9147 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009148 /* unmute internal speaker only if both HPs are unplugged and
9149 * master switch is on
9150 */
9151 if (spec->jack_present)
9152 mute = HDA_AMP_MUTE;
9153 else
Takashi Iwai834be882006-03-01 14:16:17 +01009154 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009155 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9156 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009157}
9158
9159/* unsolicited event for HP jack sensing */
9160static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9161 unsigned int res)
9162{
9163 if ((res >> 26) != ALC_HP_EVENT)
9164 return;
9165 alc262_fujitsu_automute(codec, 1);
9166}
9167
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009168static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9169{
9170 alc262_fujitsu_automute(codec, 1);
9171}
9172
Takashi Iwai834be882006-03-01 14:16:17 +01009173/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009174static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9175 .ops = &snd_hda_bind_vol,
9176 .values = {
9177 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9178 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9179 0
9180 },
9181};
Takashi Iwai834be882006-03-01 14:16:17 +01009182
Jiang zhe0e31daf2008-03-20 12:12:39 +01009183/* mute/unmute internal speaker according to the hp jack and mute state */
9184static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9185{
9186 struct alc_spec *spec = codec->spec;
9187 unsigned int mute;
9188
9189 if (force || !spec->sense_updated) {
9190 unsigned int present_int_hp;
9191 /* need to execute and sync at first */
9192 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9193 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9194 AC_VERB_GET_PIN_SENSE, 0);
9195 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9196 spec->sense_updated = 1;
9197 }
9198 if (spec->jack_present) {
9199 /* mute internal speaker */
9200 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9201 HDA_AMP_MUTE, HDA_AMP_MUTE);
9202 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9203 HDA_AMP_MUTE, HDA_AMP_MUTE);
9204 } else {
9205 /* unmute internal speaker if necessary */
9206 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9207 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9208 HDA_AMP_MUTE, mute);
9209 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9210 HDA_AMP_MUTE, mute);
9211 }
9212}
9213
9214/* unsolicited event for HP jack sensing */
9215static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9216 unsigned int res)
9217{
9218 if ((res >> 26) != ALC_HP_EVENT)
9219 return;
9220 alc262_lenovo_3000_automute(codec, 1);
9221}
9222
Takashi Iwai834be882006-03-01 14:16:17 +01009223/* bind hp and internal speaker mute (with plug check) */
9224static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9225 struct snd_ctl_elem_value *ucontrol)
9226{
9227 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9228 long *valp = ucontrol->value.integer.value;
9229 int change;
9230
Tony Vroon5d9fab22008-03-14 17:09:18 +01009231 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9232 HDA_AMP_MUTE,
9233 valp ? 0 : HDA_AMP_MUTE);
9234 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9235 HDA_AMP_MUTE,
9236 valp ? 0 : HDA_AMP_MUTE);
9237
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009238 if (change)
9239 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009240 return change;
9241}
9242
9243static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009244 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009245 {
9246 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9247 .name = "Master Playback Switch",
9248 .info = snd_hda_mixer_amp_switch_info,
9249 .get = snd_hda_mixer_amp_switch_get,
9250 .put = alc262_fujitsu_master_sw_put,
9251 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9252 },
9253 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9254 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009255 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9256 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009257 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9258 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9259 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009260 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9261 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9262 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009263 { } /* end */
9264};
9265
Jiang zhe0e31daf2008-03-20 12:12:39 +01009266/* bind hp and internal speaker mute (with plug check) */
9267static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9268 struct snd_ctl_elem_value *ucontrol)
9269{
9270 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9271 long *valp = ucontrol->value.integer.value;
9272 int change;
9273
9274 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9275 HDA_AMP_MUTE,
9276 valp ? 0 : HDA_AMP_MUTE);
9277
9278 if (change)
9279 alc262_lenovo_3000_automute(codec, 0);
9280 return change;
9281}
9282
9283static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9284 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9285 {
9286 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9287 .name = "Master Playback Switch",
9288 .info = snd_hda_mixer_amp_switch_info,
9289 .get = snd_hda_mixer_amp_switch_get,
9290 .put = alc262_lenovo_3000_master_sw_put,
9291 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9292 },
9293 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9294 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9295 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9298 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9299 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9300 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9301 { } /* end */
9302};
9303
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009304/* additional init verbs for Benq laptops */
9305static struct hda_verb alc262_EAPD_verbs[] = {
9306 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9307 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9308 {}
9309};
9310
Kailang Yang83c34212007-07-05 11:43:05 +02009311static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9312 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9313 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9314
9315 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9316 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9317 {}
9318};
9319
Tobin Davisf651b502007-10-26 12:40:47 +02009320/* Samsung Q1 Ultra Vista model setup */
9321static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009322 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9323 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009324 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9325 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9326 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009327 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009328 { } /* end */
9329};
9330
9331static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009332 /* output mixer */
9333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9336 /* speaker */
9337 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9338 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9339 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9340 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9341 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009343 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9344 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9345 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9346 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9347 /* internal mic */
9348 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9349 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9350 /* ADC, choose mic */
9351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9356 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9357 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009361 {}
9362};
9363
Tobin Davisf651b502007-10-26 12:40:47 +02009364/* mute/unmute internal speaker according to the hp jack and mute state */
9365static void alc262_ultra_automute(struct hda_codec *codec)
9366{
9367 struct alc_spec *spec = codec->spec;
9368 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009369
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009370 mute = 0;
9371 /* auto-mute only when HP is used as HP */
9372 if (!spec->cur_mux[0]) {
9373 unsigned int present;
9374 /* need to execute and sync at first */
9375 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9376 present = snd_hda_codec_read(codec, 0x15, 0,
9377 AC_VERB_GET_PIN_SENSE, 0);
9378 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9379 if (spec->jack_present)
9380 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009381 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009382 /* mute/unmute internal speaker */
9383 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9384 HDA_AMP_MUTE, mute);
9385 /* mute/unmute HP */
9386 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9387 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009388}
9389
9390/* unsolicited event for HP jack sensing */
9391static void alc262_ultra_unsol_event(struct hda_codec *codec,
9392 unsigned int res)
9393{
9394 if ((res >> 26) != ALC880_HP_EVENT)
9395 return;
9396 alc262_ultra_automute(codec);
9397}
9398
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009399static struct hda_input_mux alc262_ultra_capture_source = {
9400 .num_items = 2,
9401 .items = {
9402 { "Mic", 0x1 },
9403 { "Headphone", 0x7 },
9404 },
9405};
9406
9407static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9408 struct snd_ctl_elem_value *ucontrol)
9409{
9410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9411 struct alc_spec *spec = codec->spec;
9412 int ret;
9413
9414 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9415 if (!ret)
9416 return 0;
9417 /* reprogram the HP pin as mic or HP according to the input source */
9418 snd_hda_codec_write_cache(codec, 0x15, 0,
9419 AC_VERB_SET_PIN_WIDGET_CONTROL,
9420 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9421 alc262_ultra_automute(codec); /* mute/unmute HP */
9422 return ret;
9423}
9424
9425static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9426 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9427 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9428 {
9429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9430 .name = "Capture Source",
9431 .info = alc882_mux_enum_info,
9432 .get = alc882_mux_enum_get,
9433 .put = alc262_ultra_mux_enum_put,
9434 },
9435 { } /* end */
9436};
9437
Kailang Yangdf694da2005-12-05 19:42:22 +01009438/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009439static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9440 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009441{
9442 hda_nid_t nid;
9443 int err;
9444
9445 spec->multiout.num_dacs = 1; /* only use one dac */
9446 spec->multiout.dac_nids = spec->private_dac_nids;
9447 spec->multiout.dac_nids[0] = 2;
9448
9449 nid = cfg->line_out_pins[0];
9450 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009451 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9452 "Front Playback Volume",
9453 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9454 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009455 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009456 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9457 "Front Playback Switch",
9458 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9459 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009460 return err;
9461 }
9462
Takashi Iwai82bc9552006-03-21 11:24:42 +01009463 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009464 if (nid) {
9465 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009466 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9467 "Speaker Playback Volume",
9468 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9469 HDA_OUTPUT));
9470 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009471 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009472 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9473 "Speaker Playback Switch",
9474 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9475 HDA_OUTPUT));
9476 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009477 return err;
9478 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009479 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9480 "Speaker Playback Switch",
9481 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9482 HDA_OUTPUT));
9483 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009484 return err;
9485 }
9486 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009487 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009488 if (nid) {
9489 /* spec->multiout.hp_nid = 2; */
9490 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009491 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9492 "Headphone Playback Volume",
9493 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9494 HDA_OUTPUT));
9495 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009496 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009497 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9498 "Headphone Playback Switch",
9499 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9500 HDA_OUTPUT));
9501 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009502 return err;
9503 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009504 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9505 "Headphone Playback Switch",
9506 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9507 HDA_OUTPUT));
9508 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009509 return err;
9510 }
9511 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009512 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009513}
9514
9515/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009516#define alc262_auto_create_analog_input_ctls \
9517 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009518
9519/*
9520 * generic initialization of ADC, input mixers and output mixers
9521 */
9522static struct hda_verb alc262_volume_init_verbs[] = {
9523 /*
9524 * Unmute ADC0-2 and set the default input to mic-in
9525 */
9526 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9528 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9529 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9530 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9531 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9532
Takashi Iwaicb53c622007-08-10 17:21:45 +02009533 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009534 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009535 * Note: PASD motherboards uses the Line In 2 as the input for
9536 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009537 */
9538 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009544
9545 /*
9546 * Set up output mixers (0x0c - 0x0f)
9547 */
9548 /* set vol=0 to output mixers */
9549 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9550 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9551 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +02009552
Kailang Yangdf694da2005-12-05 19:42:22 +01009553 /* set up input amps for analog loopback */
9554 /* Amp Indices: DAC = 0, mixer = 1 */
9555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9557 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9558 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9559 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9560 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9561
9562 /* FIXME: use matrix-type input source selection */
9563 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9564 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9565 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9566 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9567 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9568 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9569 /* Input mixer2 */
9570 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9571 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9572 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9574 /* Input mixer3 */
9575 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9579
9580 { }
9581};
9582
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009583static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9584 /*
9585 * Unmute ADC0-2 and set the default input to mic-in
9586 */
9587 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9588 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9589 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9590 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9591 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9592 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9593
Takashi Iwaicb53c622007-08-10 17:21:45 +02009594 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009595 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009596 * Note: PASD motherboards uses the Line In 2 as the input for
9597 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009598 */
9599 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009600 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9601 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9604 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9605 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9606 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +02009607
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009608 /*
9609 * Set up output mixers (0x0c - 0x0e)
9610 */
9611 /* set vol=0 to output mixers */
9612 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9613 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9614 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9615
9616 /* set up input amps for analog loopback */
9617 /* Amp Indices: DAC = 0, mixer = 1 */
9618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9619 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9620 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9621 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9622 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9623 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9624
Takashi Iwaice875f02008-01-28 18:17:43 +01009625 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009626 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9627 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9628
9629 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9630 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9631
9632 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9633 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9634
9635 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9636 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9637 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9638 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9639 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9640
9641 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9642 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9643 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9644 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9645 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9646 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9647
9648
9649 /* FIXME: use matrix-type input source selection */
9650 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9651 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9652 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9653 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9654 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9656 /* Input mixer2 */
9657 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9658 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9659 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9660 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9661 /* Input mixer3 */
9662 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9666
Takashi Iwaice875f02008-01-28 18:17:43 +01009667 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9668
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009669 { }
9670};
9671
Kailang Yangcd7509a2007-01-26 18:33:17 +01009672static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9673 /*
9674 * Unmute ADC0-2 and set the default input to mic-in
9675 */
9676 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9678 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9679 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9680 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9682
Takashi Iwaicb53c622007-08-10 17:21:45 +02009683 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009684 * mixer widget
9685 * Note: PASD motherboards uses the Line In 2 as the input for front
9686 * panel mic (mic 2)
9687 */
9688 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009689 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9690 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009697 /*
9698 * Set up output mixers (0x0c - 0x0e)
9699 */
9700 /* set vol=0 to output mixers */
9701 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9702 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9704
9705 /* set up input amps for analog loopback */
9706 /* Amp Indices: DAC = 0, mixer = 1 */
9707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9711 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9713
9714
9715 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9716 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9717 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9718 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9719 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9720 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9721 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9722
9723 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9725
9726 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9727 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9728
9729 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9730 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9731 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9732 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9733 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9734 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9735
9736 /* FIXME: use matrix-type input source selection */
9737 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9738 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9739 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9740 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9741 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9742 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9743 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9744 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9745 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9746 /* Input mixer2 */
9747 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9748 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9749 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9750 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9751 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9752 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9754 /* Input mixer3 */
9755 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9756 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9757 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9760 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9761 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9762
Takashi Iwaice875f02008-01-28 18:17:43 +01009763 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9764
Kailang Yangcd7509a2007-01-26 18:33:17 +01009765 { }
9766};
9767
Takashi Iwaicb53c622007-08-10 17:21:45 +02009768#ifdef CONFIG_SND_HDA_POWER_SAVE
9769#define alc262_loopbacks alc880_loopbacks
9770#endif
9771
Kailang Yangdf694da2005-12-05 19:42:22 +01009772/* pcm configuration: identiacal with ALC880 */
9773#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9774#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9775#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9776#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9777
9778/*
9779 * BIOS auto configuration
9780 */
9781static int alc262_parse_auto_config(struct hda_codec *codec)
9782{
9783 struct alc_spec *spec = codec->spec;
9784 int err;
9785 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9786
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009787 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9788 alc262_ignore);
9789 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009790 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009791 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009792 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009793 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9794 if (err < 0)
9795 return err;
9796 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9797 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009798 return err;
9799
9800 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9801
9802 if (spec->autocfg.dig_out_pin)
9803 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9804 if (spec->autocfg.dig_in_pin)
9805 spec->dig_in_nid = ALC262_DIGIN_NID;
9806
9807 if (spec->kctl_alloc)
9808 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9809
9810 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009811 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009812 spec->input_mux = &spec->private_imux;
9813
Takashi Iwai776e1842007-08-29 15:07:11 +02009814 err = alc_auto_add_mic_boost(codec);
9815 if (err < 0)
9816 return err;
9817
Kailang Yangdf694da2005-12-05 19:42:22 +01009818 return 1;
9819}
9820
9821#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9822#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9823#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +02009824#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +01009825
9826
9827/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009828static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009829{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009830 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009831 alc262_auto_init_multi_out(codec);
9832 alc262_auto_init_hp_out(codec);
9833 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009834 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009835 if (spec->unsol_event)
9836 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009837}
9838
9839/*
9840 * configuration and preset
9841 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009842static const char *alc262_models[ALC262_MODEL_LAST] = {
9843 [ALC262_BASIC] = "basic",
9844 [ALC262_HIPPO] = "hippo",
9845 [ALC262_HIPPO_1] = "hippo_1",
9846 [ALC262_FUJITSU] = "fujitsu",
9847 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009848 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009849 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009850 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009851 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009852 [ALC262_BENQ_T31] = "benq-t31",
9853 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009854 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +01009855 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009856 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009857 [ALC262_AUTO] = "auto",
9858};
9859
9860static struct snd_pci_quirk alc262_cfg_tbl[] = {
9861 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009862 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009863 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009864 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009865 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9866 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009867 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009868 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009869 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009870 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009871 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009872 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009873 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009874 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009875 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009876 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009877 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009878 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009879 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9880 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9881 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009882 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9883 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009884 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009885 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009886 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009887 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9888 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9889 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +09009890 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
9891 ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009892 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009893 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009894 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009895 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +01009896 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009897 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009898 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009899 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009900 {}
9901};
9902
9903static struct alc_config_preset alc262_presets[] = {
9904 [ALC262_BASIC] = {
9905 .mixers = { alc262_base_mixer },
9906 .init_verbs = { alc262_init_verbs },
9907 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9908 .dac_nids = alc262_dac_nids,
9909 .hp_nid = 0x03,
9910 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9911 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009912 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009913 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009914 [ALC262_HIPPO] = {
9915 .mixers = { alc262_base_mixer },
9916 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9917 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9918 .dac_nids = alc262_dac_nids,
9919 .hp_nid = 0x03,
9920 .dig_out_nid = ALC262_DIGOUT_NID,
9921 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9922 .channel_mode = alc262_modes,
9923 .input_mux = &alc262_capture_source,
9924 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009925 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009926 },
9927 [ALC262_HIPPO_1] = {
9928 .mixers = { alc262_hippo1_mixer },
9929 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9930 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9931 .dac_nids = alc262_dac_nids,
9932 .hp_nid = 0x02,
9933 .dig_out_nid = ALC262_DIGOUT_NID,
9934 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9935 .channel_mode = alc262_modes,
9936 .input_mux = &alc262_capture_source,
9937 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009938 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009939 },
Takashi Iwai834be882006-03-01 14:16:17 +01009940 [ALC262_FUJITSU] = {
9941 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009942 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9943 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009944 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9945 .dac_nids = alc262_dac_nids,
9946 .hp_nid = 0x03,
9947 .dig_out_nid = ALC262_DIGOUT_NID,
9948 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9949 .channel_mode = alc262_modes,
9950 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009951 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009952 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +01009953 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009954 [ALC262_HP_BPC] = {
9955 .mixers = { alc262_HP_BPC_mixer },
9956 .init_verbs = { alc262_HP_BPC_init_verbs },
9957 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9958 .dac_nids = alc262_dac_nids,
9959 .hp_nid = 0x03,
9960 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9961 .channel_mode = alc262_modes,
9962 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009963 .unsol_event = alc262_hp_bpc_unsol_event,
9964 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009965 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009966 [ALC262_HP_BPC_D7000_WF] = {
9967 .mixers = { alc262_HP_BPC_WildWest_mixer },
9968 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9969 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9970 .dac_nids = alc262_dac_nids,
9971 .hp_nid = 0x03,
9972 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9973 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009974 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009975 .unsol_event = alc262_hp_wildwest_unsol_event,
9976 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009977 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009978 [ALC262_HP_BPC_D7000_WL] = {
9979 .mixers = { alc262_HP_BPC_WildWest_mixer,
9980 alc262_HP_BPC_WildWest_option_mixer },
9981 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9982 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9983 .dac_nids = alc262_dac_nids,
9984 .hp_nid = 0x03,
9985 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9986 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009987 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009988 .unsol_event = alc262_hp_wildwest_unsol_event,
9989 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009990 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009991 [ALC262_HP_TC_T5735] = {
9992 .mixers = { alc262_hp_t5735_mixer },
9993 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9994 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9995 .dac_nids = alc262_dac_nids,
9996 .hp_nid = 0x03,
9997 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9998 .channel_mode = alc262_modes,
9999 .input_mux = &alc262_capture_source,
10000 .unsol_event = alc262_hp_t5735_unsol_event,
10001 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010002 },
10003 [ALC262_HP_RP5700] = {
10004 .mixers = { alc262_hp_rp5700_mixer },
10005 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10006 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10007 .dac_nids = alc262_dac_nids,
10008 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10009 .channel_mode = alc262_modes,
10010 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010011 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010012 [ALC262_BENQ_ED8] = {
10013 .mixers = { alc262_base_mixer },
10014 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10015 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10016 .dac_nids = alc262_dac_nids,
10017 .hp_nid = 0x03,
10018 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10019 .channel_mode = alc262_modes,
10020 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010021 },
Kailang Yang272a5272007-05-14 11:00:38 +020010022 [ALC262_SONY_ASSAMD] = {
10023 .mixers = { alc262_sony_mixer },
10024 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10025 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10026 .dac_nids = alc262_dac_nids,
10027 .hp_nid = 0x02,
10028 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10029 .channel_mode = alc262_modes,
10030 .input_mux = &alc262_capture_source,
10031 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010032 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010033 },
10034 [ALC262_BENQ_T31] = {
10035 .mixers = { alc262_benq_t31_mixer },
10036 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10037 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10038 .dac_nids = alc262_dac_nids,
10039 .hp_nid = 0x03,
10040 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10041 .channel_mode = alc262_modes,
10042 .input_mux = &alc262_capture_source,
10043 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010044 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010045 },
Tobin Davisf651b502007-10-26 12:40:47 +020010046 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010047 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
10048 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010049 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10050 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010051 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10052 .channel_mode = alc262_modes,
10053 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010054 .adc_nids = alc262_adc_nids, /* ADC0 */
10055 .capsrc_nids = alc262_capsrc_nids,
10056 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010057 .unsol_event = alc262_ultra_unsol_event,
10058 .init_hook = alc262_ultra_automute,
10059 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010060 [ALC262_LENOVO_3000] = {
10061 .mixers = { alc262_lenovo_3000_mixer },
10062 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10063 alc262_lenovo_3000_unsol_verbs },
10064 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10065 .dac_nids = alc262_dac_nids,
10066 .hp_nid = 0x03,
10067 .dig_out_nid = ALC262_DIGOUT_NID,
10068 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10069 .channel_mode = alc262_modes,
10070 .input_mux = &alc262_fujitsu_capture_source,
10071 .unsol_event = alc262_lenovo_3000_unsol_event,
10072 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010073 [ALC262_NEC] = {
10074 .mixers = { alc262_nec_mixer },
10075 .init_verbs = { alc262_nec_verbs },
10076 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10077 .dac_nids = alc262_dac_nids,
10078 .hp_nid = 0x03,
10079 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10080 .channel_mode = alc262_modes,
10081 .input_mux = &alc262_capture_source,
10082 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010083};
10084
10085static int patch_alc262(struct hda_codec *codec)
10086{
10087 struct alc_spec *spec;
10088 int board_config;
10089 int err;
10090
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010091 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010092 if (spec == NULL)
10093 return -ENOMEM;
10094
10095 codec->spec = spec;
10096#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010097 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10098 * under-run
10099 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010100 {
10101 int tmp;
10102 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10103 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10104 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10105 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10106 }
10107#endif
10108
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010109 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10110
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010111 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10112 alc262_models,
10113 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010114
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010115 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010116 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10117 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010118 board_config = ALC262_AUTO;
10119 }
10120
10121 if (board_config == ALC262_AUTO) {
10122 /* automatic parse from the BIOS config */
10123 err = alc262_parse_auto_config(codec);
10124 if (err < 0) {
10125 alc_free(codec);
10126 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010127 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010128 printk(KERN_INFO
10129 "hda_codec: Cannot set up configuration "
10130 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010131 board_config = ALC262_BASIC;
10132 }
10133 }
10134
10135 if (board_config != ALC262_AUTO)
10136 setup_preset(spec, &alc262_presets[board_config]);
10137
10138 spec->stream_name_analog = "ALC262 Analog";
10139 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10140 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010141
Kailang Yangdf694da2005-12-05 19:42:22 +010010142 spec->stream_name_digital = "ALC262 Digital";
10143 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10144 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10145
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010146 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010147 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010148 unsigned int wcap = get_wcaps(codec, 0x07);
10149
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010150 /* get type */
10151 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010152 if (wcap != AC_WID_AUD_IN) {
10153 spec->adc_nids = alc262_adc_nids_alt;
10154 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010155 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010156 spec->mixers[spec->num_mixers] =
10157 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +010010158 spec->num_mixers++;
10159 } else {
10160 spec->adc_nids = alc262_adc_nids;
10161 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010162 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010163 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
10164 spec->num_mixers++;
10165 }
10166 }
10167
Takashi Iwai2134ea42008-01-10 16:53:55 +010010168 spec->vmaster_nid = 0x0c;
10169
Kailang Yangdf694da2005-12-05 19:42:22 +010010170 codec->patch_ops = alc_patch_ops;
10171 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010172 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010173#ifdef CONFIG_SND_HDA_POWER_SAVE
10174 if (!spec->loopback.amplist)
10175 spec->loopback.amplist = alc262_loopbacks;
10176#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020010177
Kailang Yangdf694da2005-12-05 19:42:22 +010010178 return 0;
10179}
10180
Kailang Yangdf694da2005-12-05 19:42:22 +010010181/*
Kailang Yanga361d842007-06-05 12:30:55 +020010182 * ALC268 channel source setting (2 channel)
10183 */
10184#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10185#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010186
Kailang Yanga361d842007-06-05 12:30:55 +020010187static hda_nid_t alc268_dac_nids[2] = {
10188 /* front, hp */
10189 0x02, 0x03
10190};
10191
10192static hda_nid_t alc268_adc_nids[2] = {
10193 /* ADC0-1 */
10194 0x08, 0x07
10195};
10196
10197static hda_nid_t alc268_adc_nids_alt[1] = {
10198 /* ADC0 */
10199 0x08
10200};
10201
Takashi Iwaie1406342008-02-11 18:32:32 +010010202static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10203
Kailang Yanga361d842007-06-05 12:30:55 +020010204static struct snd_kcontrol_new alc268_base_mixer[] = {
10205 /* output mixer control */
10206 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10207 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10208 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010210 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10211 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10212 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010213 { }
10214};
10215
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010216/* bind Beep switches of both NID 0x0f and 0x10 */
10217static struct hda_bind_ctls alc268_bind_beep_sw = {
10218 .ops = &snd_hda_bind_sw,
10219 .values = {
10220 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10221 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10222 0
10223 },
10224};
10225
10226static struct snd_kcontrol_new alc268_beep_mixer[] = {
10227 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10228 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10229 { }
10230};
10231
Kailang Yangd1a991a2007-08-15 16:21:59 +020010232static struct hda_verb alc268_eapd_verbs[] = {
10233 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10234 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10235 { }
10236};
10237
Takashi Iwaid2738092007-08-16 14:59:45 +020010238/* Toshiba specific */
10239#define alc268_toshiba_automute alc262_hippo_automute
10240
10241static struct hda_verb alc268_toshiba_verbs[] = {
10242 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10243 { } /* end */
10244};
10245
10246/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010247/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010248static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10249 .ops = &snd_hda_bind_vol,
10250 .values = {
10251 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10252 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10253 0
10254 },
10255};
10256
Takashi Iwai889c4392007-08-23 18:56:52 +020010257/* mute/unmute internal speaker according to the hp jack and mute state */
10258static void alc268_acer_automute(struct hda_codec *codec, int force)
10259{
10260 struct alc_spec *spec = codec->spec;
10261 unsigned int mute;
10262
10263 if (force || !spec->sense_updated) {
10264 unsigned int present;
10265 present = snd_hda_codec_read(codec, 0x14, 0,
10266 AC_VERB_GET_PIN_SENSE, 0);
10267 spec->jack_present = (present & 0x80000000) != 0;
10268 spec->sense_updated = 1;
10269 }
10270 if (spec->jack_present)
10271 mute = HDA_AMP_MUTE; /* mute internal speaker */
10272 else /* unmute internal speaker if necessary */
10273 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10274 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10275 HDA_AMP_MUTE, mute);
10276}
10277
10278
10279/* bind hp and internal speaker mute (with plug check) */
10280static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10281 struct snd_ctl_elem_value *ucontrol)
10282{
10283 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10284 long *valp = ucontrol->value.integer.value;
10285 int change;
10286
10287 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10288 HDA_AMP_MUTE,
10289 valp[0] ? 0 : HDA_AMP_MUTE);
10290 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10291 HDA_AMP_MUTE,
10292 valp[1] ? 0 : HDA_AMP_MUTE);
10293 if (change)
10294 alc268_acer_automute(codec, 0);
10295 return change;
10296}
Takashi Iwaid2738092007-08-16 14:59:45 +020010297
10298static struct snd_kcontrol_new alc268_acer_mixer[] = {
10299 /* output mixer control */
10300 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10301 {
10302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10303 .name = "Master Playback Switch",
10304 .info = snd_hda_mixer_amp_switch_info,
10305 .get = snd_hda_mixer_amp_switch_get,
10306 .put = alc268_acer_master_sw_put,
10307 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10308 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010309 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10310 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10311 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010312 { }
10313};
10314
10315static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010316 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10317 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010318 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10319 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010320 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10321 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010322 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10323 { }
10324};
10325
10326/* unsolicited event for HP jack sensing */
10327static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10328 unsigned int res)
10329{
Takashi Iwai889c4392007-08-23 18:56:52 +020010330 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010331 return;
10332 alc268_toshiba_automute(codec);
10333}
10334
10335static void alc268_acer_unsol_event(struct hda_codec *codec,
10336 unsigned int res)
10337{
Takashi Iwai889c4392007-08-23 18:56:52 +020010338 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010339 return;
10340 alc268_acer_automute(codec, 1);
10341}
10342
Takashi Iwai889c4392007-08-23 18:56:52 +020010343static void alc268_acer_init_hook(struct hda_codec *codec)
10344{
10345 alc268_acer_automute(codec, 1);
10346}
10347
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010348static struct snd_kcontrol_new alc268_dell_mixer[] = {
10349 /* output mixer control */
10350 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10351 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10352 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10354 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10355 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10356 { }
10357};
10358
10359static struct hda_verb alc268_dell_verbs[] = {
10360 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10361 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10362 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10363 { }
10364};
10365
10366/* mute/unmute internal speaker according to the hp jack and mute state */
10367static void alc268_dell_automute(struct hda_codec *codec)
10368{
10369 unsigned int present;
10370 unsigned int mute;
10371
10372 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10373 if (present & 0x80000000)
10374 mute = HDA_AMP_MUTE;
10375 else
10376 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10377 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10378 HDA_AMP_MUTE, mute);
10379}
10380
10381static void alc268_dell_unsol_event(struct hda_codec *codec,
10382 unsigned int res)
10383{
10384 if ((res >> 26) != ALC880_HP_EVENT)
10385 return;
10386 alc268_dell_automute(codec);
10387}
10388
10389#define alc268_dell_init_hook alc268_dell_automute
10390
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010391static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10392 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10393 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10394 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10395 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10396 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10397 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10398 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10399 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10400 { }
10401};
10402
10403static struct hda_verb alc267_quanta_il1_verbs[] = {
10404 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10405 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10406 { }
10407};
10408
10409static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10410{
10411 unsigned int present;
10412
10413 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10414 & AC_PINSENSE_PRESENCE;
10415 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10416 present ? 0 : PIN_OUT);
10417}
10418
10419static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10420{
10421 unsigned int present;
10422
10423 present = snd_hda_codec_read(codec, 0x18, 0,
10424 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10425 snd_hda_codec_write(codec, 0x23, 0,
10426 AC_VERB_SET_CONNECT_SEL,
10427 present ? 0x00 : 0x01);
10428}
10429
10430static void alc267_quanta_il1_automute(struct hda_codec *codec)
10431{
10432 alc267_quanta_il1_hp_automute(codec);
10433 alc267_quanta_il1_mic_automute(codec);
10434}
10435
10436static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10437 unsigned int res)
10438{
10439 switch (res >> 26) {
10440 case ALC880_HP_EVENT:
10441 alc267_quanta_il1_hp_automute(codec);
10442 break;
10443 case ALC880_MIC_EVENT:
10444 alc267_quanta_il1_mic_automute(codec);
10445 break;
10446 }
10447}
10448
Kailang Yanga361d842007-06-05 12:30:55 +020010449/*
10450 * generic initialization of ADC, input mixers and output mixers
10451 */
10452static struct hda_verb alc268_base_init_verbs[] = {
10453 /* Unmute DAC0-1 and set vol = 0 */
10454 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10455 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10456 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10457 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10458 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10459 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10460
10461 /*
10462 * Set up output mixers (0x0c - 0x0e)
10463 */
10464 /* set vol=0 to output mixers */
10465 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10468 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10469
10470 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10471 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10472
10473 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10475 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10477 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10478 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10479 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10480 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10481
10482 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10483 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10484 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10485 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10488 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010489
10490 /* set PCBEEP vol = 0, mute connections */
10491 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10492 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10493 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010494
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010495 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020010496
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010497 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10498 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10499 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10500 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020010501
Kailang Yanga361d842007-06-05 12:30:55 +020010502 { }
10503};
10504
10505/*
10506 * generic initialization of ADC, input mixers and output mixers
10507 */
10508static struct hda_verb alc268_volume_init_verbs[] = {
10509 /* set output DAC */
10510 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10511 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10512 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10513 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10514
10515 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10516 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10517 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10518 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10519 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10520
10521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10524 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10525 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10526
10527 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10528 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10529 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10530 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10531
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010532 /* set PCBEEP vol = 0, mute connections */
10533 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10535 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010536
10537 { }
10538};
10539
10540#define alc268_mux_enum_info alc_mux_enum_info
10541#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010010542#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020010543
10544static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10545 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10546 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10547 {
10548 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10549 /* The multiple "Capture Source" controls confuse alsamixer
10550 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010551 */
10552 /* .name = "Capture Source", */
10553 .name = "Input Source",
10554 .count = 1,
10555 .info = alc268_mux_enum_info,
10556 .get = alc268_mux_enum_get,
10557 .put = alc268_mux_enum_put,
10558 },
10559 { } /* end */
10560};
10561
10562static struct snd_kcontrol_new alc268_capture_mixer[] = {
10563 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10564 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10565 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10566 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10567 {
10568 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10569 /* The multiple "Capture Source" controls confuse alsamixer
10570 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010571 */
10572 /* .name = "Capture Source", */
10573 .name = "Input Source",
10574 .count = 2,
10575 .info = alc268_mux_enum_info,
10576 .get = alc268_mux_enum_get,
10577 .put = alc268_mux_enum_put,
10578 },
10579 { } /* end */
10580};
10581
10582static struct hda_input_mux alc268_capture_source = {
10583 .num_items = 4,
10584 .items = {
10585 { "Mic", 0x0 },
10586 { "Front Mic", 0x1 },
10587 { "Line", 0x2 },
10588 { "CD", 0x3 },
10589 },
10590};
10591
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010592static struct hda_input_mux alc268_acer_capture_source = {
10593 .num_items = 3,
10594 .items = {
10595 { "Mic", 0x0 },
10596 { "Internal Mic", 0x6 },
10597 { "Line", 0x2 },
10598 },
10599};
10600
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010601#ifdef CONFIG_SND_DEBUG
10602static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010603 /* Volume widgets */
10604 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10605 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10606 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10607 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10608 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10609 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10610 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10611 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10612 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10613 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10614 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10615 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10616 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010010617 /* The below appears problematic on some hardwares */
10618 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010619 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10620 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10621 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10622 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10623
10624 /* Modes for retasking pin widgets */
10625 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10626 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10627 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10628 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10629
10630 /* Controls for GPIO pins, assuming they are configured as outputs */
10631 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10632 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10633 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10634 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10635
10636 /* Switches to allow the digital SPDIF output pin to be enabled.
10637 * The ALC268 does not have an SPDIF input.
10638 */
10639 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10640
10641 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10642 * this output to turn on an external amplifier.
10643 */
10644 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10645 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10646
10647 { } /* end */
10648};
10649#endif
10650
Kailang Yanga361d842007-06-05 12:30:55 +020010651/* create input playback/capture controls for the given pin */
10652static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10653 const char *ctlname, int idx)
10654{
10655 char name[32];
10656 int err;
10657
10658 sprintf(name, "%s Playback Volume", ctlname);
10659 if (nid == 0x14) {
10660 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10661 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10662 HDA_OUTPUT));
10663 if (err < 0)
10664 return err;
10665 } else if (nid == 0x15) {
10666 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10667 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10668 HDA_OUTPUT));
10669 if (err < 0)
10670 return err;
10671 } else
10672 return -1;
10673 sprintf(name, "%s Playback Switch", ctlname);
10674 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10675 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10676 if (err < 0)
10677 return err;
10678 return 0;
10679}
10680
10681/* add playback controls from the parsed DAC table */
10682static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10683 const struct auto_pin_cfg *cfg)
10684{
10685 hda_nid_t nid;
10686 int err;
10687
10688 spec->multiout.num_dacs = 2; /* only use one dac */
10689 spec->multiout.dac_nids = spec->private_dac_nids;
10690 spec->multiout.dac_nids[0] = 2;
10691 spec->multiout.dac_nids[1] = 3;
10692
10693 nid = cfg->line_out_pins[0];
10694 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020010695 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020010696
10697 nid = cfg->speaker_pins[0];
10698 if (nid == 0x1d) {
10699 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10700 "Speaker Playback Volume",
10701 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10702 if (err < 0)
10703 return err;
10704 }
10705 nid = cfg->hp_pins[0];
10706 if (nid)
10707 alc268_new_analog_output(spec, nid, "Headphone", 0);
10708
10709 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10710 if (nid == 0x16) {
10711 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10712 "Mono Playback Switch",
10713 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10714 if (err < 0)
10715 return err;
10716 }
Kailang Yangea1fb292008-08-26 12:58:38 +020010717 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020010718}
10719
10720/* create playback/capture controls for input pins */
10721static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10722 const struct auto_pin_cfg *cfg)
10723{
10724 struct hda_input_mux *imux = &spec->private_imux;
10725 int i, idx1;
10726
10727 for (i = 0; i < AUTO_PIN_LAST; i++) {
10728 switch(cfg->input_pins[i]) {
10729 case 0x18:
10730 idx1 = 0; /* Mic 1 */
10731 break;
10732 case 0x19:
10733 idx1 = 1; /* Mic 2 */
10734 break;
10735 case 0x1a:
10736 idx1 = 2; /* Line In */
10737 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020010738 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020010739 idx1 = 3; /* CD */
10740 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010010741 case 0x12:
10742 case 0x13:
10743 idx1 = 6; /* digital mics */
10744 break;
Kailang Yanga361d842007-06-05 12:30:55 +020010745 default:
10746 continue;
10747 }
10748 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10749 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020010750 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020010751 }
10752 return 0;
10753}
10754
10755static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10756{
10757 struct alc_spec *spec = codec->spec;
10758 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10759 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10760 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10761 unsigned int dac_vol1, dac_vol2;
10762
10763 if (speaker_nid) {
10764 snd_hda_codec_write(codec, speaker_nid, 0,
10765 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10766 snd_hda_codec_write(codec, 0x0f, 0,
10767 AC_VERB_SET_AMP_GAIN_MUTE,
10768 AMP_IN_UNMUTE(1));
10769 snd_hda_codec_write(codec, 0x10, 0,
10770 AC_VERB_SET_AMP_GAIN_MUTE,
10771 AMP_IN_UNMUTE(1));
10772 } else {
10773 snd_hda_codec_write(codec, 0x0f, 0,
10774 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10775 snd_hda_codec_write(codec, 0x10, 0,
10776 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10777 }
10778
10779 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020010780 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020010781 dac_vol2 = AMP_OUT_ZERO;
10782 else if (line_nid == 0x15)
10783 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020010784 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020010785 dac_vol2 = AMP_OUT_ZERO;
10786 else if (hp_nid == 0x15)
10787 dac_vol1 = AMP_OUT_ZERO;
10788 if (line_nid != 0x16 || hp_nid != 0x16 ||
10789 spec->autocfg.line_out_pins[1] != 0x16 ||
10790 spec->autocfg.line_out_pins[2] != 0x16)
10791 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10792
10793 snd_hda_codec_write(codec, 0x02, 0,
10794 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10795 snd_hda_codec_write(codec, 0x03, 0,
10796 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10797}
10798
10799/* pcm configuration: identiacal with ALC880 */
10800#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10801#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010802#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010803#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10804
10805/*
10806 * BIOS auto configuration
10807 */
10808static int alc268_parse_auto_config(struct hda_codec *codec)
10809{
10810 struct alc_spec *spec = codec->spec;
10811 int err;
10812 static hda_nid_t alc268_ignore[] = { 0 };
10813
10814 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10815 alc268_ignore);
10816 if (err < 0)
10817 return err;
10818 if (!spec->autocfg.line_outs)
10819 return 0; /* can't find valid BIOS pin config */
10820
10821 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10822 if (err < 0)
10823 return err;
10824 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10825 if (err < 0)
10826 return err;
10827
10828 spec->multiout.max_channels = 2;
10829
10830 /* digital only support output */
10831 if (spec->autocfg.dig_out_pin)
10832 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10833
10834 if (spec->kctl_alloc)
10835 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10836
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010837 if (spec->autocfg.speaker_pins[0] != 0x1d)
10838 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10839
Kailang Yanga361d842007-06-05 12:30:55 +020010840 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10841 spec->num_mux_defs = 1;
10842 spec->input_mux = &spec->private_imux;
10843
Takashi Iwai776e1842007-08-29 15:07:11 +020010844 err = alc_auto_add_mic_boost(codec);
10845 if (err < 0)
10846 return err;
10847
Kailang Yanga361d842007-06-05 12:30:55 +020010848 return 1;
10849}
10850
10851#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10852#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10853#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10854
10855/* init callback for auto-configuration model -- overriding the default init */
10856static void alc268_auto_init(struct hda_codec *codec)
10857{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010858 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020010859 alc268_auto_init_multi_out(codec);
10860 alc268_auto_init_hp_out(codec);
10861 alc268_auto_init_mono_speaker_out(codec);
10862 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010863 if (spec->unsol_event)
10864 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020010865}
10866
10867/*
10868 * configuration and preset
10869 */
10870static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010871 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020010872 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010873 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010874 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010875 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010876 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010877#ifdef CONFIG_SND_DEBUG
10878 [ALC268_TEST] = "test",
10879#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010880 [ALC268_AUTO] = "auto",
10881};
10882
10883static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020010884 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010885 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010010886 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010887 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010010888 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010889 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010890 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020010891 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010892 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020010893 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020010894 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020010895 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010896 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010897 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020010898 {}
10899};
10900
10901static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010902 [ALC267_QUANTA_IL1] = {
10903 .mixers = { alc267_quanta_il1_mixer },
10904 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10905 alc267_quanta_il1_verbs },
10906 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10907 .dac_nids = alc268_dac_nids,
10908 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10909 .adc_nids = alc268_adc_nids_alt,
10910 .hp_nid = 0x03,
10911 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10912 .channel_mode = alc268_modes,
10913 .input_mux = &alc268_capture_source,
10914 .unsol_event = alc267_quanta_il1_unsol_event,
10915 .init_hook = alc267_quanta_il1_automute,
10916 },
Kailang Yanga361d842007-06-05 12:30:55 +020010917 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010918 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10919 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020010920 .init_verbs = { alc268_base_init_verbs },
10921 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10922 .dac_nids = alc268_dac_nids,
10923 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10924 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010925 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020010926 .hp_nid = 0x03,
10927 .dig_out_nid = ALC268_DIGOUT_NID,
10928 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10929 .channel_mode = alc268_modes,
10930 .input_mux = &alc268_capture_source,
10931 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010932 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010933 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10934 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010935 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10936 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010937 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10938 .dac_nids = alc268_dac_nids,
10939 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10940 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010941 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010942 .hp_nid = 0x03,
10943 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10944 .channel_mode = alc268_modes,
10945 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010946 .unsol_event = alc268_toshiba_unsol_event,
10947 .init_hook = alc268_toshiba_automute,
10948 },
10949 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010950 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
10951 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010952 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10953 alc268_acer_verbs },
10954 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10955 .dac_nids = alc268_dac_nids,
10956 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10957 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010958 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020010959 .hp_nid = 0x02,
10960 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10961 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010962 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010963 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020010964 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010965 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010966 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010967 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010968 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10969 alc268_dell_verbs },
10970 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10971 .dac_nids = alc268_dac_nids,
10972 .hp_nid = 0x02,
10973 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10974 .channel_mode = alc268_modes,
10975 .unsol_event = alc268_dell_unsol_event,
10976 .init_hook = alc268_dell_init_hook,
10977 .input_mux = &alc268_capture_source,
10978 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010979 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010980 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10981 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010982 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10983 alc268_toshiba_verbs },
10984 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10985 .dac_nids = alc268_dac_nids,
10986 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10987 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010988 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010989 .hp_nid = 0x03,
10990 .dig_out_nid = ALC268_DIGOUT_NID,
10991 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10992 .channel_mode = alc268_modes,
10993 .input_mux = &alc268_capture_source,
10994 .unsol_event = alc268_toshiba_unsol_event,
10995 .init_hook = alc268_toshiba_automute
10996 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010997#ifdef CONFIG_SND_DEBUG
10998 [ALC268_TEST] = {
10999 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11000 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11001 alc268_volume_init_verbs },
11002 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11003 .dac_nids = alc268_dac_nids,
11004 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11005 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011006 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011007 .hp_nid = 0x03,
11008 .dig_out_nid = ALC268_DIGOUT_NID,
11009 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11010 .channel_mode = alc268_modes,
11011 .input_mux = &alc268_capture_source,
11012 },
11013#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011014};
11015
11016static int patch_alc268(struct hda_codec *codec)
11017{
11018 struct alc_spec *spec;
11019 int board_config;
11020 int err;
11021
11022 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11023 if (spec == NULL)
11024 return -ENOMEM;
11025
11026 codec->spec = spec;
11027
11028 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11029 alc268_models,
11030 alc268_cfg_tbl);
11031
11032 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11033 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11034 "trying auto-probe from BIOS...\n");
11035 board_config = ALC268_AUTO;
11036 }
11037
11038 if (board_config == ALC268_AUTO) {
11039 /* automatic parse from the BIOS config */
11040 err = alc268_parse_auto_config(codec);
11041 if (err < 0) {
11042 alc_free(codec);
11043 return err;
11044 } else if (!err) {
11045 printk(KERN_INFO
11046 "hda_codec: Cannot set up configuration "
11047 "from BIOS. Using base mode...\n");
11048 board_config = ALC268_3ST;
11049 }
11050 }
11051
11052 if (board_config != ALC268_AUTO)
11053 setup_preset(spec, &alc268_presets[board_config]);
11054
Kailang Yang2f893282008-05-27 12:14:47 +020011055 if (codec->vendor_id == 0x10ec0267) {
11056 spec->stream_name_analog = "ALC267 Analog";
11057 spec->stream_name_digital = "ALC267 Digital";
11058 } else {
11059 spec->stream_name_analog = "ALC268 Analog";
11060 spec->stream_name_digital = "ALC268 Digital";
11061 }
11062
Kailang Yanga361d842007-06-05 12:30:55 +020011063 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11064 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011065 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011066
Kailang Yanga361d842007-06-05 12:30:55 +020011067 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11068
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011069 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11070 /* override the amp caps for beep generator */
11071 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11072 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11073 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11074 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11075 (0 << AC_AMPCAP_MUTE_SHIFT));
11076
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011077 if (!spec->adc_nids && spec->input_mux) {
11078 /* check whether NID 0x07 is valid */
11079 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011080 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011081
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011082 /* get type */
11083 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011084 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011085 spec->adc_nids = alc268_adc_nids_alt;
11086 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
11087 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020011088 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011089 spec->num_mixers++;
11090 } else {
11091 spec->adc_nids = alc268_adc_nids;
11092 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
11093 spec->mixers[spec->num_mixers] =
11094 alc268_capture_mixer;
11095 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020011096 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011097 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011098 /* set default input source */
11099 for (i = 0; i < spec->num_adc_nids; i++)
11100 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11101 0, AC_VERB_SET_CONNECT_SEL,
11102 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011103 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011104
11105 spec->vmaster_nid = 0x02;
11106
Kailang Yanga361d842007-06-05 12:30:55 +020011107 codec->patch_ops = alc_patch_ops;
11108 if (board_config == ALC268_AUTO)
11109 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011110
Kailang Yanga361d842007-06-05 12:30:55 +020011111 return 0;
11112}
11113
11114/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011115 * ALC269 channel source setting (2 channel)
11116 */
11117#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11118
11119#define alc269_dac_nids alc260_dac_nids
11120
11121static hda_nid_t alc269_adc_nids[1] = {
11122 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011123 0x08,
11124};
11125
Takashi Iwaie01bf502008-08-21 16:25:07 +020011126static hda_nid_t alc269_capsrc_nids[1] = {
11127 0x23,
11128};
11129
11130/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11131 * not a mux!
11132 */
11133
Kailang Yangf53281e2008-07-18 12:36:43 +020011134static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11135 .num_items = 2,
11136 .items = {
11137 { "i-Mic", 0x5 },
11138 { "e-Mic", 0x0 },
11139 },
11140};
11141
11142static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11143 .num_items = 2,
11144 .items = {
11145 { "i-Mic", 0x1 },
11146 { "e-Mic", 0x0 },
11147 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011148};
11149
11150#define alc269_modes alc260_modes
11151#define alc269_capture_source alc880_lg_lw_capture_source
11152
11153static struct snd_kcontrol_new alc269_base_mixer[] = {
11154 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11155 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11156 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11157 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11158 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11159 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020011160 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11161 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011162 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11163 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11164 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11165 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11166 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11167 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11168 { } /* end */
11169};
11170
Kailang Yangf53281e2008-07-18 12:36:43 +020011171/* bind volumes of both NID 0x0c and 0x0d */
11172static struct hda_bind_ctls alc269_epc_bind_vol = {
11173 .ops = &snd_hda_bind_vol,
11174 .values = {
11175 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11176 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11177 0
11178 },
11179};
11180
11181static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11182 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11183 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11184 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11185 { } /* end */
11186};
11187
Kailang Yangf6a92242007-12-13 16:52:54 +010011188/* capture mixer elements */
11189static struct snd_kcontrol_new alc269_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011190 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11191 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011192 {
11193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11194 /* The multiple "Capture Source" controls confuse alsamixer
11195 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010011196 */
11197 /* .name = "Capture Source", */
11198 .name = "Input Source",
11199 .count = 1,
11200 .info = alc_mux_enum_info,
11201 .get = alc_mux_enum_get,
11202 .put = alc_mux_enum_put,
11203 },
11204 { } /* end */
11205};
11206
Kailang Yangf53281e2008-07-18 12:36:43 +020011207/* capture mixer elements */
11208static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11209 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11210 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11211 { } /* end */
11212};
11213
Takashi Iwai2005af22008-08-20 18:38:26 +020011214/* beep control */
11215static struct snd_kcontrol_new alc269_beep_mixer[] = {
11216 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11217 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
11218 { } /* end */
11219};
11220
Kailang Yangf6a92242007-12-13 16:52:54 +010011221/*
11222 * generic initialization of ADC, input mixers and output mixers
11223 */
11224static struct hda_verb alc269_init_verbs[] = {
11225 /*
11226 * Unmute ADC0 and set the default input to mic-in
11227 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011228 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011229
11230 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
11231 * analog-loopback mixer widget
11232 * Note: PASD motherboards uses the Line In 2 as the input for
11233 * front panel mic (mic 2)
11234 */
11235 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11238 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11239 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11240 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11241
11242 /*
11243 * Set up output mixers (0x0c - 0x0e)
11244 */
11245 /* set vol=0 to output mixers */
11246 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11247 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11248
11249 /* set up input amps for analog loopback */
11250 /* Amp Indices: DAC = 0, mixer = 1 */
11251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11252 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11253 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11254 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11255 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11256 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11257
11258 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11259 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11260 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11261 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11262 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11263 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11264 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11265
11266 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11268 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11269 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11270 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11271 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11273
11274 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11275 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11276
11277 /* FIXME: use matrix-type input source selection */
11278 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11279 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11280 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11282 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11284
11285 /* set EAPD */
11286 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11287 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11288 { }
11289};
11290
Kailang Yangf53281e2008-07-18 12:36:43 +020011291static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11292 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11293 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11294 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11295 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11296 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11297 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11298 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11299 {}
11300};
11301
11302static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11303 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11304 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11305 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11307 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11308 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11309 {}
11310};
11311
11312/* toggle speaker-output according to the hp-jack state */
11313static void alc269_speaker_automute(struct hda_codec *codec)
11314{
11315 unsigned int present;
11316 unsigned int bits;
11317
11318 present = snd_hda_codec_read(codec, 0x15, 0,
11319 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11320 bits = present ? AMP_IN_MUTE(0) : 0;
11321 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11322 AMP_IN_MUTE(0), bits);
11323 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11324 AMP_IN_MUTE(0), bits);
11325}
11326
11327static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11328{
11329 unsigned int present;
11330
11331 present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0)
11332 & AC_PINSENSE_PRESENCE;
11333 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11334 present ? 0 : 5);
11335}
11336
11337static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11338{
11339 unsigned int present;
11340
11341 present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0)
11342 & AC_PINSENSE_PRESENCE;
11343 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11344 present ? AMP_IN_UNMUTE(0) : AMP_IN_MUTE(0));
11345 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11346 present ? AMP_IN_MUTE(1) : AMP_IN_UNMUTE(1));
11347}
11348
11349/* unsolicited event for HP jack sensing */
11350static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11351 unsigned int res)
11352{
11353 if ((res >> 26) == ALC880_HP_EVENT)
11354 alc269_speaker_automute(codec);
11355
11356 if ((res >> 26) == ALC880_MIC_EVENT)
11357 alc269_eeepc_dmic_automute(codec);
11358}
11359
11360static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11361{
11362 alc269_speaker_automute(codec);
11363 alc269_eeepc_dmic_automute(codec);
11364}
11365
11366/* unsolicited event for HP jack sensing */
11367static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
Kailang Yangea1fb292008-08-26 12:58:38 +020011368 unsigned int res)
Kailang Yangf53281e2008-07-18 12:36:43 +020011369{
11370 if ((res >> 26) == ALC880_HP_EVENT)
11371 alc269_speaker_automute(codec);
11372
11373 if ((res >> 26) == ALC880_MIC_EVENT)
11374 alc269_eeepc_amic_automute(codec);
11375}
11376
11377static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
11378{
11379 alc269_speaker_automute(codec);
11380 alc269_eeepc_amic_automute(codec);
11381}
11382
Kailang Yangf6a92242007-12-13 16:52:54 +010011383/* add playback controls from the parsed DAC table */
11384static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11385 const struct auto_pin_cfg *cfg)
11386{
11387 hda_nid_t nid;
11388 int err;
11389
11390 spec->multiout.num_dacs = 1; /* only use one dac */
11391 spec->multiout.dac_nids = spec->private_dac_nids;
11392 spec->multiout.dac_nids[0] = 2;
11393
11394 nid = cfg->line_out_pins[0];
11395 if (nid) {
11396 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11397 "Front Playback Volume",
11398 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
11399 if (err < 0)
11400 return err;
11401 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11402 "Front Playback Switch",
11403 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11404 if (err < 0)
11405 return err;
11406 }
11407
11408 nid = cfg->speaker_pins[0];
11409 if (nid) {
11410 if (!cfg->line_out_pins[0]) {
11411 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11412 "Speaker Playback Volume",
11413 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11414 HDA_OUTPUT));
11415 if (err < 0)
11416 return err;
11417 }
11418 if (nid == 0x16) {
11419 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11420 "Speaker Playback Switch",
11421 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11422 HDA_OUTPUT));
11423 if (err < 0)
11424 return err;
11425 } else {
11426 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11427 "Speaker Playback Switch",
11428 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11429 HDA_OUTPUT));
11430 if (err < 0)
11431 return err;
11432 }
11433 }
11434 nid = cfg->hp_pins[0];
11435 if (nid) {
11436 /* spec->multiout.hp_nid = 2; */
11437 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
11438 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11439 "Headphone Playback Volume",
11440 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11441 HDA_OUTPUT));
11442 if (err < 0)
11443 return err;
11444 }
11445 if (nid == 0x16) {
11446 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11447 "Headphone Playback Switch",
11448 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11449 HDA_OUTPUT));
11450 if (err < 0)
11451 return err;
11452 } else {
11453 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11454 "Headphone Playback Switch",
11455 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11456 HDA_OUTPUT));
11457 if (err < 0)
11458 return err;
11459 }
11460 }
11461 return 0;
11462}
11463
11464#define alc269_auto_create_analog_input_ctls \
11465 alc880_auto_create_analog_input_ctls
11466
11467#ifdef CONFIG_SND_HDA_POWER_SAVE
11468#define alc269_loopbacks alc880_loopbacks
11469#endif
11470
11471/* pcm configuration: identiacal with ALC880 */
11472#define alc269_pcm_analog_playback alc880_pcm_analog_playback
11473#define alc269_pcm_analog_capture alc880_pcm_analog_capture
11474#define alc269_pcm_digital_playback alc880_pcm_digital_playback
11475#define alc269_pcm_digital_capture alc880_pcm_digital_capture
11476
11477/*
11478 * BIOS auto configuration
11479 */
11480static int alc269_parse_auto_config(struct hda_codec *codec)
11481{
11482 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020011483 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010011484 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
11485
11486 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11487 alc269_ignore);
11488 if (err < 0)
11489 return err;
11490
11491 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
11492 if (err < 0)
11493 return err;
11494 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
11495 if (err < 0)
11496 return err;
11497
11498 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11499
11500 if (spec->autocfg.dig_out_pin)
11501 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
11502
11503 if (spec->kctl_alloc)
11504 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11505
Takashi Iwai2005af22008-08-20 18:38:26 +020011506 /* create a beep mixer control if the pin 0x1d isn't assigned */
11507 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
11508 if (spec->autocfg.input_pins[i] == 0x1d)
11509 break;
11510 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
11511 spec->mixers[spec->num_mixers++] = alc269_beep_mixer;
11512
Kailang Yangf6a92242007-12-13 16:52:54 +010011513 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
11514 spec->num_mux_defs = 1;
11515 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020011516 /* set default input source */
11517 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
11518 0, AC_VERB_SET_CONNECT_SEL,
11519 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010011520
11521 err = alc_auto_add_mic_boost(codec);
11522 if (err < 0)
11523 return err;
11524
Kailang Yangf53281e2008-07-18 12:36:43 +020011525 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11526 spec->num_mixers++;
11527
Kailang Yangf6a92242007-12-13 16:52:54 +010011528 return 1;
11529}
11530
11531#define alc269_auto_init_multi_out alc882_auto_init_multi_out
11532#define alc269_auto_init_hp_out alc882_auto_init_hp_out
11533#define alc269_auto_init_analog_input alc882_auto_init_analog_input
11534
11535
11536/* init callback for auto-configuration model -- overriding the default init */
11537static void alc269_auto_init(struct hda_codec *codec)
11538{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011539 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010011540 alc269_auto_init_multi_out(codec);
11541 alc269_auto_init_hp_out(codec);
11542 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011543 if (spec->unsol_event)
11544 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010011545}
11546
11547/*
11548 * configuration and preset
11549 */
11550static const char *alc269_models[ALC269_MODEL_LAST] = {
11551 [ALC269_BASIC] = "basic",
11552};
11553
11554static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011555 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
11556 ALC269_ASUS_EEEPC_P703),
11557 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
11558 ALC269_ASUS_EEEPC_P901),
Kailang Yangf6a92242007-12-13 16:52:54 +010011559 {}
11560};
11561
11562static struct alc_config_preset alc269_presets[] = {
11563 [ALC269_BASIC] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011564 .mixers = { alc269_base_mixer, alc269_capture_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010011565 .init_verbs = { alc269_init_verbs },
11566 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11567 .dac_nids = alc269_dac_nids,
11568 .hp_nid = 0x03,
11569 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11570 .channel_mode = alc269_modes,
11571 .input_mux = &alc269_capture_source,
11572 },
Kailang Yangf53281e2008-07-18 12:36:43 +020011573 [ALC269_ASUS_EEEPC_P703] = {
11574 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer },
11575 .init_verbs = { alc269_init_verbs,
11576 alc269_eeepc_amic_init_verbs },
11577 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11578 .dac_nids = alc269_dac_nids,
11579 .hp_nid = 0x03,
11580 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11581 .channel_mode = alc269_modes,
11582 .input_mux = &alc269_eeepc_amic_capture_source,
11583 .unsol_event = alc269_eeepc_amic_unsol_event,
11584 .init_hook = alc269_eeepc_amic_inithook,
11585 },
11586 [ALC269_ASUS_EEEPC_P901] = {
11587 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer},
11588 .init_verbs = { alc269_init_verbs,
11589 alc269_eeepc_dmic_init_verbs },
11590 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11591 .dac_nids = alc269_dac_nids,
11592 .hp_nid = 0x03,
11593 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11594 .channel_mode = alc269_modes,
11595 .input_mux = &alc269_eeepc_dmic_capture_source,
11596 .unsol_event = alc269_eeepc_dmic_unsol_event,
11597 .init_hook = alc269_eeepc_dmic_inithook,
11598 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011599};
11600
11601static int patch_alc269(struct hda_codec *codec)
11602{
11603 struct alc_spec *spec;
11604 int board_config;
11605 int err;
11606
11607 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11608 if (spec == NULL)
11609 return -ENOMEM;
11610
11611 codec->spec = spec;
11612
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011613 alc_fix_pll_init(codec, 0x20, 0x04, 15);
11614
Kailang Yangf6a92242007-12-13 16:52:54 +010011615 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
11616 alc269_models,
11617 alc269_cfg_tbl);
11618
11619 if (board_config < 0) {
11620 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
11621 "trying auto-probe from BIOS...\n");
11622 board_config = ALC269_AUTO;
11623 }
11624
11625 if (board_config == ALC269_AUTO) {
11626 /* automatic parse from the BIOS config */
11627 err = alc269_parse_auto_config(codec);
11628 if (err < 0) {
11629 alc_free(codec);
11630 return err;
11631 } else if (!err) {
11632 printk(KERN_INFO
11633 "hda_codec: Cannot set up configuration "
11634 "from BIOS. Using base mode...\n");
11635 board_config = ALC269_BASIC;
11636 }
11637 }
11638
11639 if (board_config != ALC269_AUTO)
11640 setup_preset(spec, &alc269_presets[board_config]);
11641
11642 spec->stream_name_analog = "ALC269 Analog";
11643 spec->stream_analog_playback = &alc269_pcm_analog_playback;
11644 spec->stream_analog_capture = &alc269_pcm_analog_capture;
11645
11646 spec->stream_name_digital = "ALC269 Digital";
11647 spec->stream_digital_playback = &alc269_pcm_digital_playback;
11648 spec->stream_digital_capture = &alc269_pcm_digital_capture;
11649
11650 spec->adc_nids = alc269_adc_nids;
11651 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020011652 spec->capsrc_nids = alc269_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010011653
11654 codec->patch_ops = alc_patch_ops;
11655 if (board_config == ALC269_AUTO)
11656 spec->init_hook = alc269_auto_init;
11657#ifdef CONFIG_SND_HDA_POWER_SAVE
11658 if (!spec->loopback.amplist)
11659 spec->loopback.amplist = alc269_loopbacks;
11660#endif
11661
11662 return 0;
11663}
11664
11665/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011666 * ALC861 channel source setting (2/6 channel selection for 3-stack)
11667 */
11668
11669/*
11670 * set the path ways for 2 channel output
11671 * need to set the codec line out and mic 1 pin widgets to inputs
11672 */
11673static struct hda_verb alc861_threestack_ch2_init[] = {
11674 /* set pin widget 1Ah (line in) for input */
11675 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011676 /* set pin widget 18h (mic1/2) for input, for mic also enable
11677 * the vref
11678 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011679 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11680
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011681 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11682#if 0
11683 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11684 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11685#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011686 { } /* end */
11687};
11688/*
11689 * 6ch mode
11690 * need to set the codec line out and mic 1 pin widgets to outputs
11691 */
11692static struct hda_verb alc861_threestack_ch6_init[] = {
11693 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11694 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11695 /* set pin widget 18h (mic1) for output (CLFE)*/
11696 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11697
11698 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011699 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011700
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011701 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11702#if 0
11703 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11704 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11705#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011706 { } /* end */
11707};
11708
11709static struct hda_channel_mode alc861_threestack_modes[2] = {
11710 { 2, alc861_threestack_ch2_init },
11711 { 6, alc861_threestack_ch6_init },
11712};
Takashi Iwai22309c32006-08-09 16:57:28 +020011713/* Set mic1 as input and unmute the mixer */
11714static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
11715 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11716 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11717 { } /* end */
11718};
11719/* Set mic1 as output and mute mixer */
11720static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
11721 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11722 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11723 { } /* end */
11724};
11725
11726static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
11727 { 2, alc861_uniwill_m31_ch2_init },
11728 { 4, alc861_uniwill_m31_ch4_init },
11729};
Kailang Yangdf694da2005-12-05 19:42:22 +010011730
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011731/* Set mic1 and line-in as input and unmute the mixer */
11732static struct hda_verb alc861_asus_ch2_init[] = {
11733 /* set pin widget 1Ah (line in) for input */
11734 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011735 /* set pin widget 18h (mic1/2) for input, for mic also enable
11736 * the vref
11737 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011738 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11739
11740 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11741#if 0
11742 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11743 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11744#endif
11745 { } /* end */
11746};
11747/* Set mic1 nad line-in as output and mute mixer */
11748static struct hda_verb alc861_asus_ch6_init[] = {
11749 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11750 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11751 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11752 /* set pin widget 18h (mic1) for output (CLFE)*/
11753 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11754 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11755 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11756 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11757
11758 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11759#if 0
11760 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11761 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11762#endif
11763 { } /* end */
11764};
11765
11766static struct hda_channel_mode alc861_asus_modes[2] = {
11767 { 2, alc861_asus_ch2_init },
11768 { 6, alc861_asus_ch6_init },
11769};
11770
Kailang Yangdf694da2005-12-05 19:42:22 +010011771/* patch-ALC861 */
11772
11773static struct snd_kcontrol_new alc861_base_mixer[] = {
11774 /* output mixer control */
11775 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11776 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11777 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11778 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11779 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11780
11781 /*Input mixer control */
11782 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11783 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11784 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11785 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11786 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11787 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11788 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11789 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11790 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011792
Kailang Yangdf694da2005-12-05 19:42:22 +010011793 /* Capture mixer control */
11794 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11795 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11796 {
11797 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11798 .name = "Capture Source",
11799 .count = 1,
11800 .info = alc_mux_enum_info,
11801 .get = alc_mux_enum_get,
11802 .put = alc_mux_enum_put,
11803 },
11804 { } /* end */
11805};
11806
11807static struct snd_kcontrol_new alc861_3ST_mixer[] = {
11808 /* output mixer control */
11809 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11810 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11811 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11812 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11813 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11814
11815 /* Input mixer control */
11816 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11817 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11818 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11819 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11820 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11821 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11822 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11823 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11825 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011826
Kailang Yangdf694da2005-12-05 19:42:22 +010011827 /* Capture mixer control */
11828 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11829 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11830 {
11831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11832 .name = "Capture Source",
11833 .count = 1,
11834 .info = alc_mux_enum_info,
11835 .get = alc_mux_enum_get,
11836 .put = alc_mux_enum_put,
11837 },
11838 {
11839 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11840 .name = "Channel Mode",
11841 .info = alc_ch_mode_info,
11842 .get = alc_ch_mode_get,
11843 .put = alc_ch_mode_put,
11844 .private_value = ARRAY_SIZE(alc861_threestack_modes),
11845 },
11846 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011847};
11848
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011849static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011850 /* output mixer control */
11851 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11853 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020011854
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011855 /*Capture mixer control */
11856 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11857 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11858 {
11859 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11860 .name = "Capture Source",
11861 .count = 1,
11862 .info = alc_mux_enum_info,
11863 .get = alc_mux_enum_get,
11864 .put = alc_mux_enum_put,
11865 },
11866
11867 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011868};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011869
Takashi Iwai22309c32006-08-09 16:57:28 +020011870static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
11871 /* output mixer control */
11872 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11873 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11874 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11875 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11876 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11877
11878 /* Input mixer control */
11879 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11880 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11881 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11882 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11883 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11884 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11885 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11886 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11887 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011889
Takashi Iwai22309c32006-08-09 16:57:28 +020011890 /* Capture mixer control */
11891 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11892 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11893 {
11894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11895 .name = "Capture Source",
11896 .count = 1,
11897 .info = alc_mux_enum_info,
11898 .get = alc_mux_enum_get,
11899 .put = alc_mux_enum_put,
11900 },
11901 {
11902 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11903 .name = "Channel Mode",
11904 .info = alc_ch_mode_info,
11905 .get = alc_ch_mode_get,
11906 .put = alc_ch_mode_put,
11907 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
11908 },
11909 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011910};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011911
11912static struct snd_kcontrol_new alc861_asus_mixer[] = {
11913 /* output mixer control */
11914 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11915 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11916 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11917 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11918 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11919
11920 /* Input mixer control */
11921 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11922 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11923 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11924 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11925 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11926 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11927 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11928 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11929 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
11931
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011932 /* Capture mixer control */
11933 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11934 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11935 {
11936 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11937 .name = "Capture Source",
11938 .count = 1,
11939 .info = alc_mux_enum_info,
11940 .get = alc_mux_enum_get,
11941 .put = alc_mux_enum_put,
11942 },
11943 {
11944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11945 .name = "Channel Mode",
11946 .info = alc_ch_mode_info,
11947 .get = alc_ch_mode_get,
11948 .put = alc_ch_mode_put,
11949 .private_value = ARRAY_SIZE(alc861_asus_modes),
11950 },
11951 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011952};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011953
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011954/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011955static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011956 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11957 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11958 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
11959 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
11960 { }
11961};
11962
Kailang Yangdf694da2005-12-05 19:42:22 +010011963/*
11964 * generic initialization of ADC, input mixers and output mixers
11965 */
11966static struct hda_verb alc861_base_init_verbs[] = {
11967 /*
11968 * Unmute ADC0 and set the default input to mic-in
11969 */
11970 /* port-A for surround (rear panel) */
11971 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11972 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
11973 /* port-B for mic-in (rear panel) with vref */
11974 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11975 /* port-C for line-in (rear panel) */
11976 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11977 /* port-D for Front */
11978 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11979 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11980 /* port-E for HP out (front panel) */
11981 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11982 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011983 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011984 /* port-F for mic-in (front panel) with vref */
11985 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11986 /* port-G for CLFE (rear panel) */
11987 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11988 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11989 /* port-H for side (rear panel) */
11990 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11991 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
11992 /* CD-in */
11993 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11994 /* route front mic to ADC1*/
11995 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11996 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011997
Kailang Yangdf694da2005-12-05 19:42:22 +010011998 /* Unmute DAC0~3 & spdif out*/
11999 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12000 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12001 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12002 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12003 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012004
Kailang Yangdf694da2005-12-05 19:42:22 +010012005 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12006 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12007 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12008 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12009 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012010
Kailang Yangdf694da2005-12-05 19:42:22 +010012011 /* Unmute Stereo Mixer 15 */
12012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12013 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12014 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012015 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012016
12017 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12018 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12019 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12020 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12021 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12022 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12023 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12024 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012025 /* hp used DAC 3 (Front) */
12026 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012027 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12028
12029 { }
12030};
12031
12032static struct hda_verb alc861_threestack_init_verbs[] = {
12033 /*
12034 * Unmute ADC0 and set the default input to mic-in
12035 */
12036 /* port-A for surround (rear panel) */
12037 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12038 /* port-B for mic-in (rear panel) with vref */
12039 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12040 /* port-C for line-in (rear panel) */
12041 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12042 /* port-D for Front */
12043 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12044 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12045 /* port-E for HP out (front panel) */
12046 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12047 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012048 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012049 /* port-F for mic-in (front panel) with vref */
12050 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12051 /* port-G for CLFE (rear panel) */
12052 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12053 /* port-H for side (rear panel) */
12054 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12055 /* CD-in */
12056 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12057 /* route front mic to ADC1*/
12058 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12059 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12060 /* Unmute DAC0~3 & spdif out*/
12061 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12062 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12063 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12064 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12065 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012066
Kailang Yangdf694da2005-12-05 19:42:22 +010012067 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12068 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12069 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12070 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12071 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012072
Kailang Yangdf694da2005-12-05 19:42:22 +010012073 /* Unmute Stereo Mixer 15 */
12074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12075 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12076 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012078
12079 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12080 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12081 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12082 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12083 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12084 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12085 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12086 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012087 /* hp used DAC 3 (Front) */
12088 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012089 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12090 { }
12091};
Takashi Iwai22309c32006-08-09 16:57:28 +020012092
12093static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
12094 /*
12095 * Unmute ADC0 and set the default input to mic-in
12096 */
12097 /* port-A for surround (rear panel) */
12098 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12099 /* port-B for mic-in (rear panel) with vref */
12100 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12101 /* port-C for line-in (rear panel) */
12102 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12103 /* port-D for Front */
12104 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12105 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12106 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012107 /* this has to be set to VREF80 */
12108 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012109 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012110 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012111 /* port-F for mic-in (front panel) with vref */
12112 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12113 /* port-G for CLFE (rear panel) */
12114 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12115 /* port-H for side (rear panel) */
12116 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12117 /* CD-in */
12118 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12119 /* route front mic to ADC1*/
12120 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12122 /* Unmute DAC0~3 & spdif out*/
12123 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12124 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12125 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12126 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12127 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012128
Takashi Iwai22309c32006-08-09 16:57:28 +020012129 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12130 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12131 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12132 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12133 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012134
Takashi Iwai22309c32006-08-09 16:57:28 +020012135 /* Unmute Stereo Mixer 15 */
12136 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12137 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12138 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012139 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012140
12141 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12142 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12143 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12144 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12146 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12148 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012149 /* hp used DAC 3 (Front) */
12150 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012151 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12152 { }
12153};
12154
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012155static struct hda_verb alc861_asus_init_verbs[] = {
12156 /*
12157 * Unmute ADC0 and set the default input to mic-in
12158 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012159 /* port-A for surround (rear panel)
12160 * according to codec#0 this is the HP jack
12161 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012162 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12163 /* route front PCM to HP */
12164 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12165 /* port-B for mic-in (rear panel) with vref */
12166 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12167 /* port-C for line-in (rear panel) */
12168 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12169 /* port-D for Front */
12170 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12171 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12172 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012173 /* this has to be set to VREF80 */
12174 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012175 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012176 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012177 /* port-F for mic-in (front panel) with vref */
12178 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12179 /* port-G for CLFE (rear panel) */
12180 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12181 /* port-H for side (rear panel) */
12182 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12183 /* CD-in */
12184 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12185 /* route front mic to ADC1*/
12186 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12187 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12188 /* Unmute DAC0~3 & spdif out*/
12189 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12190 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12191 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12192 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12193 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12194 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12195 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12196 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12197 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12198 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012199
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012200 /* Unmute Stereo Mixer 15 */
12201 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12202 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12203 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012204 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012205
12206 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12207 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12208 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12209 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12210 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12211 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12212 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12213 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012214 /* hp used DAC 3 (Front) */
12215 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012216 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12217 { }
12218};
12219
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012220/* additional init verbs for ASUS laptops */
12221static struct hda_verb alc861_asus_laptop_init_verbs[] = {
12222 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
12223 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
12224 { }
12225};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012226
Kailang Yangdf694da2005-12-05 19:42:22 +010012227/*
12228 * generic initialization of ADC, input mixers and output mixers
12229 */
12230static struct hda_verb alc861_auto_init_verbs[] = {
12231 /*
12232 * Unmute ADC0 and set the default input to mic-in
12233 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012234 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010012235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012236
Kailang Yangdf694da2005-12-05 19:42:22 +010012237 /* Unmute DAC0~3 & spdif out*/
12238 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12239 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12240 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12241 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012243
Kailang Yangdf694da2005-12-05 19:42:22 +010012244 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12245 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12246 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12247 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12248 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012249
Kailang Yangdf694da2005-12-05 19:42:22 +010012250 /* Unmute Stereo Mixer 15 */
12251 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12252 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12253 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
12255
12256 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12257 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12258 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12259 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12260 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12261 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12262 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12263 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12264
12265 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12266 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012267 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12268 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012269 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12270 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012271 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012273
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012274 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012275
12276 { }
12277};
12278
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012279static struct hda_verb alc861_toshiba_init_verbs[] = {
12280 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012281
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012282 { }
12283};
12284
12285/* toggle speaker-output according to the hp-jack state */
12286static void alc861_toshiba_automute(struct hda_codec *codec)
12287{
12288 unsigned int present;
12289
12290 present = snd_hda_codec_read(codec, 0x0f, 0,
12291 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012292 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
12293 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12294 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
12295 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012296}
12297
12298static void alc861_toshiba_unsol_event(struct hda_codec *codec,
12299 unsigned int res)
12300{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012301 if ((res >> 26) == ALC880_HP_EVENT)
12302 alc861_toshiba_automute(codec);
12303}
12304
Kailang Yangdf694da2005-12-05 19:42:22 +010012305/* pcm configuration: identiacal with ALC880 */
12306#define alc861_pcm_analog_playback alc880_pcm_analog_playback
12307#define alc861_pcm_analog_capture alc880_pcm_analog_capture
12308#define alc861_pcm_digital_playback alc880_pcm_digital_playback
12309#define alc861_pcm_digital_capture alc880_pcm_digital_capture
12310
12311
12312#define ALC861_DIGOUT_NID 0x07
12313
12314static struct hda_channel_mode alc861_8ch_modes[1] = {
12315 { 8, NULL }
12316};
12317
12318static hda_nid_t alc861_dac_nids[4] = {
12319 /* front, surround, clfe, side */
12320 0x03, 0x06, 0x05, 0x04
12321};
12322
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012323static hda_nid_t alc660_dac_nids[3] = {
12324 /* front, clfe, surround */
12325 0x03, 0x05, 0x06
12326};
12327
Kailang Yangdf694da2005-12-05 19:42:22 +010012328static hda_nid_t alc861_adc_nids[1] = {
12329 /* ADC0-2 */
12330 0x08,
12331};
12332
12333static struct hda_input_mux alc861_capture_source = {
12334 .num_items = 5,
12335 .items = {
12336 { "Mic", 0x0 },
12337 { "Front Mic", 0x3 },
12338 { "Line", 0x1 },
12339 { "CD", 0x4 },
12340 { "Mixer", 0x5 },
12341 },
12342};
12343
12344/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012345static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
12346 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012347{
12348 int i;
12349 hda_nid_t nid;
12350
12351 spec->multiout.dac_nids = spec->private_dac_nids;
12352 for (i = 0; i < cfg->line_outs; i++) {
12353 nid = cfg->line_out_pins[i];
12354 if (nid) {
12355 if (i >= ARRAY_SIZE(alc861_dac_nids))
12356 continue;
12357 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
12358 }
12359 }
12360 spec->multiout.num_dacs = cfg->line_outs;
12361 return 0;
12362}
12363
12364/* add playback controls from the parsed DAC table */
12365static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
12366 const struct auto_pin_cfg *cfg)
12367{
12368 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012369 static const char *chname[4] = {
12370 "Front", "Surround", NULL /*CLFE*/, "Side"
12371 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012372 hda_nid_t nid;
12373 int i, idx, err;
12374
12375 for (i = 0; i < cfg->line_outs; i++) {
12376 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012377 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010012378 continue;
12379 if (nid == 0x05) {
12380 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012381 err = add_control(spec, ALC_CTL_BIND_MUTE,
12382 "Center Playback Switch",
12383 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12384 HDA_OUTPUT));
12385 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012386 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012387 err = add_control(spec, ALC_CTL_BIND_MUTE,
12388 "LFE Playback Switch",
12389 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12390 HDA_OUTPUT));
12391 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012392 return err;
12393 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012394 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
12395 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010012396 if (nid == alc861_dac_nids[idx])
12397 break;
12398 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012399 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12400 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12401 HDA_OUTPUT));
12402 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012403 return err;
12404 }
12405 }
12406 return 0;
12407}
12408
12409static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
12410{
12411 int err;
12412 hda_nid_t nid;
12413
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012414 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010012415 return 0;
12416
12417 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
12418 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012419 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12420 "Headphone Playback Switch",
12421 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12422 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012423 return err;
12424 spec->multiout.hp_nid = nid;
12425 }
12426 return 0;
12427}
12428
12429/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012430static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
12431 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012432{
Kailang Yangdf694da2005-12-05 19:42:22 +010012433 struct hda_input_mux *imux = &spec->private_imux;
12434 int i, err, idx, idx1;
12435
12436 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012437 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012438 case 0x0c:
12439 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012440 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012441 break;
12442 case 0x0f:
12443 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012444 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012445 break;
12446 case 0x0d:
12447 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012448 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012449 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012450 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010012451 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012452 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012453 break;
12454 case 0x11:
12455 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012456 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010012457 break;
12458 default:
12459 continue;
12460 }
12461
Takashi Iwai4a471b72005-12-07 13:56:29 +010012462 err = new_analog_input(spec, cfg->input_pins[i],
12463 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010012464 if (err < 0)
12465 return err;
12466
Takashi Iwai4a471b72005-12-07 13:56:29 +010012467 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010012468 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012469 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010012470 }
12471 return 0;
12472}
12473
12474static struct snd_kcontrol_new alc861_capture_mixer[] = {
12475 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12476 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12477
12478 {
12479 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12480 /* The multiple "Capture Source" controls confuse alsamixer
12481 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010012482 */
12483 /* .name = "Capture Source", */
12484 .name = "Input Source",
12485 .count = 1,
12486 .info = alc_mux_enum_info,
12487 .get = alc_mux_enum_get,
12488 .put = alc_mux_enum_put,
12489 },
12490 { } /* end */
12491};
12492
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012493static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
12494 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010012495 int pin_type, int dac_idx)
12496{
Jacek Luczak564c5be2008-05-03 18:41:23 +020012497 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
12498 pin_type);
12499 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12500 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010012501}
12502
12503static void alc861_auto_init_multi_out(struct hda_codec *codec)
12504{
12505 struct alc_spec *spec = codec->spec;
12506 int i;
12507
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012508 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010012509 for (i = 0; i < spec->autocfg.line_outs; i++) {
12510 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012511 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010012512 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012513 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012514 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012515 }
12516}
12517
12518static void alc861_auto_init_hp_out(struct hda_codec *codec)
12519{
12520 struct alc_spec *spec = codec->spec;
12521 hda_nid_t pin;
12522
Takashi Iwaieb06ed82006-09-20 17:10:27 +020012523 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012524 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012525 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
12526 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012527 pin = spec->autocfg.speaker_pins[0];
12528 if (pin)
12529 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010012530}
12531
12532static void alc861_auto_init_analog_input(struct hda_codec *codec)
12533{
12534 struct alc_spec *spec = codec->spec;
12535 int i;
12536
12537 for (i = 0; i < AUTO_PIN_LAST; i++) {
12538 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012539 if (nid >= 0x0c && nid <= 0x11) {
12540 snd_hda_codec_write(codec, nid, 0,
12541 AC_VERB_SET_PIN_WIDGET_CONTROL,
12542 i <= AUTO_PIN_FRONT_MIC ?
12543 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010012544 }
12545 }
12546}
12547
12548/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012549/* return 1 if successful, 0 if the proper config is not found,
12550 * or a negative error code
12551 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012552static int alc861_parse_auto_config(struct hda_codec *codec)
12553{
12554 struct alc_spec *spec = codec->spec;
12555 int err;
12556 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
12557
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012558 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12559 alc861_ignore);
12560 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012561 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012562 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010012563 return 0; /* can't find valid BIOS pin config */
12564
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012565 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
12566 if (err < 0)
12567 return err;
12568 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
12569 if (err < 0)
12570 return err;
12571 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
12572 if (err < 0)
12573 return err;
12574 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
12575 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012576 return err;
12577
12578 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12579
12580 if (spec->autocfg.dig_out_pin)
12581 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
12582
12583 if (spec->kctl_alloc)
12584 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12585
12586 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
12587
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012588 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010012589 spec->input_mux = &spec->private_imux;
12590
12591 spec->adc_nids = alc861_adc_nids;
12592 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
12593 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
12594 spec->num_mixers++;
12595
12596 return 1;
12597}
12598
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012599/* additional initialization for auto-configuration model */
12600static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012601{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012602 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012603 alc861_auto_init_multi_out(codec);
12604 alc861_auto_init_hp_out(codec);
12605 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012606 if (spec->unsol_event)
12607 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012608}
12609
Takashi Iwaicb53c622007-08-10 17:21:45 +020012610#ifdef CONFIG_SND_HDA_POWER_SAVE
12611static struct hda_amp_list alc861_loopbacks[] = {
12612 { 0x15, HDA_INPUT, 0 },
12613 { 0x15, HDA_INPUT, 1 },
12614 { 0x15, HDA_INPUT, 2 },
12615 { 0x15, HDA_INPUT, 3 },
12616 { } /* end */
12617};
12618#endif
12619
Kailang Yangdf694da2005-12-05 19:42:22 +010012620
12621/*
12622 * configuration and preset
12623 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012624static const char *alc861_models[ALC861_MODEL_LAST] = {
12625 [ALC861_3ST] = "3stack",
12626 [ALC660_3ST] = "3stack-660",
12627 [ALC861_3ST_DIG] = "3stack-dig",
12628 [ALC861_6ST_DIG] = "6stack-dig",
12629 [ALC861_UNIWILL_M31] = "uniwill-m31",
12630 [ALC861_TOSHIBA] = "toshiba",
12631 [ALC861_ASUS] = "asus",
12632 [ALC861_ASUS_LAPTOP] = "asus-laptop",
12633 [ALC861_AUTO] = "auto",
12634};
12635
12636static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010012637 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012638 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12639 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12640 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012641 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020012642 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010012643 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020012644 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
12645 * Any other models that need this preset?
12646 */
12647 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020012648 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
12649 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012650 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
12651 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
12652 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
12653 /* FIXME: the below seems conflict */
12654 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
12655 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
12656 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010012657 {}
12658};
12659
12660static struct alc_config_preset alc861_presets[] = {
12661 [ALC861_3ST] = {
12662 .mixers = { alc861_3ST_mixer },
12663 .init_verbs = { alc861_threestack_init_verbs },
12664 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12665 .dac_nids = alc861_dac_nids,
12666 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12667 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012668 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012669 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12670 .adc_nids = alc861_adc_nids,
12671 .input_mux = &alc861_capture_source,
12672 },
12673 [ALC861_3ST_DIG] = {
12674 .mixers = { alc861_base_mixer },
12675 .init_verbs = { alc861_threestack_init_verbs },
12676 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12677 .dac_nids = alc861_dac_nids,
12678 .dig_out_nid = ALC861_DIGOUT_NID,
12679 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12680 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012681 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012682 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12683 .adc_nids = alc861_adc_nids,
12684 .input_mux = &alc861_capture_source,
12685 },
12686 [ALC861_6ST_DIG] = {
12687 .mixers = { alc861_base_mixer },
12688 .init_verbs = { alc861_base_init_verbs },
12689 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12690 .dac_nids = alc861_dac_nids,
12691 .dig_out_nid = ALC861_DIGOUT_NID,
12692 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
12693 .channel_mode = alc861_8ch_modes,
12694 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12695 .adc_nids = alc861_adc_nids,
12696 .input_mux = &alc861_capture_source,
12697 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012698 [ALC660_3ST] = {
12699 .mixers = { alc861_3ST_mixer },
12700 .init_verbs = { alc861_threestack_init_verbs },
12701 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
12702 .dac_nids = alc660_dac_nids,
12703 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12704 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012705 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012706 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12707 .adc_nids = alc861_adc_nids,
12708 .input_mux = &alc861_capture_source,
12709 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012710 [ALC861_UNIWILL_M31] = {
12711 .mixers = { alc861_uniwill_m31_mixer },
12712 .init_verbs = { alc861_uniwill_m31_init_verbs },
12713 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12714 .dac_nids = alc861_dac_nids,
12715 .dig_out_nid = ALC861_DIGOUT_NID,
12716 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
12717 .channel_mode = alc861_uniwill_m31_modes,
12718 .need_dac_fix = 1,
12719 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12720 .adc_nids = alc861_adc_nids,
12721 .input_mux = &alc861_capture_source,
12722 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012723 [ALC861_TOSHIBA] = {
12724 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012725 .init_verbs = { alc861_base_init_verbs,
12726 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012727 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12728 .dac_nids = alc861_dac_nids,
12729 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12730 .channel_mode = alc883_3ST_2ch_modes,
12731 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12732 .adc_nids = alc861_adc_nids,
12733 .input_mux = &alc861_capture_source,
12734 .unsol_event = alc861_toshiba_unsol_event,
12735 .init_hook = alc861_toshiba_automute,
12736 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012737 [ALC861_ASUS] = {
12738 .mixers = { alc861_asus_mixer },
12739 .init_verbs = { alc861_asus_init_verbs },
12740 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12741 .dac_nids = alc861_dac_nids,
12742 .dig_out_nid = ALC861_DIGOUT_NID,
12743 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
12744 .channel_mode = alc861_asus_modes,
12745 .need_dac_fix = 1,
12746 .hp_nid = 0x06,
12747 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12748 .adc_nids = alc861_adc_nids,
12749 .input_mux = &alc861_capture_source,
12750 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012751 [ALC861_ASUS_LAPTOP] = {
12752 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
12753 .init_verbs = { alc861_asus_init_verbs,
12754 alc861_asus_laptop_init_verbs },
12755 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12756 .dac_nids = alc861_dac_nids,
12757 .dig_out_nid = ALC861_DIGOUT_NID,
12758 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12759 .channel_mode = alc883_3ST_2ch_modes,
12760 .need_dac_fix = 1,
12761 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12762 .adc_nids = alc861_adc_nids,
12763 .input_mux = &alc861_capture_source,
12764 },
12765};
Kailang Yangdf694da2005-12-05 19:42:22 +010012766
12767
12768static int patch_alc861(struct hda_codec *codec)
12769{
12770 struct alc_spec *spec;
12771 int board_config;
12772 int err;
12773
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012774 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012775 if (spec == NULL)
12776 return -ENOMEM;
12777
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012778 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012779
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012780 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
12781 alc861_models,
12782 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012783
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012784 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012785 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
12786 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012787 board_config = ALC861_AUTO;
12788 }
12789
12790 if (board_config == ALC861_AUTO) {
12791 /* automatic parse from the BIOS config */
12792 err = alc861_parse_auto_config(codec);
12793 if (err < 0) {
12794 alc_free(codec);
12795 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012796 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012797 printk(KERN_INFO
12798 "hda_codec: Cannot set up configuration "
12799 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012800 board_config = ALC861_3ST_DIG;
12801 }
12802 }
12803
12804 if (board_config != ALC861_AUTO)
12805 setup_preset(spec, &alc861_presets[board_config]);
12806
12807 spec->stream_name_analog = "ALC861 Analog";
12808 spec->stream_analog_playback = &alc861_pcm_analog_playback;
12809 spec->stream_analog_capture = &alc861_pcm_analog_capture;
12810
12811 spec->stream_name_digital = "ALC861 Digital";
12812 spec->stream_digital_playback = &alc861_pcm_digital_playback;
12813 spec->stream_digital_capture = &alc861_pcm_digital_capture;
12814
Takashi Iwai2134ea42008-01-10 16:53:55 +010012815 spec->vmaster_nid = 0x03;
12816
Kailang Yangdf694da2005-12-05 19:42:22 +010012817 codec->patch_ops = alc_patch_ops;
12818 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012819 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012820#ifdef CONFIG_SND_HDA_POWER_SAVE
12821 if (!spec->loopback.amplist)
12822 spec->loopback.amplist = alc861_loopbacks;
12823#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012824
Kailang Yangdf694da2005-12-05 19:42:22 +010012825 return 0;
12826}
12827
12828/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012829 * ALC861-VD support
12830 *
12831 * Based on ALC882
12832 *
12833 * In addition, an independent DAC
12834 */
12835#define ALC861VD_DIGOUT_NID 0x06
12836
12837static hda_nid_t alc861vd_dac_nids[4] = {
12838 /* front, surr, clfe, side surr */
12839 0x02, 0x03, 0x04, 0x05
12840};
12841
12842/* dac_nids for ALC660vd are in a different order - according to
12843 * Realtek's driver.
12844 * This should probably tesult in a different mixer for 6stack models
12845 * of ALC660vd codecs, but for now there is only 3stack mixer
12846 * - and it is the same as in 861vd.
12847 * adc_nids in ALC660vd are (is) the same as in 861vd
12848 */
12849static hda_nid_t alc660vd_dac_nids[3] = {
12850 /* front, rear, clfe, rear_surr */
12851 0x02, 0x04, 0x03
12852};
12853
12854static hda_nid_t alc861vd_adc_nids[1] = {
12855 /* ADC0 */
12856 0x09,
12857};
12858
Takashi Iwaie1406342008-02-11 18:32:32 +010012859static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12860
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012861/* input MUX */
12862/* FIXME: should be a matrix-type input source selection */
12863static struct hda_input_mux alc861vd_capture_source = {
12864 .num_items = 4,
12865 .items = {
12866 { "Mic", 0x0 },
12867 { "Front Mic", 0x1 },
12868 { "Line", 0x2 },
12869 { "CD", 0x4 },
12870 },
12871};
12872
Kailang Yang272a5272007-05-14 11:00:38 +020012873static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010012874 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020012875 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010012876 { "Ext Mic", 0x0 },
12877 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020012878 },
12879};
12880
Kailang Yangd1a991a2007-08-15 16:21:59 +020012881static struct hda_input_mux alc861vd_hp_capture_source = {
12882 .num_items = 2,
12883 .items = {
12884 { "Front Mic", 0x0 },
12885 { "ATAPI Mic", 0x1 },
12886 },
12887};
12888
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012889#define alc861vd_mux_enum_info alc_mux_enum_info
12890#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010012891/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
12892#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012893
12894/*
12895 * 2ch mode
12896 */
12897static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
12898 { 2, NULL }
12899};
12900
12901/*
12902 * 6ch mode
12903 */
12904static struct hda_verb alc861vd_6stack_ch6_init[] = {
12905 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12906 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12907 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12908 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12909 { } /* end */
12910};
12911
12912/*
12913 * 8ch mode
12914 */
12915static struct hda_verb alc861vd_6stack_ch8_init[] = {
12916 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12917 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12918 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12919 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12920 { } /* end */
12921};
12922
12923static struct hda_channel_mode alc861vd_6stack_modes[2] = {
12924 { 6, alc861vd_6stack_ch6_init },
12925 { 8, alc861vd_6stack_ch8_init },
12926};
12927
12928static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
12929 {
12930 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12931 .name = "Channel Mode",
12932 .info = alc_ch_mode_info,
12933 .get = alc_ch_mode_get,
12934 .put = alc_ch_mode_put,
12935 },
12936 { } /* end */
12937};
12938
12939static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
12940 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12941 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12942
12943 {
12944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12945 /* The multiple "Capture Source" controls confuse alsamixer
12946 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012947 */
12948 /* .name = "Capture Source", */
12949 .name = "Input Source",
12950 .count = 1,
12951 .info = alc861vd_mux_enum_info,
12952 .get = alc861vd_mux_enum_get,
12953 .put = alc861vd_mux_enum_put,
12954 },
12955 { } /* end */
12956};
12957
12958/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12959 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12960 */
12961static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
12962 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12963 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12964
12965 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12966 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
12967
12968 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
12969 HDA_OUTPUT),
12970 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
12971 HDA_OUTPUT),
12972 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12973 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
12974
12975 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
12976 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
12977
12978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12979
12980 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12982 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12983
12984 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12985 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12986 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12987
12988 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12989 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12990
12991 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12992 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12993
12994 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12995 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12996
12997 { } /* end */
12998};
12999
13000static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13001 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13002 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13003
13004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13005
13006 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13009
13010 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13011 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13012 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13013
13014 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13015 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13016
13017 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13018 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13019
13020 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13021 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13022
13023 { } /* end */
13024};
13025
Kailang Yangbdd148a2007-05-08 15:19:08 +020013026static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
13027 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13028 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
13029 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13030
13031 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13032
13033 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13034 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13035 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13036
13037 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13038 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13039 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13040
13041 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13042 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13043
13044 { } /* end */
13045};
13046
Tobin Davisb419f342008-03-07 11:57:51 +010013047/* Pin assignment: Speaker=0x14, HP = 0x15,
13048 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020013049 */
13050static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010013051 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13052 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013053 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13054 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010013055 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13056 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13057 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13058 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13059 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13060 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13061 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
13062 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013063 { } /* end */
13064};
13065
Kailang Yangd1a991a2007-08-15 16:21:59 +020013066/* Pin assignment: Speaker=0x14, Line-out = 0x15,
13067 * Front Mic=0x18, ATAPI Mic = 0x19,
13068 */
13069static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
13070 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13071 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13072 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13073 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
13074 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13075 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13076 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13077 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013078
Kailang Yangd1a991a2007-08-15 16:21:59 +020013079 { } /* end */
13080};
13081
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013082/*
13083 * generic initialization of ADC, input mixers and output mixers
13084 */
13085static struct hda_verb alc861vd_volume_init_verbs[] = {
13086 /*
13087 * Unmute ADC0 and set the default input to mic-in
13088 */
13089 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13090 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13091
13092 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
13093 * the analog-loopback mixer widget
13094 */
13095 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013096 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013101
13102 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020013103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013107
13108 /*
13109 * Set up output mixers (0x02 - 0x05)
13110 */
13111 /* set vol=0 to output mixers */
13112 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13113 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13114 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13115 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13116
13117 /* set up input amps for analog loopback */
13118 /* Amp Indices: DAC = 0, mixer = 1 */
13119 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13120 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13121 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13122 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13123 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13124 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13125 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13126 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13127
13128 { }
13129};
13130
13131/*
13132 * 3-stack pin configuration:
13133 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13134 */
13135static struct hda_verb alc861vd_3stack_init_verbs[] = {
13136 /*
13137 * Set pin mode and muting
13138 */
13139 /* set front pin widgets 0x14 for output */
13140 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13141 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13142 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13143
13144 /* Mic (rear) pin: input vref at 80% */
13145 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13146 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13147 /* Front Mic pin: input vref at 80% */
13148 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13149 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13150 /* Line In pin: input */
13151 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13152 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13153 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13154 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13155 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13156 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13157 /* CD pin widget for input */
13158 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13159
13160 { }
13161};
13162
13163/*
13164 * 6-stack pin configuration:
13165 */
13166static struct hda_verb alc861vd_6stack_init_verbs[] = {
13167 /*
13168 * Set pin mode and muting
13169 */
13170 /* set front pin widgets 0x14 for output */
13171 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13172 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13173 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13174
13175 /* Rear Pin: output 1 (0x0d) */
13176 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13178 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13179 /* CLFE Pin: output 2 (0x0e) */
13180 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13181 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13182 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13183 /* Side Pin: output 3 (0x0f) */
13184 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13185 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13186 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13187
13188 /* Mic (rear) pin: input vref at 80% */
13189 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13190 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13191 /* Front Mic pin: input vref at 80% */
13192 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13193 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13194 /* Line In pin: input */
13195 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13196 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13197 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13198 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13199 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13200 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13201 /* CD pin widget for input */
13202 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13203
13204 { }
13205};
13206
Kailang Yangbdd148a2007-05-08 15:19:08 +020013207static struct hda_verb alc861vd_eapd_verbs[] = {
13208 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13209 { }
13210};
13211
Kailang Yangf9423e72008-05-27 12:32:25 +020013212static struct hda_verb alc660vd_eapd_verbs[] = {
13213 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13214 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13215 { }
13216};
13217
Kailang Yangbdd148a2007-05-08 15:19:08 +020013218static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
13219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
13222 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020013223 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020013224 {}
13225};
13226
13227/* toggle speaker-output according to the hp-jack state */
13228static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
13229{
13230 unsigned int present;
13231 unsigned char bits;
13232
13233 present = snd_hda_codec_read(codec, 0x1b, 0,
13234 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013235 bits = present ? HDA_AMP_MUTE : 0;
13236 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13237 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013238}
13239
13240static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
13241{
13242 unsigned int present;
13243 unsigned char bits;
13244
13245 present = snd_hda_codec_read(codec, 0x18, 0,
13246 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013247 bits = present ? HDA_AMP_MUTE : 0;
13248 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
13249 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013250}
13251
13252static void alc861vd_lenovo_automute(struct hda_codec *codec)
13253{
13254 alc861vd_lenovo_hp_automute(codec);
13255 alc861vd_lenovo_mic_automute(codec);
13256}
13257
13258static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
13259 unsigned int res)
13260{
13261 switch (res >> 26) {
13262 case ALC880_HP_EVENT:
13263 alc861vd_lenovo_hp_automute(codec);
13264 break;
13265 case ALC880_MIC_EVENT:
13266 alc861vd_lenovo_mic_automute(codec);
13267 break;
13268 }
13269}
13270
Kailang Yang272a5272007-05-14 11:00:38 +020013271static struct hda_verb alc861vd_dallas_verbs[] = {
13272 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13273 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13274 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13275 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13276
13277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13279 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13281 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13283 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13284 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013285
Kailang Yang272a5272007-05-14 11:00:38 +020013286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13287 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13291 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13292 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13293 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13294
13295 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13296 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13297 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13298 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13299 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13300 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13301 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13302 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13303
13304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13305 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13306 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13307 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13308
13309 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013310 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020013311 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13312
13313 { } /* end */
13314};
13315
13316/* toggle speaker-output according to the hp-jack state */
13317static void alc861vd_dallas_automute(struct hda_codec *codec)
13318{
13319 unsigned int present;
13320
13321 present = snd_hda_codec_read(codec, 0x15, 0,
13322 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013323 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13324 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020013325}
13326
13327static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
13328{
13329 if ((res >> 26) == ALC880_HP_EVENT)
13330 alc861vd_dallas_automute(codec);
13331}
13332
Takashi Iwaicb53c622007-08-10 17:21:45 +020013333#ifdef CONFIG_SND_HDA_POWER_SAVE
13334#define alc861vd_loopbacks alc880_loopbacks
13335#endif
13336
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013337/* pcm configuration: identiacal with ALC880 */
13338#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
13339#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
13340#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
13341#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
13342
13343/*
13344 * configuration and preset
13345 */
13346static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
13347 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013348 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013349 [ALC861VD_3ST] = "3stack",
13350 [ALC861VD_3ST_DIG] = "3stack-digout",
13351 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020013352 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020013353 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013354 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013355 [ALC861VD_AUTO] = "auto",
13356};
13357
13358static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013359 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
13360 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010013361 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013362 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Alexander Holler2522d732008-07-17 23:36:15 +020013363 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO),
Mike Crash6963f842007-06-25 12:12:51 +020013364 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013365 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013366 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020013367 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020013368 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020013369 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010013370 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020013371 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013372 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
13373 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020013374 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020013375 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013376 {}
13377};
13378
13379static struct alc_config_preset alc861vd_presets[] = {
13380 [ALC660VD_3ST] = {
13381 .mixers = { alc861vd_3st_mixer },
13382 .init_verbs = { alc861vd_volume_init_verbs,
13383 alc861vd_3stack_init_verbs },
13384 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13385 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013386 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13387 .channel_mode = alc861vd_3stack_2ch_modes,
13388 .input_mux = &alc861vd_capture_source,
13389 },
Mike Crash6963f842007-06-25 12:12:51 +020013390 [ALC660VD_3ST_DIG] = {
13391 .mixers = { alc861vd_3st_mixer },
13392 .init_verbs = { alc861vd_volume_init_verbs,
13393 alc861vd_3stack_init_verbs },
13394 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13395 .dac_nids = alc660vd_dac_nids,
13396 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020013397 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13398 .channel_mode = alc861vd_3stack_2ch_modes,
13399 .input_mux = &alc861vd_capture_source,
13400 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013401 [ALC861VD_3ST] = {
13402 .mixers = { alc861vd_3st_mixer },
13403 .init_verbs = { alc861vd_volume_init_verbs,
13404 alc861vd_3stack_init_verbs },
13405 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13406 .dac_nids = alc861vd_dac_nids,
13407 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13408 .channel_mode = alc861vd_3stack_2ch_modes,
13409 .input_mux = &alc861vd_capture_source,
13410 },
13411 [ALC861VD_3ST_DIG] = {
13412 .mixers = { alc861vd_3st_mixer },
13413 .init_verbs = { alc861vd_volume_init_verbs,
13414 alc861vd_3stack_init_verbs },
13415 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13416 .dac_nids = alc861vd_dac_nids,
13417 .dig_out_nid = ALC861VD_DIGOUT_NID,
13418 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13419 .channel_mode = alc861vd_3stack_2ch_modes,
13420 .input_mux = &alc861vd_capture_source,
13421 },
13422 [ALC861VD_6ST_DIG] = {
13423 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
13424 .init_verbs = { alc861vd_volume_init_verbs,
13425 alc861vd_6stack_init_verbs },
13426 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13427 .dac_nids = alc861vd_dac_nids,
13428 .dig_out_nid = ALC861VD_DIGOUT_NID,
13429 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
13430 .channel_mode = alc861vd_6stack_modes,
13431 .input_mux = &alc861vd_capture_source,
13432 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020013433 [ALC861VD_LENOVO] = {
13434 .mixers = { alc861vd_lenovo_mixer },
13435 .init_verbs = { alc861vd_volume_init_verbs,
13436 alc861vd_3stack_init_verbs,
13437 alc861vd_eapd_verbs,
13438 alc861vd_lenovo_unsol_verbs },
13439 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13440 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013441 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13442 .channel_mode = alc861vd_3stack_2ch_modes,
13443 .input_mux = &alc861vd_capture_source,
13444 .unsol_event = alc861vd_lenovo_unsol_event,
13445 .init_hook = alc861vd_lenovo_automute,
13446 },
Kailang Yang272a5272007-05-14 11:00:38 +020013447 [ALC861VD_DALLAS] = {
13448 .mixers = { alc861vd_dallas_mixer },
13449 .init_verbs = { alc861vd_dallas_verbs },
13450 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13451 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020013452 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13453 .channel_mode = alc861vd_3stack_2ch_modes,
13454 .input_mux = &alc861vd_dallas_capture_source,
13455 .unsol_event = alc861vd_dallas_unsol_event,
13456 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013457 },
13458 [ALC861VD_HP] = {
13459 .mixers = { alc861vd_hp_mixer },
13460 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
13461 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13462 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013463 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013464 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13465 .channel_mode = alc861vd_3stack_2ch_modes,
13466 .input_mux = &alc861vd_hp_capture_source,
13467 .unsol_event = alc861vd_dallas_unsol_event,
13468 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020013469 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013470};
13471
13472/*
13473 * BIOS auto configuration
13474 */
13475static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
13476 hda_nid_t nid, int pin_type, int dac_idx)
13477{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013478 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013479}
13480
13481static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
13482{
13483 struct alc_spec *spec = codec->spec;
13484 int i;
13485
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013486 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013487 for (i = 0; i <= HDA_SIDE; i++) {
13488 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013489 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013490 if (nid)
13491 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013492 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013493 }
13494}
13495
13496
13497static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
13498{
13499 struct alc_spec *spec = codec->spec;
13500 hda_nid_t pin;
13501
13502 pin = spec->autocfg.hp_pins[0];
13503 if (pin) /* connect to front and use dac 0 */
13504 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013505 pin = spec->autocfg.speaker_pins[0];
13506 if (pin)
13507 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013508}
13509
13510#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
13511#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
13512
13513static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
13514{
13515 struct alc_spec *spec = codec->spec;
13516 int i;
13517
13518 for (i = 0; i < AUTO_PIN_LAST; i++) {
13519 hda_nid_t nid = spec->autocfg.input_pins[i];
13520 if (alc861vd_is_input_pin(nid)) {
13521 snd_hda_codec_write(codec, nid, 0,
13522 AC_VERB_SET_PIN_WIDGET_CONTROL,
13523 i <= AUTO_PIN_FRONT_MIC ?
13524 PIN_VREF80 : PIN_IN);
13525 if (nid != ALC861VD_PIN_CD_NID)
13526 snd_hda_codec_write(codec, nid, 0,
13527 AC_VERB_SET_AMP_GAIN_MUTE,
13528 AMP_OUT_MUTE);
13529 }
13530 }
13531}
13532
Takashi Iwaif511b012008-08-15 16:46:42 +020013533#define alc861vd_auto_init_input_src alc882_auto_init_input_src
13534
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013535#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
13536#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
13537
13538/* add playback controls from the parsed DAC table */
13539/* Based on ALC880 version. But ALC861VD has separate,
13540 * different NIDs for mute/unmute switch and volume control */
13541static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
13542 const struct auto_pin_cfg *cfg)
13543{
13544 char name[32];
13545 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
13546 hda_nid_t nid_v, nid_s;
13547 int i, err;
13548
13549 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013550 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013551 continue;
13552 nid_v = alc861vd_idx_to_mixer_vol(
13553 alc880_dac_to_idx(
13554 spec->multiout.dac_nids[i]));
13555 nid_s = alc861vd_idx_to_mixer_switch(
13556 alc880_dac_to_idx(
13557 spec->multiout.dac_nids[i]));
13558
13559 if (i == 2) {
13560 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013561 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13562 "Center Playback Volume",
13563 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
13564 HDA_OUTPUT));
13565 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013566 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013567 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13568 "LFE Playback Volume",
13569 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
13570 HDA_OUTPUT));
13571 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013572 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013573 err = add_control(spec, ALC_CTL_BIND_MUTE,
13574 "Center Playback Switch",
13575 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
13576 HDA_INPUT));
13577 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013578 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013579 err = add_control(spec, ALC_CTL_BIND_MUTE,
13580 "LFE Playback Switch",
13581 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
13582 HDA_INPUT));
13583 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013584 return err;
13585 } else {
13586 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013587 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13588 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
13589 HDA_OUTPUT));
13590 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013591 return err;
13592 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013593 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013594 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013595 HDA_INPUT));
13596 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013597 return err;
13598 }
13599 }
13600 return 0;
13601}
13602
13603/* add playback controls for speaker and HP outputs */
13604/* Based on ALC880 version. But ALC861VD has separate,
13605 * different NIDs for mute/unmute switch and volume control */
13606static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
13607 hda_nid_t pin, const char *pfx)
13608{
13609 hda_nid_t nid_v, nid_s;
13610 int err;
13611 char name[32];
13612
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013613 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013614 return 0;
13615
13616 if (alc880_is_fixed_pin(pin)) {
13617 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13618 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013619 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013620 spec->multiout.hp_nid = nid_v;
13621 else
13622 spec->multiout.extra_out_nid[0] = nid_v;
13623 /* control HP volume/switch on the output mixer amp */
13624 nid_v = alc861vd_idx_to_mixer_vol(
13625 alc880_fixed_pin_idx(pin));
13626 nid_s = alc861vd_idx_to_mixer_switch(
13627 alc880_fixed_pin_idx(pin));
13628
13629 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013630 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13631 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
13632 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013633 return err;
13634 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013635 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13636 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
13637 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013638 return err;
13639 } else if (alc880_is_multi_pin(pin)) {
13640 /* set manual connection */
13641 /* we have only a switch on HP-out PIN */
13642 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013643 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13644 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13645 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013646 return err;
13647 }
13648 return 0;
13649}
13650
13651/* parse the BIOS configuration and set up the alc_spec
13652 * return 1 if successful, 0 if the proper config is not found,
13653 * or a negative error code
13654 * Based on ALC880 version - had to change it to override
13655 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
13656static int alc861vd_parse_auto_config(struct hda_codec *codec)
13657{
13658 struct alc_spec *spec = codec->spec;
13659 int err;
13660 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
13661
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013662 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13663 alc861vd_ignore);
13664 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013665 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013666 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013667 return 0; /* can't find valid BIOS pin config */
13668
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013669 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13670 if (err < 0)
13671 return err;
13672 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
13673 if (err < 0)
13674 return err;
13675 err = alc861vd_auto_create_extra_out(spec,
13676 spec->autocfg.speaker_pins[0],
13677 "Speaker");
13678 if (err < 0)
13679 return err;
13680 err = alc861vd_auto_create_extra_out(spec,
13681 spec->autocfg.hp_pins[0],
13682 "Headphone");
13683 if (err < 0)
13684 return err;
13685 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
13686 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013687 return err;
13688
13689 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13690
13691 if (spec->autocfg.dig_out_pin)
13692 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
13693
13694 if (spec->kctl_alloc)
13695 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13696
13697 spec->init_verbs[spec->num_init_verbs++]
13698 = alc861vd_volume_init_verbs;
13699
13700 spec->num_mux_defs = 1;
13701 spec->input_mux = &spec->private_imux;
13702
Takashi Iwai776e1842007-08-29 15:07:11 +020013703 err = alc_auto_add_mic_boost(codec);
13704 if (err < 0)
13705 return err;
13706
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013707 return 1;
13708}
13709
13710/* additional initialization for auto-configuration model */
13711static void alc861vd_auto_init(struct hda_codec *codec)
13712{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013713 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013714 alc861vd_auto_init_multi_out(codec);
13715 alc861vd_auto_init_hp_out(codec);
13716 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020013717 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013718 if (spec->unsol_event)
13719 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013720}
13721
13722static int patch_alc861vd(struct hda_codec *codec)
13723{
13724 struct alc_spec *spec;
13725 int err, board_config;
13726
13727 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13728 if (spec == NULL)
13729 return -ENOMEM;
13730
13731 codec->spec = spec;
13732
13733 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
13734 alc861vd_models,
13735 alc861vd_cfg_tbl);
13736
13737 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
13738 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
13739 "ALC861VD, trying auto-probe from BIOS...\n");
13740 board_config = ALC861VD_AUTO;
13741 }
13742
13743 if (board_config == ALC861VD_AUTO) {
13744 /* automatic parse from the BIOS config */
13745 err = alc861vd_parse_auto_config(codec);
13746 if (err < 0) {
13747 alc_free(codec);
13748 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013749 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013750 printk(KERN_INFO
13751 "hda_codec: Cannot set up configuration "
13752 "from BIOS. Using base mode...\n");
13753 board_config = ALC861VD_3ST;
13754 }
13755 }
13756
13757 if (board_config != ALC861VD_AUTO)
13758 setup_preset(spec, &alc861vd_presets[board_config]);
13759
Kailang Yang2f893282008-05-27 12:14:47 +020013760 if (codec->vendor_id == 0x10ec0660) {
13761 spec->stream_name_analog = "ALC660-VD Analog";
13762 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020013763 /* always turn on EAPD */
13764 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
Kailang Yang2f893282008-05-27 12:14:47 +020013765 } else {
13766 spec->stream_name_analog = "ALC861VD Analog";
13767 spec->stream_name_digital = "ALC861VD Digital";
13768 }
13769
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013770 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
13771 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
13772
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013773 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
13774 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
13775
13776 spec->adc_nids = alc861vd_adc_nids;
13777 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010013778 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013779
13780 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
13781 spec->num_mixers++;
13782
Takashi Iwai2134ea42008-01-10 16:53:55 +010013783 spec->vmaster_nid = 0x02;
13784
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013785 codec->patch_ops = alc_patch_ops;
13786
13787 if (board_config == ALC861VD_AUTO)
13788 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013789#ifdef CONFIG_SND_HDA_POWER_SAVE
13790 if (!spec->loopback.amplist)
13791 spec->loopback.amplist = alc861vd_loopbacks;
13792#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013793
13794 return 0;
13795}
13796
13797/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013798 * ALC662 support
13799 *
13800 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
13801 * configuration. Each pin widget can choose any input DACs and a mixer.
13802 * Each ADC is connected from a mixer of all inputs. This makes possible
13803 * 6-channel independent captures.
13804 *
13805 * In addition, an independent DAC for the multi-playback (not used in this
13806 * driver yet).
13807 */
13808#define ALC662_DIGOUT_NID 0x06
13809#define ALC662_DIGIN_NID 0x0a
13810
13811static hda_nid_t alc662_dac_nids[4] = {
13812 /* front, rear, clfe, rear_surr */
13813 0x02, 0x03, 0x04
13814};
13815
13816static hda_nid_t alc662_adc_nids[1] = {
13817 /* ADC1-2 */
13818 0x09,
13819};
Takashi Iwaie1406342008-02-11 18:32:32 +010013820
Kailang Yang77a261b2008-02-19 11:38:05 +010013821static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010013822
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013823/* input MUX */
13824/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013825static struct hda_input_mux alc662_capture_source = {
13826 .num_items = 4,
13827 .items = {
13828 { "Mic", 0x0 },
13829 { "Front Mic", 0x1 },
13830 { "Line", 0x2 },
13831 { "CD", 0x4 },
13832 },
13833};
13834
13835static struct hda_input_mux alc662_lenovo_101e_capture_source = {
13836 .num_items = 2,
13837 .items = {
13838 { "Mic", 0x1 },
13839 { "Line", 0x2 },
13840 },
13841};
Kailang Yang291702f2007-10-16 14:28:03 +020013842
13843static struct hda_input_mux alc662_eeepc_capture_source = {
13844 .num_items = 2,
13845 .items = {
13846 { "i-Mic", 0x1 },
13847 { "e-Mic", 0x0 },
13848 },
13849};
13850
Kailang Yang6dda9f42008-05-27 12:05:31 +020013851static struct hda_input_mux alc663_capture_source = {
13852 .num_items = 3,
13853 .items = {
13854 { "Mic", 0x0 },
13855 { "Front Mic", 0x1 },
13856 { "Line", 0x2 },
13857 },
13858};
13859
13860static struct hda_input_mux alc663_m51va_capture_source = {
13861 .num_items = 2,
13862 .items = {
13863 { "Ext-Mic", 0x0 },
13864 { "D-Mic", 0x9 },
13865 },
13866};
13867
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013868#define alc662_mux_enum_info alc_mux_enum_info
13869#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013870#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013871
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013872/*
13873 * 2ch mode
13874 */
13875static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
13876 { 2, NULL }
13877};
13878
13879/*
13880 * 2ch mode
13881 */
13882static struct hda_verb alc662_3ST_ch2_init[] = {
13883 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
13884 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13885 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
13886 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13887 { } /* end */
13888};
13889
13890/*
13891 * 6ch mode
13892 */
13893static struct hda_verb alc662_3ST_ch6_init[] = {
13894 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13895 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13896 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
13897 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13898 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13899 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
13900 { } /* end */
13901};
13902
13903static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
13904 { 2, alc662_3ST_ch2_init },
13905 { 6, alc662_3ST_ch6_init },
13906};
13907
13908/*
13909 * 2ch mode
13910 */
13911static struct hda_verb alc662_sixstack_ch6_init[] = {
13912 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13913 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13914 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13915 { } /* end */
13916};
13917
13918/*
13919 * 6ch mode
13920 */
13921static struct hda_verb alc662_sixstack_ch8_init[] = {
13922 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13923 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13924 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13925 { } /* end */
13926};
13927
13928static struct hda_channel_mode alc662_5stack_modes[2] = {
13929 { 2, alc662_sixstack_ch6_init },
13930 { 6, alc662_sixstack_ch8_init },
13931};
13932
13933/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13934 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13935 */
13936
13937static struct snd_kcontrol_new alc662_base_mixer[] = {
13938 /* output mixer control */
13939 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013940 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013941 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013942 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013943 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13944 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013945 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13946 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13948
13949 /*Input mixer control */
13950 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
13951 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
13952 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
13953 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
13954 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
13955 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
13956 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
13957 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013958 { } /* end */
13959};
13960
13961static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
13962 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013963 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13965 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13966 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13971 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13972 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13973 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13974 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013975 { } /* end */
13976};
13977
13978static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
13979 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013980 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013981 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013982 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013983 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13984 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013985 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13986 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13994 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13996 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13997 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013998 { } /* end */
13999};
14000
14001static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
14002 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14003 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14005 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14007 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14008 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014011 { } /* end */
14012};
14013
Kailang Yang291702f2007-10-16 14:28:03 +020014014static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010014015 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014016
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010014017 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14018 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014019
14020 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
14021 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14022 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14023
14024 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
14025 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14026 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14027 { } /* end */
14028};
14029
Kailang Yang8c427222008-01-10 13:03:59 +010014030static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010014031 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14032 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014033 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14034 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
14035 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14036 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
14037 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
14038 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014039 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014040 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
14041 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14042 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14045 { } /* end */
14046};
14047
Kailang Yang6dda9f42008-05-27 12:05:31 +020014048static struct snd_kcontrol_new alc663_m51va_mixer[] = {
14049 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14050 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14051 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14054 HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT),
14055 { } /* end */
14056};
14057
14058static struct snd_kcontrol_new alc663_g71v_mixer[] = {
14059 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14060 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14061 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14062 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14063 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14064
14065 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14066 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14067 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14068 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14069 { } /* end */
14070};
14071
14072static struct snd_kcontrol_new alc663_g50v_mixer[] = {
14073 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14074 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14075 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14076
14077 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14078 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14079 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14080 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14081 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14082 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14083 { } /* end */
14084};
14085
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014086static struct snd_kcontrol_new alc662_chmode_mixer[] = {
14087 {
14088 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14089 .name = "Channel Mode",
14090 .info = alc_ch_mode_info,
14091 .get = alc_ch_mode_get,
14092 .put = alc_ch_mode_put,
14093 },
14094 { } /* end */
14095};
14096
14097static struct hda_verb alc662_init_verbs[] = {
14098 /* ADC: mute amp left and right */
14099 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14100 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14101 /* Front mixer: unmute input/output amp left and right (volume = 0) */
14102
Takashi Iwaicb53c622007-08-10 17:21:45 +020014103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14107 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014108
Kailang Yangb60dd392007-09-20 12:50:29 +020014109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14110 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14111 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14112 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14113 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14114 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014115
14116 /* Front Pin: output 0 (0x0c) */
14117 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14118 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14119
14120 /* Rear Pin: output 1 (0x0d) */
14121 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14123
14124 /* CLFE Pin: output 2 (0x0e) */
14125 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14126 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14127
14128 /* Mic (rear) pin: input vref at 80% */
14129 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14130 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14131 /* Front Mic pin: input vref at 80% */
14132 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14133 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14134 /* Line In pin: input */
14135 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14137 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14138 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14140 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14141 /* CD pin widget for input */
14142 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14143
14144 /* FIXME: use matrix-type input source selection */
14145 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14146 /* Input mixer */
14147 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14148 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14149 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14150 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020014151
14152 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14153 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14154 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14155 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014156
14157 /* always trun on EAPD */
14158 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14159 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14160
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014161 { }
14162};
14163
14164static struct hda_verb alc662_sue_init_verbs[] = {
14165 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14166 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020014167 {}
14168};
14169
14170static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
14171 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14172 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14173 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014174};
14175
Kailang Yang8c427222008-01-10 13:03:59 +010014176/* Set Unsolicited Event*/
14177static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
14178 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14179 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14180 {}
14181};
14182
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014183/*
14184 * generic initialization of ADC, input mixers and output mixers
14185 */
14186static struct hda_verb alc662_auto_init_verbs[] = {
14187 /*
14188 * Unmute ADC and set the default input to mic-in
14189 */
14190 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14191 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14192
14193 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
14194 * mixer widget
14195 * Note: PASD motherboards uses the Line In 2 as the input for front
14196 * panel mic (mic 2)
14197 */
14198 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014204
14205 /*
14206 * Set up output mixers (0x0c - 0x0f)
14207 */
14208 /* set vol=0 to output mixers */
14209 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14210 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14211 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14212
14213 /* set up input amps for analog loopback */
14214 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020014215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14217 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14218 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14219 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14220 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014221
14222
14223 /* FIXME: use matrix-type input source selection */
14224 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14225 /* Input mixer */
14226 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020014227 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014228 { }
14229};
14230
Takashi Iwai24fb9172008-09-02 14:48:20 +020014231/* additional verbs for ALC663 */
14232static struct hda_verb alc663_auto_init_verbs[] = {
14233 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14234 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14235 { }
14236};
14237
Kailang Yang6dda9f42008-05-27 12:05:31 +020014238static struct hda_verb alc663_m51va_init_verbs[] = {
14239 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14240 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14241 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14242
14243 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
14244
14245 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14246 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14247 {}
14248};
14249
14250static struct hda_verb alc663_g71v_init_verbs[] = {
14251 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14252 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
14253 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
14254
14255 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14256 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14257 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14258
14259 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14260 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
14261 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
14262 {}
14263};
14264
14265static struct hda_verb alc663_g50v_init_verbs[] = {
14266 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14267 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14268 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14269
14270 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14271 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14272 {}
14273};
14274
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014275/* capture mixer elements */
14276static struct snd_kcontrol_new alc662_capture_mixer[] = {
14277 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14278 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14279 {
14280 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14281 /* The multiple "Capture Source" controls confuse alsamixer
14282 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014283 */
14284 /* .name = "Capture Source", */
14285 .name = "Input Source",
14286 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010014287 .info = alc662_mux_enum_info,
14288 .get = alc662_mux_enum_get,
14289 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014290 },
14291 { } /* end */
14292};
14293
14294static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
14295{
14296 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014297 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014298
14299 present = snd_hda_codec_read(codec, 0x14, 0,
14300 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014301 bits = present ? HDA_AMP_MUTE : 0;
14302 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14303 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014304}
14305
14306static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
14307{
14308 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014309 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014310
14311 present = snd_hda_codec_read(codec, 0x1b, 0,
14312 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014313 bits = present ? HDA_AMP_MUTE : 0;
14314 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14315 HDA_AMP_MUTE, bits);
14316 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14317 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014318}
14319
14320static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
14321 unsigned int res)
14322{
14323 if ((res >> 26) == ALC880_HP_EVENT)
14324 alc662_lenovo_101e_all_automute(codec);
14325 if ((res >> 26) == ALC880_FRONT_EVENT)
14326 alc662_lenovo_101e_ispeaker_automute(codec);
14327}
14328
Kailang Yang291702f2007-10-16 14:28:03 +020014329static void alc662_eeepc_mic_automute(struct hda_codec *codec)
14330{
14331 unsigned int present;
14332
14333 present = snd_hda_codec_read(codec, 0x18, 0,
14334 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14335 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14336 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14337 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14338 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14339 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14340 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14341 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14342 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14343}
14344
14345/* unsolicited event for HP jack sensing */
14346static void alc662_eeepc_unsol_event(struct hda_codec *codec,
14347 unsigned int res)
14348{
14349 if ((res >> 26) == ALC880_HP_EVENT)
14350 alc262_hippo1_automute( codec );
14351
14352 if ((res >> 26) == ALC880_MIC_EVENT)
14353 alc662_eeepc_mic_automute(codec);
14354}
14355
14356static void alc662_eeepc_inithook(struct hda_codec *codec)
14357{
14358 alc262_hippo1_automute( codec );
14359 alc662_eeepc_mic_automute(codec);
14360}
14361
Kailang Yang8c427222008-01-10 13:03:59 +010014362static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
14363{
14364 unsigned int mute;
14365 unsigned int present;
14366
14367 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
14368 present = snd_hda_codec_read(codec, 0x14, 0,
14369 AC_VERB_GET_PIN_SENSE, 0);
14370 present = (present & 0x80000000) != 0;
14371 if (present) {
14372 /* mute internal speaker */
14373 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014374 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010014375 } else {
14376 /* unmute internal speaker if necessary */
14377 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
14378 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014379 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010014380 }
14381}
14382
14383/* unsolicited event for HP jack sensing */
14384static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
14385 unsigned int res)
14386{
14387 if ((res >> 26) == ALC880_HP_EVENT)
14388 alc662_eeepc_ep20_automute(codec);
14389}
14390
14391static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
14392{
14393 alc662_eeepc_ep20_automute(codec);
14394}
14395
Kailang Yang6dda9f42008-05-27 12:05:31 +020014396static void alc663_m51va_speaker_automute(struct hda_codec *codec)
14397{
14398 unsigned int present;
14399 unsigned char bits;
14400
14401 present = snd_hda_codec_read(codec, 0x21, 0,
14402 AC_VERB_GET_PIN_SENSE, 0)
14403 & AC_PINSENSE_PRESENCE;
14404 bits = present ? HDA_AMP_MUTE : 0;
14405 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14406 HDA_AMP_MUTE, bits);
14407}
14408
14409static void alc663_m51va_mic_automute(struct hda_codec *codec)
14410{
14411 unsigned int present;
14412
14413 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014414 AC_VERB_GET_PIN_SENSE, 0)
14415 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020014416 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014417 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014418 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014419 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014420 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014421 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014422 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014423 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014424}
14425
14426static void alc663_m51va_unsol_event(struct hda_codec *codec,
14427 unsigned int res)
14428{
14429 switch (res >> 26) {
14430 case ALC880_HP_EVENT:
14431 alc663_m51va_speaker_automute(codec);
14432 break;
14433 case ALC880_MIC_EVENT:
14434 alc663_m51va_mic_automute(codec);
14435 break;
14436 }
14437}
14438
14439static void alc663_m51va_inithook(struct hda_codec *codec)
14440{
14441 alc663_m51va_speaker_automute(codec);
14442 alc663_m51va_mic_automute(codec);
14443}
14444
14445static void alc663_g71v_hp_automute(struct hda_codec *codec)
14446{
14447 unsigned int present;
14448 unsigned char bits;
14449
14450 present = snd_hda_codec_read(codec, 0x21, 0,
14451 AC_VERB_GET_PIN_SENSE, 0)
14452 & AC_PINSENSE_PRESENCE;
14453 bits = present ? HDA_AMP_MUTE : 0;
14454 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14455 HDA_AMP_MUTE, bits);
14456 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14457 HDA_AMP_MUTE, bits);
14458}
14459
14460static void alc663_g71v_front_automute(struct hda_codec *codec)
14461{
14462 unsigned int present;
14463 unsigned char bits;
14464
14465 present = snd_hda_codec_read(codec, 0x15, 0,
14466 AC_VERB_GET_PIN_SENSE, 0)
14467 & AC_PINSENSE_PRESENCE;
14468 bits = present ? HDA_AMP_MUTE : 0;
14469 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14470 HDA_AMP_MUTE, bits);
14471}
14472
14473static void alc663_g71v_unsol_event(struct hda_codec *codec,
14474 unsigned int res)
14475{
14476 switch (res >> 26) {
14477 case ALC880_HP_EVENT:
14478 alc663_g71v_hp_automute(codec);
14479 break;
14480 case ALC880_FRONT_EVENT:
14481 alc663_g71v_front_automute(codec);
14482 break;
14483 case ALC880_MIC_EVENT:
14484 alc662_eeepc_mic_automute(codec);
14485 break;
14486 }
14487}
14488
14489static void alc663_g71v_inithook(struct hda_codec *codec)
14490{
14491 alc663_g71v_front_automute(codec);
14492 alc663_g71v_hp_automute(codec);
14493 alc662_eeepc_mic_automute(codec);
14494}
14495
14496static void alc663_g50v_unsol_event(struct hda_codec *codec,
14497 unsigned int res)
14498{
14499 switch (res >> 26) {
14500 case ALC880_HP_EVENT:
14501 alc663_m51va_speaker_automute(codec);
14502 break;
14503 case ALC880_MIC_EVENT:
14504 alc662_eeepc_mic_automute(codec);
14505 break;
14506 }
14507}
14508
14509static void alc663_g50v_inithook(struct hda_codec *codec)
14510{
14511 alc663_m51va_speaker_automute(codec);
14512 alc662_eeepc_mic_automute(codec);
14513}
14514
Takashi Iwaicb53c622007-08-10 17:21:45 +020014515#ifdef CONFIG_SND_HDA_POWER_SAVE
14516#define alc662_loopbacks alc880_loopbacks
14517#endif
14518
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014519
14520/* pcm configuration: identiacal with ALC880 */
14521#define alc662_pcm_analog_playback alc880_pcm_analog_playback
14522#define alc662_pcm_analog_capture alc880_pcm_analog_capture
14523#define alc662_pcm_digital_playback alc880_pcm_digital_playback
14524#define alc662_pcm_digital_capture alc880_pcm_digital_capture
14525
14526/*
14527 * configuration and preset
14528 */
14529static const char *alc662_models[ALC662_MODEL_LAST] = {
14530 [ALC662_3ST_2ch_DIG] = "3stack-dig",
14531 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
14532 [ALC662_3ST_6ch] = "3stack-6ch",
14533 [ALC662_5ST_DIG] = "6stack-dig",
14534 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020014535 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010014536 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yang6dda9f42008-05-27 12:05:31 +020014537 [ALC663_ASUS_M51VA] = "m51va",
14538 [ALC663_ASUS_G71V] = "g71v",
14539 [ALC663_ASUS_H13] = "h13",
14540 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014541 [ALC662_AUTO] = "auto",
14542};
14543
14544static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014545 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V),
14546 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
14547 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010014548 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020014549 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010014550 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014551 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014552 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
14553 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
14554 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014555 {}
14556};
14557
14558static struct alc_config_preset alc662_presets[] = {
14559 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014560 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014561 .init_verbs = { alc662_init_verbs },
14562 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14563 .dac_nids = alc662_dac_nids,
14564 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014565 .dig_in_nid = ALC662_DIGIN_NID,
14566 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14567 .channel_mode = alc662_3ST_2ch_modes,
14568 .input_mux = &alc662_capture_source,
14569 },
14570 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014571 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14572 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014573 .init_verbs = { alc662_init_verbs },
14574 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14575 .dac_nids = alc662_dac_nids,
14576 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014577 .dig_in_nid = ALC662_DIGIN_NID,
14578 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14579 .channel_mode = alc662_3ST_6ch_modes,
14580 .need_dac_fix = 1,
14581 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014582 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014583 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014584 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14585 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014586 .init_verbs = { alc662_init_verbs },
14587 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14588 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014589 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14590 .channel_mode = alc662_3ST_6ch_modes,
14591 .need_dac_fix = 1,
14592 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014593 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014594 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014595 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
14596 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014597 .init_verbs = { alc662_init_verbs },
14598 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14599 .dac_nids = alc662_dac_nids,
14600 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014601 .dig_in_nid = ALC662_DIGIN_NID,
14602 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
14603 .channel_mode = alc662_5stack_modes,
14604 .input_mux = &alc662_capture_source,
14605 },
14606 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014607 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014608 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
14609 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14610 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014611 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14612 .channel_mode = alc662_3ST_2ch_modes,
14613 .input_mux = &alc662_lenovo_101e_capture_source,
14614 .unsol_event = alc662_lenovo_101e_unsol_event,
14615 .init_hook = alc662_lenovo_101e_all_automute,
14616 },
Kailang Yang291702f2007-10-16 14:28:03 +020014617 [ALC662_ASUS_EEEPC_P701] = {
14618 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
14619 .init_verbs = { alc662_init_verbs,
14620 alc662_eeepc_sue_init_verbs },
14621 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14622 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020014623 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14624 .channel_mode = alc662_3ST_2ch_modes,
14625 .input_mux = &alc662_eeepc_capture_source,
14626 .unsol_event = alc662_eeepc_unsol_event,
14627 .init_hook = alc662_eeepc_inithook,
14628 },
Kailang Yang8c427222008-01-10 13:03:59 +010014629 [ALC662_ASUS_EEEPC_EP20] = {
14630 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
14631 alc662_chmode_mixer },
14632 .init_verbs = { alc662_init_verbs,
14633 alc662_eeepc_ep20_sue_init_verbs },
14634 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14635 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010014636 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14637 .channel_mode = alc662_3ST_6ch_modes,
14638 .input_mux = &alc662_lenovo_101e_capture_source,
14639 .unsol_event = alc662_eeepc_ep20_unsol_event,
14640 .init_hook = alc662_eeepc_ep20_inithook,
14641 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014642 [ALC663_ASUS_M51VA] = {
14643 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14644 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14645 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14646 .dac_nids = alc662_dac_nids,
14647 .dig_out_nid = ALC662_DIGOUT_NID,
14648 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14649 .channel_mode = alc662_3ST_2ch_modes,
14650 .input_mux = &alc663_m51va_capture_source,
14651 .unsol_event = alc663_m51va_unsol_event,
14652 .init_hook = alc663_m51va_inithook,
14653 },
14654 [ALC663_ASUS_G71V] = {
14655 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
14656 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
14657 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14658 .dac_nids = alc662_dac_nids,
14659 .dig_out_nid = ALC662_DIGOUT_NID,
14660 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14661 .channel_mode = alc662_3ST_2ch_modes,
14662 .input_mux = &alc662_eeepc_capture_source,
14663 .unsol_event = alc663_g71v_unsol_event,
14664 .init_hook = alc663_g71v_inithook,
14665 },
14666 [ALC663_ASUS_H13] = {
14667 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14668 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14669 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14670 .dac_nids = alc662_dac_nids,
14671 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14672 .channel_mode = alc662_3ST_2ch_modes,
14673 .input_mux = &alc663_m51va_capture_source,
14674 .unsol_event = alc663_m51va_unsol_event,
14675 .init_hook = alc663_m51va_inithook,
14676 },
14677 [ALC663_ASUS_G50V] = {
14678 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
14679 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
14680 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14681 .dac_nids = alc662_dac_nids,
14682 .dig_out_nid = ALC662_DIGOUT_NID,
14683 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14684 .channel_mode = alc662_3ST_6ch_modes,
14685 .input_mux = &alc663_capture_source,
14686 .unsol_event = alc663_g50v_unsol_event,
14687 .init_hook = alc663_g50v_inithook,
14688 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014689};
14690
14691
14692/*
14693 * BIOS auto configuration
14694 */
14695
14696/* add playback controls from the parsed DAC table */
14697static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
14698 const struct auto_pin_cfg *cfg)
14699{
14700 char name[32];
14701 static const char *chname[4] = {
14702 "Front", "Surround", NULL /*CLFE*/, "Side"
14703 };
14704 hda_nid_t nid;
14705 int i, err;
14706
14707 for (i = 0; i < cfg->line_outs; i++) {
14708 if (!spec->multiout.dac_nids[i])
14709 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020014710 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014711 if (i == 2) {
14712 /* Center/LFE */
14713 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14714 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014715 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14716 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014717 if (err < 0)
14718 return err;
14719 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14720 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014721 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14722 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014723 if (err < 0)
14724 return err;
14725 err = add_control(spec, ALC_CTL_BIND_MUTE,
14726 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014727 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
14728 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014729 if (err < 0)
14730 return err;
14731 err = add_control(spec, ALC_CTL_BIND_MUTE,
14732 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014733 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
14734 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014735 if (err < 0)
14736 return err;
14737 } else {
14738 sprintf(name, "%s Playback Volume", chname[i]);
14739 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014740 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14741 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014742 if (err < 0)
14743 return err;
14744 sprintf(name, "%s Playback Switch", chname[i]);
14745 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014746 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
14747 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014748 if (err < 0)
14749 return err;
14750 }
14751 }
14752 return 0;
14753}
14754
14755/* add playback controls for speaker and HP outputs */
14756static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
14757 const char *pfx)
14758{
14759 hda_nid_t nid;
14760 int err;
14761 char name[32];
14762
14763 if (!pin)
14764 return 0;
14765
Takashi Iwai24fb9172008-09-02 14:48:20 +020014766 if (pin == 0x17) {
14767 /* ALC663 has a mono output pin on 0x17 */
14768 sprintf(name, "%s Playback Switch", pfx);
14769 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14770 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
14771 return err;
14772 }
14773
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014774 if (alc880_is_fixed_pin(pin)) {
14775 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14776 /* printk("DAC nid=%x\n",nid); */
14777 /* specify the DAC as the extra output */
14778 if (!spec->multiout.hp_nid)
14779 spec->multiout.hp_nid = nid;
14780 else
14781 spec->multiout.extra_out_nid[0] = nid;
14782 /* control HP volume/switch on the output mixer amp */
14783 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14784 sprintf(name, "%s Playback Volume", pfx);
14785 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14786 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14787 if (err < 0)
14788 return err;
14789 sprintf(name, "%s Playback Switch", pfx);
14790 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14791 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
14792 if (err < 0)
14793 return err;
14794 } else if (alc880_is_multi_pin(pin)) {
14795 /* set manual connection */
14796 /* we have only a switch on HP-out PIN */
14797 sprintf(name, "%s Playback Switch", pfx);
14798 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14799 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14800 if (err < 0)
14801 return err;
14802 }
14803 return 0;
14804}
14805
14806/* create playback/capture controls for input pins */
14807static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
14808 const struct auto_pin_cfg *cfg)
14809{
14810 struct hda_input_mux *imux = &spec->private_imux;
14811 int i, err, idx;
14812
14813 for (i = 0; i < AUTO_PIN_LAST; i++) {
14814 if (alc880_is_input_pin(cfg->input_pins[i])) {
14815 idx = alc880_input_pin_idx(cfg->input_pins[i]);
14816 err = new_analog_input(spec, cfg->input_pins[i],
14817 auto_pin_cfg_labels[i],
14818 idx, 0x0b);
14819 if (err < 0)
14820 return err;
14821 imux->items[imux->num_items].label =
14822 auto_pin_cfg_labels[i];
14823 imux->items[imux->num_items].index =
14824 alc880_input_pin_idx(cfg->input_pins[i]);
14825 imux->num_items++;
14826 }
14827 }
14828 return 0;
14829}
14830
14831static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
14832 hda_nid_t nid, int pin_type,
14833 int dac_idx)
14834{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014835 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014836 /* need the manual connection? */
14837 if (alc880_is_multi_pin(nid)) {
14838 struct alc_spec *spec = codec->spec;
14839 int idx = alc880_multi_pin_idx(nid);
14840 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
14841 AC_VERB_SET_CONNECT_SEL,
14842 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
14843 }
14844}
14845
14846static void alc662_auto_init_multi_out(struct hda_codec *codec)
14847{
14848 struct alc_spec *spec = codec->spec;
14849 int i;
14850
Kailang Yang8c427222008-01-10 13:03:59 +010014851 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014852 for (i = 0; i <= HDA_SIDE; i++) {
14853 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014854 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014855 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014856 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014857 i);
14858 }
14859}
14860
14861static void alc662_auto_init_hp_out(struct hda_codec *codec)
14862{
14863 struct alc_spec *spec = codec->spec;
14864 hda_nid_t pin;
14865
14866 pin = spec->autocfg.hp_pins[0];
14867 if (pin) /* connect to front */
14868 /* use dac 0 */
14869 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014870 pin = spec->autocfg.speaker_pins[0];
14871 if (pin)
14872 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014873}
14874
14875#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
14876#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
14877
14878static void alc662_auto_init_analog_input(struct hda_codec *codec)
14879{
14880 struct alc_spec *spec = codec->spec;
14881 int i;
14882
14883 for (i = 0; i < AUTO_PIN_LAST; i++) {
14884 hda_nid_t nid = spec->autocfg.input_pins[i];
14885 if (alc662_is_input_pin(nid)) {
14886 snd_hda_codec_write(codec, nid, 0,
14887 AC_VERB_SET_PIN_WIDGET_CONTROL,
14888 (i <= AUTO_PIN_FRONT_MIC ?
14889 PIN_VREF80 : PIN_IN));
14890 if (nid != ALC662_PIN_CD_NID)
14891 snd_hda_codec_write(codec, nid, 0,
14892 AC_VERB_SET_AMP_GAIN_MUTE,
14893 AMP_OUT_MUTE);
14894 }
14895 }
14896}
14897
Takashi Iwaif511b012008-08-15 16:46:42 +020014898#define alc662_auto_init_input_src alc882_auto_init_input_src
14899
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014900static int alc662_parse_auto_config(struct hda_codec *codec)
14901{
14902 struct alc_spec *spec = codec->spec;
14903 int err;
14904 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
14905
14906 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14907 alc662_ignore);
14908 if (err < 0)
14909 return err;
14910 if (!spec->autocfg.line_outs)
14911 return 0; /* can't find valid BIOS pin config */
14912
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014913 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14914 if (err < 0)
14915 return err;
14916 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
14917 if (err < 0)
14918 return err;
14919 err = alc662_auto_create_extra_out(spec,
14920 spec->autocfg.speaker_pins[0],
14921 "Speaker");
14922 if (err < 0)
14923 return err;
14924 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
14925 "Headphone");
14926 if (err < 0)
14927 return err;
14928 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
14929 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014930 return err;
14931
14932 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14933
14934 if (spec->autocfg.dig_out_pin)
14935 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
14936
14937 if (spec->kctl_alloc)
14938 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
14939
14940 spec->num_mux_defs = 1;
14941 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020014942
Takashi Iwai8c87286f2007-06-19 12:11:16 +020014943 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Takashi Iwai24fb9172008-09-02 14:48:20 +020014944 if (codec->vendor_id == 0x10ec0663)
14945 spec->init_verbs[spec->num_init_verbs++] =
14946 alc663_auto_init_verbs;
Takashi Iwaiee979a142008-09-02 15:42:20 +020014947
14948 err = alc_auto_add_mic_boost(codec);
14949 if (err < 0)
14950 return err;
14951
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014952 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
14953 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020014954 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014955}
14956
14957/* additional initialization for auto-configuration model */
14958static void alc662_auto_init(struct hda_codec *codec)
14959{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014960 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014961 alc662_auto_init_multi_out(codec);
14962 alc662_auto_init_hp_out(codec);
14963 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014964 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014965 if (spec->unsol_event)
14966 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014967}
14968
14969static int patch_alc662(struct hda_codec *codec)
14970{
14971 struct alc_spec *spec;
14972 int err, board_config;
14973
14974 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14975 if (!spec)
14976 return -ENOMEM;
14977
14978 codec->spec = spec;
14979
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014980 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14981
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014982 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
14983 alc662_models,
14984 alc662_cfg_tbl);
14985 if (board_config < 0) {
14986 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
14987 "trying auto-probe from BIOS...\n");
14988 board_config = ALC662_AUTO;
14989 }
14990
14991 if (board_config == ALC662_AUTO) {
14992 /* automatic parse from the BIOS config */
14993 err = alc662_parse_auto_config(codec);
14994 if (err < 0) {
14995 alc_free(codec);
14996 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020014997 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014998 printk(KERN_INFO
14999 "hda_codec: Cannot set up configuration "
15000 "from BIOS. Using base mode...\n");
15001 board_config = ALC662_3ST_2ch_DIG;
15002 }
15003 }
15004
15005 if (board_config != ALC662_AUTO)
15006 setup_preset(spec, &alc662_presets[board_config]);
15007
Kailang Yang6dda9f42008-05-27 12:05:31 +020015008 if (codec->vendor_id == 0x10ec0663) {
15009 spec->stream_name_analog = "ALC663 Analog";
15010 spec->stream_name_digital = "ALC663 Digital";
15011 } else {
15012 spec->stream_name_analog = "ALC662 Analog";
15013 spec->stream_name_digital = "ALC662 Digital";
15014 }
15015
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015016 spec->stream_analog_playback = &alc662_pcm_analog_playback;
15017 spec->stream_analog_capture = &alc662_pcm_analog_capture;
15018
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015019 spec->stream_digital_playback = &alc662_pcm_digital_playback;
15020 spec->stream_digital_capture = &alc662_pcm_digital_capture;
15021
Takashi Iwaie1406342008-02-11 18:32:32 +010015022 spec->adc_nids = alc662_adc_nids;
15023 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
15024 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015025
Takashi Iwai2134ea42008-01-10 16:53:55 +010015026 spec->vmaster_nid = 0x02;
15027
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015028 codec->patch_ops = alc_patch_ops;
15029 if (board_config == ALC662_AUTO)
15030 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015031#ifdef CONFIG_SND_HDA_POWER_SAVE
15032 if (!spec->loopback.amplist)
15033 spec->loopback.amplist = alc662_loopbacks;
15034#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015035
15036 return 0;
15037}
15038
15039/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070015040 * patch entries
15041 */
15042struct hda_codec_preset snd_hda_preset_realtek[] = {
15043 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015044 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015045 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020015046 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015047 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015048 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015049 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015050 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
15051 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
15052 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015053 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
15054 .patch = patch_alc883 },
15055 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
15056 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015057 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015058 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070015059 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015060 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020015061 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020015062 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010015063 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015064 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015065 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070015066 {} /* terminator */
15067};